]> git.proxmox.com Git - mirror_frr.git/commitdiff
eigrpd: Fix add and delete of routes into the rib
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 6 Apr 2017 00:35:50 +0000 (20:35 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 6 Apr 2017 00:35:50 +0000 (20:35 -0400)
Use the eigrp_topology_successors to give us the
list of successors we want to install.

Modify route add to send all the nexthops

Modify route delete to just delete the route

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
eigrpd/eigrp_topology.c
eigrpd/eigrp_zebra.c
eigrpd/eigrp_zebra.h

index 7015d595355302e322d07b8f9ef159571f2aa262..29664eaebb6faa0db15154bdf61d1951a9bafc39 100644 (file)
@@ -317,6 +317,13 @@ eigrp_topology_table_lookup_ipv4(struct list *topology_table,
   return NULL;
 }
 
+/*
+ * For a future optimization, put the successor list into it's
+ * own separate list from the full list?
+ *
+ * That way we can clean up all the list_new and list_delete's
+ * that we are doing.  DBS
+ */
 struct list *
 eigrp_topology_get_successor(struct eigrp_prefix_entry *table_node)
 {
@@ -475,24 +482,23 @@ eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest)
 void
 eigrp_update_routing_table(struct eigrp_prefix_entry * prefix)
 {
+  struct list *successors = eigrp_topology_get_successor(prefix);
   struct listnode *node;
   struct eigrp_neighbor_entry *entry;
 
-  for (ALL_LIST_ELEMENTS_RO(prefix->entries, node, entry))
+  if (successors)
     {
-      if (entry->flags & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)
-        {
-          if (!(entry->flags & EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG))
-            {
-              eigrp_zebra_route_add(prefix->destination_ipv4, entry);
-              entry->flags |= EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
-            }
-        }
-      else if (entry->flags & EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG)
-        {
-          eigrp_zebra_route_delete(prefix->destination_ipv4, entry);
-          entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
-        }
+      eigrp_zebra_route_add(prefix->destination_ipv4, successors);
+      for (ALL_LIST_ELEMENTS_RO (successors, node, entry))
+       entry->flags |= EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
+
+      list_delete(successors);
+    }
+  else
+    {
+      eigrp_zebra_route_delete(prefix->destination_ipv4);
+      for (ALL_LIST_ELEMENTS_RO (prefix->entries, node, entry))
+       entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
     }
 }
 
index f4cb4235b9f0548cdc3c68e55f3e317a70cc8a58..6f38079f696c02a77b8ae499972caba011bed387 100644 (file)
@@ -403,8 +403,10 @@ zebra_interface_if_lookup (struct stream *s)
 }
 
 void
-eigrp_zebra_route_add (struct prefix_ipv4 *p, struct eigrp_neighbor_entry *te)
+eigrp_zebra_route_add (struct prefix_ipv4 *p, struct list *successors)
 {
+  struct eigrp_neighbor_entry *te;
+  struct listnode *node;
   u_char message;
   u_char flags;
   int psize;
@@ -418,11 +420,6 @@ eigrp_zebra_route_add (struct prefix_ipv4 *p, struct eigrp_neighbor_entry *te)
       /* EIGRP pass nexthop and metric */
       SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP);
 
-      /* Distance value. */
-//      distance = eigrp_distance_apply (p, er);
-//      if (distance)
-//        SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
-
       /* Make packet. */
       s = zclient->obuf;
       stream_reset (s);
@@ -441,12 +438,15 @@ eigrp_zebra_route_add (struct prefix_ipv4 *p, struct eigrp_neighbor_entry *te)
       stream_write (s, (u_char *) & p->prefix, psize);
 
       /* Nexthop count. */
-      stream_putc (s, 1);
+      stream_putc (s, successors->count);
 
       /* Nexthop, ifindex, distance and metric information. */
