From patchwork Fri Aug 25 09:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13365245 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 7FFC2C8CE for ; Fri, 25 Aug 2023 09:08:50 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2103.outbound.protection.outlook.com [40.107.6.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F5A81FCA; Fri, 25 Aug 2023 02:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=El3AtzeBh7FzA8YEVFXQpBt4T2xmBLYUkfn3IDGGpETbaeC+r3W8kdoXAr0tO4grj1cXnGyKEvuVv/jt3i9hIRZdV3gIA2a+BUyfS5sCQT3GUQoCUm9MXfUVMizdsl0ZR9+63oZHg8/Vnbjcld2mtP2kKc+jcQDMruZtQ/n3fQAMqDYLtV5bNPfwxuM0/m3UeVJ6Fw9oQPT7xsyqbckqRZdqGqAef0azdnTO1UDfm20WnBodxgju4x4gpSv+eyANO4ePYj/4BjZOl5cimX64r1C1SpR0g0nEo5dvsI7k0Fw4EmUxWm8eUr/Ga9HCaCFYx6t+5C2whaValx1I20EPpQ== 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=jK1SaxBau9ezB/599xhQ+OmyNo0RpfRZjw0urTfez3U=; b=cRbgczttlbB1BD+QK8XvBKT4q2Z4XeKbq9KQ7p8Cr6HG1pj0PZPktUSpSbJFzmascH48eMBKGkeXUORfi9Gz+glfAaqVCAn3AS0wj5/M+Vcf/8qX3SXIOgPFjX1R2FE3gSnkuquDVa9WOLMCjcjQTqD3vFFn2SN0yf9Nf/E7kuBj8aWlP4x/ceClP/WefUev22iE4OETXziNe+WxYzwt9+1sgqTC5yXoy8E7JDRDqvS2bT5pbB8DcrLzOv9oJ10nySWP0OJcZZs8RBAWBch0zSOtG1x60jtyOqUiraqL27ttryVhBq1sImc7cKoPeChRG89HWX2jvWVWwrHirI9Ssw== 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=jK1SaxBau9ezB/599xhQ+OmyNo0RpfRZjw0urTfez3U=; b=AjNNNKHjArVftDSbrpOT4lQkyDaiWqNi3ykDOXc7PFmdqDMAIHBHfsby8jkGI65IHwRRoT82HExKo0eODpYm3k3KkUmyopwkvx2seeUCw2+irYHp7rs0eGB75RSjWlnHC1lJWSNOLMz4x3YERKIwdZRf6rQSNtFv/CBnHM3o2YQ= 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 DB9P189MB1499.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:26c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 09:08:38 +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.6699.028; Fri, 25 Aug 2023 09:08:38 +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 v2 1/3] ipv4: ignore dst hint for multipath routes Date: Fri, 25 Aug 2023 11:08:28 +0200 Message-Id: <20230825090830.18635-2-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825090830.18635-1-sriram.yagnaraman@est.tech> References: <20230825090830.18635-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0030.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:b::35) 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_|DB9P189MB1499:EE_ X-MS-Office365-Filtering-Correlation-Id: 29af3bc3-6b4d-4d3d-76bc-08dba54ade45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lU6onDRLpINo/qQoHIDvptisIYC7Rt9QAAdeRQbRU1T3vMzkyOshCkkteLCJRJpNpNIbN7+1QFQ4lCKHkufnjLy8PyOuAkf3beemEBfEyR3Nk84JdtiwdxzORRzfjDekrZ6RHDN63KEoyKcyFLuADXYzBXx/HKuMoOl0SNuYQDm28B4nQaFvQhuLbFpdj/riC6lDRgZcObd6qPnPcVu2FCx7q+b8mbEd8FsFRtdLd6Ub+iHAYFp3UygftOM1PCZu2CRWnGwYnJWKTSKFzvjohvcF+5fjLjq0NsIaXElwSNlI3jTbDd7b8RJfAjkyqefnYVRaHMo2w+4glz6BpVMJgaBDN8XJ9Qlsy7m+5R5gUolXexYVhEoA/0Lt9rPmw4fVdi2s9jjC69tXBPLRTSwH0/zruKBC+BFqr6txIVsOoKdiTy/kcCkzsdCljX5yohSxtdQ8dzA3rjL3I9Lbgkef0cGXhcNCsne90kh6D+q2uH2xoAytQfVCnSWvNxkz0tqWIoK1L4/0W7Z/+GWy+EiqyJdHR63csn0+ct9JDdgBsqxOmAgR3sJ6+ItkBtci+GQm289lPGYZlzyQox9F3OqdwDsbsBCQhauc3W2coD6iuFnaM+bUbniEFqTcysF98BkICS52IIKzUBNEClj8B8npSw== 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)(136003)(346002)(376002)(396003)(39840400004)(186009)(1800799009)(109986022)(451199024)(66476007)(54906003)(66556008)(70586007)(66946007)(316002)(478600001)(26005)(38100700002)(6666004)(41300700001)(6506007)(86362001)(6486002)(6512007)(2906002)(4326008)(8676002)(8936002)(83380400001)(2616005)(5660300002)(7416002)(44832011)(1076003)(36756003)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nFgAekcRvK7Pd1ucSOf0EOS3fwtVgV6W7iXmpYLHKlILZs2ULK9E4vf3X1vjueaEkBryerMCrOuAF67HeBpJ73XTTLmrkt16mgnQfcigvgK7q3eu53joMDJ6o2IxYB1aPdiMxO19sJWDGfpwgyP5XokZBpfn3J32YxFhKEjzSk6gsUzNnMmLABdoR0/X6WuYOmE3Yy4UIT+95lX6paCAlhivICrvHyrtD5I3+xi8k2SY2MRRGANltXSglJpxwxXBjwc0FBwuncUZZeGYn9wc9eNfLTx+pBySRItR1Ry+Fp9fBJei6Q6p2R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E/lP+qwTYEdvr4SNsEvUP/J/QGpw5w1XFYdzR8uDKVLT5ng4rlpgZLUpRlw0eGzZgcVolEEDnFF4mBAkNj5rtcyjzY0wiGrHZG5dkNiOGnwDX8aX8+oCtHPPwrFcr9QxFm1hcIiKs8u53uPl9fBNc8jRM2NcWYny2S0f09IJspqMOQuq6rP4v86pQ4uDdw7qeAJNBgsZXfgo1w+w6slNUYUq/60X28d3l8naw== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: 29af3bc3-6b4d-4d3d-76bc-08dba54ade45 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 09:08:37.9351 (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: mqgMQH2UVQ1m6tIP/yC9ekDoiKjnCiBkrdlGs1qMIk4uP8CtCxp//ORrjj1mPteO/OV8JPsxolEgxEj68eqUWajbpyYUM0yaka2mhSY8s3c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P189MB1499 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 --- 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 92fede388d52..33626619aee7 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 Fri Aug 25 09:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13365244 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 6C558C2EF for ; Fri, 25 Aug 2023 09:08:49 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2103.outbound.protection.outlook.com [40.107.6.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6CF1FC4; Fri, 25 Aug 2023 02:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MBpYAdC0uc98N35CUyKKJkhOOyEj+ye7zh+cuon6RVHr2kD9Jrr8mvBA3g9RPsamRSvBzWlGHejByQB3APUUe2PkOGAPR3VAcXweznLotxXj3zPe9xVR7Pp5Yb2yVMwUuYUGn9d/5uXW06GwMy3lUfcqBaCqSzjzF83NxQZNeHrYTNvCcigxwStrI7RfteVKJEFnpiNnvlQigCGN0H75rq59BWnBJHtPPIORbgZUT2Q6Qk8QVZQNSD7UbxbqzVGUxQNJoUXD4m8GOYShg5FHowJgQ1gWIiOYVpE5lHhdTWYwDdJ/tZmWNqsQXnfwhPb4ssB0HxlF9S3+F5RilQhJKQ== 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=Q89TH4qzI6EqD61X7pPKSlzcGLJ6xTonkvVtjY+AOJ8=; b=hHKAYfdfqXdDEzWBoqrvpeTZ0qaE/siGOT8qCKZpqULsyh5uNqkyB8Y0sNShJXCl75ioeBbbETL/ifJwrx4SSuuExyntAtup6mdB16BTQ/FbmMBN0LeluqzvCD+kZSK8Gc8Ip5zAamklqQ6Sj9ej+V+j87SoZ/sJmUT0Riw2yaLkdgMVk414Bz/p5CfXIiBlWdnFD7yU0cSFVJUuChwbwA+QVpx1KTtv6g9sXnT4WafbaVblBTJLvMKnj4A5tviFxOeaRY+EOdAYP4hBwbwHe8q2vMezfD9N9SdbQRoC5oBzYzvREmmkwOqE1nvy3Z9amsvgeyVaknBLTicWRERNRw== 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=Q89TH4qzI6EqD61X7pPKSlzcGLJ6xTonkvVtjY+AOJ8=; b=dQv4ctICcxuN9ECab3XI2zfROZjUAJf09wPrssF+alugdHgYdzqJ3mztreAtOsDaPL4/lcIDkQ4HxVhErgaP9f20Ml2XaPxgmqqKw14cQWz9CSVcPGJfMgKVgjIgD8M17v/TMKZt/1Ma09DTzFqJxrSrCcrLPp2jlb6UGKlaVNQ= 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 DB9P189MB1499.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:26c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 09:08:38 +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.6699.028; Fri, 25 Aug 2023 09:08:38 +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 v2 2/3] ipv6: ignore dst hint for multipath routes Date: Fri, 25 Aug 2023 11:08:29 +0200 Message-Id: <20230825090830.18635-3-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825090830.18635-1-sriram.yagnaraman@est.tech> References: <20230825090830.18635-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0022.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:b::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_|DB9P189MB1499:EE_ X-MS-Office365-Filtering-Correlation-Id: a4ec5660-4e70-467c-206f-08dba54ade94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JFjXR2jiUigyXBINFZMeWrSuHHqoxrgBBVgNQztcMeZrzoKpKa7RlZnhZ2VRqdQvR7e9bmQyqoej4uQsZAhQNPWDXDDulLy1xHMQIGBM2TRA8zNrrOsIOs2QkqeemR7ijm5hvN3DFVnjD8nO2kJ/009S+xZ/7G0u4kHsyMFpt2w9tNz3L6niWGR9LfZmXC4ukpPyOFI9O0hDxNVB1At7nbQZFx1O0GlLpBYdPf8pLWtQID0l5KglKXl/FDGK1g7A3Jz59xn7gauNrO2+5Zbn0OVrQuA2bKNWz/IefLmVDCMd7+YENxdD5DkEqa5Wb7AV6EbAi8suOqEDJEDVD2irTkZy81WwdtaO0YwNUfStmBo7Sd40nVytWHrMhXdRnmUIc0MIYyDkye9XJhCsKXwpMM/aK2AunXm0nPCtxkXNkpBQL/BDIzUDbFqjCcgPVryXH/WFDgApGth+rIafeJmtVhCb8VLtisqC8xnm2L9/Ju7jjFnVMQ2ZRIFRRE+8jRJ3d9Shr2MHFPXZUJ0MDdHSfplwVgrMDX0LPVyJFl7+dLZ3gLw2oPrtO8Nn4cfnxYix7bz8/vTxXp3cAK1g3Yt/+pv7jjUgkgPXVFSmG6UYGqHOckLroKchLaaIlu2RaPqymglrkKW+QZjmGcEsk2ZUMQ== 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)(136003)(346002)(376002)(396003)(39840400004)(186009)(1800799009)(109986022)(451199024)(66476007)(54906003)(66556008)(70586007)(66946007)(316002)(478600001)(26005)(38100700002)(6666004)(41300700001)(6506007)(86362001)(6486002)(6512007)(2906002)(4326008)(8676002)(8936002)(83380400001)(2616005)(5660300002)(7416002)(44832011)(1076003)(36756003)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vR9a0i9SlbQ7D1ZOFxURxvPcSFJK1+Atmu0dKtkNKIUAIBvFowIF1Z+8ixuTuzXzuNUw7ygX6nDgqmY0hn4KlAinH9zPDJmd6CUZEg/0UcoMjtbxnVYQ/dyRjAHG1eOf7lTR+7WjcUYrDYfaup1rebsDP0UmesV1cMICIsEl7fgneWHcoaR6JHPRh9rOj41kGiAb4RquuIdYwZDp4C7TRAhdaekNp3LMo9Zishb7MpXPAfkASeN4omiPDwQVauSwzj+84Xvm0OJ2pYi3O/lLKV+hjFf7y1S7xzSG3HQNTH0M2lmDyKXPyPDHtkzJOMPhHmOeJoM855mJ18PpamH3yIg+7daFMCP7U9omm/GMQyhX7brM/gtd2cucAC4my4RxIlofG6K3e/CG/QnGB38rRQXQ1kL0E0No91AHlEdiKGXsrY4ZHR7GXbooKPYCFL7Hq91+dQytJ0IHNRL/tW4+TYcrEo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cIFCjb/L9n3rC4r4w2LF8zm11hEqS12t3W3yXqRFY5Vk58cluxgONpPYGlvGpQOM5w+I943RlVs6qIwGWVwpNJ5Y5Q== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: a4ec5660-4e70-467c-206f-08dba54ade94 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 09:08:38.5120 (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: TVxtZxgzCb0XQrE4bRCDx+qJZO/U4bs7rRKIS2niXl7s+WNl1rni6vePkOkqj24mlXyRPGOjDoB3HrtUSaE9dOyPaoxjYuTUmWcCSP3jeaA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P189MB1499 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 --- include/linux/ipv6.h | 1 + net/ipv6/ip6_input.c | 3 ++- net/ipv6/route.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 839247a4f48e..fe3492a67b35 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -146,6 +146,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 56a55585eb79..4631e03c84b4 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -424,6 +424,8 @@ void fib6_select_path(const struct net *net, struct fib6_result *res, if (match->nh && have_oif_match && res->nh) return; + 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 Fri Aug 25 09:08: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: 13365246 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 085D1C8CE for ; Fri, 25 Aug 2023 09:08:51 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2103.outbound.protection.outlook.com [40.107.6.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F3819BF; Fri, 25 Aug 2023 02:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dosl79buXOpnWKjxssmFSEYFVnmACnYwTd8eEf6iIGiioeQiVMpZW9XQ+jlP1Q855EDllcLuH7KVhL03oNqCI0hKGaSxDjVxMRX0OmlnPfb8B7BVttsIe59xQZs9ZduJeKoupB7b4UPb+8V9VbIJfQwoWRyPNZsnbnF/clcsK3I6XPUbqudIYYBY9FX0461jHgVKWgl1nRDZ0McYceiTP3mpApIAyWGTs95KrTFjThtyA6fJaqVAx7ya0va2ztizss6+/opBW1JuXBSlYNBraRCbpEbeIkjbc6K0yyFFFFWtWp/8hU4mH4P0/EF8Os0FVGLT2tWcD8rlsPy8kcg9Ow== 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=K35+jhyNPgWDC7nOAfWdThB6lwVCLHE8sCCpfpt08f4=; b=EXKDb8eIwjjbRCeVVZOY5GaLjuaOYXTxCGHl+WmtczLHBeyU9qhsZH29bUsxby+mg5k6kIl1yMZ4hZk5ghoTa7JwBYEYegwUS9gXK9n5m2sNErbZRpA5CJ0C9+uFBf0ZjggEZwhM4MFrrliBb1wZRnmo0gEFXSyTOw2/N3Jgn3+poiTbUgDOt0GiLOg2cCquU+XGccpeplBPHIuLutdu4LNzyn1jHw8f1StDYFLcdSqAtQ2BE0OqEKaUNMnqwZAKlg84IN7Y9RmiKbthK+3cYX/UTVJEgQ+mBB1ONKg75N4wv0w1BHImpnZZIqBYKL4q/DDw+fBkf9Xn/nd0kf2Ygw== 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=K35+jhyNPgWDC7nOAfWdThB6lwVCLHE8sCCpfpt08f4=; b=SIG49+Mo8kIoayxwmHbT9GKewwrUpscpWPuTemvYiG5EL/M1+jlcQ/xgyxqyQVLaZdKiQ6HguIs7Y55NDNRjDj9Ib2hSlTQvouOwiaNKkpBPYK+/oiQdh+/qcUVzmcY9xLP9wAVGv2qQ2Ydl5CcjS1O9f9BtVxfIYHHl6NWF3kw= 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 DB9P189MB1499.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:26c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 09:08: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.6699.028; Fri, 25 Aug 2023 09:08: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 v2 3/3] selftests: forwarding: Add test for load-balancing between multiple servers Date: Fri, 25 Aug 2023 11:08:30 +0200 Message-Id: <20230825090830.18635-4-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825090830.18635-1-sriram.yagnaraman@est.tech> References: <20230825090830.18635-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0001.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:b::31) 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_|DB9P189MB1499:EE_ X-MS-Office365-Filtering-Correlation-Id: 7880fef7-dcdd-40a4-e7ba-08dba54adf46 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5cBpdeQXJ9FswsUgMQDAE2F9Gd54s9bjzv0MLrarxfXWI58z590BZMbiyKs1ollJc0mupZ5k5NC1ApidjzNVnmLY76S/LW+CoeU5X347bY8xcHAzL5896iE2B0omT5lrk+eAGrjfKPIXVVhlbPQn6CkpMWRNnSOD1FFYHr27lH26tO3z4w4gMxJYSu1kGicz3TCrMONLPd3sc65XhBf1RCcLHN4W1AKX6CjgX3W31K/AmPJ3MWaEvrPGAs8TZs0ewSBXa7rik2F/GkrduuYAaoUrwlpQeST2uyFeqmcggAtZAbJe3Ll5DvPJFE7pt8JCY+79jiiHjbRDI7TEZ+FECYaUtG5StSG+HTwvqb4wuu7DrCf+06sP5fZMkYVIM1S+mEurWllUGu6r51DU3tw9iHguywviq5G0xoPJjqZ8vK8yifKo3BWE1LiqNjYVBpw0fV8O3Xgo2+9x3KihJAVW0DJamWHKFoiKmfK8URPinILHbSu56avNEYVJrIeMjjJQv/SkXtjv58s86ValnbENlZ+OraT8ioodG6yrJfHsRXNeRyeg6caXimz+nwAAiU1SB6Es4Xf0ped5A0uGD94CL5Ktyb5elFfLICHy5D+HV1W1O8RejdrCOgc9t9eybEVRiAH+MA3mzYfx67hQT8ZMmA== 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)(136003)(346002)(376002)(396003)(39840400004)(186009)(1800799009)(109986022)(451199024)(66476007)(54906003)(66556008)(70586007)(66946007)(316002)(478600001)(26005)(38100700002)(6666004)(41300700001)(6506007)(86362001)(6486002)(6512007)(2906002)(4326008)(8676002)(66574015)(8936002)(83380400001)(2616005)(5660300002)(7416002)(44832011)(1076003)(36756003)(266003)(37730700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wFN5mEzmUpcr9A6A5YXff5rvFAy8LJfriVaihoyOedehWwvNDaI4rKIHxmoYJWUQourZFS4+bosUrkMhb9uWIRaGpjnvmOSbiYW65twH5sohV4CerKbE70ML1CYtn5Ys4HIJ/bWh4B8AFnUlT6gAWWb2BbLDBV2y94udYCkekcGJXmHaWuNDGe5N1brp7VE9sEtL6rt9UDf8EaZ6lK8GgcEMw5DoL/VuJ/TW9JbVe8Lu0UsImSBD8CCpSNMTLKrPBpP02zdFhAHiBRQuS/m/nFL12AY8ptzpH5vWO06wnxUx+04F4aLDjXTmTU5reIyWchgeBVtYLMK/x68XEHlq4zXoHi+Cx33qGR64S6gKvEql4U4ejmO1Rdsv7033fOXd0wTbP0mrvw+19B5j3129JblRRO2b78r3ATltlE3ABfULDdXH+4ZTiycmKDiAXs5FdRYNEO6/teBVLcUytaqpBOmZ1sHoUBVE/QQ0cYu1flGfY6tHzEnAUNFTpk+n1mhtDoe4KpYzbyjtPHhu2GBKTLeRIrHzWDEPOUsvFYX2wXWtLQKvHEoUzYs2E2tEdqzVlzAC7M6r+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40a4-e7ba-08dba54adf46 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 09:08:39.6205 (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: MHk49icLnOjKycjasicdfTl+JX2Qy0oFc4c09m3Cpd4M5hoTlf6pWJfFKzGHJ/lSu1Vii8il1/yu8xFHVzWJgrRanPBer44L8lzL+M7pgBY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P189MB1499 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 Create a topology with a host, and a router. The host (veth0) is in the default namespace, and a network namespace is created for the router, the peer veth1 is moved to the router netns. A dummy interface is added inside the router netns, to simulate a network that has two neighbors. An ECMP route to a virtual IP (vip) with the two neighbors as the next hop is added. 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 15% for the number of packets received on veth1 in the router. See diagram in the test for more information. Suggested-by: Ido Schimmel Signed-off-by: Sriram Yagnaraman --- .../testing/selftests/net/forwarding/Makefile | 1 + tools/testing/selftests/net/forwarding/lib.sh | 5 + .../net/forwarding/router_multipath_vip.sh | 255 ++++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/router_multipath_vip.sh diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile index 770efbe24f0d..bf4e5745fd5c 100644 --- a/tools/testing/selftests/net/forwarding/Makefile +++ b/tools/testing/selftests/net/forwarding/Makefile @@ -70,6 +70,7 @@ TEST_PROGS = bridge_igmp.sh \ router_mpath_nh.sh \ router_multicast.sh \ router_multipath.sh \ + router_multipath_vip.sh \ router_nh.sh \ router.sh \ router_vid_1.sh \ diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index f69015bf2dea..75a7b138c399 100755 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -787,6 +787,11 @@ link_stats_tx_packets_get() link_stats_get $1 tx packets } +link_stats_rx_packets_get() +{ + link_stats_get $1 rx packets +} + link_stats_rx_errors_get() { link_stats_get $1 rx errors diff --git a/tools/testing/selftests/net/forwarding/router_multipath_vip.sh b/tools/testing/selftests/net/forwarding/router_multipath_vip.sh new file mode 100755 index 000000000000..9aefebd8085c --- /dev/null +++ b/tools/testing/selftests/net/forwarding/router_multipath_vip.sh @@ -0,0 +1,255 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +--------------------+ +# | H1 | +# | | +# | $h1 + | +# | 192.0.2.2/28 | | +# | 2001:db8:1::2/64 | | +# | | | +# +------------------|-+ +# | +# +------------------|-----------------------+ +----------------------+ +# | SW | | | | +# | (netns ns-r1) | | | + $neigh1 | +# | $rp1 + | | 192.0.2.18/28 | +# | 192.0.2.1/28 | | 2001:db8:2::2/64 | +# | 2001:db8:1::1/64 + vip | | | +# | 198.51.100.0/24 | +----------------------+ +# | 2001:db8:3::/64 | | | +# | | | + $neigh2 | +# | | | 192.0.2.19/28 | +# | | | 2001:db8:2::3/64 | +# | | | | +# +------------------------------------------+ +----------------------+ + +ALL_TESTS="multipath_test" +NUM_NETIFS=2 +source lib.sh + +ns_create() +{ + local ns="$1" + + ip netns add $ns + + in_ns $ns ip link set dev lo up + in_ns $ns forwarding_enable +} + +ns_destroy() +{ + local ns="$1" + + ip netns del $ns &> /dev/null +} + +h1_create() +{ + ip link set dev $h1 up + ip address add 192.0.2.2/28 dev $h1 + ip address add 2001:db8:1::2/64 dev $h1 + + ethtool -K $h1 tcp-segmentation-offload off +} + +h1_destroy() +{ + ethtool -K $h1 tcp-segmentation-offload on + + ip address del 2001:db8:1::2/64 dev $h1 + ip address del 192.0.2.2/28 dev $h1 + ip link set dev $h1 down +} + +router_create() +{ + ns="ns-r1" + dummy="dum1" + + echo 20000 > /sys/class/net/$rp1/gro_flush_timeout + echo 1 > /sys/class/net/$rp1/napi_defer_hard_irqs + ethtool -K $rp1 generic-receive-offload on + + ns_create $ns + ip link set dev $rp1 netns $ns + + ip -n $ns link set dev $rp1 up + ip -n $ns address add dev $rp1 192.0.2.1/28 + + ip -n $ns link add name $dummy up type dummy + ip -n $ns address add 192.0.2.17/28 dev $dummy + ip -n $ns address add 2001:db8:2::1/64 dev $dummy + + ip -n $ns neigh add 192.0.2.18 lladdr 00:11:22:33:44:55 nud perm dev $dummy + ip -n $ns neigh add 192.0.2.19 lladdr 00:aa:bb:cc:dd:ee nud perm dev $dummy + ip -n $ns neigh add 2001:db8:2::2 lladdr 00:11:22:33:44:55 nud perm dev $dummy + ip -n $ns neigh add 2001:db8:2::3 lladdr 00:aa:bb:cc:dd:ee nud perm dev $dummy + + ip -n $ns route add 198.51.100.0/24 \ + nexthop via 192.0.2.18 \ + nexthop via 192.0.2.19 + + ip -n $ns route add 2001:db8:3::/64 \ + nexthop via 2001:db8:2::2 \ + nexthop via 2001:db8:2::3 +} + +router_destroy() +{ + ns="ns-r1" + dummy="dum1" + + ip -n $ns link del dev $dummy + + ip -n $ns address del dev $rp1 192.0.2.1/28 + ip -n $ns link set dev $rp1 down + ip -n $ns link set dev $rp1 netns 1 + + ns_destroy $ns + + echo 0 > /sys/class/net/$rp1/gro_flush_timeout + echo 0 > /sys/class/net/$rp1/napi_defer_hard_irqs + ethtool -K $rp1 generic-receive-offload off +} + +perf_stat() +{ + local tracepoint="$1" + local cmd="$2" + local out="$3" + + perf stat -o $out -j $tracepoint -a & + perf_stat_pid=$! + + $cmd + + kill -SIGINT $perf_stat_pid && wait $perf_stat_pid +} + +perf_evaluate() +{ + local desc="$1" + local expected=$2 + local perf_output="$3" + + RET=0 + measured=$(tail -n 1 $perf_output | jq '.["counter-value"] | tonumber | floor') + + diff=$(echo $expected - $measured | bc -l) + diff=${diff#-} + + test "$(echo "$diff / $expected > 0.15" | bc -l)" -eq 0 + check_err $? "Too large discrepancy between expected and measured fib lookup counts" + log_test "$desc" + log_info "Expected count $expected Measured count $measured" +} + +run_test_and_check_tpv4() +{ + local src_ip="$1" + local dst_ip="$2" + local t0_rp1 t1_rp1 + local expected + + # Transmit multiple flows from h1 to vip and check that fib lookup + # tracepoint is hit for each packet. + in_ns ns-r1 sysctl_set net.ipv4.fib_multipath_hash_policy 1 + + t0_rp1=$(in_ns ns-r1 link_stats_rx_packets_get $rp1) + + smac=$(mac_get $h1) + dmac=$(in_ns ns-r1 mac_get $rp1) + cmd="$MZ $h1 -q -p 64 -a $smac -b $dmac -A $src_ip -B $dst_ip + -t udp 'sp=1024,dp=1024-65535'" + + perf_output=$(mktemp) + perf_stat "-e fib:fib_table_lookup" "$cmd" "$perf_output" + + t1_rp1=$(in_ns ns-r1 link_stats_rx_packets_get $rp1) + expected="$(echo "$t1_rp1 - $t0_rp1" | bc -l)" + + perf_evaluate "IPv4 multipath: fib_table_lookup" $expected "$perf_output" + rm $perf_output + + in_ns ns-r1 sysctl_restore net.ipv4.fib_multipath_hash_policy +} + +run_test_and_check_tpv6() +{ + local src_ip="$1" + local dst_ip="$2" + local t0_rp1 t1_rp1 + local expected + + # Transmit multiple flows from h1 to vip and check that fib lookup + # tracepoint is hit for each packet. + in_ns ns-r1 sysctl_set net.ipv4.fib_multipath_hash_policy 1 + + t0_rp1=$(in_ns ns-r1 link_stats_rx_packets_get $rp1) + + smac=$(mac_get $h1) + dmac=$(in_ns ns-r1 mac_get $rp1) + cmd="$MZ $h1 -6 -q -p 64 -a $smac -b $dmac -A $src_ip -B $dst_ip + -t udp 'sp=1024,dp=1024-65535'" + + perf_output=$(mktemp) + perf_stat "-e fib6:fib6_table_lookup" "$cmd" "$perf_output" + + # fib6_table_lookup is called twice for each packet, for + # RT6_TABLE_LOCAL and RT6_TABLE_MAIN + t1_rp1=$(in_ns ns-r1 link_stats_rx_packets_get $rp1) + expected="$(echo "2*($t1_rp1 - $t0_rp1)" | bc -l)" + + perf_evaluate "IPv6 multipath: fib6_table_lookup" $expected "$perf_output" + rm $perf_output + + in_ns ns-r1 sysctl_restore net.ipv4.fib_multipath_hash_policy +} + +multipath_test() +{ + log_info "Running multipath tests" + run_test_and_check_tpv4 "192.0.2.2" "198.51.100.1" + run_test_and_check_tpv6 "2001:db8:1::2" "2001:db8:3::1" +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + rp1=${NETIFS[p2]} + + + h1_create + router_create +} + +setup_wait() +{ + h1=${NETIFS[p1]} + rp1=${NETIFS[p2]} + + setup_wait_dev $h1 + in_ns ns-r1 setup_wait_dev $rp1 + + # Make sure links are ready. + sleep $WAIT_TIME +} + +cleanup() +{ + pre_cleanup + + router_destroy + h1_destroy +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS