From 3ce588804a2003e62352069af9a4667d1c899a2e Mon Sep 17 00:00:00 2001 From: Jorge Boncompte Date: Thu, 27 Jul 2017 12:14:32 +0200 Subject: [PATCH] zebra: do not treat kernel routes as implicit withdraws Kernel does not send the best route after adding or deleting routes, if we treat routes for an existing prefix as implicit withdraw the zebra RIB goes out of sync with FIB and can announce wrong route to protocols. host:~# vtysh -c 'show ip route' S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0 C>* 192.168.1.0/24 is directly connected, eth0 host:~# ip route add 192.0.2.0/24 via 192.168.1.101 metric 100 host:~# vtysh -c 'show ip route' S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0 K>* 192.0.2.0/24 via 192.168.1.101, eth0 C>* 192.168.1.0/24 is directly connected, eth0 host:~# ip route add 192.0.2.0/24 via 192.168.1.102 metric 50 host:~# vtysh -c 'show ip route' S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0 K>* 192.0.2.0/24 via 192.168.1.102, eth0 C>* 192.168.1.0/24 is directly connected, eth0 host:~# ip route del 192.0.2.0/24 via 192.168.1.102 metric 50 host:~# vtysh -c 'show ip route' S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0 C>* 192.168.1.0/24 is directly connected, eth0 host:~# ip route show 192.0.2.0/24 192.0.2.0/24 via 10.10.1.101 dev eth0 metric 100 Signed-off-by: Jorge Boncompte --- zebra/zebra_rib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index f5ee2dff90..8dca4f9f83 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2240,7 +2240,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p, if (same->type == re->type && same->instance == re->instance && same->table == re->table - && same->type != ZEBRA_ROUTE_CONNECT) + && !RIB_SYSTEM_ROUTE(same)) break; } @@ -2469,11 +2469,11 @@ int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, continue; if (re->instance != instance) continue; - if (re->type != ZEBRA_ROUTE_CONNECT) { + if (!RIB_SYSTEM_ROUTE(re)) { same = re; break; } - /* Duplicate connected route comes in. */ + /* Duplicate system route comes in. */ else if ((nexthop = re->nexthop) && nexthop->type == NEXTHOP_TYPE_IFINDEX && nexthop->ifindex == ifindex -- 2.39.5