-      stream_putc (s, NEXTHOP_TYPE_IPV4_IFINDEX);
-      stream_put_in_addr (s, &te->adv_router->src);
-      stream_putl (s, te->ei->ifp->ifindex);
+      for (ALL_LIST_ELEMENTS_RO (successors, node, te))
+       {
+         stream_putc (s, NEXTHOP_TYPE_IPV4_IFINDEX);
+         stream_put_in_addr (s, &te->adv_router->src);
+         stream_putl (s, te->ei->ifp->ifindex);
+       }
 
       if (IS_DEBUG_EIGRP (zebra, ZEBRA_REDISTRIBUTE))
         {
@@ -457,7 +457,6 @@ eigrp_zebra_route_add (struct prefix_ipv4 *p, struct eigrp_neighbor_entry *te)
                      inet_ntop(AF_INET, 0 /*&p->nexthop*/, buf[1], sizeof (buf[1])));
         }
 
-      //stream_putl (s, te->distance);
       stream_putw_at (s, 0, stream_get_endp (s));
 
       zclient_send_message (zclient);
@@ -465,61 +464,31 @@ eigrp_zebra_route_add (struct prefix_ipv4 *p, struct eigrp_neighbor_entry *te)
 }
 
 void
-eigrp_zebra_route_delete (struct prefix_ipv4 *p, struct eigrp_neighbor_entry *te)
+eigrp_zebra_route_delete (struct prefix_ipv4 *p)
 {
-  u_char message;
-  u_char flags;
-  int psize;
-  struct stream *s;
+  struct zapi_ipv4 api;
 
   if (zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP])
     {
-      message = 0;
-      flags = 0;
-      /* Make packet. */
-      s = zclient->obuf;
-      stream_reset (s);
-
-      /* Put command, type, flags, message. */
-      zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE, VRF_DEFAULT);
-      stream_putc (s, ZEBRA_ROUTE_EIGRP);
-      stream_putw (s, 0);         // Instance
-      stream_putl (s, flags);
-      stream_putc (s, message);
-      stream_putw (s, SAFI_UNICAST);
-
-      /* Put prefix information. */
-      psize = PSIZE (p->prefixlen);
-      stream_putc (s, p->prefixlen);
-      stream_write (s, (u_char *) & p->prefix, psize);
-
-      /* Nexthop count. */
-      stream_putc (s, 1);
-
-      /* Nexthop, ifindex, distance and metric information. */
-      stream_putc (s, NEXTHOP_TYPE_IPV4_IFINDEX);
-      stream_put_in_addr (s, &te->adv_router->src);
-      stream_putl (s, te->ei->ifp->ifindex);
+      api.vrf_id = VRF_DEFAULT;
+      api.type = ZEBRA_ROUTE_EIGRP;
+      api.instance = 0;
+      api.flags = 0;
+      api.message = 0;
+      api.safi = SAFI_UNICAST;
+      zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api);
 
       if (IS_DEBUG_EIGRP (zebra, ZEBRA_REDISTRIBUTE))
-        {
+       {
           char buf[2][INET_ADDRSTRLEN];
           zlog_debug ("Zebra: Route del %s/%d nexthop %s",
                      inet_ntop (AF_INET, &p->prefix,  buf[0], sizeof (buf[0])),
                      p->prefixlen,
                      inet_ntop (AF_INET, 0 /*&p->nexthop*/, buf[1], sizeof (buf[1])));
         }
-
-
-      if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
-        {
-          stream_putl (s, te->distance);
-        }
-
-      stream_putw_at (s, 0, stream_get_endp (s));
-
-      zclient_send_message (zclient);
     }
+
+  return;
 }
 
 vrf_bitmap_t
index f1c8e62e7a6c92099e6646884f4d1ef808410e0b..4cd6b1e9572de8b874e103319ff9e43346cfb02d 100644 (file)
@@ -34,8 +34,8 @@
 
 extern void eigrp_zebra_init (void);
 
-extern void eigrp_zebra_route_add (struct prefix_ipv4 *, struct eigrp_neighbor_entry *);
-extern void eigrp_zebra_route_delete (struct prefix_ipv4 *, struct eigrp_neighbor_entry *);
+extern void eigrp_zebra_route_add (struct prefix_ipv4 *, struct list *);
+extern void eigrp_zebra_route_delete (struct prefix_ipv4 *);
 extern int eigrp_redistribute_set (struct eigrp *, int, struct eigrp_metrics);
 extern int eigrp_redistribute_unset (struct eigrp *, int);
 extern vrf_bitmap_t eigrp_is_type_redistributed (int);