From: Stephen Worley Date: Mon, 23 Jul 2018 22:33:53 +0000 (-0400) Subject: zebra: Add check for nexthop loop to prevent hanging X-Git-Tag: frr-6.1-dev~140^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=3c04071d996f84f265776f068ff21dc48d895139;p=matthieu%2Ffrr.git zebra: Add check for nexthop loop to prevent hanging Bad nexthop messages from netlink were causing zebra to hang here. Added a check to verify the length of the nexthop so it doesn't keep trying to read. Signed-off-by: Stephen Worley --- diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index b346247d4b..ec84c4c622 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -581,6 +581,9 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, route_entry_nexthop_ifindex_add( re, index, nh_vrf_id); + if (rtnh->rtnh_len == 0) + break; + len -= NLMSG_ALIGN(rtnh->rtnh_len); rtnh = RTNH_NEXT(rtnh); } @@ -701,6 +704,9 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h, oif[oif_count] = rtnh->rtnh_ifindex; oif_count++; + if (rtnh->rtnh_len == 0) + break; + len -= NLMSG_ALIGN(rtnh->rtnh_len); rtnh = RTNH_NEXT(rtnh); }