diff options
author | David Ahern <dsahern@gmail.com> | 2019-04-17 00:36:07 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-18 09:10:47 +0300 |
commit | 75ef7389dd2339e5f2a7347aadbdbded8dd8430f (patch) | |
tree | d38595fdb002e663196f0138463c2617d67cd4fc /net/ipv6 | |
parent | b748f26092626332f73e71d75e4390de6b8bdf9b (diff) | |
download | linux-75ef7389dd2339e5f2a7347aadbdbded8dd8430f.tar.xz |
ipv6: Pass fib6_result to rt6_device_match
Pass fib6_result to rt6_device_match with f6i set. rt6_device_match
updates f6i in the result if it finds a better match and sets nh.
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/route.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 85799a09e144..6bea5ac05982 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -491,29 +491,40 @@ static bool __rt6_device_match(struct net *net, const struct fib6_nh *nh, return false; } -static inline struct fib6_info *rt6_device_match(struct net *net, - struct fib6_info *rt, - const struct in6_addr *saddr, - int oif, - int flags) +static void rt6_device_match(struct net *net, struct fib6_result *res, + const struct in6_addr *saddr, int oif, int flags) { - const struct fib6_nh *nh; - struct fib6_info *sprt; + struct fib6_info *f6i = res->f6i; + struct fib6_info *spf6i; + struct fib6_nh *nh; - if (!oif && ipv6_addr_any(saddr) && - !(rt->fib6_nh.fib_nh_flags & RTNH_F_DEAD)) - return rt; + if (!oif && ipv6_addr_any(saddr)) { + nh = &f6i->fib6_nh; + if (!(nh->fib_nh_flags & RTNH_F_DEAD)) { + res->nh = nh; + return; + } + } - for (sprt = rt; sprt; sprt = rcu_dereference(sprt->fib6_next)) { - nh = &sprt->fib6_nh; - if (__rt6_device_match(net, nh, saddr, oif, flags)) - return sprt; + for (spf6i = f6i; spf6i; spf6i = rcu_dereference(spf6i->fib6_next)) { + nh = &spf6i->fib6_nh; + if (__rt6_device_match(net, nh, saddr, oif, flags)) { + res->f6i = spf6i; + res->nh = nh; + } } - if (oif && flags & RT6_LOOKUP_F_IFACE) - return net->ipv6.fib6_null_entry; + if (oif && flags & RT6_LOOKUP_F_IFACE) { + res->f6i = net->ipv6.fib6_null_entry; + res->nh = &res->f6i->fib6_nh; + return; + } - return rt->fib6_nh.fib_nh_flags & RTNH_F_DEAD ? net->ipv6.fib6_null_entry : rt; + res->nh = &f6i->fib6_nh; + if (res->nh->fib_nh_flags & RTNH_F_DEAD) { + res->f6i = net->ipv6.fib6_null_entry; + res->nh = &res->f6i->fib6_nh; + } } #ifdef CONFIG_IPV6_ROUTER_PREF @@ -1089,8 +1100,8 @@ restart: if (!res.f6i) res.f6i = net->ipv6.fib6_null_entry; else - res.f6i = rt6_device_match(net, res.f6i, &fl6->saddr, - fl6->flowi6_oif, flags); + rt6_device_match(net, &res, &fl6->saddr, fl6->flowi6_oif, + flags); if (res.f6i == net->ipv6.fib6_null_entry) { fn = fib6_backtrack(fn, &fl6->saddr); |