Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9741574rwp; Thu, 20 Jul 2023 09:03:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlF8zQj1pXvIeAhAtw6PE/j7s6G8A0056a7z1o+nC/0UKZah4jhhObK75UuIj+cej+d4+EGK X-Received: by 2002:a17:906:1096:b0:993:d9bb:748b with SMTP id u22-20020a170906109600b00993d9bb748bmr5020356eju.1.1689869038401; Thu, 20 Jul 2023 09:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689869038; cv=none; d=google.com; s=arc-20160816; b=WP1gTPI/30cptsaMg7sea4vxcC9HFktx3yc0ljBmIlrKawfP3G7IbEbrweLMNkaQLx s5MgvnnlITcr4BMuGCp+CEfJ9gDeZfJfKrrcR4CTJzBLTNZjMn6cPGZl9sJ0chRtSwsp DcswP23RMKk6Bl3dBIUNxqRf2ZRPW4SpzxkOBLadzu3IkF1fHnHknRtlRcLlon1UQ+9b lv88o3EEIfVA9hwmTvb028uv0F6mv9oqVDtgyE2xq1PCijwGz5v6+nO+Rr9VADLRf6TR ZF4lZTYcHzUdJjHLvEWrBMnFNzYlq822TRthoD1V9XXo1ee/CO45jJ2YpfPErJPs3yG4 Otww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ZdVJZVl6fStQQeKvcn+uv4he0gktFQA+lWrCoBobdhE=; fh=LiqxiaYtrbpNYsoyBrjp6J6GjE6TDCW22vDAUEKbyiM=; b=uXc3RLB3B0l2l6mfqwwkAr88rbXNKBda5J/+gHwq/M9ot4HQ9PTakPsUcBL+nopT7a I9pU7NWpXP4XPDUVxNSgK/F1InIAmenOKb28MlyiRaMzHW1jsGvyivmH2FJiz52x4tmi a/PbfNcQNbai5uUy7L1u/Vp0QGQnSDGzu9TVXmkAsJA1s3611RuM5RqTw6oTuf0zLMzg R4t2T1nC3lEW2EmusJ8O9zLHJxK0vX0gqUXlkM2AJr6NedDzKQNrzRSGqI/AdriMEE9M Rm3bQqv55z6jycHxNUf9NX0dbWdg4JTmp1t1aSkfJShipyqI1e43O7Ezr3HnLE07nsu6 2SYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DXSLZmG9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c22-20020a17090603d600b00992fec0f917si890012eja.634.2023.07.20.09.03.23; Thu, 20 Jul 2023 09:03:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DXSLZmG9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232494AbjGTPSa (ORCPT + 99 others); Thu, 20 Jul 2023 11:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232509AbjGTPSX (ORCPT ); Thu, 20 Jul 2023 11:18:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8F4A26B5; Thu, 20 Jul 2023 08:18:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F182661B4C; Thu, 20 Jul 2023 15:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE618C433CA; Thu, 20 Jul 2023 15:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689866298; bh=sa++SOpu0OOLby+nKZrbEuQPjr0iW/gaMnyzIgw8AIU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=DXSLZmG9sH0SlU10hMwLPvpQ57q5vtc5mk3AOtculg3jPG/bzaG/46wihnNLqpBMY yIxcbT7DTFFZDQOfrHs48EqyD+YFZbAGdxgkLCqj+8CMxTBt3HQ++0NhH7u0iTVTx9 x9NsVsjIEjoWKrgfh7HYIk/yjxAiADzoiff2n14ynez7axrZy1+OeL0bK/ZlHPv1in SUeHNo0McwOMg4p70PH1whla7mm4AVI8Fnsor4TXJYlo4AK5+fbA0gSA5g5JNf7dzL +98fyTCfeFq3OBJ+yj2bWcRfYyfQFTsn75Eu4WrGrp7Bh5nFmFeod55CvzgTXrmpWP rlxluoJWrdcyA== Message-ID: Date: Thu, 20 Jul 2023 09:18:17 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH net-next v2 3/4] nexthop: Do not return invalid nexthop object during multipath selection Content-Language: en-US To: Benjamin Poirier , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , Ido Schimmel References: <20230719-nh_select-v2-0-04383e89f868@nvidia.com> <20230719-nh_select-v2-3-04383e89f868@nvidia.com> From: David Ahern In-Reply-To: <20230719-nh_select-v2-3-04383e89f868@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/19/23 7:57 AM, Benjamin Poirier wrote: > With legacy nexthops, when net.ipv4.fib_multipath_use_neigh is set, > fib_select_multipath() will never set res->nhc to a nexthop that is not > good (as per fib_good_nh()). OTOH, with nexthop objects, > nexthop_select_path_hthr() may return a nexthop that failed the > nexthop_is_good_nh() test even if there was one that passed. Refactor > nexthop_select_path_hthr() to follow a selection logic more similar to > fib_select_multipath(). > > The issue can be demonstrated with the following sequence of commands. The > first block shows that things work as expected with legacy nexthops. The > last sequence of `ip rou get` in the second block shows the problem case - > some routes still use the .2 nexthop. > > sysctl net.ipv4.fib_multipath_use_neigh=1 > ip link add dummy1 up type dummy > ip rou add 198.51.100.0/24 nexthop via 192.0.2.1 dev dummy1 onlink nexthop via 192.0.2.2 dev dummy1 onlink > for i in {10..19}; do ip -o rou get 198.51.100.$i; done > ip neigh add 192.0.2.1 dev dummy1 nud failed > echo ".1 failed:" # results should not use .1 > for i in {10..19}; do ip -o rou get 198.51.100.$i; done > ip neigh del 192.0.2.1 dev dummy1 > ip neigh add 192.0.2.2 dev dummy1 nud failed > echo ".2 failed:" # results should not use .2 > for i in {10..19}; do ip -o rou get 198.51.100.$i; done > ip link del dummy1 > > ip link add dummy1 up type dummy > ip nexthop add id 1 via 192.0.2.1 dev dummy1 onlink > ip nexthop add id 2 via 192.0.2.2 dev dummy1 onlink > ip nexthop add id 1001 group 1/2 > ip rou add 198.51.100.0/24 nhid 1001 > for i in {10..19}; do ip -o rou get 198.51.100.$i; done > ip neigh add 192.0.2.1 dev dummy1 nud failed > echo ".1 failed:" # results should not use .1 > for i in {10..19}; do ip -o rou get 198.51.100.$i; done > ip neigh del 192.0.2.1 dev dummy1 > ip neigh add 192.0.2.2 dev dummy1 nud failed > echo ".2 failed:" # results should not use .2 > for i in {10..19}; do ip -o rou get 198.51.100.$i; done > ip link del dummy1 > > Signed-off-by: Ido Schimmel > Signed-off-by: Benjamin Poirier > --- > net/ipv4/nexthop.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > Reviewed-by: David Ahern