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 9AF65C10F12 for ; Tue, 16 Apr 2019 00:56:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AC4C20830 for ; Tue, 16 Apr 2019 00:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555376195; bh=VmQ7yCac4D2i8AMEplKBqcbYsMU4bg1+LlrF0sXlA1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=i7rmOyoSnOx9yjQcG5yZupsbB7To3f1BGrFgvzc20oUZqk4crxP9A+mR+rtMYzRpl rFLqQ3G1zMSONO3nYyEs75J3jnli2cgCYugqw76KaOkS3UifnmyRXT0qtomlc9BzKg O2jp2T2/jqhzHnQsxZJ9S4FD1czupUYzQXj9mZ7g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728364AbfDPA4e (ORCPT ); Mon, 15 Apr 2019 20:56:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:41828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728289AbfDPA4V (ORCPT ); Mon, 15 Apr 2019 20:56:21 -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 E4C96218FE; Tue, 16 Apr 2019 00:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555376181; bh=VmQ7yCac4D2i8AMEplKBqcbYsMU4bg1+LlrF0sXlA1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmGdaGO5bqRr1R2aKTZOZ4q1Oeh8QFx/X22yMbsAz1M0KucM2Woks6pk4Hc0vj88w IbK688McRtKKVEumKqYPZ7Li5MKtjFcDWJs322AUmW2cNhUR62zObGXA55o+jPwIzm fLTdmzPFST6L/Z40yl845+SiBo7+PbKHYmCrV1tY= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, David Ahern Subject: [PATCH net-next 10/13] ipv6: Pass fib6_result to rt6_select and find_rr_leaf Date: Mon, 15 Apr 2019 17:56:49 -0700 Message-Id: <20190416005652.29286-11-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190416005652.29286-1-dsahern@kernel.org> References: <20190416005652.29286-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Pass fib6_result to rt6_select. Instead of returning the fib entry, it will set f6i and nh based on the lookup. find_rr_leaf is changed to remove the match option in favor of taking fib6_result and having __find_rr_leaf set f6i in the result. In the process, update fib6_info references in __find_rr_leaf to f6i names. Signed-off-by: David Ahern --- net/ipv6/route.c | 82 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 7a3eecdb933d..de2a901b4d30 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -695,66 +695,68 @@ static bool find_match(struct fib6_nh *nh, u32 fib6_flags, return rc; } -static void __find_rr_leaf(struct fib6_info *rt_start, +static void __find_rr_leaf(struct fib6_info *f6i_start, struct fib6_info *nomatch, u32 metric, - struct fib6_info **match, struct fib6_info **cont, + struct fib6_result *res, struct fib6_info **cont, int oif, int strict, bool *do_rr, int *mpri) { - struct fib6_info *rt; + struct fib6_info *f6i; - for (rt = rt_start; - rt && rt != nomatch; - rt = rcu_dereference(rt->fib6_next)) { + for (f6i = f6i_start; + f6i && f6i != nomatch; + f6i = rcu_dereference(f6i->fib6_next)) { struct fib6_nh *nh; - if (cont && rt->fib6_metric != metric) { - *cont = rt; + if (cont && f6i->fib6_metric != metric) { + *cont = f6i; return; } - if (fib6_check_expired(rt)) + if (fib6_check_expired(f6i)) continue; - nh = &rt->fib6_nh; - if (find_match(nh, rt->fib6_flags, oif, strict, mpri, do_rr)) - *match = rt; + nh = &f6i->fib6_nh; + if (find_match(nh, f6i->fib6_flags, oif, strict, mpri, do_rr)) { + res->f6i = f6i; + res->nh = nh; + } } } -static struct fib6_info *find_rr_leaf(struct fib6_node *fn, - struct fib6_info *leaf, - struct fib6_info *rr_head, - u32 metric, int oif, int strict, - bool *do_rr) +static void find_rr_leaf(struct fib6_node *fn, struct fib6_info *leaf, + struct fib6_info *rr_head, int oif, int strict, + bool *do_rr, struct fib6_result *res) { - struct fib6_info *match = NULL, *cont = NULL; + u32 metric = rr_head->fib6_metric; + struct fib6_info *cont = NULL; int mpri = -1; - __find_rr_leaf(rr_head, NULL, metric, &match, &cont, + __find_rr_leaf(rr_head, NULL, metric, res, &cont, oif, strict, do_rr, &mpri); - __find_rr_leaf(leaf, rr_head, metric, &match, &cont, + __find_rr_leaf(leaf, rr_head, metric, res, &cont, oif, strict, do_rr, &mpri); - if (match || !cont) - return match; + if (res->f6i || !cont) + return; - __find_rr_leaf(cont, NULL, metric, &match, NULL, + __find_rr_leaf(cont, NULL, metric, res, NULL, oif, strict, do_rr, &mpri); - - return match; } -static struct fib6_info *rt6_select(struct net *net, struct fib6_node *fn, - int oif, int strict) +static void rt6_select(struct net *net, struct fib6_node *fn, int oif, + struct fib6_result *res, int strict) { struct fib6_info *leaf = rcu_dereference(fn->leaf); - struct fib6_info *match, *rt0; + struct fib6_info *rt0; bool do_rr = false; int key_plen; + /* make sure this function or its helpers sets f6i */ + res->f6i = NULL; + if (!leaf || leaf == net->ipv6.fib6_null_entry) - return net->ipv6.fib6_null_entry; + goto out; rt0 = rcu_dereference(fn->rr_ptr); if (!rt0) @@ -771,11 +773,9 @@ static struct fib6_info *rt6_select(struct net *net, struct fib6_node *fn, key_plen = rt0->fib6_src.plen; #endif if (fn->fn_bit != key_plen) - return net->ipv6.fib6_null_entry; - - match = find_rr_leaf(fn, leaf, rt0, rt0->fib6_metric, oif, strict, - &do_rr); + goto out; + find_rr_leaf(fn, leaf, rt0, oif, strict, &do_rr, res); if (do_rr) { struct fib6_info *next = rcu_dereference(rt0->fib6_next); @@ -792,7 +792,11 @@ static struct fib6_info *rt6_select(struct net *net, struct fib6_node *fn, } } - return match ? match : net->ipv6.fib6_null_entry; +out: + if (!res->f6i) { + res->f6i = net->ipv6.fib6_null_entry; + res->nh = &res->f6i->fib6_nh; + } } static bool rt6_is_gw_or_nonexthop(const struct fib6_result *res) @@ -1839,7 +1843,7 @@ struct fib6_info *fib6_table_lookup(struct net *net, struct fib6_table *table, int oif, struct flowi6 *fl6, int strict) { struct fib6_node *fn, *saved_fn; - struct fib6_info *f6i; + struct fib6_result res; fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr); saved_fn = fn; @@ -1848,8 +1852,8 @@ struct fib6_info *fib6_table_lookup(struct net *net, struct fib6_table *table, oif = 0; redo_rt6_select: - f6i = rt6_select(net, fn, oif, strict); - if (f6i == net->ipv6.fib6_null_entry) { + rt6_select(net, fn, oif, &res, strict); + if (res.f6i == net->ipv6.fib6_null_entry) { fn = fib6_backtrack(fn, &fl6->saddr); if (fn) goto redo_rt6_select; @@ -1861,9 +1865,9 @@ struct fib6_info *fib6_table_lookup(struct net *net, struct fib6_table *table, } } - trace_fib6_table_lookup(net, f6i, table, fl6); + trace_fib6_table_lookup(net, res.f6i, table, fl6); - return f6i; + return res.f6i; } struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, -- 2.11.0