From: Donald Sharp Date: Wed, 16 Sep 2015 12:30:23 +0000 (-0700) Subject: Warn user in various max path edge cases X-Git-Tag: frr-2.0-rc1~1254^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=6878b9db997273aa1eab64d3717430e5027f771c;p=matthieu%2Ffrr.git Warn user in various max path edge cases 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 --- diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am index 7fdaa17957..54b26187a7 100644 --- a/bgpd/Makefile.am +++ b/bgpd/Makefile.am @@ -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) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index f1397f6561..d2c0a41bab 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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; } diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index e0124dcb49..dfff7869aa 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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 diff --git a/zebra/zserv.c b/zebra/zserv.c index 188665814a..1bd5b98825 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -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); diff --git a/zebra/zserv.h b/zebra/zserv.h index db20bad263..41aaecef14 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -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 *);