From: Ido Schimmel Date: Tue, 1 May 2018 13:16:35 +0000 (+0300) Subject: iproute: Parse last nexthop in a multipath route X-Git-Tag: v4.17.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0ec7c9f875cd0d385497bc5e18f0a32e7887663;p=thirdparty%2Fiproute2.git iproute: Parse last nexthop in a multipath route Continue parsing a multipath payload as long as another nexthop can fit in the payload. # ip route add 192.0.2.0/24 nexthop dev dummy0 nexthop dev dummy1 Before: # ip route show 192.0.2.0/24 192.0.2.0/24 nexthop dev dummy0 weight 1 After: # ip route show 192.0.2.0/24 192.0.2.0/24 nexthop dev dummy0 weight 1 nexthop dev dummy1 weight 1 Fixes: f48e14880a0e ("iproute: refactor multipath print") Signed-off-by: Ido Schimmel Acked-by: David Ahern Signed-off-by: Stephen Hemminger --- diff --git a/ip/iproute.c b/ip/iproute.c index 44351bc51..56dd9f25e 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -650,7 +650,7 @@ static void print_rta_multipath(FILE *fp, const struct rtmsg *r, int len = RTA_PAYLOAD(rta); int first = 1; - while (len > sizeof(*nh)) { + while (len >= sizeof(*nh)) { struct rtattr *tb[RTA_MAX + 1]; if (nh->rtnh_len > len)