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=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,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 6128AC468BD for ; Fri, 7 Jun 2019 15:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3ACA821655 for ; Fri, 7 Jun 2019 15:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559920186; bh=kFEAIyzBfwcYI9meJokuOZ6z0r4O6u6it5pY8fg4aKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YHj5oY+8JEFmLNw2cjlmgaYFKUpDuZ4/vAcRjd7dlBFlwk3JMHS16gsnqQykxWw9s mIWJaiudRqTPtP7y8HcJegHsVeHa0Cg/Mn4FllpO61S5otxNZ5L8aILhjTsUR3AEh6 zB2TrPr1zqZEqSTsdsxSayv3mSYE3Lqx55e0Ukek= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729660AbfFGPJp (ORCPT ); Fri, 7 Jun 2019 11:09:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:51280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729574AbfFGPJn (ORCPT ); Fri, 7 Jun 2019 11:09:43 -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 09B292146E; Fri, 7 Jun 2019 15:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559920183; bh=kFEAIyzBfwcYI9meJokuOZ6z0r4O6u6it5pY8fg4aKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQ55OudG/WW+EWVcNBIL1k9WqZYCjqUwBiLpJz7gZxlJc8IyTRjofBFmt6lpvv9l7 BM04C7lZ0j9kWQ9lRwjkzttk9AWjqTsTM/VdGfDe0NQpc3ivvCvA+BhChtxHi4kiuj CgtvcCmCkdCM9IZgkI31CIK1KMTZH+geocS6Bja4= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, kafai@fb.com, weiwan@google.com, sbrivio@redhat.com, David Ahern Subject: [PATCH v2 net-next 03/20] ipv6: Handle all fib6_nh in a nexthop in rt6_device_match Date: Fri, 7 Jun 2019 08:09:24 -0700 Message-Id: <20190607150941.11371-4-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190607150941.11371-1-dsahern@kernel.org> References: <20190607150941.11371-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Add a hook in rt6_device_match to handle nexthop struct in a fib6_info. The new rt6_nh_dev_match uses nexthop_for_each_fib6_nh to walk each fib6_nh in a nexthop and call __rt6_device_match. On match, rt6_nh_dev_match returns the fib6_nh and rt6_device_match uses it to setup fib6_result. Signed-off-by: David Ahern --- net/ipv6/route.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index f42fe3dcb8c6..8cb59554c023 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -494,6 +494,45 @@ static bool __rt6_device_match(struct net *net, const struct fib6_nh *nh, return false; } +struct fib6_nh_dm_arg { + struct net *net; + const struct in6_addr *saddr; + int oif; + int flags; + struct fib6_nh *nh; +}; + +static int __rt6_nh_dev_match(struct fib6_nh *nh, void *_arg) +{ + struct fib6_nh_dm_arg *arg = _arg; + + arg->nh = nh; + return __rt6_device_match(arg->net, nh, arg->saddr, arg->oif, + arg->flags); +} + +/* returns fib6_nh from nexthop or NULL */ +static struct fib6_nh *rt6_nh_dev_match(struct net *net, struct nexthop *nh, + struct fib6_result *res, + const struct in6_addr *saddr, + int oif, int flags) +{ + struct fib6_nh_dm_arg arg = { + .net = net, + .saddr = saddr, + .oif = oif, + .flags = flags, + }; + + if (nexthop_is_blackhole(nh)) + return NULL; + + if (nexthop_for_each_fib6_nh(nh, __rt6_nh_dev_match, &arg)) + return arg.nh; + + return NULL; +} + static void rt6_device_match(struct net *net, struct fib6_result *res, const struct in6_addr *saddr, int oif, int flags) { @@ -514,8 +553,19 @@ static void rt6_device_match(struct net *net, struct fib6_result *res, } for (spf6i = f6i; spf6i; spf6i = rcu_dereference(spf6i->fib6_next)) { - nh = spf6i->fib6_nh; - if (__rt6_device_match(net, nh, saddr, oif, flags)) { + bool matched = false; + + if (unlikely(spf6i->nh)) { + nh = rt6_nh_dev_match(net, spf6i->nh, res, saddr, + oif, flags); + if (nh) + matched = true; + } else { + nh = spf6i->fib6_nh; + if (__rt6_device_match(net, nh, saddr, oif, flags)) + matched = true; + } + if (matched) { res->f6i = spf6i; goto out; } -- 2.11.0