public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
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 07/10] ipv6: Be smarter with null_entry handling in ip6_pol_route_lookup
Date: Tue,  9 Apr 2019 14:41:16 -0700	[thread overview]
Message-ID: <20190409214119.15258-8-dsahern@kernel.org> (raw)
In-Reply-To: <20190409214119.15258-1-dsahern@kernel.org>

From: David Ahern <dsahern@gmail•com>

Clean up the fib6_null_entry handling in ip6_pol_route_lookup.
rt6_device_match can return fib6_null_entry, but fib6_multipath_select
can not. Consolidate the fib6_null_entry handling and on the final
null_entry check set rt and goto out - no need to defer to a second
check after rt6_find_cached_rt.

Signed-off-by: David Ahern <dsahern@gmail•com>
---
 net/ipv6/route.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 52aa48a8dbda..0745ed872e5b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1062,36 +1062,37 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net,
 	fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
 restart:
 	f6i = rcu_dereference(fn->leaf);
-	if (!f6i) {
+	if (!f6i)
 		f6i = net->ipv6.fib6_null_entry;
-	} else {
+	else
 		f6i = rt6_device_match(net, f6i, &fl6->saddr,
 				      fl6->flowi6_oif, flags);
-		if (f6i->fib6_nsiblings && fl6->flowi6_oif == 0)
-			f6i = fib6_multipath_select(net, f6i, fl6,
-						    fl6->flowi6_oif, skb,
-						    flags);
-	}
+
 	if (f6i == net->ipv6.fib6_null_entry) {
 		fn = fib6_backtrack(fn, &fl6->saddr);
 		if (fn)
 			goto restart;
-	}
 
-	trace_fib6_table_lookup(net, f6i, table, fl6);
+		rt = net->ipv6.ip6_null_entry;
+		dst_hold(&rt->dst);
+		goto out;
+	}
 
+	if (f6i->fib6_nsiblings && fl6->flowi6_oif == 0)
+		f6i = fib6_multipath_select(net, f6i, fl6, fl6->flowi6_oif, skb,
+					    flags);
 	/* Search through exception table */
 	rt = rt6_find_cached_rt(f6i, &fl6->daddr, &fl6->saddr);
 	if (rt) {
 		if (ip6_hold_safe(net, &rt))
 			dst_use_noref(&rt->dst, jiffies);
-	} else if (f6i == net->ipv6.fib6_null_entry) {
-		rt = net->ipv6.ip6_null_entry;
-		dst_hold(&rt->dst);
 	} else {
 		rt = ip6_create_rt_rcu(f6i);
 	}
 
+out:
+	trace_fib6_table_lookup(net, f6i, table, fl6);
+
 	rcu_read_unlock();
 
 	return rt;
-- 
2.11.0


  parent reply	other threads:[~2019-04-09 21:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 21:41 [PATCH net-next 00/10] ipv6: Refactor nexthop selection helpers during a fib lookup David Ahern
2019-04-09 21:41 ` [PATCH net-next 01/10] ipv6: Only call rt6_check_neigh for nexthop with gateway David Ahern
2019-04-09 21:41 ` [PATCH net-next 02/10] ipv6: Remove rt6_check_dev David Ahern
2019-04-09 21:41 ` [PATCH net-next 03/10] ipv6: Change rt6_probe to take a fib6_nh David Ahern
2019-04-09 21:41 ` [PATCH net-next 04/10] ipv6: Pass fib6_nh and flags to rt6_score_route David Ahern
2019-04-09 21:41 ` [PATCH net-next 05/10] ipv6: Refactor find_match David Ahern
2019-04-09 21:41 ` [PATCH net-next 06/10] ipv6: Refactor find_rr_leaf David Ahern
2019-04-09 21:41 ` David Ahern [this message]
2019-04-09 21:41 ` [PATCH net-next 08/10] ipv6: Move fib6_multipath_select down in ip6_pol_route David Ahern
2019-04-09 21:41 ` [PATCH net-next 09/10] ipv6: Refactor rt6_device_match David Ahern
2019-04-09 21:41 ` [PATCH net-next 10/10] ipv6: Refactor __ip6_route_redirect David Ahern
2019-04-10 17:36   ` Martin Lau
2019-04-10 18:45     ` David Ahern
2019-04-10 20:45       ` Martin Lau
2019-04-11  4:54         ` David Ahern
2019-04-11 21:24 ` [PATCH net-next 00/10] ipv6: Refactor nexthop selection helpers during a fib lookup David Miller

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=20190409214119.15258-8-dsahern@kernel.org \
    --to=dsahern@kernel$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=dsahern@gmail$(echo .)com \
    --cc=idosch@mellanox$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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