From: Donald Sharp Date: Fri, 12 Jun 2015 14:59:09 +0000 (-0700) Subject: The nexthop reveived for a prefix in a BGP update is cached in the X-Git-Tag: frr-2.0-rc1~1334 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=22a29185cae41939309622fc5c719d2827e78669;p=matthieu%2Ffrr.git The nexthop reveived for a prefix in a BGP update is cached in the nexthop cache in BGP and registered for resolution with the nexthop tracking (NHT) component. If the prefix were to be received from the same peer with a different nexthop, the prior nexthop needs to be processed for cleanup and unregistered and removed from the cache, if appropriate. That is handled with this patch. Signed-off-by: Vivek Venkataraman Reviewed-by: Dinesh G Dutt Reviewed-by: Donald Sharp --- diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 397b379faf..ab4effcb1e 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -206,8 +206,14 @@ bgp_find_or_add_nexthop (struct bgp *bgp, afi_t afi, struct bgp_info *ri, if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED)) register_zebra_rnh(bnc, is_bgp_static_route); - if (ri) + if (ri && ri->nexthop != bnc) { + /* Unlink from existing nexthop cache, if any. This will also free + * the nexthop cache entry, if appropriate. + */ + bgp_unlink_nexthop (ri); + + /* Link to new nexthop cache. */ path_nh_map(ri, bnc, 1); if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) && bnc->metric)