From patchwork Wed Aug 30 09:13:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13370066 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 3BFDF1FB3 for ; Wed, 30 Aug 2023 09:13:57 +0000 (UTC) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2137.outbound.protection.outlook.com [40.107.105.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0D5D2; Wed, 30 Aug 2023 02:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oDkyRpu1UnOv82mXhrH1Ks+bbZlu2sFGfMSd3qTmCnrICAnguv9ir5IzKa3yT+k5qNtOrbJPf69PXNlYU8Jbf5L6J7GvfDIDi/qTTgvRg8kOIS5PE3vq6Brs8ob3m6raNdv6vLv+BQ6gQcl0JXyWGnpVb/9MyzalgX4+dIyjxap64af+TeTO6mNOSqJ2YiAuzbiqQdDTAnX4TGsYoRxyRxZ/7zKF1zLIUXxXGNwPSwe28Bajqrk2xaebGWAueXEqilUkiyOppDYqYE9rmy66nL4VIM+PVaSalcLBI9BxJXQC9tkyzv/cqwewbmrWE4oXH1HhXMtw0q/ch76aQSSDew== 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=X7UmUM+Kr5wa1eWcSZxGoI4W2i2lwZHkeaiUVXvoFkfS3pzR9J8Z3a8WGyKWpz0k0ZOvDtCm6UlSovlhpOlZfTQSVVkys8ZAihKVkjuhYnXXcc1tAmEFywe8IjlC8RFODZNmoDxKWVtfOjwuAs4tMKmAY4yQGYFZ3P3VeMIH4YjtuKh8VgbO1rZFERgIgCSBeUxg9gCYKcWkzH/7vQXgjDKT/FJU7o2w9CrVZFj1zqXv24OEF504gx8imN5IfhR7btQ9rQwQxStWK6hPKGRninP89Kb5rhl4Q9VN3sNGfRY2cxDFP/DA8Hf1SQJrEcUZoEwNlP7J5dsCSuHGtn3P1g== 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=HVuHe2/86oebDhi613RT4jsqP9F8SG9g9LPFes+J22m3b8XBvV8/YjmKswOkY6cyN4SCM7s6mIwodW+Hmf5ei8jP7YJgMsWaHzgUGoRenUFr416qMyILKPG1UW0YelRRGgVXZY+FzkC/W5k/a0hJGDqZ8TgYLwjYPE6M7FXdbh8= 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 AS8P189MB2096.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:52d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36; Wed, 30 Aug 2023 09:13:54 +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.020; Wed, 30 Aug 2023 09:13:53 +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 v4 1/3] ipv4: ignore dst hint for multipath routes Date: Wed, 30 Aug 2023 11:13:39 +0200 Message-Id: <20230830091341.17273-2-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230830091341.17273-1-sriram.yagnaraman@est.tech> References: <20230830091341.17273-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GVX0EPF000013DB.SWEP280.PROD.OUTLOOK.COM (2603:10a6:144:1::14) 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_|AS8P189MB2096:EE_ X-MS-Office365-Filtering-Correlation-Id: 69af8b93-d493-43a7-ccbe-08dba9396eac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2VBnGtyS7If7If/I89ySS2E+WfdOqIzcc79SNg8ovQoKiqQ8APcEFiWqSgZx9O7s0eunAWLXHw/5/NRSAUQdnMk84nJj1Zf0hql3HhNbnSIYF06oeLH9zAzXBBrniEASUcgtHWyXhzW90lISADGFxMMXSW6TA09D+8nbCYJxN53AmTCQXP8fkht3bcro7TGB39rLA6SEZwGQ3Rm+A3TRgUB6318f+OsN4CIw7nzYD4yv+4VkFPnuGqgZVaW/q9JJD4nXk4RlkmiSozSeb0brfA4SHSdqcWsJ3JmSoKCCkUg90TOArXJng/nKmmumPcH3WWIUalZb6g0H8Rm8VqX4knE79kaGB/j63+Fl8cNb6M4QDtRIefQ6vGRIeelJsLlPgZ2D4dG7voIy/R02XN3sYTQ2ZNS338vqgrsAh7aT2ZbiLSUdVO1vWcYQJxeskPyuN28/YZiqn0kzOHgWGD53JIxpZ6E9WEFOQHFkrNQIzON1ZGyqjqBpSRr/556SGwiYQLx69YsrEMiFdS43JwUIUkFbelMt0kzwWG7TiIxPHt5GvDpsUrCPUiJfTaJ6e8qDZCB/eW33YWbs017Wf+eCxxWo6qDdb/fcRCR74hTH/Q9tIAALEdNVceUUigsfh3y16wEIYpfKBq5yg+Hv/HifVA== 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)(376002)(396003)(39840400004)(1800799009)(109986022)(186009)(451199024)(8936002)(6666004)(478600001)(70586007)(66556008)(6506007)(66946007)(66476007)(54906003)(6486002)(316002)(38100700002)(41300700001)(6512007)(26005)(44832011)(5660300002)(8676002)(36756003)(1076003)(83380400001)(2906002)(2616005)(86362001)(7416002)(4326008)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ncZVowc7Prr2xyCl3PJ+CyXJpkytzIhLeQgAFy8qghs+WM9M1V20H8CHdciMrKJd2XlsWJokBDhQmR8h8E3AyATsPp1fC21bgHHX5Ae8sr8UzKZEImtUFsaquvBZQsGQaV3e572Hjm/mncZJMBOG96MnRMH3qoSbTE7OID35reDQ1jxWaLUfBIoLFJ0K7MdbjvtWYnUbz/5PTiFvwIW2jtKEQfYxpYdTKjx//uHHGdjgueGqnLZ7YKiuHi+aOmZ/zpL4zQ/KvAtTXdkH0eM8SYVMKMv1aQb7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vrqBkNc8yDEJckwEYT/LxONgLXkpgrS+7DqUwqn60oQHrXcleUstGlfVTAJpzWM/olzdJU065THilth/8RdRVvCJPP25JYTfmv93YEJwpUGOKRVd1fpOavuAwz2VNIe80NQyQPhn6rHdq6UmXNxS0uuhIM0wETsDzaTntPesPQtFJ6SlD53WIaFtln5f85O4YDiBHN9o0XmUROrv0mtQhQOyH8QIjaGtDBjjvWfUBQWq2NnyGoJIGmeKStLNVE4AVT5D/wSg== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: 69af8b93-d493-43a7-ccbe-08dba9396eac X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2023 09:13:53.8934 (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: UPmIpsAmOilzKnJwgaJ+/t4mykdhLhAEn8c9eOiEwjxXN0DtcrsIN+a8PGuA3I+1CYxn7l52zhBEGXd4KMd/16k4lDriw4y+P8vrP1m8jXM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P189MB2096 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 Wed Aug 30 09:13:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13370067 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 DBACC187B for ; Wed, 30 Aug 2023 09:14:01 +0000 (UTC) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2107.outbound.protection.outlook.com [40.107.241.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 841C1CCB; Wed, 30 Aug 2023 02:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P8NOQRWlKfiZ8I/JZfmQg/tWGpcResoeUcvUiA3Xlywra/K3JLjB4iaWxJURYT7b7eb1Es4qeK3a5UUDVV9UmdXCcNJPMFwYjPMPqIEHOgDk86T0SGvieVjKr4Dk+sCoHwlDV6t3aFeOdTOXvXEXet6nSV8n2HCqgqoFVpfRMrVBMrZwUHaXJHtqMnWPl4CfUyc6qngySybNC5R5FvgD2y3qIITPfNgArzgsQZDGmJqZXVmAkMBQR6uXzkTUAhOjQtuoFdayA37aeaj7soi8H1MCUvVPSYWcN6HBoSI52gJ0jH7VAZ2drD7PUq7QRVVWM4Rwph/6x+5/4BwzrEDH6g== 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=k9FdkeenSrJQEcTV7KeQDoot1m0kLN8BxQX07uotgELG13p7114/0mc+nlK9CNYJWhm1Y5WnsQYl7zOgCj2pJrz+DcjbUkboce6WPs4fWgdXwuP5hVMBlfYosWU+DEfXhJBU2479oEzljuaRcahIB97syFPYAywkIzFwu1Yc64mGtpYybfVxDdFlwzFVqvxMoWZvwiGHYfURti8lyWqfu4nT7Reb17Amh4KGam5CQRcpT0btvzIiwPMXWAfaKZVZWatPsjA/c0iQZr9ncGJL3R2qWlZWw6yJu4awewq0aqf1xjRqgHG+3f1OpEQ6i4cRCOR75RTnQfPSSzvaKfav4w== 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=awuXy1hCLxULs+0vAh0D6KEl2C5hFEXXQup+PRMav+Iot6bIMk6ymtIDTHiEVYyayUdYtT2c6VeflSKDjiy0mK/OdCROSmMjR8X/7qTNAQGjZ9s3wgrSU9vkoKLilmTW8MJ6ou6mutOdCUK9DIQiQhaoLBx4NaWImVRiBzjJtTk= 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 AS8P189MB2096.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:52d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36; Wed, 30 Aug 2023 09:13:58 +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.020; Wed, 30 Aug 2023 09:13:57 +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 v4 2/3] ipv6: ignore dst hint for multipath routes Date: Wed, 30 Aug 2023 11:13:40 +0200 Message-Id: <20230830091341.17273-3-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230830091341.17273-1-sriram.yagnaraman@est.tech> References: <20230830091341.17273-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GVX0EPF000013E4.SWEP280.PROD.OUTLOOK.COM (2603:10a6:144:1::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_|AS8P189MB2096:EE_ X-MS-Office365-Filtering-Correlation-Id: d62f3f34-7ed5-4b72-e114-08dba9397107 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bd4eQHHy2ttlAp8ElzgoPQARFRidZuSs3nAG2iUKwS1dXs4IEUXEoS7DeDBSdhoJE3bwe9NxDzrhbLeNXjfWzYlUdY1H2PPVqxdS6CV6hRzWkS3HRdYqE0lnsM4ZFJRbJPwkliMOwA0Y7gw3Q0dmgQp0DjqjVTYY4IABJUNT5Vxarvpv20kM4hUyEenomtMCniwQlrAbJXuURUlcYvNsWF+aM7DrARjht6hOz1i/JieqXERbr6uTT3AnywoOkT9xFv8o92BWTKFhdCetZV6CND11BXSZJPbBgYFAwxaewOiM9M5dx6zSeiNGTsIcld0eAKuzgFmwXWE0u3hOlleEjYUJISZUxGDoQqwkIjTfdJY5ECyAM/AgBjZDG+xKUVdvoOJpvwgMXmpKHkcj2mjMnrNkhXc39Nb5H/ZhRMerIuUVaz5Uxr4PYn7Kffx2Y30uvB69CyeucacAQv1y0OxsbVAxcKgSP0fXCCoY1gC6f9sG2m5ue9RXXHkOApRf4QqLod5NkUa2jnr0qDFNyYO7XVOlewlvW5o1SSKeXl/kMleCYOMELahMkVE8PWhKntVPZ44NvBP4qXirzIKEc+ov/WZl3TrnGVChrXzG6miVcS2V9UQXqJF9SSyfHlXN/3FFfQ6qKQ5UXaGeXJziSDMPbw== 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)(376002)(396003)(39840400004)(1800799009)(109986022)(186009)(451199024)(8936002)(6666004)(478600001)(70586007)(66556008)(6506007)(66946007)(66476007)(54906003)(6486002)(316002)(38100700002)(41300700001)(6512007)(26005)(44832011)(5660300002)(8676002)(36756003)(1076003)(83380400001)(2906002)(2616005)(86362001)(7416002)(4326008)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T+RiLultxA/SYVX3cIG1wvER8pH2QxM4knGhEvJrmUjpFh7/jtg5Rk7uwg5FciYt3mHo5oXv02D/EaDH2Jg1yCvqe6GxkUW9EZxZLhh5eAtiLR1ZUYKd4jppKAlHn4sKX/bBUWn4eqwjP1LaUbTnl1bO0syKG2tYsZUk+lD/5OeV/5aiXOLy1hT2siDc6qfVNlwLbOig8+27I24Q26rsdiGE21boR13tme5zh+WA47A61DqKuFVAH2c61Q2u1m5TLlprFdxuwDTvosxxeRXeVDSskUe8POUeg52leiVPyO7FngMlExZ0/JElDHKC8UzqbObdA2dpT1f3I0LdWqT+thnVmC5Kji4h4yMEjawKTgAqxPGw1x9vHnHNGLb6pwYjmkddXxBxh1MwFQXG8B09C4Oa+ibDHBu+4jvcH247H0IrN4byQFXahIxItvxwuBFyFcj9oCwBHfvswOkp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OVf7esWgt0Lb0ODNK1se69LVFcID8/akUqJxXUwFatgn8O971YCzLE2wwspMAEZBZsOq4vy9mjSyflQV7mJTEf3TQ== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: d62f3f34-7ed5-4b72-e114-08dba9397107 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2023 09:13:57.8781 (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: ZEePKVyK8d66Za/KN+kM89UX5LrfZ4zngyOKhH+nGgf3E7bsBQ61I9y1FTYEzxEKMAE1sGmfLwhjWhg3cQFi35nYP2fgqy7EzpRO57NTwVA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P189MB2096 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 Wed Aug 30 09:13:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13370068 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 AC22920F7 for ; Wed, 30 Aug 2023 09:14:03 +0000 (UTC) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2107.outbound.protection.outlook.com [40.107.241.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 969ECD2; Wed, 30 Aug 2023 02:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BQXJNilCplBaS//hBH4uVJhCiQsEiRJn8GaSOQdxQ27roueezjcuPX9axY8ohxK3XqJf0C6vEjkyp+McZz3GcUYpSLHQNINDdZhy0EvBwmOXYlXrCZeofzZEx9A7cofOrsoc+W6uVOXZ0RXHKa2GtRCe/YYNBGioIKqA5Ap6N3q04BWZPc2B3IDbFLHC3z/T9zoVO1vXHyltpA/Q0e0voAtHyb0BskkNiP3C6RaS/O7umi8ObLvguQLCrT6pU0Anh2EAbeZ+hLjGaGGVsHiNlfE1twGlsqRECI30Aek+VhXDXfW0j/DHhYCfFI2TztBDS5kL9w/ggcXyhlbGXXT9Qw== 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=aITOkYZxw+sCNlDp0ho1SDATgMLbyhuStRLDxu5hvpA=; b=h3cjbRWKSuq0oQpWKEyNDCZuQagzbfSH3ZfkT8EMNU8zDxRWrFDbcBWF25sUYaQbYsJ1AoIcu6C2fhVxAUt1XV6w6cLO+lmSsXOvueOuT+ARkReAoqk4cAiCOjGlHaaBovK6a4Gb2URnlRjZ4rJO7D5PkbmqCvsy8AMnIyipy/hEq4gWC40F6xf4X4WlORb5DZvMmMHYpy48jTMskgFSLhJc/KMiYDFKY1eUyxS2tOnZ4UzlwUKfarZupc12Q6KsqELrfdr5YboR+YAY5jgma7pYLfosf5kviXleQoW+5qjmj1AZiz1MdSgJaEDES+VGspikfxjt5qn8+FCc5gNBuA== 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=aITOkYZxw+sCNlDp0ho1SDATgMLbyhuStRLDxu5hvpA=; b=BwA1CPCewUih2SFCHW++nxWnlSVHsrBn22pGYpysJbhJicw5oQrzjB/9WjKfLAaPo2aVOXGTGnJ3LYbEJ4N04EdAu6+oCJKJvG9Bb8huyv9aLNcUPvr0bY053edQkamADwpAUbvTsDYfSIgHaWAp9DfxjzhIKBpk0S8cbKNanEk= 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 AS8P189MB2096.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:52d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36; Wed, 30 Aug 2023 09:13:59 +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.020; Wed, 30 Aug 2023 09:13:58 +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 v4 3/3] selftests: fib_tests: Add multipath list receive tests Date: Wed, 30 Aug 2023 11:13:41 +0200 Message-Id: <20230830091341.17273-4-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230830091341.17273-1-sriram.yagnaraman@est.tech> References: <20230830091341.17273-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GVX0EPF000013D5.SWEP280.PROD.OUTLOOK.COM (2603:10a6:144:1::d) 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_|AS8P189MB2096:EE_ X-MS-Office365-Filtering-Correlation-Id: 5704ad02-81db-490d-d1ff-08dba93971a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: umLQdF1gVOTSO4+hO2XKDNnoFNfRoNJ5CZ30CTpttib9JkqrAqQO79O0DUYJCUrdyuKcUDRFueIwVZdkD8C+SNTaEbzSjpZu1j/anphiF58rP+hEuBknGQmoEy8PDYLpjWKG7cXNdlx9ArhyliLI1oUUf0P8hy9CJrcqNOvBRV02t2CaXsyblT2q2fdlFRJzjsOzvROpRP0u/N3CFFVliG0PzuT1hbL47ppxnv8N02fjCWIDAWWx5OsSklMLutvemdPe5eTybrrk73XALCZhMPlsAGPcnU/h7V78m8SEF3eFcYuUYjqN+nJIKgN09ndHGaq1lUHMadiBG3Xg31yNvQHFWJ5rFkKPBB0PoPIQw9DvtqT+x7qWoB/JtDJIJNsNss0+c965q3JdIS0mI++5GOTCNhyEWJwvE6Y7o3rV0aHPCoFipMzPGLPcOJTnt/+k++SANj0X6Z/OBXlvH10igomcDMrJbx1d4sZ1ze/FjwEJhD0Dn+wyaUZ/50mkb+i21nj/VkTJcOQhaaiZUp9vQKw249XAY8JcDlESjF7414vJNO37z964kIhRj2P8Wf1rOXs7HILgn9sxSUtUFs32EUMXjhjdoQuFwhvdq3aj71DO7gU4mSysSpdy/iV1BbRm 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)(376002)(396003)(39840400004)(1800799009)(109986022)(186009)(451199024)(8936002)(6666004)(478600001)(70586007)(66556008)(6506007)(66946007)(66476007)(54906003)(6486002)(316002)(38100700002)(41300700001)(6512007)(26005)(44832011)(5660300002)(8676002)(36756003)(1076003)(83380400001)(2906002)(2616005)(86362001)(7416002)(4326008)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AHzldkeKa+2YWc/Xo5OGRieKE7HBR75EIySZn5k9C+1CGIvogHIZi1TwMNvmZgZi6lApip6y/HHTwrwGGaw3BOoyj/PJMU0cfDr6Lh8d65opPnGDMk7rqSHqwi1SumC34TB1UbRGYWijUB2Fi6eouYEUkN0I7JUT+Yporn/usKXesdR1IKzaAnrRg5MDK4CbmueHII6ZmgEGBUi/w0ypZhS8S1d2awbnrin/E6qMp+IMTNJp5ypb7pL17KSfP4EJWOONY/ubDVhpR5Mac9qGJGtfh9fkqsa1LpRE4fdsnYNKP0yasOZkcb9M3EHT8XkuOf6zOytcMgoqBN8BKEOqlcGZj+/dZloI/oRQ4zeTbdSmZeYmNENzNsxEJr4V5qF9Hc2yjkyIaYqNSfqHB2N6GgWayErw3yRyOSO9j5etXrxu4JRBCiOluJaEJRRVLSGyJWqc2th2fUUKfEEhZwO7bJM0vlLnz10dsQCcfLcthcgqrDzChr+QUKthlvYH1kNtGgP2ZhBpq02LN9RrGRRNCYVL3SU/oz079EXA9rnfdZ1jWhnP9hY+TW0ibf+wCF0uMnQmFg4nFUe3yi5isxd3eS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ba93971a2 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2023 09:13:58.8884 (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: xHJb+hdTd5LQw1vDYWvS3Fb67wib/td04zQSnpo9Kj9fZvcfOVQeeAmxBuACM0uX8DLQjDZyTzalnWAe2ilzL+gKonDIH76feSj7MuCOd6E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P189MB2096 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 | 158 ++++++++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh index d328af4a149c..42f49fa48c26 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,159 @@ 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 name=$1; shift + local file=$1; shift + local expected=$1; shift + local exp=$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 $exp" | bc) + [[ $res -eq 1 ]] + log_test $? 0 "$name 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 "Multipath" $tmp_file $diff ">= 0.95" + + 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 "Multipath" $tmp_file $diff ">= 0.95" + + rm $tmp_file + route_cleanup +} + ################################################################################ # usage @@ -2433,6 +2587,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