From: vivek Date: Thu, 29 Oct 2015 17:30:45 +0000 (-0700) Subject: BGP: Do appropriate cleanup on receipt of redistribute update X-Git-Tag: frr-2.0-rc1~1213^2~21 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=d289687f8b341363597c2f20276181341b4872c4;p=matthieu%2Ffrr.git BGP: Do appropriate cleanup on receipt of redistribute update When there is a change to a redistributed route, either an attribute such as the metric or the route type itself has changed, protocol clients receive an update of the route instead of a delete and add as a result of an earlier optimization. The update needs to be handled as an implicit delete for any existing redistributed route, especially to handle change in route type. Signed-off-by: Vivek Venkataraman Reviewed-by: Donald Sharp Reviewed-by: Daniel Walton Ticket: CM-7578 Reviewed By: CCR-3718 Testing Done: Manual verification Related-to: CM-6768 --- diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index c7b0b4364e..052c2efacb 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -438,6 +438,7 @@ zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length) struct in_addr nexthop; struct prefix_ipv4 p; unsigned int ifindex; + int i; s = zclient->ibuf; nexthop.s_addr = 0; @@ -497,6 +498,20 @@ zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length) api.metric, api.tag); } + + /* + * The ADD message is actually an UPDATE and there is no explicit DEL + * for a prior redistributed route, if any. So, perform an implicit + * DEL processing for the same redistributed route from any other + * source type. + */ + for (i = 0; i < ZEBRA_ROUTE_MAX; i++) + { + if (i != api.type) + bgp_redistribute_delete((struct prefix *)&p, i, api.instance); + } + + /* Now perform the add/update. */ bgp_redistribute_add((struct prefix *)&p, &nexthop, NULL, ifindex, api.metric, api.type, api.instance, api.tag); } @@ -530,6 +545,7 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length) struct in6_addr nexthop; struct prefix_ipv6 p; unsigned int ifindex; + int i; s = zclient->ibuf; memset (&nexthop, 0, sizeof (struct in6_addr)); @@ -595,6 +611,19 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length) api.metric, api.tag); } + + /* + * The ADD message is actually an UPDATE and there is no explicit DEL + * for a prior redistributed route, if any. So, perform an implicit + * DEL processing for the same redistributed route from any other + * source type. + */ + for (i = 0; i < ZEBRA_ROUTE_MAX; i++) + { + if (i != api.type) + bgp_redistribute_delete((struct prefix *)&p, i, api.instance); + } + bgp_redistribute_add ((struct prefix *)&p, NULL, &nexthop, ifindex, api.metric, api.type, api.instance, api.tag); }