From 6e1e2e8da971bbdc1d4dc79012a81282f92dde00 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 28 Oct 2021 08:10:28 -0400 Subject: [PATCH] zebra: Fix netlink RTM_NEWNEXTHOP parsing for nested attributes With the addition of resillient hashing for nexthops, the parsing of nexthops requires telling the decoder functions that there may be nested attributes. This was found by code inspection of iproute2/ipnexthop.c when trying to understand resillient hashing as well as statistics gathering for nexthops that are / will be in upstream kernels in the near future. Signed-off-by: Donald Sharp --- zebra/debug_nl.c | 2 +- zebra/rt_netlink.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/zebra/debug_nl.c b/zebra/debug_nl.c index 2175aaff60..7a44ff761b 100644 --- a/zebra/debug_nl.c +++ b/zebra/debug_nl.c @@ -1045,7 +1045,7 @@ next_rta: plen = RTA_PAYLOAD(rta); zlog_debug(" rta [len=%d (payload=%zu) type=(%d) %s]", rta->rta_len, plen, rta->rta_type, nhm_rta2str(rta->rta_type)); - switch (rta->rta_type) { + switch (rta->rta_type & ~NLA_F_NESTED) { case NHA_ID: u32v = *(uint32_t *)RTA_DATA(rta); zlog_debug(" %u", u32v); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 780b601734..b3f04e421e 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -2892,7 +2892,8 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) return -1; } - netlink_parse_rtattr(tb, NHA_MAX, RTM_NHA(nhm), len); + netlink_parse_rtattr_flags(tb, NHA_MAX, RTM_NHA(nhm), len, + NLA_F_NESTED); if (!tb[NHA_ID]) {