From patchwork Sat Aug 19 11:48:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 715276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 098ECEE49A5 for ; Sat, 19 Aug 2023 11:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbjHSLuu (ORCPT ); Sat, 19 Aug 2023 07:50:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjHSLut (ORCPT ); Sat, 19 Aug 2023 07:50:49 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2138.outbound.protection.outlook.com [40.107.14.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04428E40; Sat, 19 Aug 2023 04:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZFIU6O+emtVKgNF89ZxfB1ELeUCRmnzyO94TMzS6oHJwixmI9ilEPbXSjL7+wgAbES7sgFjFTAyEhe1v6VpmwTDlBluJBOhrBHzwYxFKHxXyVCx9j89fRB/w/UXavEzRXK8m8A9JG/49NFzzgZQcltptDQcfsI9Z3itlWlW9zMtugcNkDB8bNv9hi/AVa4j2PflJY9DyEi8M4TCo0CTkmV+RtaBlOa0Fs4Cm5h0OW3h3zeo0Zl/epokcFfdHFUpmUaPCYIo9LveTv68PIesNY8MFpNlZBdS70K7UGm4IejohTOL2eC6ZTh5m4EUG0CMhirRhCXIztLQ1YS+b0V3M0Q== 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=2o0rhJlqav+t4qyW/MoMaNO6Zvbg4RccRp9L+S10wY0=; b=lz10ptwt8yvfP0TNlbdRnu11C41uYI/OyxbxsR8ik1PRKhaO/P0jr3ewkklaVlMiMPBEycz1ZrmXh/2d1Zsx9l3/k1XGPHLgLwI9oivXxEhupXQmIsKcvhGF72IHxnAPOODJxN2aSoLVn2SPgXIHSMZASjMokuZ2XAzSCWYBvu2jnsQeWNg1nDjZn3A4mzglnNB+0/mudxIHablv/6A/TlmcVRcEu4Dv2LEU4LbkhFl5+jvhhTezjohDNFgedt55k5IOUuy346VDi0oIGQBybnfQHoQWwepwVCvlkUkNWyQ9TPqmMXD8WPpZ2Dgo984QFIhGiYrsZmL9dQ1DhYs1lQ== 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=2o0rhJlqav+t4qyW/MoMaNO6Zvbg4RccRp9L+S10wY0=; b=UoGha7CxEp5w7IHOmXlDEEutBLxbhluoGKtlm4qbZdRlENer48xOJQsQvVHgZPCCWDbj/ugZM0RlQlBiTn3qADiUU5BjH4iD3iCqpjQYxvQP/MYNFZDhOz1AdRErUS9iKjcuQAis5GUtBw7iexwgQ5P7xRwU6//YSljY7HfHGSM= 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 VE1P189MB1133.EURP189.PROD.OUTLOOK.COM (2603:10a6:800:14a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Sat, 19 Aug 2023 11:48:32 +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.020; Sat, 19 Aug 2023 11:48:32 +0000 From: Sriram Yagnaraman 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 , Sriram Yagnaraman Subject: [PATCH 1/3] ipv4: ignore dst hint for multipath routes Date: Sat, 19 Aug 2023 13:48:23 +0200 Message-Id: <20230819114825.30867-2-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230819114825.30867-1-sriram.yagnaraman@est.tech> References: <20230819114825.30867-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0114.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:8::32) To DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBP189MB1433:EE_|VE1P189MB1133:EE_ X-MS-Office365-Filtering-Correlation-Id: c2430af3-a665-4bca-4f88-08dba0aa3605 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5gMhI+08ZNBM3FkaZAq29eow+VZk3aBWFbFeR1EbJSwEmOXxvUwuLQ8ghBLOtbPwt4bLaVPR+lBh0M4KosbDGalvrgMji56GuBCgSdsk/SsmmUB18SNuiNlfJgiz3N3Zy4GKLBPHmHnLtGsTlxd3FQCFN4IaO2Apl3bakTuenV5mnm2lYLZitWxkP52/DUuyYQFaL+FpQvG0KenhND6r4+yrX5EBsm4K/djCsTZTK7jmXgRBmTqTmb2nOAgG9bWFbeFd90Bp4naAdOiQhAJPHouGZRL+mSEK4L4prGAXLu0uNaVbrIe9lh0V14dwYSpVhQ/86WXRMOah8n0vBba8tRDj2q4r9USKpIAKYFdsOStXyR39NTryDx7nJ1lAZ+AF6Cxd7HPxPeSTCWj2RHjCvq8xAx0RMi8GZOtch/YzBcixnmjkc3RHKHJmTp7Oc5Sge9YhjXHySedO+RSI1TcjENyBU029Ut1J/437YL/nqZLL/qd9FIdRvVVBO0Ic41yIu1cgzU1Jv00lFm9spodJw496quPTS9KQAWaVurE5Gj2zMuAG3qDM/sc4W3883MG0ed7whgrMT7+RhY969dlEiY+Ufmk3YILs0qOzUjpJahaUqiX3vCQIubRG14v6OZBY 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)(396003)(376002)(39830400003)(136003)(346002)(451199024)(1800799009)(109986022)(186009)(66556008)(66946007)(54906003)(66476007)(2906002)(4326008)(8676002)(8936002)(41300700001)(316002)(70586007)(6666004)(6486002)(5660300002)(44832011)(6506007)(478600001)(6512007)(2616005)(1076003)(26005)(83380400001)(38100700002)(86362001)(36756003)(266003)(37730700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6JpoubQOcbYFPo/O9BAZ2M4lTvkR2g4UufNEUc9LHZgNlJ77Ue1cd75abu1MrmBm09pG4zKdkr5NcaFoEw/5ftBQhbV5wgbaiVbh073J+5STxeOO2YiJ8xoPHYNJzTvS+5JDLVDLJWktKchBIkS4+6rZmuGrjXnvK+G63pZx/ttln8/bD61/0ixPbifyOJrOSV+QmGeEoldgcVgLF6PuGCASBreY7YnP5DK7uj05iefq+A9qqQ94DjMe1i/938+X4GBBBb/2tTU0Idmk9zDesTG56lLn9GTBgLwOPIIfiewvcqW69hHGDw6V50JhHAQ9L/oU2ymNdJOAKztF13jP4G6KrtFs/mzo5AIpYY930uAVmdLkph0dXAuhlr0ZGGNNeH7wolhJ3UoZMifo1zv3qYJwzr1vY0kslALfb/uEYmXwWDL6Ll8eSZ7vRcB/4ctOfSme3cgKOalUFCTSX7mIxqy+XDq5VqkKHYSoHtvJtjZjU/YU1lM7as2z1tDocXrSd0M7Qq+zfbfyVQsopkmVDhw8ZsMY2+quEm+7oFAz2Gq9ajbyNgMn5dBzRSkMRwiOyoD2mmNxgZdut4xj0aRyF3M2mB0k6qJA+CTz4UKGw2UdOmLajvuVQXfG1Pk/HSebVMZCJBeXCR/ATJ6Yh1gFy+gDkYbGlpOlql4EjHBGHY8jGeEV5389EDC6+8oZE3C8fSekMuAGkqaCt80XI1brZ4i0Ch2NwhnEo817+VMUsZWMIau9gcvRNxWXogOVJc5oFlcP5MydtyHnuSWQmh33bGdczN4wugMB2kp7TSZKo4/DFXhG68d+fLwygHxbK3TE4/uVXgKpC8tvWC9uOMn4eznI+/qgtB+oOKdyKUIgQHrS3n0NCYRDmgzt4GcFajeheYHHp6m3MDJy697/7wyzkEvhBrbM5ferK0iVHPqFyKK0lFZ+cIQ5tuHBljp9pbupahJXa6wyRzBkMLile6wYdtTeiM9+JP1syTvWqQ7wsK33A8yU9BjCtEGokOE2BxTWOOAn04JqGjeUYW4HlWMtj7Q6XIuwjd+5KppioFGhPQJtOsKGR/RQ9ypNnLDe25gAK1Y1PsoXet1ubB7U5Epxy6G3+7lcffy7DXvhOoC/gSukGMEaU557UCStYTO6YtU+/ogGtzcrHxmCmnCCSDmAoGX4anQviQdZMB555U0MeQLD8dkAu2jUQfbA6+3PggaIhxL52gnueUJN4tw6oOt0txlPGfAN4NnuOawcWpheNwCUmnxFFXjv3u37cUsPOKulfby2u2IOyMMMaOQDwhBSoc9wDId/nn+5zDYWcYKxR4sekRGWSapooi3+2N1LsGlWhuh7QzmcEO54vfdGLJnuzyZTMT5OmhKMRQZWQGW9pz83wFgfqM6tyHrYPiOOcEHf+jA+4EJLtKx6zW5mwmjofHKlYF/Xmk7pI0DVi01IjdTbEGPtOQQli5N+h8l++8XWgucJC8suvTdrZ2AUi7peAUQ/MT44wUy2gP521YJy6Jfr8OeJz35uPYZ9mXt5WCH4lKhgditIFhqIcrl/4BMv8SJ/lyvkU3OAYgqj7YMQOK1wj6p6L8MnXXTqwrbXdDpBdAsV2ARVL4yyOkWE/YC4+w== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: c2430af3-a665-4bca-4f88-08dba0aa3605 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2023 11:48:31.5248 (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: mURj3FkXPq1gqQVZoFc2XFgnAs0OBkUayr9joIfxp6d8Kk7+91esC+SRVpxFm5fzfJ8fgQEm/gPRbzaW8rrQK9TVoMsXHZGw2dz2qTne1BI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1P189MB1133 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Route hints when the next hop is part of a multipath group causes packets in the same receive batch to the same next hop irrespective of multipath hash of the packet. So, do not extract route hint for packets whose destination is part of multipath group. 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 332521170d9b..bdce572fa422 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 Sat Aug 19 11:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 715100 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE4DAEE49A5 for ; Sat, 19 Aug 2023 11:50:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbjHSLu7 (ORCPT ); Sat, 19 Aug 2023 07:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjHSLu6 (ORCPT ); Sat, 19 Aug 2023 07:50:58 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2138.outbound.protection.outlook.com [40.107.14.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6333C10; Sat, 19 Aug 2023 04:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jNhjzywRzUrJjkB2RFLHx5GIyV/JyzcxsyCRpGAqqkNaoUS/uJU5dPOjNZhigUPgvTSthDZSk4mq50fkXPx+u8bFS39Wi6NC+VrjgCSbr7zrUrDEk6J5vNU38Wq0h09XqzIZ3Vf3HkwKyM3uzmEu1x8YCyYIB0E9INuiJK1Ur5lJFFe1A2syMi66t4WtXn3ns9YX+NcKy4mDt7Wzom50E9doChrMJ1l8ssSs5BBxG7Z8ikhtPpMr056udlMdcG7aMsJyzrZD1QEt/vcVLBUkWfniFxiUkb5HebwQf53CVBAR2PPvR9UEn1+/DKzw80ovDHfrCjG9NTNfl6gQSVGtjQ== 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=WJ2YzlcVi6EnBaE6c23fRg75/fbGRMCYIYYVhtNnaco=; b=ZfIv3OvvMFTJbwH2H6Bb1ooagaom6ewL3EHP4PxaWv1QmgAItdWKlw2/6stH/kz8OjVZ1qat3w2ICOABq+tNR/NwUWv8YjdJv4CA2E0ugjpZc+3FxjZ/DC87DtoMhb4nQBkeBxRKxop79yaQ9Jjl7eMyRZYfrzg5zScgMdVgtubcCibgcJA+0uBg6Fd4fUOVUYNrWEB2Xqi+OtHuikO7ucQgB84DLiJ9cRy9EYV12t2v5QuC7XQYBvGqtL8DJ5FWqfEVfieMxtoA+IdtBTcyixRne3vw52iZ77AqV9xNm+pUdqmylghAZ4uZs4HRM9C5xtqvBp8okBg7wbhT7ICOcg== 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=WJ2YzlcVi6EnBaE6c23fRg75/fbGRMCYIYYVhtNnaco=; b=Jr22gqDyNVeUSOa+PTtzC/XFhMtl3mespX+kJIJLndW9ZK/m8jpgm3v17o3A0Mbp7/zs0Dr4tyewe+V/ZcSm/I4mQGFs+9fulcPwjpXKgg9c1VcAtmly7pQmkHlZhXiA1uVs3oX9N4lLWSvx7xdOoXuiA3GPEvjICXLKG3LPog0= 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 VE1P189MB1133.EURP189.PROD.OUTLOOK.COM (2603:10a6:800:14a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Sat, 19 Aug 2023 11:48:33 +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.020; Sat, 19 Aug 2023 11:48:32 +0000 From: Sriram Yagnaraman 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 , Sriram Yagnaraman Subject: [PATCH 2/3] ipv6: ignore dst hint for multipath routes Date: Sat, 19 Aug 2023 13:48:24 +0200 Message-Id: <20230819114825.30867-3-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230819114825.30867-1-sriram.yagnaraman@est.tech> References: <20230819114825.30867-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0115.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:8::18) To DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBP189MB1433:EE_|VE1P189MB1133:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f0b92e7-a5d7-4714-3a51-08dba0aa36de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: etYlnPnB6iPX1cgm/+2548vHUxK2Khod6PL+Ew2dHuDNo9UKNQWFvkIWPs16nvIi7zwRVdR0JkUEu5PJPR+j1Ot5nrcNb7TOIpzx6pIIRlNfnOG20nx6IU4b9rCU5jPLT3cKW+bBCETTx1/NRZuqz7qwZfiRREV5yVfZBZIXaxFIjsun3TptDCdJfNA9BYL9xVokYxXK+LqATQdl2/+tbf9kGWKCPrrpT8SUjL+IpygD5jBB93WIu7yAg7Mj9iw1NZcn9ngHQc9yXImsbkOwHdN/oD+UEXp10BGAgNPWWHJMg6tbCAS7tPBPR6XdODIj5LjT/oWVFARZrigXydNAyPFMYZsduE8CdTLqlRVTkA1d8Ki1sr7Zvjw4Q5wyd72Xv2CZynsYNE7UFyYjM1amAsjBm9eWHKPeUXszntyWstVFEq0j4GVdqt6GQaa0xnIkkULQuGHAuqk3iFajdNVDSVx2eHAQjfigH6P8OmwBZf/rJVkEKQUBxAAB//mkdgmkXaTl/nrFzgFD5Hv+h16vHHr6FleDtCfBPUoseLUuaqyZScHNmpHxtomcQNVV5WP4IJZGQjpiiX4dCNSVAnOgws6gL/gmKw+mrbp7AQ2vAVQX2FZTopZcljZG6XR0tvoLiEuf7zXAJnh3E/X6TV5FNQ== 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)(396003)(376002)(39830400003)(136003)(346002)(451199024)(1800799009)(109986022)(186009)(66556008)(66946007)(54906003)(66476007)(2906002)(4326008)(8676002)(8936002)(41300700001)(316002)(70586007)(6666004)(6486002)(5660300002)(44832011)(6506007)(478600001)(6512007)(2616005)(1076003)(26005)(83380400001)(38100700002)(86362001)(36756003)(266003)(37730700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1Q6teInSD3WMHwxqGvErw/DIvIUYjVJGCsgZBru6V9Wn4t54/e3lv5L8HrdYlWQO/Wax719kxXqhDa3dbwUEzHYuhuDtkZed61NjmGji/scJEgEEgIsCk9fx1pHT4Hln9iu6uZr0oLmCh8rhxxtPzU72at8ajYnV1KUntMCjqv8BLKD8VrnQ0M2znIxLgm0R1xoB325kBnZMrs46zc1bIZesMe//4t0XDBi10bnL28iYjSrJ29E2mZ9zS+ai15z20siZ8pvk939wSw4Wqawp7Ts18FMVt6nso7G0PC2CODMszHlPPm8BvzDK+tIcG/1Trx7pxrMbGtrY+/AHRhJjspyTPJDGCBjea9YMc0JhhACMXXYCn+ywJOjA306Nl7fmZfEXG5QGlKp67uYg5LUX8MrUJ+Hlt647ruxY/Ya/6oKOrtpuBxmJcX0xvFWCOIC1lJ+OSwHXenFycGT9mWn2MPkUnhGOhZhhsSZRGGeh5ZNkHOzAOu8JevA1C2EUK+9/bySxm8VZV9Dloq6Mauy7058YeR/bix45EYA+xOJM4NlJRulyAwhZojYTceyCSuHuh/WLi5SPqK8Pgnh7fzP9ygUHF+9AcmEEv3XQd4I1xziaPr6nderiReOeL3ENIHF4Jfqe4fShzj+1nCbkO9LcOSS3b6OmbFLgk1VASuo8RoxOUbV6CCA9rmKLbt5TWcvAME0x8qpyE3mNOS5RP1sS1RPTLu5LeXkg4+uoCZuLvM/GGNaenldRNrcR7lgY4KB0kgj5ErB1rANT6TYdBcKrNKtww+AqAvnOZOjMy+4fdu5RvB22YCnEzrH+lSJbMcWPAHYMkFrWRmGTZnVAf/8QtsoMhKiWt4sjgg2zkN5D6TUNk2TlLEJ4aQFUIluWRWcxWDYmRnORv4qkVOcOnhVUg3t03Q26sjU8urBG1sng6dOvrBfSl9pzYjmo9QigtTkjCn69bx74nWDU9VRmK4i7iTbCIpJYA/W+vcj+qHhLIRags+pcfz8ARDOYbqTQT2OD4SpbngbmUaidj4uj2Uhbs7qF5uVB9OgXrtZsSqCSb8/mY2HiUgb5vO2r5GIk3VeWAAHO/T6jWbHO6+zRXSVnz4hQWWdXQpvKYFUfZ9lGpj49ZlpJQkPLcUGU3v6LHaY+lGIVInYdix7IGKpsoCXQV1j48h8/KfvtY1N8/Bp8zffSGklJUUb4Ktz+/gdO3mk12ZOrunEL+WmOOGHFc2jgoM/b3aFr2kK0QkfrRq+MAsG/8GpBY35FBPOyn3uNhPgqy7uPP2EGgT+hPgXaRpBoc0fgdcolLTEgqTep9FnjmnkCcLxy+ZevvjIsVZcBOcsrcvRBheKjxUc8TjHl6AzPeqy89/EbxxkyWb8WTQgAZQxtJ/xlDGjfB4AyaS0BfCTuc3/OP4+1W7Mtc7jqhfEsk5atbqSXTptSuZDSxqAsEs6M/ZoOYmXjTb9upmO4nuVR0NXVy4DYagYOvXXY4WwVF/iYTWPoVz5Vp4PUG2BUCb/bwauPfDc66DDS5y44qssav5432xlGpm3vUXrDrtScvXNEXuRUydj5Bs6/c2CN6osNWC7hE7/3wTYI6UVxilQ01mEMaYYpRTHWHUPwJesQ/Q== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: 5f0b92e7-a5d7-4714-3a51-08dba0aa36de X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2023 11:48:32.9241 (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: vLsl/AFIb9L8a280ezP0H0I5U99IVaGNuggKbT8SlyI+OT6JeyqIll8g8AapYz5LUUGwcnAyslML9eP7ooSYI1HCrqcEkGxmE0xodRWRWEk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1P189MB1133 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Route hints when the next hop is part of a multipath group causes packets in the same receive batch to the same next hop irrespective of multipath hash of the packet. So, do not extract route hint for packets whose destination is part of multipath group. 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 Sat Aug 19 11:48:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 715275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD78EEE49A8 for ; Sat, 19 Aug 2023 11:51:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230429AbjHSLvA (ORCPT ); Sat, 19 Aug 2023 07:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjHSLvA (ORCPT ); Sat, 19 Aug 2023 07:51:00 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2138.outbound.protection.outlook.com [40.107.14.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC60FE5C; Sat, 19 Aug 2023 04:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DfTpQ7lfofi2wGq8My/M1jRgRpN6bKR0VVeBwxgKmvMounljC6ISfmg5tFXJHAvrH4uuZO3tHTkNW/403+dqSALSmG6Gs5wLESugLnp3U9H96FOw/NnUx/3hsj9sdtrDRJ65Y5lONi2W8aYXijvSbpop8swoZZIOIp2Nra5S/fa1vpEd7GzkQ7itMipQEiNnKGaqTmK0Aece29msFvOLC6YVGUde9vN7Op6kzaPb9+A0oYi4gQWu7hFdoBCYNGCfPQaYLWDl1EB8iKvFflpi03Nm6eYL+hjR92CXiUpoZjBSQOGpC82xp0EGV/ZgWu3a+HF5Q5eLnkZxtLFymXT48g== 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=YkbX+ZI0nGHKx2vEMEZEgT7eMDVlwWbv/3LWOR9s4LI=; b=QIn2i4YivWqoizQuwGHvwWFWyfU7JTlim8zdMkNHaab2FbtfK4r4u9zGPvRbRWuQ9H3DabShIpzPND9/tRNRseeBrF1uMdGX2tNlgpEo41jcCUkCbe+SaiWbrHLF8w25jQDVUxxgNWzb5tWqbv9dyzFTxmovbIUUjrEPMLnAuJrERj7TEEovEgBxZFwRqwyM7eAIP3anSerSEuRRGm0nUiVfKBktoegCyZojawSp3jgorkjHTnefyQGAwVKn6DybqZghRnAZipifHzTCRvZ4LF2cd1DxDMWBwF/qTYL6SJVyiXxaQIvsKsGk3NELCpYtRruZmIduNXqlmNlUGPXXOg== 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=YkbX+ZI0nGHKx2vEMEZEgT7eMDVlwWbv/3LWOR9s4LI=; b=agn8FnT6r8YuLoq3r+V+l/pMUnZXb0GNhk9K60DqjrHEEWmvsL5L5JLZ5EF4VbUGaZBkPNEogMZzY6jEPjJJ2m5dcG6gkh+Rafii1Y3WwXfApEcgblD7tL4C/vaUwtYeBjt7TKE2EBrJmP6+Yye/eQHUhaEJVBWQeiL02XD+Z08= 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 VE1P189MB1133.EURP189.PROD.OUTLOOK.COM (2603:10a6:800:14a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Sat, 19 Aug 2023 11:48:33 +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.020; Sat, 19 Aug 2023 11:48:33 +0000 From: Sriram Yagnaraman 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 , Sriram Yagnaraman Subject: [PATCH 3/3] selftests: forwarding: Add test for load-balancing between multiple servers Date: Sat, 19 Aug 2023 13:48:25 +0200 Message-Id: <20230819114825.30867-4-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230819114825.30867-1-sriram.yagnaraman@est.tech> References: <20230819114825.30867-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0114.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:8::32) To DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBP189MB1433:EE_|VE1P189MB1133:EE_ X-MS-Office365-Filtering-Correlation-Id: 66803608-4af4-4da4-d90e-08dba0aa3719 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U77Jkv3UJ0vSS+8eilwhpgdPpvhcZkAeVEi36cakejXAcS+qcWCCANxf85oNfXnG3/XIMdun58jdljjjZojPG+qQuHWtD2W1fWSHnWF+2l+VNfFjZbDH37uIA1FhpIFyhldmlNybEo5DAG+ga3vusBIKMyfaVWOL2A6wU4spXO9iTpRoFk1tZMInXuhP7RrITxigspvneQzGUBZuxdP3ON8lS3yqbt2xc2nQQ6+BsEuy7uf9l2T3A3eFuhT9k9iPgkdOaBWeeahoC0euS1WCSBp8FM74QpxOEfRz1T/+onP4Y2D38TC6+WmsTxIQ9PoQZAOLAW7+kGtKYY886c2k0nabc+blf2YOMO4Lppo4VspGFZ79epz1Qtq+57ts+t5i2lIlUTCepIEcAAWHnlovVbybDJJ61Lnyz7sz7hLh2D19dRQD399xEfeyDbg9tqSPAtnp4gcEMF+ekEnZ4YQZH+rZHixgdTYXMzYitcB4yY00BodDQ8Lr54T40YTnrEb0RMiV/obVfK6/qlpdyrXZcJQ048VxYZ0eHNN4+/TUl5K0/UsNtbTd7v2dQC+LpgJsToVez9pXBIznISeWvZZb04tYydQ5i5KkqRkDEGr27T8ugdSXmIyzVrGvd7YbBaV6 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)(396003)(376002)(39830400003)(136003)(346002)(451199024)(1800799009)(109986022)(186009)(30864003)(66556008)(66946007)(54906003)(66476007)(2906002)(4326008)(8676002)(8936002)(41300700001)(316002)(70586007)(6666004)(6486002)(5660300002)(44832011)(6506007)(478600001)(6512007)(2616005)(1076003)(26005)(83380400001)(38100700002)(66574015)(86362001)(36756003)(266003)(37730700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jjnTfGtidzbo/TuYdx433/se71DZq7rRCWnf4TDydzqNfgMBREXIiN6GmOVb43uwcVLvKf2Q6G6L5QeFFVHbcycM0zPrEncSuXLoVZBd0iBQGZVqImRLllw81fM4RthrPQNxLLAeoqpy7SvxCvwR99Y62I+GE0nZHUWBqblizQiruglDZWnSdpKHwIIk/WMPlJ4ncJSd3RpOU6E9DLptw2xmXveYF5Rq/K2OO4wh66+RoC7j6EPIcQWWrSOQy+Atf0OpN6MJefUsTJtj2X05yFSwCPeaBFHs2GUospNVcd/GLKWmVaeHrtlWi8UfApkY0Pka8es5Db67frBejukapMidVHR0tFxyTw+PfMh1lbAn5neVXRbRjgYpd2kNqGnIR+xkXpJqrmI8p8sbkgc7XykU9ni224HzxMWcIveBJEzsyLh5a6WPyFHDXLeEWmvErvDWJLvddsGVx4zS7p8JXcvSs12cQOKdxQIfBfEXoGm5XkuukIXgGDIfslutS65gMlgcFIC3Bp+jJsydeLd+XZrqGTAruPKhTVdLAEzn7K34W3l1MYmQtZwP9w5kYh3igZOQgz+Ugdvt+45I6+1LBkpnxe5FQz0G/WvnWS9xnH5x+lvL5Fv7jOOnkNoe7nLhuN3unai1O6cdn1EW++g72sMj9OCOR/5uxPzHKzfUMV5aBYDVMT2umK68MXKl1cgpjVqMHNqT1WC1YKKyozEU/n/aS4GaX5gLFOekivYGItSF5O2pzHmuvhKx1xHAAa1lciqoPh030UlSycSrcZMRS8pZW6jrZAQyIm6R7GF7OD9q0bElVjjPsTufT5jYE8Fd+cVPQ5QY62/oknVLUegaqpJQ85yQMPT64dwUPZ8VHYuy/qGye2NsuqeebwsoZ1kogIhl2FVg68KsghyG6WX2rBgVfnPdnz8yM4Q3f3iIdbsKeG70p4CUkZDVo6MFapKFDl0k7QmPZIwHJ3gqTKxegMrQ8OybYfjEYKTWh+3QSmw3XYT2lQe8tt2220BAtLqR8liYNecsZejsmTYLYyKlrriMGLuUYg/YWXPHYQBxWL7X7tVCS/vFaHDZISj9B77EN4qiB+33w2pW05lPEMYXt3RID2k7Ynvhz7pcm0K929sfcowcTpFY3VGwIYv1QeB4l5WlyEaXHz49DbIxoJNSZ6mgXg30XsKW76sqHrFg1xhRmsqXxe3ma/YlJURYd1zixxVplV5zAUOrVXzZWZhpUMtaw8S98RthPcUvFmY0i+r/ea39yNHZeVGFuUfPzljo0DgdRf5hGMA/EOUQ8jJKkA4kF260DofsepJbFP8KMHpkaLCdrvh6Zdyah/CaMlUonyQwYHyP2hrczVGkkkaanfdlxEM9CBxCyLJYB8EWdYDd29oYtvkIMfkUpWSVTJWnDX3TARvXqVjRBA6nQAFgm1qQBFbRQxNFwyLGiwwiM+WDM9I8ZUgIdFliR1exonZ+f289LmiYnM6/qWKuiQBK8B+KZQ9psChdQe/K9FvtXZo4ykWRFGSW0GsEZC15vACx23dFiorjwpdG4Ej19txm/4p6Bl2jdeSvlSVJroGcZFvoWx9X3pJ+DgMKFh9C+Yjxx11oxo/x2aajGV4q/TvkGQ== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: 66803608-4af4-4da4-d90e-08dba0aa3719 X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2023 11:48:33.4095 (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: mJBYwOH7fPjPSM0vllCy6rNAcwI4OVoManKj1y+a+lzyl9wCLz77jVzrG84JumnT82zqgJ/5teu3fjmDaw1S2WFGIo/hfM1q0mbh/Yv9+J8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1P189MB1133 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Create a topology with 3 hosts, a router each in it's own network namespace. Test IPv4 and IPv6 multipath routing from h1 to h2/h3 via router r1 where a multipath route is setup to load-balance between h2 and h3. See diagram in the test for more information. Signed-off-by: Sriram Yagnaraman --- .../testing/selftests/net/forwarding/Makefile | 1 + .../net/forwarding/router_multipath_vip.sh | 403 ++++++++++++++++++ 2 files changed, 404 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/router_multipath_vip.sh b/tools/testing/selftests/net/forwarding/router_multipath_vip.sh new file mode 100755 index 000000000000..15c7598d42df --- /dev/null +++ b/tools/testing/selftests/net/forwarding/router_multipath_vip.sh @@ -0,0 +1,403 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +--------------------+ +----------------------+ +# | H1 | | H2 | +# | | | | +# | $h1 + | | + $h2 | +# | 192.0.2.2/24 | | | | 198.51.100.2/24 | +# | 2001:db8:1::2/64 | | | | 2001:db8:2::2/64 | +# | | | | | | +# +------------------|-+ +-|--------------------+ +# | | +# +------------------|-------------------------|--------------------+ +# | SW | | | +# | | | | +# | $rp1 + + $rp2 | +# | 192.0.2.1/24 198.51.100.1/24 | +# | 2001:db8:1::1/64 + vip 2001:db8:2::1/64 | +# | 198.18.0.0/24 | +# | 2001:db8:18::/64 + $rp3 | +# | | 203.0.113.1/24 | +# | | 2001:db8:3::1/64 | +# | | | +# | | | +# +--------------------------------------------|--------------------+ +# | +# +-|--------------------+ +# | | H3 | +# | | | +# | | 203.0.113.2/24 | +# | | 2001:db8:3::2/64 | +# | + $h3 | +# | | +# +----------------------+ + +ALL_TESTS="ping_ipv4 ping_ipv6 multipath_test" +NUM_NETIFS=6 +source lib.sh + +ns_create() +{ + ns=$1 + + ip netns add $ns + in_ns $ns ip link set dev lo up + in_ns $ns sysctl -q -w net.ipv4.ip_forward=1 + in_ns $ns sysctl -q -w net.ipv6.conf.all.forwarding=1 +} + +ns_destroy() +{ + ip netns del $1 +} + +h1_create() +{ + local ns="ns-h1" + + ns_create $ns + ip link set dev $h1 netns $ns + + in_ns $ns ip link set dev $h1 up + + in_ns $ns ip address add 192.0.2.2/24 dev $h1 + in_ns $ns ip address add 2001:db8:1::2/64 dev $h1 + + in_ns $ns ip route add default via 192.0.2.1 + in_ns $ns ip route add default via 2001:db8:1::1 +} + +h1_destroy() +{ + local ns="ns-h1" + + in_ns $ns ip route del default via 2001:db8:1::1 + in_ns $ns ip route del default via 192.0.2.1 + + in_ns $ns ip address del 2001:db8:1::2/64 dev $h1 + in_ns $ns ip address del 192.0.2.2/24 dev $h1 + + in_ns $ns ip link set dev $h1 down + in_ns $ns ip link set dev $h1 netns 1 + ns_destroy $ns +} + +h2_create() +{ + local ns="ns-h2" + + ns_create $ns + ip link set dev $h2 netns $ns + + in_ns $ns ip link set dev $h2 up + + in_ns $ns ip address add 198.51.100.2/24 dev $h2 + in_ns $ns ip address add 2001:db8:2::2/64 dev $h2 + + in_ns $ns ip address add 198.18.0.0/24 dev lo + in_ns $ns ip address add 2001:db8:18::/64 dev lo + + in_ns $ns ip route add 192.0.2.0/24 via 198.51.100.1 + in_ns $ns ip route add 2001:db8:1::/64 nexthop via 2001:db8:2::1 +} + +h2_destroy() +{ + local ns="ns-h2" + + in_ns $ns ip route del 2001:db8:1::/64 nexthop via 2001:db8:2::1 + in_ns $ns ip route del 192.0.2.0/24 via 198.51.100.1 + + in_ns $ns ip address del 2001:db8:18::/64 dev lo + in_ns $ns ip address del 198.18.0.0/24 dev lo + + in_ns $ns ip address del 2001:db8:2::2/64 dev $h2 + in_ns $ns ip address del 198.51.100.2/24 dev $h2 + + in_ns $ns ip link set dev $h2 down + in_ns $ns ip link set dev $h2 netns 1 + ns_destroy $ns +} + +h3_create() +{ + local ns="ns-h3" + + ns_create $ns + ip link set dev $h3 netns $ns + + in_ns $ns ip link set dev $h3 up + + in_ns $ns ip address add 203.0.113.2/24 dev $h3 + in_ns $ns ip address add 2001:db8:3::2/64 dev $h3 + + in_ns $ns ip address add 198.18.0.0/24 dev lo + in_ns $ns ip address add 2001:db8:18::/64 dev lo + + in_ns $ns ip route add 192.0.2.0/24 via 203.0.113.1 + in_ns $ns ip route add 2001:db8:1::/64 nexthop via 2001:db8:3::1 +} + +h3_destroy() +{ + local ns="ns-h3" + + in_ns $ns ip route del 2001:db8:1::/64 nexthop via 2001:db8:3::1 + in_ns $ns ip route del 192.0.2.0/24 via 203.0.113.1 + + in_ns $ns ip address del 198.18.0.0/24 dev lo + in_ns $ns ip address del 2001:db8:18::/64 dev lo + + in_ns $ns ip address del 2001:db8:3::2/64 dev $h3 + in_ns $ns ip address del 203.0.113.2/24 dev $h3 + + in_ns $ns ip link set dev $h3 down + in_ns $ns ip link set dev $h3 netns 1 + ns_destroy $ns +} + +router1_create() +{ + local ns="ns-r1" + + ns_create $ns + ip link set dev $rp1 netns $ns + ip link set dev $rp2 netns $ns + ip link set dev $rp3 netns $ns + + in_ns $ns ip link set dev $rp1 up + in_ns $ns ip link set dev $rp2 up + in_ns $ns ip link set dev $rp3 up + + in_ns $ns ip address add 192.0.2.1/24 dev $rp1 + in_ns $ns ip address add 2001:db8:1::1/64 dev $rp1 + + in_ns $ns ip address add 198.51.100.1/24 dev $rp2 + in_ns $ns ip address add 2001:db8:2::1/64 dev $rp2 + + in_ns $ns ip address add 203.0.113.1/24 dev $rp3 + in_ns $ns ip address add 2001:db8:3::1/64 dev $rp3 + + in_ns $ns ip route add 198.18.0.0/24 \ + nexthop via 198.51.100.2 \ + nexthop via 203.0.113.2 + in_ns $ns ip route add 2001:db8:18::/64 \ + nexthop via 2001:db8:2::2 \ + nexthop via 2001:db8:3::2 +} + +router1_destroy() +{ + local ns="ns-r1" + + in_ns $ns ip route del 2001:db8:18::/64 + in_ns $ns ip route del 198.18.0.0/24 + + in_ns $ns ip address del 2001:db8:3::1/64 dev $rp3 + in_ns $ns ip address del 203.0.113.1/24 dev $rp3 + + in_ns $ns ip address del 2001:db8:2::1/64 dev $rp2 + in_ns $ns ip address del 198.51.100.1/24 dev $rp2 + + in_ns $ns ip address del 2001:db8:1::1/64 dev $rp1 + in_ns $ns ip address del 192.0.2.1/24 dev $rp1 + + in_ns $ns ip link set dev $rp3 down + in_ns $ns ip link set dev $rp2 down + in_ns $ns ip link set dev $rp1 down + + in_ns $ns ip link set dev $rp3 netns 1 + in_ns $ns ip link set dev $rp2 netns 1 + in_ns $ns ip link set dev $rp1 netns 1 + ns_destroy $ns +} + +multipath4_test() +{ + local desc="$1" + local weight_rp2=$2 + local weight_rp3=$3 + local t0_rp2 t0_rp3 t1_rp2 t1_rp3 + local packets_rp2 packets_rp3 + + # Transmit multiple flows from h1 to h2 and make sure they are + # distributed between both multipath links (rp2 and rp3) + # according to the configured weights. + in_ns ns-r1 sysctl_set net.ipv4.fib_multipath_hash_policy 1 + in_ns ns-r1 ip route replace 198.18.0.0/24 \ + nexthop via 198.51.100.2 weight $weight_rp2 \ + nexthop via 203.0.113.2 weight $weight_rp3 + + t0_rp2=$(in_ns ns-r1 link_stats_tx_packets_get $rp2) + t0_rp3=$(in_ns ns-r1 link_stats_tx_packets_get $rp3) + + in_ns ns-h1 $MZ $h1 -q -p 64 -A 192.0.2.2 -B 198.18.0.0 \ + -d 1msec -t udp "sp=1024,dp=0-32768" + + t1_rp2=$(in_ns ns-r1 link_stats_tx_packets_get $rp2) + t1_rp3=$(in_ns ns-r1 link_stats_tx_packets_get $rp3) + + let "packets_rp2 = $t1_rp2 - $t0_rp2" + let "packets_rp3 = $t1_rp3 - $t0_rp3" + in_ns ns-r1 multipath_eval "$desc" $weight_rp2 $weight_rp3 $packets_rp2 $packets_rp3 + + in_ns ns-r1 ip route replace 198.18.0.0/24 \ + nexthop via 198.51.100.2 \ + nexthop via 203.0.113.2 + + in_ns ns-r1 sysctl_restore net.ipv4.fib_multipath_hash_policy +} + +multipath6_l4_test() +{ + local desc="$1" + local weight_rp2=$2 + local weight_rp3=$3 + local t0_rp2 t0_rp3 t1_rp2 t1_rp3 + local packets_rp2 packets_rp3 + + # Transmit multiple flows from h1 to h2 and make sure they are + # distributed between both multipath links (rp2 and rp3) + # according to the configured weights. + in_ns ns-r1 sysctl_set net.ipv6.fib_multipath_hash_policy 1 + in_ns ns-r1 ip route replace 2001:db8:18::/64 \ + nexthop via 2001:db8:2::2 weight $weight_rp2 \ + nexthop via 2001:db8:3::2 weight $weight_rp3 + + t0_rp2=$(in_ns ns-r1 link_stats_tx_packets_get $rp2) + t0_rp3=$(in_ns ns-r1 link_stats_tx_packets_get $rp3) + + in_ns ns-h1 $MZ $h1 -6 -q -p 64 -A 2001:db8:1::2 -B 2001:db8:18::0 \ + -d 1msec -t udp "sp=1024,dp=0-32768" + + t1_rp2=$(in_ns ns-r1 link_stats_tx_packets_get $rp2) + t1_rp3=$(in_ns ns-r1 link_stats_tx_packets_get $rp3) + + let "packets_rp2 = $t1_rp2 - $t0_rp2" + let "packets_rp3 = $t1_rp3 - $t0_rp3" + in_ns ns-r1 multipath_eval "$desc" $weight_rp2 $weight_rp3 $packets_rp2 $packets_rp3 + + in_ns ns-r1 ip route replace 2001:db8:18::/64 \ + nexthop via 2001:db8:2::2 \ + nexthop via 2001:db8:3::2 + + in_ns ns-r1 sysctl_restore net.ipv6.fib_multipath_hash_policy +} + +multipath_test() +{ + log_info "Running IPv4 multipath tests" + multipath4_test "ECMP" 1 1 + multipath4_test "Weighted MP 2:1" 2 1 + multipath4_test "Weighted MP 11:45" 11 45 + + log_info "Running IPv6 L4 hash multipath tests" + multipath6_l4_test "ECMP" 1 1 + multipath6_l4_test "Weighted MP 2:1" 2 1 + multipath6_l4_test "Weighted MP 11:45" 11 45 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + rp1=${NETIFS[p2]} + + rp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + rp3=${NETIFS[p5]} + h3=${NETIFS[p6]} + + h1_create + h2_create + h3_create + + router1_create + + forwarding_enable +} + +setup_wait() +{ + h1=${NETIFS[p1]} + rp1=${NETIFS[p2]} + + rp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + rp3=${NETIFS[p5]} + h3=${NETIFS[p6]} + + in_ns ns-h1 setup_wait_dev $h1 + in_ns ns-h2 setup_wait_dev $h2 + in_ns ns-h3 setup_wait_dev $h3 + in_ns ns-r1 setup_wait_dev $rp1 + in_ns ns-r1 setup_wait_dev $rp2 + in_ns ns-r1 setup_wait_dev $rp3 + + # Make sure links are ready. + sleep $WAIT_TIME +} + +cleanup() +{ + pre_cleanup + + forwarding_restore + + router1_destroy + + h3_destroy + h2_destroy + h1_destroy +} + +ping_test() +{ + RET=0 + + local ns=$1 + local dip=$2 + local args=$3 + + in_ns $ns $PING $args $dip -c $PING_COUNT -i 0.1 \ + -w $PING_TIMEOUT &> /dev/null + check_err $? + log_test "ping$args" +} + +ping6_test() +{ + RET=0 + + local ns=$1 + local dip=$2 + local args=$3 + + in_ns $ns $PING6 $args $dip -c $PING_COUNT -i 0.1 \ + -w $PING_TIMEOUT &> /dev/null + check_err $? + log_test "ping6$args" +} + +ping_ipv4() +{ + ping_test ns-h1 198.51.100.2 + ping_test ns-h1 203.0.113.2 +} + +ping_ipv6() +{ + ping6_test ns-h1 2001:db8:2::2 + ping6_test ns-h1 2001:db8:3::2 +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS