]> git.puffer.fish Git - matthieu/frr.git/commitdiff
BGP: Do appropriate cleanup on receipt of redistribute update
authorvivek <vivek@cumulusnetworks.com>
Thu, 29 Oct 2015 17:30:45 +0000 (10:30 -0700)
committervivek <vivek@cumulusnetworks.com>
Thu, 29 Oct 2015 17:30:45 +0000 (10:30 -0700)
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 <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Ticket: CM-7578
Reviewed By: CCR-3718
Testing Done: Manual verification
Related-to: CM-6768
bgpd/bgp_zebra.c

index c7b0b4364e6184382c9bfdae7ecef05b6f871477..052c2efacb421f4f75c0c5de940de167c6edfef5 100644 (file)
@@ -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);
     }