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 04/13] ipv6: Pass fib6_result to ip6_create_rt_rcu
Date: Mon, 15 Apr 2019 17:56:43 -0700 [thread overview]
Message-ID: <20190416005652.29286-5-dsahern@kernel.org> (raw)
In-Reply-To: <20190416005652.29286-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
Change ip6_create_rt_rcu to take fib6_result over a fib6_info.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
net/ipv6/route.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index f267b3060ac7..5e84d0894f6b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1038,22 +1038,24 @@ static bool ip6_hold_safe(struct net *net, struct rt6_info **prt)
}
/* called with rcu_lock held */
-static struct rt6_info *ip6_create_rt_rcu(struct fib6_info *rt)
+static struct rt6_info *ip6_create_rt_rcu(const struct fib6_result *res)
{
- unsigned short flags = fib6_info_dst_flags(rt);
- struct net_device *dev = rt->fib6_nh.fib_nh_dev;
+ struct net_device *dev = res->nh->fib_nh_dev;
+ struct fib6_info *f6i = res->f6i;
+ unsigned short flags;
struct rt6_info *nrt;
- if (!fib6_info_hold_safe(rt))
+ if (!fib6_info_hold_safe(f6i))
goto fallback;
+ flags = fib6_info_dst_flags(f6i);
nrt = ip6_dst_alloc(dev_net(dev), dev, flags);
if (!nrt) {
- fib6_info_release(rt);
+ fib6_info_release(f6i);
goto fallback;
}
- ip6_rt_copy_init(nrt, rt);
+ ip6_rt_copy_init(nrt, f6i);
return nrt;
fallback:
@@ -1104,7 +1106,7 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net,
if (ip6_hold_safe(net, &rt))
dst_use_noref(&rt->dst, jiffies);
} else {
- rt = ip6_create_rt_rcu(res.f6i);
+ rt = ip6_create_rt_rcu(&res);
}
out:
@@ -2413,12 +2415,13 @@ void ip6_sk_dst_store_flow(struct sock *sk, struct dst_entry *dst,
NULL);
}
-static bool ip6_redirect_nh_match(struct fib6_info *f6i,
- struct fib6_nh *nh,
+static bool ip6_redirect_nh_match(const struct fib6_result *res,
struct flowi6 *fl6,
const struct in6_addr *gw,
struct rt6_info **ret)
{
+ const struct fib6_nh *nh = res->nh;
+
if (nh->fib_nh_flags & RTNH_F_DEAD || !nh->fib_nh_gw_family ||
fl6->flowi6_oif != nh->fib_nh_dev->ifindex)
return false;
@@ -2429,12 +2432,9 @@ static bool ip6_redirect_nh_match(struct fib6_info *f6i,
* is different.
*/
if (!ipv6_addr_equal(gw, &nh->fib_nh_gw6)) {
- struct fib6_result res = {
- .f6i = f6i,
- };
struct rt6_info *rt_cache;
- rt_cache = rt6_find_cached_rt(&res, &fl6->daddr, &fl6->saddr);
+ rt_cache = rt6_find_cached_rt(res, &fl6->daddr, &fl6->saddr);
if (rt_cache &&
ipv6_addr_equal(gw, &rt_cache->rt6i_gateway)) {
*ret = rt_cache;
@@ -2459,6 +2459,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
{
struct ip6rd_flowi *rdfl = (struct ip6rd_flowi *)fl6;
struct rt6_info *ret = NULL;
+ struct fib6_result res = {};
struct fib6_info *rt;
struct fib6_node *fn;
@@ -2476,12 +2477,14 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
restart:
for_each_fib6_node_rt_rcu(fn) {
+ res.f6i = rt;
+ res.nh = &rt->fib6_nh;
+
if (fib6_check_expired(rt))
continue;
if (rt->fib6_flags & RTF_REJECT)
break;
- if (ip6_redirect_nh_match(rt, &rt->fib6_nh, fl6,
- &rdfl->gateway, &ret))
+ if (ip6_redirect_nh_match(&res, fl6, &rdfl->gateway, &ret))
goto out;
}
@@ -2498,11 +2501,13 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
goto restart;
}
+ res.f6i = rt;
+ res.nh = &rt->fib6_nh;
out:
if (ret)
ip6_hold_safe(net, &ret);
else
- ret = ip6_create_rt_rcu(rt);
+ ret = ip6_create_rt_rcu(&res);
rcu_read_unlock();
--
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 ` David Ahern [this message]
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 ` [PATCH net-next 09/13] ipv6: Pass fib6_result to rt6_device_match David Ahern
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-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.