summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2024-08-22 11:29:11 +0200
committerLouis Scalbert <louis.scalbert@6wind.com>2025-03-10 09:54:18 +0100
commit5cde97678e85d51a90d8bf09149cd1b3ec6a7e82 (patch)
tree87558ba6fa7430bdf962f0b8af704bcd28156729
parentfb8bf9cf5929967e9a453679ae7b498203936ff8 (diff)
zebra: fix removed default route at vrf enabling
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 <louis.scalbert@6wind.com>
-rw-r--r--zebra/zebra_vrf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index 7e53a2e804..faafcf7892 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -457,8 +457,11 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);
+ /* create a fake default route or get the existing one */
rn = srcdest_rnode_get(zvrf->table[afi][safi], &p, NULL);
- zebra_rib_create_dest(rn);
+ if (!rn->info)
+ /* do not override the existing default route */
+ zebra_rib_create_dest(rn);
}
/* Allocate new zebra VRF. */