Commit 75ef7389 authored by David Ahern's avatar David Ahern Committed by David S. Miller

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: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b748f260
...@@ -491,29 +491,40 @@ static bool __rt6_device_match(struct net *net, const struct fib6_nh *nh, ...@@ -491,29 +491,40 @@ static bool __rt6_device_match(struct net *net, const struct fib6_nh *nh,
return false; return false;
} }
static inline struct fib6_info *rt6_device_match(struct net *net, static void rt6_device_match(struct net *net, struct fib6_result *res,
struct fib6_info *rt, const struct in6_addr *saddr, int oif, int flags)
const struct in6_addr *saddr,
int oif,
int flags)
{ {
const struct fib6_nh *nh; struct fib6_info *f6i = res->f6i;
struct fib6_info *sprt; struct fib6_info *spf6i;
struct fib6_nh *nh;
if (!oif && ipv6_addr_any(saddr) && if (!oif && ipv6_addr_any(saddr)) {
!(rt->fib6_nh.fib_nh_flags & RTNH_F_DEAD)) nh = &f6i->fib6_nh;
return rt; if (!(nh->fib_nh_flags & RTNH_F_DEAD)) {
res->nh = nh;
return;
}
}
for (sprt = rt; sprt; sprt = rcu_dereference(sprt->fib6_next)) { for (spf6i = f6i; spf6i; spf6i = rcu_dereference(spf6i->fib6_next)) {
nh = &sprt->fib6_nh; nh = &spf6i->fib6_nh;
if (__rt6_device_match(net, nh, saddr, oif, flags)) if (__rt6_device_match(net, nh, saddr, oif, flags)) {
return sprt; res->f6i = spf6i;
res->nh = nh;
}
} }
if (oif && flags & RT6_LOOKUP_F_IFACE) if (oif && flags & RT6_LOOKUP_F_IFACE) {
return net->ipv6.fib6_null_entry; 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 #ifdef CONFIG_IPV6_ROUTER_PREF
...@@ -1089,8 +1100,8 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net, ...@@ -1089,8 +1100,8 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net,
if (!res.f6i) if (!res.f6i)
res.f6i = net->ipv6.fib6_null_entry; res.f6i = net->ipv6.fib6_null_entry;
else else
res.f6i = rt6_device_match(net, res.f6i, &fl6->saddr, rt6_device_match(net, &res, &fl6->saddr, fl6->flowi6_oif,
fl6->flowi6_oif, flags); flags);
if (res.f6i == net->ipv6.fib6_null_entry) { if (res.f6i == net->ipv6.fib6_null_entry) {
fn = fib6_backtrack(fn, &fl6->saddr); fn = fib6_backtrack(fn, &fl6->saddr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment