From e85c67d05decf340dcf5663a48c652719d04387f Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Tue, 24 Mar 2020 17:32:21 -0400 Subject: [PATCH] zebra: determine src when using nexthop objects Determine src based on nexthop data even when we are using kernel nexthop objects. Before, we were entirely skipping this step and just sending the nexthop ID, ignoring src determination. Signed-off-by: Stephen Worley (cherry picked from commit d8bfd8dc9a899f841967257a6b5f30910fdc17c8) --- zebra/rt_netlink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index dcaf2155f0..ee8ef6558f 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1666,6 +1666,23 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx) /* Kernel supports nexthop objects */ addattr32(&req.n, sizeof(req), RTA_NH_ID, dplane_ctx_get_nhe_id(ctx)); + + /* Have to determine src still */ + for (ALL_NEXTHOPS_PTR(dplane_ctx_get_ng(ctx), nexthop)) { + if (setsrc) + break; + + setsrc = nexthop_set_src(nexthop, family, &src); + } + + if (setsrc) { + if (family == AF_INET) + addattr_l(&req.n, sizeof(req), RTA_PREFSRC, + &src.ipv4, bytelen); + else if (family == AF_INET6) + addattr_l(&req.n, sizeof(req), RTA_PREFSRC, + &src.ipv6, bytelen); + } goto skip; } -- 2.39.5