From: David Ahern <dsahern@kernel.org>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: idosch@mellanox.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next 09/13] ipv6: Pass fib6_result to rt6_device_match
Date: Mon, 15 Apr 2019 17:56:48 -0700 [thread overview]
Message-ID: <20190416005652.29286-10-dsahern@kernel.org> (raw)
In-Reply-To: <20190416005652.29286-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
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>
---
net/ipv6/route.c | 49 ++++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c28fd554f7cf..7a3eecdb933d 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 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net,
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);
--
2.11.0
next prev parent reply other threads:[~2019-04-16 0:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 0:56 [PATCH net-next 00/13] ipv6: Use fib6_result for fib_lookups David Ahern
2019-04-16 0:56 ` [PATCH net-next 01/13] ipv6: Rename fib6_multipath_select and pass fib6_result David Ahern
2019-04-16 0:56 ` [PATCH net-next 02/13] ipv6: Pass fib6_result to rt6_find_cached_rt David Ahern
2019-04-16 0:56 ` [PATCH net-next 03/13] ipv6: Pass fib6_result to ip6_rt_cache_alloc David Ahern
2019-04-16 0:56 ` [PATCH net-next 04/13] ipv6: Pass fib6_result to ip6_create_rt_rcu David Ahern
2019-04-16 0:56 ` [PATCH net-next 05/13] ipv6: Pass fib6_result to pcpu route functions David Ahern
2019-04-16 0:56 ` [PATCH net-next 06/13] ipv6: Pass fib6_result to ip6_rt_get_dev_rcu and ip6_rt_copy_init David Ahern
2019-04-16 0:56 ` [PATCH net-next 07/13] ipv6: Pass fib6_result to rt6_insert_exception David Ahern
2019-04-16 0:56 ` [PATCH net-next 08/13] ipv6: Pass fib6_result to ip6_mtu_from_fib6 and fib6_mtu David Ahern
2019-04-16 0:56 ` David Ahern [this message]
2019-04-16 0:56 ` [PATCH net-next 10/13] ipv6: Pass fib6_result to rt6_select and find_rr_leaf David Ahern
2019-04-16 0:56 ` [PATCH net-next 11/13] ipv6: Pass fib6_result to fib6_table_lookup tracepoint David Ahern
2019-04-16 0:56 ` [PATCH net-next 12/13] ipv6: Pass fib6_result to fib lookups David Ahern
2019-04-16 15:00 ` David Ahern
2019-04-16 0:56 ` [PATCH net-next 13/13] ipv6: Add fib6_type and fib6_flags to fib6_result David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190416005652.29286-10-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=idosch@mellanox.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).