From patchwork Thu Aug 31 08:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13371062 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B22341FCC for ; Thu, 31 Aug 2023 08:03:48 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2133.outbound.protection.outlook.com [40.107.22.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BF41A4; Thu, 31 Aug 2023 01:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q/FLDdmv4e04cNKkaNH+WgusoscvzXgI8wqGbc4Jj9TGwmwQB09Fb2dII1lXfLnNiej2ktFXdHmlWMl7EMi5Q+bcL09K1OnmFfvYtWpDrU6/IP2bioQjkiDWvsr63NALJDUPAIxFbnIEPEF3Y0cxEpa7L8KCgzSReF1oCJdP3YaWlhyfRBabUjJN9VfkP8lK3otTYmr9UY+I7E+gGL4SsusgdT54ipCOg02jjWXgrkpEeE6YCkZN+UCg+HakKJv9y3cTn+6R02TSYq0KeMNe3GgLDhSDd0cD14NeW+U1FA3eExgNUpEqEOGlritR/MV9L/WSan+SaFx+7mZUWPbn8Q== 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=pkY11kfDOcqVDFHUtAFoI3MIPNDYp3mD2y+AgzXssrc=; b=i2cxc/nbQ83Gcxfq1byNr24DoM3vsD1KU4L7CDesHzN5sJjErxCf7lkg0SULnDT225JptS9axx+XXz9qPdXZiiTLvR4jCWazqBfo2vYVleA+rnozbC4Yo3R+7k4Cb2/gQzUmJLKZQ9I0/gPT6kDwZas4l2jXLa098O0kwujQTtWt+Fb7l/8LvuC6gWinJ8qV8ypEW5peSWiXU/RpAXlQyQow4Gr3Et2WjL/Roq/E0zmVhdxlQH/6RZxWqtIUNqdu/BXDdVkz8yxeri/buhaHEgUmLQjORNGUzrJYfBOmNN0snmUl0YCCt3p2PtXgYzSgMQMVoFIFj+m/+/z1IGn9sQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=est.tech; dmarc=pass action=none header.from=est.tech; dkim=pass header.d=est.tech; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=estab.onmicrosoft.com; s=selector2-estab-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pkY11kfDOcqVDFHUtAFoI3MIPNDYp3mD2y+AgzXssrc=; b=T9jHnz42gkCjIEi+xElbTW9GCjvxY2h+kl8/1QhtwS7DgAihx56HjjTArP9Ge2ecTXiUbDn1990lZtA/7MsRBZW9NODG8N3LBQiYiQcGnd7SKIVsQc5pY5F9xCrYUFvWUdPyrBJ0FeTb2YaSxvF1+4EwQ5SLyNDzPATWQEpcGeQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=est.tech; Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) by DB9P189MB1929.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:33a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 08:03:39 +0000 Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::759b:94eb:c2e8:c670]) by DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::759b:94eb:c2e8:c670%6]) with mapi id 15.20.6745.021; Thu, 31 Aug 2023 08:03:39 +0000 From: Sriram Yagnaraman To: Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Ido Schimmel , Shuah Khan , Petr Machata , Sriram Yagnaraman Subject: [PATCH net v5 1/3] ipv4: ignore dst hint for multipath routes Date: Thu, 31 Aug 2023 10:03:30 +0200 Message-Id: <20230831080332.2495-2-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831080332.2495-1-sriram.yagnaraman@est.tech> References: <20230831080332.2495-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GVYP280CA0014.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:fa::8) To DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBP189MB1433:EE_|DB9P189MB1929:EE_ X-MS-Office365-Filtering-Correlation-Id: e9fe18b2-4016-4422-6c83-08dba9f8c875 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cxj+29QIYZSTw2L8ToP68fWOq2oAhc2YMUf8PFO+sCK9FVtpAXsvnFvNN0X3Z3ySD3RpOH/5KZ5smLtf4hj8VEwyDK+iVgyIpY1SJ9IaVV9CJ8A+aSluk44997GMtG2LHR2nRAYPPteyYohbk9d/dfajz4sLDaR5vrLiPO+M/+YVlFI0QOZVbXYZ3rZPmSxS+54u38zxYI/ZxbQH6h10AZYaATbjN1JntqbuAATvuSeLRuSQ4RdSUFPmhITKq4VRi4lt5LtnLwpFRQR6SfWU+TvxX3M5IsK5ZlK84avREEuS/yNY8oJI6K1UQ4gcGqzX+j2RT9d1rS5lH+m5X1zDxoyblcMDYQPJvB/Q/FBFIs1WB9XH7e1HGmUhs3XM/UtWe7XXCo4+7sLdMBwfF75DhgQ6TBJbH1sqHrWCbGXulBeA/TIQrwPz3L0NLT196Xt5VuWuPIMjjLQnjRpMqi3iQIOVeAmFC5ItOlJcs+PnIZiFD2eoGdkTL3oswXWwKCis7FdvmezyYlSedrhdZ1IqmbcJIyBKQd59JLZRC/MgEQRBTDLVC3YOA2ZZM5KFRUjWC+ijI19QGNzpiTwtlJsnd8H7L7jN3U0aSL3AoX3eb9+i2ouSoHll2vyOW/t4o/5wAceS/bVlLR1lqkTWLAfAjg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBP189MB1433.EURP189.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(39840400004)(376002)(396003)(109986022)(1800799009)(451199024)(186009)(36756003)(7416002)(83380400001)(8676002)(86362001)(44832011)(41300700001)(8936002)(4326008)(5660300002)(6666004)(1076003)(26005)(2616005)(6486002)(6506007)(6512007)(478600001)(2906002)(38100700002)(54906003)(66556008)(66476007)(70586007)(66946007)(316002)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OZA78qA9mKd39TC4lhBRgDj0LEY0utQwKrzrXXpnA2fPPMLyDfgN0bPjlytcCdCXE8PXSY+LtseKbO9BDVVgqcQo+TTPkdvJJUALBWdgWk6d9Mj/A6B/5ktkE+f2eCoZ5eWeCalj2Z4Xkz06UTDv0x3/g1CdDiQqGpgkADi1QBS+d44a34r2JjMSIc4h5sPUKkw5lAM9oOQUdDm78EZVRsjBEKkeabKp22EJDPdrtj4fybGWb7mLEgsOlkOL1clqfWyqi6o6CEblgfH4Gykk5jNsatg9XOW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F/U7asVMZ70DdhbQd5yOa82uxi/C7YnLNtgNlyccHLQ9/W03A2nymeKeUEIY/bk/8MdtWebO9NkZvTE+Zie22nOKvrzLdWEvM/h5Ptkh3dsApN08F6iOTdvKJtiQZAd643cVUY5lBcJil+aHiZvHV0xbyRmKoJFUZ+WoEVP6MEVw2ed2vLI888cXVJq/RXCcnNP0D1yd9DcjlnjI8HaOGcDcy2+5hmK5EMw6vsM9AEdZxOf1gkKeR/+hTA== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: e9fe18b2-4016-4422-6c83-08dba9f8c875 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 08:03:38.4921 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d2585e63-66b9-44b6-a76e-4f4b217d97fd X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FZb55cv5ow87wibR0XtdRdYoehK5+b095jyZ14LNOt4XYy7flqa9KurxSBBJCOz+YZalLJXYcDxM5h8F1ZHFAfZTPHVnbVexpRE+8R3dJvk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P189MB1929 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Route hints when the nexthop is part of a multipath group causes packets in the same receive batch to be sent to the same nexthop irrespective of the multipath hash of the packet. So, do not extract route hint for packets whose destination is part of a multipath group. A new SKB flag IPSKB_MULTIPATH is introduced for this purpose, set the flag when route is looked up in ip_mkroute_input() and use it in ip_extract_route_hint() to check for the existence of the flag. Fixes: 02b24941619f ("ipv4: use dst hint for ipv4 list receive") Signed-off-by: Sriram Yagnaraman Reviewed-by: Ido Schimmel Reviewed-by: David Ahern --- include/net/ip.h | 1 + net/ipv4/ip_input.c | 3 ++- net/ipv4/route.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/net/ip.h b/include/net/ip.h index 19adacd5ece0..464176a88f86 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -57,6 +57,7 @@ struct inet_skb_parm { #define IPSKB_FRAG_PMTU BIT(6) #define IPSKB_L3SLAVE BIT(7) #define IPSKB_NOPOLICY BIT(8) +#define IPSKB_MULTIPATH BIT(9) u16 frag_max_size; }; diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index fe9ead9ee863..5e9c8156656a 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -584,7 +584,8 @@ static void ip_sublist_rcv_finish(struct list_head *head) static struct sk_buff *ip_extract_route_hint(const struct net *net, struct sk_buff *skb, int rt_type) { - if (fib4_has_custom_rules(net) || rt_type == RTN_BROADCAST) + if (fib4_has_custom_rules(net) || rt_type == RTN_BROADCAST || + IPCB(skb)->flags & IPSKB_MULTIPATH) return NULL; return skb; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index a4e153dd615b..6a3f57a3fa41 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2144,6 +2144,7 @@ static int ip_mkroute_input(struct sk_buff *skb, int h = fib_multipath_hash(res->fi->fib_net, NULL, skb, hkeys); fib_select_multipath(res, h); + IPCB(skb)->flags |= IPSKB_MULTIPATH; } #endif From patchwork Thu Aug 31 08:03:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13371064 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF8537481 for ; Thu, 31 Aug 2023 08:03:57 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2133.outbound.protection.outlook.com [40.107.22.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB69BE42; Thu, 31 Aug 2023 01:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nGdhP7Wpv5oa9f+mfgkr4k8cCmopjyIiy8Hk0EMzivo15eM/IYkyYinH7Luqs/Z+GiTcapGgqndSW3rGNQIAL9/mEHnPMwssFhd0aK4+CIRbo3PK0N5sk/4fSfVEwGEFc+vC3ionp+67aUFeTNSgfay1TrN1yRQBPhQuIqtb3ZTlc1JRSTn60YhjwUGBi2sknPAgLUkRWYGxMaOvl79Uk6DsO+rRvZPtCeD/DyyQLQVi4f8SGI0khTsCxb0dL3Rh1/dhqI1lYOvT4rG5uDnVTGX3ab1TOl/8PGT6FS5lAzrQPS/lQ9X1iRHpF2Pq+UpmVmIb10Za/Tpq130zcChwuQ== 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=3fL4EOwO86H1EP4PmvHyNW6IT3Che41u35CFBg7cURI=; b=m9izACG+834J2iGkgtDJ7Xspl5Z2CNuLLTN4rJ9eIoIveuKSMF4SCygfYr1IDs3AuHwy+tJT19IOVK/djq40+MADPVssFxtfFKjnWx8F4GS8qJIDgWJJLw83iXpvRbCg7WNc+WlekaYEVIOhupexNkxGcHc3CseKyImuK5U5v523gnCEVTFvfnLiL5CY7zBrXb9x9iYUYLgoGe5Ish25dWbKECAxJPFww1fUPdAIjvYKeEf0lBhhXz9if4mkg0oEKm+upwSjX2KfjcsSC/b2a5z2bRRJDYMCG0b22g1bv6gvzosg/ADTGIh2AjNW7id6x3Va5Y2/Wrr+hpCypPCvtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=est.tech; dmarc=pass action=none header.from=est.tech; dkim=pass header.d=est.tech; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=estab.onmicrosoft.com; s=selector2-estab-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3fL4EOwO86H1EP4PmvHyNW6IT3Che41u35CFBg7cURI=; b=QMErEGSJsk7t+b8RuT4KPK+trXD9drA4nb+MwtamV7itxslnyaL3H4hxWED46QZWuP8yA0xA030BrwrtkPL3Y5AqGLums9w2ORxVf5Okmur7UPELUdbEjplLiziKH9nyseL8iilViy9qSYDRGDfy0qRgjSh+2UtXP3Fc297JyFs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=est.tech; Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) by DB9P189MB1929.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:33a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 08:03:41 +0000 Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::759b:94eb:c2e8:c670]) by DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::759b:94eb:c2e8:c670%6]) with mapi id 15.20.6745.021; Thu, 31 Aug 2023 08:03:41 +0000 From: Sriram Yagnaraman To: Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Ido Schimmel , Shuah Khan , Petr Machata , Sriram Yagnaraman Subject: [PATCH net v5 2/3] ipv6: ignore dst hint for multipath routes Date: Thu, 31 Aug 2023 10:03:31 +0200 Message-Id: <20230831080332.2495-3-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831080332.2495-1-sriram.yagnaraman@est.tech> References: <20230831080332.2495-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GVYP280CA0024.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:fa::12) To DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBP189MB1433:EE_|DB9P189MB1929:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e85f0c4-fdac-4a4e-5a2f-08dba9f8c9fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dAsNHq9wOpZjJbhNjBUB4RvQazRtNkpD7mU6XWdVJTadtbYfPIJE3n+EUdBWdtdo4BcOiJb3/8NtJP1tc9fKPYBJwS+r6diMcGcSzj2KJgV2d4fU9LBUAf0+JhyGPCN3y60eU7FqYMzeBZ9TBWnOHNvNrstTM0weWOrUI1IM3Fe6y06YESevUMbXjKWdiH+TZwIxWKAdnVoH1sdG0R1aZ0DKrFhBkNNqoc3zZImwSpXP1FTvs8usFbYC4ZbP7/r/iiLJ0o3yTkRdIT/4B7yJeAQ/Rtjcg4yNOD0Uc9Jgxjv0pKKdaaUoREPOkmtu4oiPdYKyGJ/igg0jzbIxIrxGcHbFWS+nJfamvxIwdHWSHIG+VmOuq5KfpzJW5OwKdTcWuUNj9o9rzZYkVuDjGoKYU+TbsXR0YgZP4U8r39GjsEvzUEgfO0yjA1sCKLRabXXLUiEgSvAECqZ5CSiYum4N0lRmme5C3qgB/8/ehvhtI5FOU5J0XD9YqkcqUw4c7AsJfKZq010ccMmp0vkNVhP1x53aKpvOW8Fh04pUrWrWC2VB23dIk2fTqJWLufUtSJRnu3z/OCUd9hc3HEYtwnKhIlKS3Y8qR5VW0/XcDs26id7/5CuolqnEa20PDC4+xIT7fH8UU4ylcuif1RlKShYOow== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBP189MB1433.EURP189.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(39840400004)(376002)(396003)(109986022)(1800799009)(451199024)(186009)(36756003)(7416002)(83380400001)(8676002)(86362001)(44832011)(41300700001)(8936002)(4326008)(5660300002)(6666004)(1076003)(26005)(2616005)(6486002)(6506007)(6512007)(478600001)(2906002)(38100700002)(54906003)(66556008)(66476007)(70586007)(66946007)(316002)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MA15rMU2iRixoq8gjSxkNsr0UBqLpf6i4uJT+Zd8htXwOJ14c/BAmceqXTYKWRU9guNsVG510cBZTbhWE+zGxzbUfAaYlQb7Rro1UEOgNtAPrmqE4roRQJPDd4bv9IcG7eCGvFKhtmHkm7tvX6Hg0ivYlzFfAkTl/+9gDZdy8EIebjbY8cqEOur0Znn/QSzRmgV3N1MzT7j+reX1h2dY8OTPEPQr/d6bxbf2bM5ch2sdGUAmc3EAsB8j8QHFMSdxALQM1BYWL04oIT1ilQswZAUqjEX2LXJ3PpLd0CmEU3OlMHfUzjClP3vO8rqgCR+bucYTnirBxBPemL+eHtFU9cCSKi6SsVlrPCxo8jy89pnsQAQ8n62R+OKqnfXoYTj5G8BkbMbtrcYlZvC4I6fbkeJ9IGohIHprJXfMjtS2YBkIbX5pAdJFY9MtH9T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3HhvYw4UnUgFBGtLJ0vH5xyn0KGc3BHDFerulANGmjhOPLXrG0MEz7WUG2Fdi9ECIV9uh62WDMSdMSinnYNcJvHYoqSQ530g== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: 8e85f0c4-fdac-4a4e-5a2f-08dba9f8c9fc X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 08:03:41.0484 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d2585e63-66b9-44b6-a76e-4f4b217d97fd X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: biCXmuUdRc9tVoQYThAiDigDny64MdY6zLJFy5lQDP6C4xsMEcDWi5EvoNalO8eMTmlYdogv+mLUG5KoLGYt7Ju5Qrblbyt2p1MtvuKgQcI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P189MB1929 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Route hints when the nexthop is part of a multipath group causes packets in the same receive batch to be sent to the same nexthop irrespective of the multipath hash of the packet. So, do not extract route hint for packets whose destination is part of a multipath group. A new SKB flag IP6SKB_MULTIPATH is introduced for this purpose, set the flag when route is looked up in fib6_select_path() and use it in ip6_can_use_hint() to check for the existence of the flag. Fixes: 197dbf24e360 ("ipv6: introduce and uses route look hints for list input.") Signed-off-by: Sriram Yagnaraman Reviewed-by: Ido Schimmel Reviewed-by: David Ahern --- include/linux/ipv6.h | 1 + net/ipv6/ip6_input.c | 3 ++- net/ipv6/route.c | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 5883551b1ee8..af8a771a053c 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -147,6 +147,7 @@ struct inet6_skb_parm { #define IP6SKB_JUMBOGRAM 128 #define IP6SKB_SEG6 256 #define IP6SKB_FAKEJUMBO 512 +#define IP6SKB_MULTIPATH 1024 }; #if defined(CONFIG_NET_L3_MASTER_DEV) diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index d94041bb4287..b8378814532c 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -99,7 +99,8 @@ static bool ip6_can_use_hint(const struct sk_buff *skb, static struct sk_buff *ip6_extract_route_hint(const struct net *net, struct sk_buff *skb) { - if (fib6_routes_require_src(net) || fib6_has_custom_rules(net)) + if (fib6_routes_require_src(net) || fib6_has_custom_rules(net) || + IP6CB(skb)->flags & IP6SKB_MULTIPATH) return NULL; return skb; diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 846aec8e0093..01d6d352850a 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -423,6 +423,9 @@ void fib6_select_path(const struct net *net, struct fib6_result *res, if (match->nh && have_oif_match && res->nh) return; + if (skb) + IP6CB(skb)->flags |= IP6SKB_MULTIPATH; + /* We might have already computed the hash for ICMPv6 errors. In such * case it will always be non-zero. Otherwise now is the time to do it. */ From patchwork Thu Aug 31 08:03:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13371065 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 655926FAD for ; Thu, 31 Aug 2023 08:04:00 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2133.outbound.protection.outlook.com [40.107.22.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C261DCE7; Thu, 31 Aug 2023 01:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ONB4iq87OqRt9iQ1sMjdVRuxWRzN3aMq74J4kiRrR9qri71TFOSXBdavk4TdxBbjFeKuviW3h4vjtYu2nM5sMaR/BAEYfy/g5qngvCr+b6RgNKZs68V+wPOY04UEHyItrXFZnPdJyV9LpdSDjl9bDlpPvFafjHvSUft4vJphhONV8u39xAItkc4XF3azpB/C9AJ0aMifParbxjACtj0k8psU97Tg456z9WqhOHj3cgzE9PDamhZgMK9XPh22iArwBsghacfJ1m6FtniOs9ovVAC5wgqiQkxFHBSUGVeozOM9l4o6w3zYeNs1tC1guNutp2+femYqS0yoQJtLwadmPg== 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=8v+GHjlDzHL/t070+Y37pKXuwkSJB9ccc/xn7nJFlqQ=; b=FpT8FpRps5Wkt+hQWbzkGVDYoUolMR2GttsGVR9CMyiL2+9KKlJ4UGv2KqoOKUEUXl0fbsUUrKfQqew51/L0vhGYTFym/+Gh0WwJICdoBsD7N90Teund2SiEo1dftxWnev5xVwVmcBkNzbrvQ4JwNS/F5TqlXG81DUUxP9SIniwjn8aVimXKRl0U7NR3dL3PmxMTjhdfs4J5XjiJYYeSSxGx6kYzpHcUGhse1YIwK+cJMZgLxFH55Oc2zM+b8hzTAv7NkckSwOcr2VP3wgyOzsGLoCBZWZ8LU1BroAv4/NsR+UXAH6slG4tDO7eWWj+3D85FAf7LEnnhT2rU3FQu7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=est.tech; dmarc=pass action=none header.from=est.tech; dkim=pass header.d=est.tech; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=estab.onmicrosoft.com; s=selector2-estab-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8v+GHjlDzHL/t070+Y37pKXuwkSJB9ccc/xn7nJFlqQ=; b=gnQtefOmBA7srmTU05vf/8OrbvDR8t/Qn29uj+ObNS0Au485mzraNouwSeBur7FtsmyUAr/imtaeKKf4hxPIKAArFnJt3O0OYiL1ua/URUUz5ocSjTB3HuD5iVJhIPj0ze4DG0Vz1H0nRc14TVaLvKMbOE0/ppEECCuqgYBqqmI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=est.tech; Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) by DB9P189MB1929.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:33a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 08:03:43 +0000 Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::759b:94eb:c2e8:c670]) by DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::759b:94eb:c2e8:c670%6]) with mapi id 15.20.6745.021; Thu, 31 Aug 2023 08:03:43 +0000 From: Sriram Yagnaraman To: Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Ido Schimmel , Shuah Khan , Petr Machata , Sriram Yagnaraman Subject: [PATCH net v5 3/3] selftests: fib_tests: Add multipath list receive tests Date: Thu, 31 Aug 2023 10:03:32 +0200 Message-Id: <20230831080332.2495-4-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831080332.2495-1-sriram.yagnaraman@est.tech> References: <20230831080332.2495-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0054.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:9::24) To DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBP189MB1433:EE_|DB9P189MB1929:EE_ X-MS-Office365-Filtering-Correlation-Id: 82a673d5-e7d0-40c2-d6d5-08dba9f8cb4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HUuKI2X22EinKdKH3vzkZLnUUP9AvSvW8PRFSUeRuqFRkt6RriYzm5XHGKmN9d+bbWyyBYexBrs1Fz/Ya712OYw6vzCgAFG5HTmjiQlM57YdRUdwqvRWIkOV3xwSbmtUZ29wyh1eakQpIT0CkNhMrr9EWp3sCNVQVpv8jCb8dyvNhcCKUUhoKtg/SGrC4lsVfInXdAmEbGl7MwVTi+y3QoegHbD9p+r11ks5F6bv8r1HAh98/olgis11NGH94i5kWbMStxleTgbMclj38LTBEqsbVCcmq7HVlHOGpv6D8UrLq/J3aLJXk1SMXBvm4tS+f3oYhwfBOciqU+JAwsUeUUiMpzeGJ+/lKfRwkCRC3iNlw250SIJhOZ5NyvR+8EdfZrEHyRHBZGpNRjlnbh1yDdQb3O0LvbamTy1TrJY2NdBtoMN4usZPFp6jH7ZqdtDu4/OON6S9cLdaWt3tnsZhuDStGWrTWaF/0U9TBHlpe1koPCR2sWARmPXfx0Ex6s+EQxb97dHTxg0iQjfpphqfgtCyy6SvVpGaw0huH9r9LZicH/UvbVgJiUuLDCcXJxRu4Yb43hV1y1e2UPVcDVQW5WRqa960emLqAqnbR/JGkrulZmIXref9vvkd30eBC8rA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBP189MB1433.EURP189.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(39840400004)(376002)(396003)(109986022)(1800799009)(451199024)(186009)(36756003)(7416002)(83380400001)(8676002)(86362001)(44832011)(41300700001)(8936002)(4326008)(5660300002)(6666004)(1076003)(26005)(2616005)(6486002)(6506007)(6512007)(478600001)(2906002)(38100700002)(54906003)(66556008)(66476007)(70586007)(66946007)(316002)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cHcpPthBcDF8vrFNhL72ki/jlJoXX74HujKAvvhzVDmQT0mC6aakCtKWbaCurtcAeGxtuMkdBfApGtoq7ZQBWb2NJAl2q3J7/iXVTJlaPD8YGPsMyav3n40wrdK67tVUl7Z6AZWek4o+l6w5zzgkJYo4U85H8Pr50Zfltkl6cmZRmP32BG2MV9jkaeueI3tBEhXEtuV8gzQyETUYJqRtdNlnv8XiXkF/VgUSkiRCUNV4HXsDxTrtc3qCxwvutF23Yf3hKxg8dI2E7S2dnVXFL4V5rdvnvsksTjMr/P4KOF1aNy1DDU07McGdJI2DGu9PKzjYcYt77W3KuGU72sNhgHGXTW+Nr1BJHH571ZqsFZ39wlr0ngfc11q+YexVK7TwphymYUTxE/A2RTWa2P8yjKDTYiYuei5eFu7n1CABvgte/sWxqfS22PyEWcYTiELRf7ZSr2hTCy22d2U8K6k0w86BuH2MfkexKHq3KhEAw4dVy2pd1SiE07sPabD8ze4K3FAwlCgBdXiTa50RU4FQKm4YO8QO2gLZaiFLb63ccydjlzqC8bXekWiJ2TV/7FzaNBCADMKQDeGk6KC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40c2-d6d5-08dba9f8cb4e X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 08:03:43.2429 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d2585e63-66b9-44b6-a76e-4f4b217d97fd X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LxsBFf7FKA9BhOqV2XzR7hd4NBq1yww0i5/CbT+pWlrOusYyXNGIgi3STNLHSEkPqh/g53+xdvNBww/P1EQIFACD5cV8Shu0+oL997uE3g4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P189MB1929 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The test uses perf stat to count the number of fib:fib_table_lookup tracepoint hits for IPv4 and the number of fib6:fib6_table_lookup for IPv6. The measured count is checked to be within 5% of the total number of packets sent via veth1. Signed-off-by: Sriram Yagnaraman --- tools/testing/selftests/net/fib_tests.sh | 155 ++++++++++++++++++++++- 1 file changed, 154 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh index d328af4a149c..e7d2a530618a 100755 --- a/tools/testing/selftests/net/fib_tests.sh +++ b/tools/testing/selftests/net/fib_tests.sh @@ -12,7 +12,8 @@ ksft_skip=4 TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify \ ipv6_rt ipv4_rt ipv6_addr_metric ipv4_addr_metric ipv6_route_metrics \ ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr \ - ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh fib6_gc_test" + ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh fib6_gc_test \ + ipv4_mpath_list ipv6_mpath_list" VERBOSE=0 PAUSE_ON_FAIL=no @@ -2352,6 +2353,156 @@ ipv4_bcast_neigh_test() cleanup } +mpath_dep_check() +{ + if [ ! -x "$(command -v mausezahn)" ]; then + echo "mausezahn command not found. Skipping test" + return 1 + fi + + if [ ! -x "$(command -v jq)" ]; then + echo "jq command not found. Skipping test" + return 1 + fi + + if [ ! -x "$(command -v bc)" ]; then + echo "bc command not found. Skipping test" + return 1 + fi + + if [ ! -x "$(command -v perf)" ]; then + echo "perf command not found. Skipping test" + return 1 + fi + + perf list fib:* | grep -q fib_table_lookup + if [ $? -ne 0 ]; then + echo "IPv4 FIB tracepoint not found. Skipping test" + return 1 + fi + + perf list fib6:* | grep -q fib6_table_lookup + if [ $? -ne 0 ]; then + echo "IPv6 FIB tracepoint not found. Skipping test" + return 1 + fi + + return 0 +} + +link_stats_get() +{ + local ns=$1; shift + local dev=$1; shift + local dir=$1; shift + local stat=$1; shift + + ip -n $ns -j -s link show dev $dev \ + | jq '.[]["stats64"]["'$dir'"]["'$stat'"]' +} + +list_rcv_eval() +{ + local file=$1; shift + local expected=$1; shift + + local count=$(tail -n 1 $file | jq '.["counter-value"] | tonumber | floor') + local ratio=$(echo "scale=2; $count / $expected" | bc -l) + local res=$(echo "$ratio >= 0.95" | bc) + [[ $res -eq 1 ]] + log_test $? 0 "Multipath route hit ratio ($ratio)" +} + +ipv4_mpath_list_test() +{ + echo + echo "IPv4 multipath list receive tests" + + mpath_dep_check || return 1 + + route_setup + + set -e + run_cmd "ip netns exec ns1 ethtool -K veth1 tcp-segmentation-offload off" + + run_cmd "ip netns exec ns2 bash -c \"echo 20000 > /sys/class/net/veth2/gro_flush_timeout\"" + run_cmd "ip netns exec ns2 bash -c \"echo 1 > /sys/class/net/veth2/napi_defer_hard_irqs\"" + run_cmd "ip netns exec ns2 ethtool -K veth2 generic-receive-offload on" + run_cmd "ip -n ns2 link add name nh1 up type dummy" + run_cmd "ip -n ns2 link add name nh2 up type dummy" + run_cmd "ip -n ns2 address add 172.16.201.1/24 dev nh1" + run_cmd "ip -n ns2 address add 172.16.202.1/24 dev nh2" + run_cmd "ip -n ns2 neigh add 172.16.201.2 lladdr 00:11:22:33:44:55 nud perm dev nh1" + run_cmd "ip -n ns2 neigh add 172.16.202.2 lladdr 00:aa:bb:cc:dd:ee nud perm dev nh2" + run_cmd "ip -n ns2 route add 203.0.113.0/24 + nexthop via 172.16.201.2 nexthop via 172.16.202.2" + run_cmd "ip netns exec ns2 sysctl -qw net.ipv4.fib_multipath_hash_policy=1" + set +e + + local dmac=$(ip -n ns2 -j link show dev veth2 | jq -r '.[]["address"]') + local tmp_file=$(mktemp) + local cmd="ip netns exec ns1 mausezahn veth1 -a own -b $dmac + -A 172.16.101.1 -B 203.0.113.1 -t udp 'sp=12345,dp=0-65535' -q" + + # Packets forwarded in a list using a multipath route must not reuse a + # cached result so that a flow always hits the same nexthop. In other + # words, the FIB lookup tracepoint needs to be triggered for every + # packet. + local t0_rx_pkts=$(link_stats_get ns2 veth2 rx packets) + run_cmd "perf stat -e fib:fib_table_lookup --filter 'err == 0' -j -o $tmp_file -- $cmd" + local t1_rx_pkts=$(link_stats_get ns2 veth2 rx packets) + local diff=$(echo $t1_rx_pkts - $t0_rx_pkts | bc -l) + list_rcv_eval $tmp_file $diff + + rm $tmp_file + route_cleanup +} + +ipv6_mpath_list_test() +{ + echo + echo "IPv6 multipath list receive tests" + + mpath_dep_check || return 1 + + route_setup + + set -e + run_cmd "ip netns exec ns1 ethtool -K veth1 tcp-segmentation-offload off" + + run_cmd "ip netns exec ns2 bash -c \"echo 20000 > /sys/class/net/veth2/gro_flush_timeout\"" + run_cmd "ip netns exec ns2 bash -c \"echo 1 > /sys/class/net/veth2/napi_defer_hard_irqs\"" + run_cmd "ip netns exec ns2 ethtool -K veth2 generic-receive-offload on" + run_cmd "ip -n ns2 link add name nh1 up type dummy" + run_cmd "ip -n ns2 link add name nh2 up type dummy" + run_cmd "ip -n ns2 -6 address add 2001:db8:201::1/64 dev nh1" + run_cmd "ip -n ns2 -6 address add 2001:db8:202::1/64 dev nh2" + run_cmd "ip -n ns2 -6 neigh add 2001:db8:201::2 lladdr 00:11:22:33:44:55 nud perm dev nh1" + run_cmd "ip -n ns2 -6 neigh add 2001:db8:202::2 lladdr 00:aa:bb:cc:dd:ee nud perm dev nh2" + run_cmd "ip -n ns2 -6 route add 2001:db8:301::/64 + nexthop via 2001:db8:201::2 nexthop via 2001:db8:202::2" + run_cmd "ip netns exec ns2 sysctl -qw net.ipv6.fib_multipath_hash_policy=1" + set +e + + local dmac=$(ip -n ns2 -j link show dev veth2 | jq -r '.[]["address"]') + local tmp_file=$(mktemp) + local cmd="ip netns exec ns1 mausezahn -6 veth1 -a own -b $dmac + -A 2001:db8:101::1 -B 2001:db8:301::1 -t udp 'sp=12345,dp=0-65535' -q" + + # Packets forwarded in a list using a multipath route must not reuse a + # cached result so that a flow always hits the same nexthop. In other + # words, the FIB lookup tracepoint needs to be triggered for every + # packet. + local t0_rx_pkts=$(link_stats_get ns2 veth2 rx packets) + run_cmd "perf stat -e fib6:fib6_table_lookup --filter 'err == 0' -j -o $tmp_file -- $cmd" + local t1_rx_pkts=$(link_stats_get ns2 veth2 rx packets) + local diff=$(echo $t1_rx_pkts - $t0_rx_pkts | bc -l) + list_rcv_eval $tmp_file $diff + + rm $tmp_file + route_cleanup +} + ################################################################################ # usage @@ -2433,6 +2584,8 @@ do ipv6_mangle) ipv6_mangle_test;; ipv4_bcast_neigh) ipv4_bcast_neigh_test;; fib6_gc_test|ipv6_gc) fib6_gc_test;; + ipv4_mpath_list) ipv4_mpath_list_test;; + ipv6_mpath_list) ipv6_mpath_list_test;; help) echo "Test names: $TESTS"; exit 0;; esac