Skip to content

Commit bd4fca1

Browse files
committed
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 <sharpd@nvidia.com>
1 parent 569f9e4 commit bd4fca1

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

zebra/rt_netlink.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ static inline bool _netlink_set_tag(struct nlmsghdr *n, unsigned int maxlen,
18961896
* to the message, otherwise false is returned.
18971897
*/
18981898
static int netlink_route_nexthop_encap(bool fpm, struct nlmsghdr *n,
1899-
size_t nlen, struct nexthop *nh)
1899+
size_t nlen, const struct nexthop *nh)
19001900
{
19011901
struct rtattr *nest;
19021902

@@ -1939,10 +1939,13 @@ static int netlink_route_nexthop_encap(bool fpm, struct nlmsghdr *n,
19391939
* The function returns true if the nexthop could be added
19401940
* to the message, otherwise false is returned.
19411941
*/
1942-
static bool _netlink_route_build_multipath(
1943-
const struct prefix *p, const char *routedesc, int bytelen,
1944-
const struct nexthop *nexthop, struct nlmsghdr *nlmsg, size_t req_size,
1945-
struct rtmsg *rtmsg, const union g_addr **src, route_tag_t tag)
1942+
static bool _netlink_route_build_multipath(const struct prefix *p,
1943+
const char *routedesc, int bytelen,
1944+
const struct nexthop *nexthop,
1945+
struct nlmsghdr *nlmsg,
1946+
size_t req_size, struct rtmsg *rtmsg,
1947+
const union g_addr **src,
1948+
route_tag_t tag, bool fpm)
19461949
{
19471950
char label_buf[256];
19481951
struct vrf *vrf;
@@ -2050,6 +2053,13 @@ static bool _netlink_route_build_multipath(
20502053
if (!_netlink_set_tag(nlmsg, req_size, tag))
20512054
return false;
20522055

2056+
/*
2057+
* Add encapsulation information when installing via
2058+
* FPM.
2059+
*/
2060+
if (!netlink_route_nexthop_encap(fpm, nlmsg, req_size, nexthop))
2061+
return false;
2062+
20532063
nl_attr_rtnh_end(nlmsg, rtnh);
20542064
return true;
20552065
}
@@ -2084,7 +2094,7 @@ _netlink_mpls_build_multipath(const struct prefix *p, const char *routedesc,
20842094
bytelen = (family == AF_INET ? 4 : 16);
20852095
return _netlink_route_build_multipath(p, routedesc, bytelen,
20862096
nhlfe->nexthop, nlmsg, req_size,
2087-
rtmsg, src, 0);
2097+
rtmsg, src, 0, false);
20882098
}
20892099

20902100
static void _netlink_mpls_debug(int cmd, uint32_t label, const char *routedesc)
@@ -2481,19 +2491,14 @@ ssize_t netlink_route_multipath_msg_encode(int cmd, struct zebra_dplane_ctx *ctx
24812491
: "multipath";
24822492
nexthop_num++;
24832493

2484-
if (!_netlink_route_build_multipath(
2485-
p, routedesc, bytelen, nexthop,
2486-
&req->n, datalen, &req->r, &src1,
2487-
tag))
2488-
return 0;
2489-
2490-
/*
2491-
* Add encapsulation information when installing via
2492-
* FPM.
2493-
*/
2494-
if (!netlink_route_nexthop_encap(fpm, &req->n,
2495-
datalen,
2496-
nexthop))
2494+
if (!_netlink_route_build_multipath(p, routedesc,
2495+
bytelen,
2496+
nexthop,
2497+
&req->n,
2498+
datalen,
2499+
&req->r,
2500+
&src1, tag,
2501+
fpm))
24972502
return 0;
24982503

24992504
if (!setsrc && src1) {

0 commit comments

Comments
 (0)