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 A034AC2BCA1 for ; Fri, 7 Jun 2019 15:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DBAE216FD for ; Fri, 7 Jun 2019 15:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559920189; bh=C1+wGeXgNDF+9FLVILtIpbHjcxHE+u2STjEyMpcdQNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sNMIo812V9kzITF7ED4V24ekSS6JxleMK2wk3F10LBWh4EHf6ojNt/oEKHIbf1WTl QxXeH3IsZlPjkK4/9CKd7gSG4yO0wt1/HNCo8OPTUOSAjDXDAgMjBEDv4SWjLBWtPI tQcJV2rMZ7VhtjCyWeSKlGnzOhRV0YEqC6wpyzqQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729759AbfFGPJs (ORCPT ); Fri, 7 Jun 2019 11:09:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:51372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729485AbfFGPJp (ORCPT ); Fri, 7 Jun 2019 11:09:45 -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 C228F214C6; Fri, 7 Jun 2019 15:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559920184; bh=C1+wGeXgNDF+9FLVILtIpbHjcxHE+u2STjEyMpcdQNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CZeEvOsFsz8BN3eJ91UwwagA9cBhmJQzD5htibCNcPquunymMYQD/djzJdPawukkw yWtFrrqt1yevu6bmH7f2z/f2XflELcBKWWMnBgUTW5mWauJJthm31DbsCsrTTphaSx +3NnpHmjUaxuCUwky4Bbr4hw2Yuf4lLW+pFIpIBo= 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 09/20] ipv6: Handle all fib6_nh in a nexthop in rt6_do_redirect Date: Fri, 7 Jun 2019 08:09:30 -0700 Message-Id: <20190607150941.11371-10-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 Use nexthop_for_each_fib6_nh and fib6_nh_find_match to find the fib6_nh in a nexthop that correlates to the device and gateway in the rt6_info. Signed-off-by: David Ahern --- net/ipv6/route.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 20bb19d4141e..098d3618ceb9 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3901,7 +3901,25 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu if (!res.f6i) goto out; - res.nh = res.f6i->fib6_nh; + if (res.f6i->nh) { + struct fib6_nh_match_arg arg = { + .dev = dst->dev, + .gw = &rt->rt6i_gateway, + }; + + nexthop_for_each_fib6_nh(res.f6i->nh, + fib6_nh_find_match, &arg); + + /* fib6_info uses a nexthop that does not have fib6_nh + * using the dst->dev. Should be impossible + */ + if (!arg.match) + return; + res.nh = arg.match; + } else { + res.nh = res.f6i->fib6_nh; + } + res.fib6_flags = res.f6i->fib6_flags; res.fib6_type = res.f6i->fib6_type; nrt = ip6_rt_cache_alloc(&res, &msg->dest, NULL); -- 2.11.0