Skip to content

Commit

Permalink
zebra: fix removing default route at vrf enabling
Browse files Browse the repository at this point in the history
When a routing table (RT) already has a default route before being
assigned to a VRF, the default route vanishes in zebra after the VRF
assignment.

> root@router:~# ip route add blackhole default table 100
> root@router:~# ip route show table 100
> blackhole default
> root@router:~# vtysh -c 'show ip route table 100'
> [...]
> VRF default table 100:
> K>* 0.0.0.0/0 [0/0] unreachable (blackhole), 00:00:05
> root@router:~# ip l add red type vrf table 100
> root@router:~# vtysh -c 'show ip route table 100'
> root@router:~#

Do not override the default route if it exists.

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Aug 22, 2024
1 parent f35f5f5 commit 311df79
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions zebra/zebra_vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);

if (route_node_lookup_maynull(zvrf->table[afi][safi], &p))
/* do not override the existing default route */
return;

/* create a fake default route */
rn = srcdest_rnode_get(zvrf->table[afi][safi], &p, NULL);
zebra_rib_create_dest(rn);
}
Expand Down

0 comments on commit 311df79

Please sign in to comment.