From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f194.google.com ([209.85.192.194]:36112 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980AbeBYTr4 (ORCPT ); Sun, 25 Feb 2018 14:47:56 -0500 Received: by mail-pf0-f194.google.com with SMTP id 68so5664395pfx.3 for ; Sun, 25 Feb 2018 11:47:56 -0800 (PST) From: David Ahern To: netdev@vger.kernel.org Cc: davem@davemloft.net, idosch@idosch.org, roopa@cumulusnetworks.com, eric.dumazet@gmail.com, weiwan@google.com, kafai@fb.com, yoshfuji@linux-ipv6.org, David Ahern Subject: [PATCH RFC net-next 12/20] net/ipv6: Add rt6_info create function for ip6_pol_route_lookup Date: Sun, 25 Feb 2018 11:47:22 -0800 Message-Id: <20180225194730.30063-13-dsahern@gmail.com> In-Reply-To: <20180225194730.30063-1-dsahern@gmail.com> References: <20180225194730.30063-1-dsahern@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: ip6_pol_route_lookup is the lookup function for ip6_route_lookup and rt6_lookup. At the moment it returns either a reference to a FIB entry or a cached exception. To move FIB entries to a separate struct, this lookup function need to convert FIB entries to an rt6_info that is returned to the caller. Signed-off-by: David Ahern --- net/ipv6/route.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 31832b170a9f..066203d2f9d3 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1053,6 +1053,20 @@ static bool ip6_hold_safe(struct net *net, struct rt6_info **prt, return false; } +/* called with rcu_lock held */ +static struct rt6_info *ip6_create_rt_rcu(struct rt6_info *rt) +{ + struct net_device *dev; + struct rt6_info *nrt; + + dev = ip6_rt_get_dev_rcu(rt); + nrt = __ip6_dst_alloc(dev_net(dev), dev, 0); + if (nrt) + ip6_rt_copy_init(nrt, rt); + + return nrt; +} + static struct rt6_info *ip6_pol_route_lookup(struct net *net, struct fib6_table *table, struct flowi6 *fl6, int flags) @@ -1080,18 +1094,19 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net, } /* Search through exception table */ rt_cache = rt6_find_cached_rt(rt, &fl6->daddr, &fl6->saddr); - if (rt_cache) + if (rt_cache) { rt = rt_cache; - - if (ip6_hold_safe(net, &rt, true)) - dst_use_noref(&rt->dst, jiffies); + if (ip6_hold_safe(net, &rt, true)) + dst_use_noref(&rt->dst, jiffies); + } else { + rt = ip6_create_rt_rcu(rt); + } rcu_read_unlock(); trace_fib6_table_lookup(net, rt, table, fl6); return rt; - } struct dst_entry *ip6_route_lookup(struct net *net, struct flowi6 *fl6, -- 2.11.0