From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C16B4C282CE for ; Tue, 9 Apr 2019 21:41:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E4832082A for ; Tue, 9 Apr 2019 21:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554846085; bh=dm9CucMsoMTTUeQSZNb55ti7DwCZJKTm/I2MRwWedMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jenhDNRqZm6iXyHq1bnHK6KMh3lIgf3urDBZ897tmiFe22IdVcXr09mQrERxJ/Bsv NfeZj9uf0VeLAHQWMUxZFTz19CX0RfPYxQFOPurxoqUMLrFXqAiAnqEicZkt4kx0f8 M2iSUct09JiTa79hVmNpxbcVyudj860viEokSaVk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727011AbfDIVlY (ORCPT ); Tue, 9 Apr 2019 17:41:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbfDIVlB (ORCPT ); Tue, 9 Apr 2019 17:41:01 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 515BE218E2; Tue, 9 Apr 2019 21:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554846060; bh=dm9CucMsoMTTUeQSZNb55ti7DwCZJKTm/I2MRwWedMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bf1xle6WdLRuLtAdeuDDDHmQs6r5kTp5uEXiDcde5ixQ+4//MhqhyOifX0siySPeS xQrxhYxY0NAgcoNMx2SPotjMuJ0Q8KWs+eEeGI3kY4pYpn+anW7tDi8cRI+xVDkLKu mC01JxyRAP0BIZ7T4a0f3yzjZyl+E2zUQuzGA36c= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, David Ahern 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 Message-Id: <20190409214119.15258-8-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190409214119.15258-1-dsahern@kernel.org> References: <20190409214119.15258-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern 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 --- 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