]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Warn user in various max path edge cases
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 16 Sep 2015 12:30:23 +0000 (05:30 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 16 Sep 2015 12:30:23 +0000 (05:30 -0700)
Ticket: CM-6680
Reviewed-by: CCR-3486
Testing: See bug

In these situations:
(A) user enters under bgp more 'maximum-paths' than zebra is compiled with
warn the user that there is a problem
(B) Zebra receives more maximum paths than what it can handle log the fact
that this happened

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/Makefile.am
bgpd/bgp_vty.c
zebra/rt_netlink.c
zebra/zserv.c
zebra/zserv.h

index 7fdaa179577aba7c25678f6424bd4910541c9eb0..54b26187a7bf351588cfdd0a5c6099548f48500a 100644 (file)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in.
 
 INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
-DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
+DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DMULTIPATH_NUM=@MULTIPATH_NUM@
 INSTALL_SDATA=@INSTALL@ -m 600
 
 AM_CFLAGS = $(PICFLAGS) $(WERROR)
index f1397f6561bc6f5cd978a46b219d88566be44b78..d2c0a41bab667b76b36ecc4110cadfa43013c34a 100644 (file)
@@ -1011,6 +1011,11 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
 
   bgp_recalculate_all_bestpaths (bgp);
 
+  if ((MULTIPATH_NUM != 0) && (maxpaths > MULTIPATH_NUM))
+    vty_out (vty,
+            "%% Warning: maximum-paths set to %d is greater than %d that zebra is compiled to support%s",
+            maxpaths, MULTIPATH_NUM, VTY_NEWLINE);
+
   return CMD_SUCCESS;
 }
 
index e0124dcb49cf73dc8e06d86fe2ae35685ab1ac9f..dfff7869aad4cf7392dfc285ff3a9d13f40bcf10 100644 (file)
@@ -780,7 +780,6 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h)
               if (len < (int) sizeof (*rtnh) || rtnh->rtnh_len > len)
                 break;
 
-              rib->nexthop_num++;
               index = rtnh->rtnh_ifindex;
               gate = 0;
               if (rtnh->rtnh_len > sizeof (*rtnh))
@@ -806,6 +805,8 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h)
               rtnh = RTNH_NEXT(rtnh);
             }
 
+         zserv_nexthop_num_warn(__func__, (const struct prefix *)&p,
+                                rib->nexthop_num);
           if (rib->nexthop_num == 0)
             XFREE (MTYPE_RIB, rib);
           else
@@ -983,7 +984,6 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
                   if (len < (int) sizeof (*rtnh) || rtnh->rtnh_len > len)
                     break;
 
-                  rib->nexthop_num++;
                   index = rtnh->rtnh_ifindex;
                   gate = 0;
                   if (rtnh->rtnh_len > sizeof (*rtnh))
@@ -1009,6 +1009,9 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
                   rtnh = RTNH_NEXT(rtnh);
                 }
 
+             zserv_nexthop_num_warn(__func__, (const struct prefix *)&p,
+                                    rib->nexthop_num);
+
               if (rib->nexthop_num == 0)
                 XFREE (MTYPE_RIB, rib);
               else
index 188665814aa9adf1c92ccfb3d1b950f13c089e66..1bd5b98825ba0feb0c3ce6677d7855e010ffe3c4 100644 (file)
@@ -1015,6 +1015,18 @@ zread_interface_delete (struct zserv *client, u_short length)
   return 0;
 }
 
+void
+zserv_nexthop_num_warn (const char *caller, const struct prefix *p, const u_char nexthop_num)
+{
+  if ((MULTIPATH_NUM != 0) && (nexthop_num > MULTIPATH_NUM))
+    {
+      char buff[80];
+      prefix2str(p, buff, 80);
+      zlog_warn("%s: Prefix %s has %d nexthops, but we can only use the first %d",
+               caller, buff, nexthop_num, MULTIPATH_NUM);
+    }
+}
+
 /* This function support multiple nexthop. */
 /* 
  * Parse the ZEBRA_IPV4_ROUTE_ADD sent from client. Update rib and
@@ -1060,6 +1072,7 @@ zread_ipv4_add (struct zserv *client, u_short length)
   if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP))
     {
       nexthop_num = stream_getc (s);
+      zserv_nexthop_num_warn(__func__, (const struct prefix *)&p, nexthop_num);
 
       for (i = 0; i < nexthop_num; i++)
        {
@@ -1295,6 +1308,7 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length)
       int max_nh_if = 0;
 
       nexthop_num = stream_getc (s);
+      zserv_nexthop_num_warn(__func__, (const struct prefix *)&p, nexthop_num);
       for (i = 0; i < nexthop_num; i++)
        {
          nexthop_type = stream_getc (s);
@@ -1415,7 +1429,8 @@ zread_ipv6_add (struct zserv *client, u_short length)
       int max_nh_if = 0;
 
       nexthop_num = stream_getc (s);
-      for (i = 0; i < nexthop_num; i++)
+      zserv_nexthop_num_warn(__func__, (const struct prefix *)&p, nexthop_num);
+      for (i = 0; i < nexthop_num; i++) 
        {
          nexthop_type = stream_getc (s);
 
index db20bad2630d16e0a2b4654bb36cfcdbfa35068f..41aaecef1477f944258bc5eceae686f30d694b63 100644 (file)
@@ -155,6 +155,7 @@ extern int zsend_router_id_update(struct zserv *, struct prefix *);
 extern pid_t pid;
 
 extern void zserv_create_header(struct stream *s, uint16_t cmd);
+extern void zserv_nexthop_num_warn(const char *, const struct prefix *, const u_char);
 extern int zebra_server_send_message(struct zserv *client);
 
 extern void zebra_route_map_write_delay_timer(struct vty *);