From c7a3f82db580659321ff12faaf89abf8c780d3c9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 8 May 2024 12:52:12 -0400 Subject: [PATCH] zebra: Ensure multipath encodes vxlan right for fpm usage The fpm code path for the dplane_fpm_nl module was improperly encoding the multipath nexthop data for vxlan type routes. Move this into the embedded nexthop encoding where it belongs. This change makes it so that the usage of `-M dplane_fpm_nl` is now producing the same netlink messages that `-M fpm` produces when using vxlan based nexthops. Signed-off-by: Donald Sharp --- zebra/rt_netlink.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 31486a525e17..938c658b30e8 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1728,7 +1728,7 @@ static inline bool _netlink_set_tag(struct nlmsghdr *n, unsigned int maxlen, * to the message, otherwise false is returned. */ static int netlink_route_nexthop_encap(bool fpm, struct nlmsghdr *n, - size_t nlen, struct nexthop *nh) + size_t nlen, const struct nexthop *nh) { struct rtattr *nest; @@ -1771,10 +1771,13 @@ static int netlink_route_nexthop_encap(bool fpm, struct nlmsghdr *n, * The function returns true if the nexthop could be added * to the message, otherwise false is returned. */ -static bool _netlink_route_build_multipath( - const struct prefix *p, const char *routedesc, int bytelen, - const struct nexthop *nexthop, struct nlmsghdr *nlmsg, size_t req_size, - struct rtmsg *rtmsg, const union g_addr **src, route_tag_t tag) +static bool _netlink_route_build_multipath(const struct prefix *p, + const char *routedesc, int bytelen, + const struct nexthop *nexthop, + struct nlmsghdr *nlmsg, + size_t req_size, struct rtmsg *rtmsg, + const union g_addr **src, + route_tag_t tag, bool fpm) { char label_buf[256]; struct vrf *vrf; @@ -1883,6 +1886,13 @@ static bool _netlink_route_build_multipath( if (!_netlink_set_tag(nlmsg, req_size, tag)) return false; + /* + * Add encapsulation information when installing via + * FPM. + */ + if (!netlink_route_nexthop_encap(fpm, nlmsg, req_size, nexthop)) + return false; + nl_attr_rtnh_end(nlmsg, rtnh); return true; } @@ -1917,7 +1927,7 @@ _netlink_mpls_build_multipath(const struct prefix *p, const char *routedesc, bytelen = (family == AF_INET ? 4 : 16); return _netlink_route_build_multipath(p, routedesc, bytelen, nhlfe->nexthop, nlmsg, req_size, - rtmsg, src, 0); + rtmsg, src, 0, false); } static void _netlink_mpls_debug(int cmd, uint32_t label, const char *routedesc) @@ -2292,19 +2302,14 @@ ssize_t netlink_route_multipath_msg_encode(int cmd, : "multipath"; nexthop_num++; - if (!_netlink_route_build_multipath( - p, routedesc, bytelen, nexthop, - &req->n, datalen, &req->r, &src1, - tag)) - return 0; - - /* - * Add encapsulation information when installing via - * FPM. - */ - if (!netlink_route_nexthop_encap(fpm, &req->n, - datalen, - nexthop)) + if (!_netlink_route_build_multipath(p, routedesc, + bytelen, + nexthop, + &req->n, + datalen, + &req->r, + &src1, tag, + fpm)) return 0; if (!setsrc && src1) {