Message ID | 20230719-nh_select-v2-1-04383e89f868@nvidia.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2503654vqt; Wed, 19 Jul 2023 08:07:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlH6QhDAXYrcoxPHMe6kdaMvnXpJMxhU46WpZNo1m1f2G2tQ8KBwF4R7FpOXMzyAhkA2sQJ4 X-Received: by 2002:a17:902:c246:b0:1b8:92fc:7429 with SMTP id 6-20020a170902c24600b001b892fc7429mr17861520plg.53.1689779267609; Wed, 19 Jul 2023 08:07:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689779267; cv=pass; d=google.com; s=arc-20160816; b=VWgQBzOo5KUmO8/Q+4WiAgaSYXFEzesXhD/jJqm/Z+XXbXJrEmWEFrF3lfGmGz+bZC /gQ2B70SfiNNTKA6bGBxfgKW+OiFXWk5QkVy1kQ1pEaT/4FONdr1O6WOAfguC/9BZrZA alCGW7sC1BvRi4c3TYEygT/vkYwH3Zfy4zMcygwe8ovDwtMA+Br8TfD3fVgRI/noDy+E G0dR1+SCYfQb/2jl7Rc8xV7SrC4CLSbDxbZYE2N/e4kgHJGVqWA+UmtVYLK0ajkKx8gV E0h/myR6hjqncRvQR6yzHzaVRfBs1LK37XMbeISiKFhKJod1sW+wH8RUv2mDnl+rAWDe 00EQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=tUeV8oIuvHrSih9x/1pXMDjhs4xpnIKANIY1SsSmAiE=; fh=P+OoruTqX4rYb5vOClp3S2Ec+4Lwbb7mgHr70Gx7J+k=; b=f0g5+SMojMKMzsZw0007DV9dr4eB4aKNXIHPGApj9HKV7JrHLuA8ULJUb3GHIJyoZe wJIQs/0MVixVGou/GlqRKppPfbKhhUkPQRPazBWO8P2xa1ps22vPgZK0zWfSyKfk+NtJ sF6L2ZhAletIGKzrWTwJTLmBaSVzKGcqnDrSwtABrdxdSC2obaM36thOIBxAkT/dg+OK ywKK9xQH+QIe+9C15oHHXuqr+qGWnvblTm14QeaBSQlvye0KDMOWEfu5dbGvNhJFCfA8 N6WnywXHJ19g4n/Q2gi1pDlDf/XBUaHL0EQXsB4iS7SDl9XfcDDeu31sAysyabkHB5tB JpbQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="aUiWmK2/"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170903120700b001ae4a01a7e0si3765238plh.236.2023.07.19.08.07.33; Wed, 19 Jul 2023 08:07:47 -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=@Nvidia.com header.s=selector2 header.b="aUiWmK2/"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjGSN5Q (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Wed, 19 Jul 2023 09:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231303AbjGSN5O (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Jul 2023 09:57:14 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2075.outbound.protection.outlook.com [40.107.92.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8760912C; Wed, 19 Jul 2023 06:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I62xG8eX7qsyxlAsn7pH+uR8Y9LLdWY7b9HEG7yKKwo1a1EmZyJHJ3Y2QizASdSbS9KrGQNK+uYMOQAfnEQ3yCVTau2ifBssMFuN74CjmmYPH4X3FHRzRRCNyYPZVbhLPbhPPcjSSdLgqhv0J3quXwhm04foP+cdRi3TvRlquxPPCkclGrjyiJLkXAl0IL0LYqYEDmE4JkD0R4RbehbBKzKlCIOynMn5FOgtbGlgVsdZIV0NOGtiOu8URqBymEELIY4kURANuLbFJO7Ktu/EVCJcdf2XnWbZyN8ZhLgmXXlGXSnFrorrFjx1ar4GGSYSjA2JDiyYCgf0pDWG0rW+hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tUeV8oIuvHrSih9x/1pXMDjhs4xpnIKANIY1SsSmAiE=; b=mE0BwpAAqQHjPAr5cHA2rmlGpav2jvYayl1CW84ozB0KsOuZbFAcMNTGk9TNRU4F1Fy8aQVhnWijWWc37TsxLs71n4a9LuEna09kJ29pX0WxNhXGK6Zzj6JiR7rrBvWc8Y7O1MWTahX/ocWtXu4CWAdkDry3XpzZft3mH/ymtH9q6sw1xWkiBGvqwuqiRseF4tYvthT5gY9zfpWvTIl65doImMeBZgF+KW2I7OyNXM4netzk0Qm7+wOtjGbcB2nTJE4J1+7xwIC6qBidW315JKCWwk5QHdWKnyhV9f6IuULL8z+p+l4lvE0wwqaTuBPZLB9/hbOUQElbZzr1eFa0qA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tUeV8oIuvHrSih9x/1pXMDjhs4xpnIKANIY1SsSmAiE=; b=aUiWmK2/wyWjNwxBqRm+mVkC69aYaM5QzZKfJ2I7tFoJ0/xoI59ZalAWTa3eIK3Sdg4DOyr1AKd4JN7uqLhMWpCkd5nhkjKNNx5U1vhBZQVhe7InWenDj8p4DSsR16dz+gmWNqIKdNuXlXWASuU7dQX3M0ETiZ1Zpc9Faz50mDukHLMRehGeoYlzsxJimuK7v+sRJ7H2I5vdtTauNU63VNJbgLjvWXkZXV8Y/BO1/HW1iQtzpAf/iyqcEcgACPxdwAnJDWJzg/NU4giqQNy4+obenMb9u7/mNBc0N2uMuD/rvks2+7S2/FcrNpXNA4OLk+iivtPd1oKlIkizS0vTPQ== Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by SA1PR12MB6994.namprd12.prod.outlook.com (2603:10b6:806:24d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.23; Wed, 19 Jul 2023 13:57:11 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::982f:232b:f4af:29ec]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::982f:232b:f4af:29ec%5]) with mapi id 15.20.6609.022; Wed, 19 Jul 2023 13:57:11 +0000 From: Benjamin Poirier <bpoirier@nvidia.com> To: David Ahern <dsahern@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org> CC: "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-kselftest@vger.kernel.org" <linux-kselftest@vger.kernel.org>, Ido Schimmel <idosch@nvidia.com> Subject: [PATCH net-next v2 1/4] nexthop: Factor out hash threshold fdb nexthop selection Thread-Topic: [PATCH net-next v2 1/4] nexthop: Factor out hash threshold fdb nexthop selection Thread-Index: Adm6SOo2pRJ1b9JTe0qaFpcgHytNCA== Date: Wed, 19 Jul 2023 13:57:11 +0000 Message-ID: <20230719-nh_select-v2-1-04383e89f868@nvidia.com> References: <20230719-nh_select-v2-0-04383e89f868@nvidia.com> In-Reply-To: <20230719-nh_select-v2-0-04383e89f868@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: YQBPR01CA0111.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:1::11) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) x-mailer: b4 0.12.2 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB4373:EE_|SA1PR12MB6994:EE_ x-ms-office365-filtering-correlation-id: 0179fdf1-1668-4f01-79d8-08db88600cb3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wbZ2KqZq0jkWSbxmd2wET4D2USkpHJ0X7keB/s4+Boo7TVRtRbZ/Ve8b/1PPG2bff+XRaqo0QOxunpQBHnYNLlj/QMbkzlOQAkmVkdMpFn7qIZ/GlnsWy9+hOtJoL9zHPNwfj6OtyBUBdL964J//JG/dYlgu0kzarfLKlDn+3LvadTENXS4eQ3ZN0Xy0/pARBiCYt52onele1lVxIuZEwesTU85R+2k6DzVU7AbOsh5Deg+oKJioJO50bn6nImoSbU/VhW52xm6GCel5T2C5jP4h7LYff7Am/HB8wlJQmSD1+Cj+Cuf/sDEIq9JBVWw2scwCCd6iwdNbZN5dGo6as9HmTjS9G0cZn++0elo8oH4LZFYXpFcQyg1mvLFn5WjeNbhQ3stV6ObrMRGnPnH1LshIkLf9cpyba6jMYfSZwAH20u0/oIiIcvJuf2x5qhzGhoVTTu82wQPHUTwGOtNwPFeNBOId1VglGjY0IPkKa4DFuAehtOF9lvu5lRd7B3364bQAjTMWMrGCC/60WoR0LieQeKLB2SmeklbwSBIH32CzNTas7wX5cJh4EQgYJm/K x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(366004)(136003)(39860400002)(376002)(396003)(451199021)(316002)(41300700001)(66476007)(64756008)(4326008)(66946007)(66446008)(66556008)(5660300002)(8676002)(8936002)(2616005)(83380400001)(86362001)(38100700002)(122000001)(186003)(26005)(6486002)(36756003)(6512007)(6506007)(107886003)(110136005)(54906003)(478600001)(71200400001)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?AhoaCay1JuwoEgwfu307iAbMrfFK?= =?utf-8?q?qLAsLTxE2oP3XErUQqxLJRhRY3us8u2Da91yR13SShBgfP9eBILyNWGTwn3Zf9Wnm?= =?utf-8?q?/LktqOVLTzCSMsjT4S9hMOMe+L6RrCPKPdlu43arty5d1Ln4pc6tJllJL3lBSV0RC?= =?utf-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= =?utf-8?q?P50XtHi+wHXPqrhvx+79LHjxrE1Wkvj5endTRha4BDRxA2AiOzOLtvJpKB9VzZ6L2?= =?utf-8?q?dyFNwb5zO5BfAfs9iEP9WqVq4IkmOcyXwcOQFqAGWDQlYTT5q0eDRfHV03L3oVh8G?= =?utf-8?q?OyR31jkTn3f0H+NvQs8+cgXE9p2PIf8oB+3eZ6glwvm4FNGiQjwoeB5mYRfZ4f9yD?= =?utf-8?q?nF7s8ilbOouPp8jkPPWz3BM1GIj6jx8bZh402cBNX6jZNItQEp57Ii4++3KLOawpl?= =?utf-8?q?eWHOaJVNrOQJup2f0HB0LUCpvNzCdmOTnBwPHSDZrRlIaTGxJtah+aCEViktEIIru?= =?utf-8?q?TBEI/zrBnzBr5Z1NU0njXrmXwbk8Ll3rmtuG7n2In9YzEA44hahvCdatxzqeiKyun?= =?utf-8?q?mYWwBPxnweC66MghAQEIHBfNMySHy7ujKMDV00UKhYk/bftg0ymt+Un0mNyXxfjk8?= =?utf-8?q?7z0AHt40rdbkWkYqF13hfBS9/hGQcPzKqZo7d0+7x0kaLaiF8A0EiJ4Qkq91i2Zwh?= =?utf-8?q?5LkB6gvZTKJY?= Content-Type: text/plain; charset="utf-8" Content-ID: <3226475388E5084BB5AAC618C3FD29AA@namprd12.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0179fdf1-1668-4f01-79d8-08db88600cb3 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2023 13:57:11.4082 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rcJb5PL7M9me788VnfNIwydHdacLzuF7J/dmujJ0sJ1vpOmfZVCwHMgY+Z+GfxKXrrKaQJkKiGtnzgTuEejmfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6994 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771861985319933004 X-GMAIL-MSGID: 1771861985319933004 |
Series |
nexthop: Refactor and fix nexthop selection for multipath routes
|
|
Commit Message
Benjamin Poirier
July 19, 2023, 1:57 p.m. UTC
The loop in nexthop_select_path_hthr() includes code to check for neighbor validity. Since this does not apply to fdb nexthops, simplify the loop by moving the fdb nexthop selection to its own function. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com> Reviewed-by: David Ahern <dsahern@kernel.org> --- net/ipv4/nexthop.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) -- 2.40.1
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index f95142e56da0..27089dea0ed0 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -1152,11 +1152,31 @@ static bool ipv4_good_nh(const struct fib_nh *nh) return !!(state & NUD_VALID); } +static struct nexthop *nexthop_select_path_fdb(struct nh_group *nhg, int hash) +{ + int i; + + for (i = 0; i < nhg->num_nh; i++) { + struct nh_grp_entry *nhge = &nhg->nh_entries[i]; + + if (hash > atomic_read(&nhge->hthr.upper_bound)) + continue; + + return nhge->nh; + } + + WARN_ON_ONCE(1); + return NULL; +} + static struct nexthop *nexthop_select_path_hthr(struct nh_group *nhg, int hash) { struct nexthop *rc = NULL; int i; + if (nhg->fdb_nh) + return nexthop_select_path_fdb(nhg, hash); + for (i = 0; i < nhg->num_nh; ++i) { struct nh_grp_entry *nhge = &nhg->nh_entries[i]; struct nh_info *nhi; @@ -1165,8 +1185,6 @@ static struct nexthop *nexthop_select_path_hthr(struct nh_group *nhg, int hash) continue; nhi = rcu_dereference(nhge->nh->nh_info); - if (nhi->fdb_nh) - return nhge->nh; /* nexthops always check if it is good and does * not rely on a sysctl for this behavior