]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
nh: fix scope used to find saddr when adding non gw nh
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Thu, 20 Oct 2022 10:09:52 +0000 (12:09 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 28 Nov 2022 14:18:18 +0000 (15:18 +0100)
BugLink: https://bugs.launchpad.net/bugs/1997981
[ Upstream commit bac0f937c343d651874f83b265ca8f5070ed4f06 ]

As explained by Julian, fib_nh_scope is related to fib_nh_gw4, but
fib_info_update_nhc_saddr() needs the scope of the route, which is
the scope "before" fib_nh_scope, ie fib_nh_scope - 1.

This patch fixes the problem described in commit 747c14307214 ("ip: fix
dflt addr selection for connected nexthop").

Fixes: 597cfe4fc339 ("nexthop: Add support for IPv4 nexthops")
Link: https://lore.kernel.org/netdev/6c8a44ba-c2d5-cdf-c5c7-5baf97cba38@ssi.bg/
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Reviewed-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/ipv4/nexthop.c

index cc8f120149f6b65244813a12beb513380dc13f76..6cc7d347ec0ad7b62d3bbd43cc3aa4af2574d8f2 100644 (file)
@@ -2535,7 +2535,7 @@ static int nh_create_ipv4(struct net *net, struct nexthop *nh,
        if (!err) {
                nh->nh_flags = fib_nh->fib_nh_flags;
                fib_info_update_nhc_saddr(net, &fib_nh->nh_common,
-                                         fib_nh->fib_nh_scope);
+                                         !fib_nh->fib_nh_scope ? 0 : fib_nh->fib_nh_scope - 1);
        } else {
                fib_nh_release(net, fib_nh);
        }