From patchwork Mon May 29 20:19:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 13258939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A144C77B7A for ; Mon, 29 May 2023 20:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjE2UTv (ORCPT ); Mon, 29 May 2023 16:19:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229595AbjE2UTs (ORCPT ); Mon, 29 May 2023 16:19:48 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20629.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB59FCF; Mon, 29 May 2023 13:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HP7d+6L+agk4a+PjU+Op+XEBKchLsLJV42OTL6KPmN2WROxevtlDKyptwk62VVuSG8rY36aLoEE77HpKV/SH5rchg1Hod4ZkN/0aFCN9MtMe9nUMUNFGL3T6aiOA9I7a6FRTrlhaGV3xTfOcEwY+RDbEWGa7L3RUsP4MuUJIvbrQe5SU4kDcuiyRJVkOj5HV030UAfwB7QVsF6/nEGDZoYHPSnDul53Dgou+jen1bR+zIhhrRW/YjmMVPKcrUe9VIx5weF3AIc2+U9wC+wBl1SC5KrCHUB+Oufu5OKEm1yYRj+hkbwZD7Mchyq/L0fzMPqcaKPUPMRuERMaGvPJTTg== 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=G94JeCZEPXVuTfPis6gKgswmtsaHQtxgn2reOOQ1Aks=; b=atEQy80lLjv4/h6mYc889HQDm5lW9f95+Xyve+wo4teECPmlZ63Y5RXndMca1bvGnegeF5WQskq6eNfesPiaAMj85kLRM6iJrCUdrgcq03nJUInCF6ZcA7fMSrMn3cIP3wQSwGg6H1McItrBT+YWFn3Q57hAOm4t6SK+okbL2FhvvOyJCrgsUi67xF+XqahLqZXkRzYIV6DlfTR/hnDUUiCIjpVNoSKjzyaImQReIdGkaAyQIAJl9LS2gIWIrUB3w+dh+aQoGF5QVnf5g2ex6pgQJ4vhlB9dEM0IANCXzJeWiajoOhEGgwapAVqd/mN8WqdhV4LUul0plqMVgMPtrQ== 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=G94JeCZEPXVuTfPis6gKgswmtsaHQtxgn2reOOQ1Aks=; b=oQie2lwPxFOnwRGIQczQ7jfgcUwi5+zDjGOrXd/FsgboJmVU+8H2lnnlfiv6XaTaVzVWtUM24+WQGHvinWlcPyz+fioAivNQIxWkm0l3+C+rw3zsY81SapNAkp6QnOXvphgNXVAZeAu00+PCL2b5BRF74caXPnUZHY68b6xoSQBKyZzS1CvKy9gfAwlVzF0JVjsUoL+mInvO8157Wf+B+oRp3KpMTxX8J2S2K/XW2EWboZsoFoyDVEvaobRSZf5RVUZaX1l0UUkhRNkvLoI4CGWeISPlIM7MmJdH84jOPWA/KjGXORX7ypvbH/in4qfclviaPqNl0oBhFXyrwNzxWw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by IA0PR12MB8254.namprd12.prod.outlook.com (2603:10b6:208:408::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Mon, 29 May 2023 20:19:44 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::96fe:2d5b:98bf:e1da]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::96fe:2d5b:98bf:e1da%5]) with mapi id 15.20.6433.022; Mon, 29 May 2023 20:19:43 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: David Ahern , Shuah Khan , linux-kselftest@vger.kernel.org, Ido Schimmel Subject: [PATCH net-next 0/4] nexthop: Refactor and fix nexthop selection for multipath routes Date: Mon, 29 May 2023 16:19:10 -0400 Message-Id: <20230529201914.69828-1-bpoirier@nvidia.com> X-Mailer: git-send-email 2.40.1 X-ClientProxiedBy: YQBPR0101CA0193.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:67::32) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR12MB4373:EE_|IA0PR12MB8254:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e4228b3-d525-4660-0985-08db608209f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6H2UXcCphaYVxpbera0A8U0L3IEOBYxBlsVVX/pehWkeauasGmLqwhLfF1xsuawAsFa5BCpWBxWxF9mOSFj/m4wyxpL6NxGGwQvZCXfYsJbpuQVS2z89AWYpA1B8PABBNeoGjQTBvmDCSmQE6/Q5n5nn3u0rc9y32AYokLDd7iSa0Jxcgxh0VqiV/6NIoZ42KTA8MeaYjZJppgrgerXZ9ryiFYI4Xl6zm7mLHlls60mXQG+ZQPskvgtewhu83+YinB4I+HjCo97TnNjR2thZaOTrkyzV3jjr4AcWMwhRmKsWRriXH0DTQYujTDLeumi+zKuK/Vt/AtvLrSZhIRwjikrUmAmdGetazdBOKQiFyHzjLDlDED5ZBLlON3BcLz64iMhNP/0BYr90mDymVXQvld1kpPJhabmi7nyhc69cdfOGNR7gj7SMvMYyh4buVoxXNT7stlhC5FtikG2tHz58ObJCRO+XDKTUW9witkdxf4b/Eh2IFzmbIPPCkwsBj6rDnKE2vFKL6go6ELkYBe+8gKk5wU+eU1cGEEUILET06LTnsJZTIpnBoeFPPaW+xaPy 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)(366004)(346002)(396003)(376002)(136003)(39860400002)(451199021)(38100700002)(478600001)(2616005)(66556008)(83380400001)(66476007)(66946007)(54906003)(86362001)(4326008)(6916009)(2906002)(6666004)(6512007)(6506007)(186003)(6486002)(26005)(1076003)(316002)(41300700001)(36756003)(5660300002)(107886003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p+lxEPYDXYt8fNdcRWnut7Z3lvZ+rQdSiXD6E9ZDwS4O6ZQHsTe9BvpNgcoVxH0bph6AcKcQQ2ADP4rFgoSP1FxHrb/h3ZMjfrQgl6NRYmM+kbidbde0zImPDtcf7s+w2Qba9XcK6btflrDJR7Y4kuWNPYTMBT8tHz27P5i/0RwROF5Hgw2SF92omSgoU9iHz3cM00Li9EzCJbWzhZw8GVR3mZageb0BOX3Mxtp1xGXRtPVyqgx37wOc8L0iULuaeLq4Ca+4HdIgrw9rZL3aeEIVp8GqW4j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XP/xyheU/K/+KDUsJMG3esJSBVKjAmccjQ94L1cLDupWR8dmInWbhVJM/YUqKUpSMq7geJqZ1h+wnr/tSs/3P0vDMNA8hc0oKwfw99ERV0oBRpfIEUvPnUNbioxAqDrlo6MDfLSaf0ARcfhJWDwDIsGILxR6//TMgxTb7tskuA+wslEVZMCUPJObkiCXxivCZlqzymwvk5sJ/XqhwNlEzLV8fg9ebaKb0eO9Pbn6Lz3 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e4228b3-d525-4660-0985-08db608209f0 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2023 20:19:43.4633 (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: aL0biol+j0i+WwdrJVVHMS82eRkQOO9jFL4/s9pQkkr/U5Nb7xbNycfMSuLYS/sKAoMgUVNP+6whaR7VlErnBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8254 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org In order to select a nexthop for multipath routes, fib_select_multipath() is used with legacy nexthops and nexthop_select_path_hthr() is used with nexthop objects. Those two functions perform a validity test on the neighbor related to each nexthop but their logic is structured differently. This causes a divergence in behavior and nexthop_select_path_hthr() may return a nexthop that failed the neighbor validity test even if there was one that passed. Refactor nexthop_select_path_hthr() to make it more similar to fib_select_multipath() and fix the problem mentioned above. Benjamin Poirier (4): nexthop: Factor out hash threshold fdb nexthop selection nexthop: Factor out neighbor validity check nexthop: Do not return invalid nexthop object during multipath selection selftests: net: Add test cases for nexthop groups with invalid neighbors net/ipv4/nexthop.c | 64 +++++++--- tools/testing/selftests/net/fib_nexthops.sh | 129 ++++++++++++++++++++ 2 files changed, 174 insertions(+), 19 deletions(-)