From patchwork Mon Nov 18 16:43:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878808 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2048.outbound.protection.outlook.com [40.107.237.48]) (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 E3AC31BAEDC for ; Mon, 18 Nov 2024 16:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945708; cv=fail; b=Q4lTGlLK5NTlvrxTpfNoVccU/ZVEH0Ac9lfSKKtzVq2B6FtS64LCRDgMM2k06U+V3ytK72m2J5C6lOwnaflmxeHkB3/l+g8RrB7Qm8xbO1A5nHKM607I4Fjx9qai+soon7olWjLnc+sUvJRX15h8H8w6BmD1ioKYYVTq/gYZTAw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945708; c=relaxed/simple; bh=1Nt5flOnIs2KdgOTK1Rn7k0fsKc+v5aIWnXwOXuXonc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oV3ItM0bRi3Lhwtq9FO17gmLPeGjM42YQlf2vgotxEiW0CDecPJQQE9wcLxqekXMpA+7bN2QNBi3VRnKAi05w11zCsgM4LG5bTb6uS26CTz32+WgoPXbGbJW4njmH20FcvGrE1pQbQXSboPsSAzFW+T3r+FjtAOloRhg2JryqgM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=cIPRfQhH; arc=fail smtp.client-ip=40.107.237.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="cIPRfQhH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YZVZlxItYTd7yjPX9WZXaVj3vJVs8N4Jw2OcL16U1sP5vdZSzJov7fwIEXV5v8ehqmOMpRH/wDyaw4ag5ZE4AdxbTHds8w1Iz2k6BS0rUf9E9JgT6T8HF5oajyNjK5x4+fgQYGeJt8p31JIZetO6J8Dj4afzIZejgwQxZRZILb4vhdRUVx/jzMrdJ3bUsZm6Dk469bxOwYH+HjNmdDwXRymRNNw0AAnLsYdHSFx4NPX6OATPhPbdq1bosQbpIt7DJOQA41XJKrC1g3ld9FVZgVNNzJnJSrAed5/t7ooRGEfo428uMgEuqg0R7N6UeC7oSqb96TkfevvN97xow/C8nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Dnw53MBIUTmm6mPBugC73g+K4Z4/LqO+rap3UjyYOws=; b=Kp/fiu6wLzSXSWo3+1e2PEZiK4pU4aJS+IcxjfrdXRdEUtnmcOr1Ue6a8B72GcIUHtl1rm9n4qcC7YQt5bghnuVXBtdroSrOuZFQktGAmRFq/biG8uugcd6vGjavlndXjstsWKNswflJNXCFr53ZpOvvLb/U5gmN5CfBoTUd4i7diQ+nnuIAjJ63LqyLHOwBmZtaoPd/tocmTu4aLXfgdV+TwtufbX4LZQH3+Q2E7GReFdBwjWVg9NowVndce+Evr4YX8C5knZDhsrHvB68xgnPMNwSMQQFIP1My0VUkIynML6kIZpirvbvH1fDTFO5iYnTQLirW9M1FDYiIIjScLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dnw53MBIUTmm6mPBugC73g+K4Z4/LqO+rap3UjyYOws=; b=cIPRfQhH/OUG/j8+JZkiHz2tGorWJHOZryTYLySLBtGNafTYwcIfT5J0YKBo5ejuQfJSJ1afmGas4cdb+a/Qcm1j1eDDNHBjqAc3LyMxlnAPyQQ4xD7eHYMbhHFmu86rt5quz9qMqeYwLck0cnmmd4zreY+fGoMF17rWypogFVIcZ1/8lfXI9mqwLyz56HNJdx1bHh3lSQMuDrXP0d/N2IFA6smyyoBGiC3YvynPei2P0+KO0NNCOTj8Hp3+JksmMBRsjhU/W8bz+tQ/JtOFvru4c/17Kki4b+whnx9fFEOweNVn3ZjfxGwuS7+Du2HNE02/2jrKk7MLv8v9HqmUZw== Received: from CH2PR03CA0018.namprd03.prod.outlook.com (2603:10b6:610:59::28) by CY5PR12MB6455.namprd12.prod.outlook.com (2603:10b6:930:35::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Mon, 18 Nov 2024 16:01:40 +0000 Received: from CH1PEPF0000AD77.namprd04.prod.outlook.com (2603:10b6:610:59:cafe::5b) by CH2PR03CA0018.outlook.office365.com (2603:10b6:610:59::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:01:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH1PEPF0000AD77.mail.protection.outlook.com (10.167.244.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:01:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:08 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:02 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 01/11] vxlan: In vxlan_rcv(), access flags through the vxlan netdevice Date: Mon, 18 Nov 2024 17:43:07 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD77:EE_|CY5PR12MB6455:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e758830-daf5-4604-9d7f-08dd07ea48a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: WLUQvIcXWbbWYNVgV+99VQoOd/KgC0ayD1NyrIetYdq9ufnvC49ybUcXlyrO/GcTEEo7QiCdIAKGE5xzEao460rjqPn9e/OgNpUgJZnEsxLhUSoWPFEBc0IR1TIGi5I5mfeINPBbbpreyguzrXDyakaIzDsNrcYQepF5a32EcCDtWuFjOTDzFumTDyR0zTZYErRq2uFyuB3iHJwEHOecRnrQWXaXp6oy+1iiCmMdhwag3RE2EFbLFZf5C2fVzUB4PiPeiKAQt2q84U5dYVnLVhEYduy0OSuNH7r/Su54Xu2WZ1a5nG6hxFWpcc2KXz7Bs3HASOAmCd8SigpImdYlvZPbyZpb0F4al/338sBYGmXxCpB3h4AZJPdTMGiuoMDLhewJLOJ+LB5/+1i09q72MzaY/hKiJGpKqTERApzb192iGNOyu2fqNeD2S4bBr+A+kEf/deLTL7gngk+ffOZJ3HO/BZrfyebLtnmRlI7iL54WH4BbJ08SyWmhw1S+0oRrj2BmGqKCg6VZGq4sPbob+NlpNG43T2239EQMXLX828aJo5mrV8SlIzVCC5+AMV6b2TnOwq1gAcgCeQOJqT91RHjv8i1TBxLX3VQf+5BI/tsK3+5s/+cCfwNjC5YJeRedeHOiEQ0ssM2b3KR132uWkB0LgCGDWffswKlnwVJJgtnfNaURyrj8gCCsT6bJbnsYf4r+Sy2ucjtcBsxJjFTs2swvGX8djwqW0G9NSkZ3ELprGFM7sWqeTTtTIwfzDX1n9ExaCU/8yaktCUpykX6fiDtA/eGxWYq0ENTfrVGujWyx63YOJ4LL1EqB2U8AYDjGO570whxETPLitGGguGYWeEgGWxFs/sFshhi9eaU+IV4Sg10/WHNX4tQ54O+7WNatN0fbBEDrC7c4g4oqYwlFARI0iQpfnkAz0IM5yXR+idgiAqXw57CrCsV8FxRSvaLArB5QsgmnWXBIWlU9ChvbpcYJw+ysaUpJHvXVo6hw/+xFwr8FyoY5G8TCdyRScc0wkTSQY8zr7/jWt9ER28YmXDSjXBOFI0Wp2IDSkiGaM6UOP6mB0BaPZ4AGkQt7ROfFJIg9YAcOkAlIbMw0SwIOVR6yEHEC80gzz2H+18nSYLXCg6M/gTY750+pzIlpP96S+2wGasaquk8MHcwmfHZWiKsaNfms6oshT5Nhg/LgXxZ7YxlK8YIMhbmIuajfPoXzQlGA7Po0uuOb2r8fT4bMjbxXDzL0Hol5+Rg2aV/XGlANB/ZAg0GjM3IbKAHBXL84zRWndsO3zaK3NJY7N39pcDVQZFGrnAQ4EqQPaRZYZUa/F61DGB1lbyuCK0qHCuWlvevMFg+LYlXcVrPB1CgAAuYnJB8ZIvhu58XMpGJyRx0FtJRAQ+rVs2QBuQ2zO7M+jKGvMqLAP6IbPhlfriE2Pw== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:01:37.7339 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e758830-daf5-4604-9d7f-08dd07ea48a3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD77.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6455 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC vxlan_sock.flags is constructed from vxlan_dev.cfg.flags, as the subset of flags (named VXLAN_F_RCV_FLAGS) that is important from the point of view of socket sharing. Attempts to reconfigure these flags during the vxlan netdev lifetime are also bounced. It is therefore immaterial whether we access the flags through the vxlan_dev or through the socket. Convert the socket accesses to netdevice accesses in this separate patch to make the conversions that take place in the following patches more obvious. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index edef32a593c3..071d82a0e9f3 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1717,7 +1717,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) /* For backwards compatibility, only allow reserved fields to be * used by VXLAN extensions if explicitly requested. */ - if (vs->flags & VXLAN_F_GPE) { + if (vxlan->cfg.flags & VXLAN_F_GPE) { if (!vxlan_parse_gpe_proto(&unparsed, &protocol)) goto drop; unparsed.vx_flags &= ~VXLAN_GPE_USED_BITS; @@ -1730,8 +1730,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) goto drop; } - if (vs->flags & VXLAN_F_REMCSUM_RX) { - reason = vxlan_remcsum(&unparsed, skb, vs->flags); + if (vxlan->cfg.flags & VXLAN_F_REMCSUM_RX) { + reason = vxlan_remcsum(&unparsed, skb, vxlan->cfg.flags); if (unlikely(reason)) goto drop; } @@ -1756,8 +1756,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) memset(md, 0, sizeof(*md)); } - if (vs->flags & VXLAN_F_GBP) - vxlan_parse_gbp_hdr(&unparsed, skb, vs->flags, md); + if (vxlan->cfg.flags & VXLAN_F_GBP) + vxlan_parse_gbp_hdr(&unparsed, skb, vxlan->cfg.flags, md); /* Note that GBP and GPE can never be active together. This is * ensured in vxlan_dev_configure. */ From patchwork Mon Nov 18 16:43:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878809 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2044.outbound.protection.outlook.com [40.107.102.44]) (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 3ABBA1BD9FB for ; Mon, 18 Nov 2024 16:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945711; cv=fail; b=jglruJT82wGfyADOsAnscdKlYpi76TgeKQQO9GO6l6uNzVnvs45y9VWkalM8adC0zNAWBr70rqHsO/3+/FCXfUFNRTFmOPFtQ++kCGLJZhMq7AQigFZj1HYHNG9oSeLI3vofxGt4QXWGLLCJpQtQz2TCiTZX37YYQIiS6/NiTRQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945711; c=relaxed/simple; bh=4fORPvsEbXLVZq8MRnvTMasHw+NgXKqcZO+gGA6jr2Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QGgBXsrVUXjapWCOchrXW0VqP0vnP5i6IKjhzZ2xKuDGjjbqg9QpZgFScPvF7+u/r0nWGP1JNIRnHjmUfTtsJxHWb0knUKOYOIjVKB8SSRgXpPX6PUlCDvgOL4RCdv4Hm4fwbXRlcpCgVKV25XDzWwjaIuVEm+bf31/fJDax65c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=oPvpy0TM; arc=fail smtp.client-ip=40.107.102.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="oPvpy0TM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q9qTRFmaoECBbCiYewl/LiJbiPClLWMzMma5V/s5xYfLp46TkFQD42O/dzXNq9TEV6Nz+HtY2wdJJyqYbnbymmuXNKsGvgQBIXvc4QrmMw4wh+8IhBapvRyBJCZnsnDRSwUT017A/SbKhjMhAa6loR33O/o2H4OAnhIM9/arFPH/DZXKcS5ltiGCOE+aoj8ekohGEHDpMURbDW25mEBvLJw+5wNgkmAHm8aErtX65DTzvT91TRjrY5IBSz6dQYxj6v2rYhka5XMdcR7SK1C67ANXG0fNfTsLrCFbKrEr8PyA4ED3ROG1U1AB4i4xm5Ydj+4kTqZlvLXFnQZiTJkKrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=enwBRnt/sNGwgK7wLgrncBevVJiaFC/QCok+OXdBKec=; b=xm0d/Zf1cthnibzaEIHg20mNzX7AZJd0PwBak7+R1WnyLYPH1V7DhB5oH0pj/eWATf8hbWz/4tuMoqBJ1lOTOMfhPvw3QbynGO9HiseCg4MhB7MoZSDWZO77TYvw55ccqsXUwVOqZoAgXutjyPgCWCebKPRnYJmaeCiMvKkbvml8x16k4fWGooCkh3SI4/KfcuL17k9UEWmm3DLSeL1/nd2H9blS9qBSvsjDpa1AURziQrsrrrtnvC0HwF42yyLoQ5uz6ragU4pUtZcXyk+so/eaDeMBM6l7WM4CZZPxYHNBx+ju5seogwLuXFuAABcjaSECTsOtqmwUS9vPYbo+ew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=enwBRnt/sNGwgK7wLgrncBevVJiaFC/QCok+OXdBKec=; b=oPvpy0TMbhPFCjejMpCNwzI3dGjqs90AEhcyMfPzVMciktbcW7uKUQmAC6nZlpJoFM9Sirm23HTtz/doxq55AHJrme4AwIdqkSd487C3kdft1xBYRJMxdUpl3Q52GxX8T68o1A6eX2spBU6E0TTeEWOGET2rzkVUqfykrS7thN3xJK6lNSzBRFjRFm5MyDuYb0TnR+srdUCp3JLUtoEHx2cvho224+15UkzZ5U3qniggpq7KNPf3bTF/ZFsHNNKasH0JQxWPdheOoObHd9zHM4UmDHWhHFUVz9KP2E80B/GaTWpyPfvUH71+SBxNaZALRAlxFY3jB40pp4DjwCCWEA== Received: from CH2PR10CA0007.namprd10.prod.outlook.com (2603:10b6:610:4c::17) by SA0PR12MB4352.namprd12.prod.outlook.com (2603:10b6:806:9c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:01:44 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:4c:cafe::b6) by CH2PR10CA0007.outlook.office365.com (2603:10b6:610:4c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:01:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:01:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:14 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:08 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 02/11] vxlan: vxlan_rcv() callees: Move clearing of unparsed flags out Date: Mon, 18 Nov 2024 17:43:08 +0100 Message-ID: <52d8bb7103a070447c0403fac5c32b8a06c9acd8.1731941465.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD79:EE_|SA0PR12MB4352:EE_ X-MS-Office365-Filtering-Correlation-Id: 9634b75c-3144-4c3a-623d-08dd07ea4c37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: hEA9X0b0WFrj6fRlKXzehUXJBD5OLU0TP1qBWZ0j/iicUECN81+qU2efqrbIwemQDlV4Jfgu/TjSy95O3P7kEUBQnoYWXBEmXD3JTTyifyFg4CFGPAQZ1C3nYezFrlWdSt8E11nlygfU0c7cnmcvbcqhs5hzvTQPzMQkdwfmBHfoxQ+CPyy/4chFVhInZ3kiooiToARRtVEwRIBGUp8f2/Gnzk/RTWok6ljIXE0AM998ecf1SarSb3r/FTBHKP6rUX/DlPDVpimV9kWsmPivAtPDwna2ZUCOAYAUhVKbD/PBrgYCb+tDis9zxBG5IAK822LTaFFQ7GRGZK+Gu5V8qJhGx7bArFwBU3TCmBOF4asknK+bww1bGP4I2gVwBIg+ktBZZ3Eva0QgQjitK3eZiWpTOF5++QS6IEdjZ+lBmpISHXxuLuzuuS17SIcLyX4FZWJ9MFy+XZywqagEKVnztJ0rcglD25nJW1hFyRkzIk32kwBH64FM5oGRvSzyItYI94jHrYMY6q/cbS5Z8i0K3+KzpDjMaw1jQyOmoQY4QNeLermmUC2IOA/5dPh9y/MresH0Ljk1QnMkI0RLMnPYTc545xwYyyIPRBc781DnwFZYiFKgEAKgAbg4FESYYisXhmdYh5f6r/TDXOdSWp+kGHWWpILne+VxI1guCzsXhEPH8T+uAdh7RS8vI/yHH2Msc2FOkXMbMpuTZLubHalv6D5gqd//Tt2HPgWe6/ptbreFFrPrXoWre3GtIDUUdy7oRlZ0V7f75eXvbXwbIMHi0ptTh2PJi5Me/WBZe+4KbvUBqxZGfNwtpFv3jsGr2N7m1EqTluxN1YmzxTOX5yQ3LCq6iO3J325GuILDYmUCz9/QsEUfhwv4+qRdpuwoHDS8s16/WDKB7oMmn8wzVidNe041WyglaoO/VarT2Z6IE8syA890CwPjyO79ihajSkHGT0KJC0TNZ4DrxkJhrznT1I9AQjaWZ7c58V8ODnuShC1uWB8S+72qjrZ8pBVzAlgovU74Om3ydhb+hM3SoD3BuOQkYIKOv6fTWHmnmUWmJGqrrMXWgX7CsYJzZQMAfi/UEiXepr2iBGwKUxQ7Wj04bD0t5Vm07kkAoh0pSYGxSeZBD9PSIN5Oy7YCQUqE1yxyDHtYKjxB3hVCiqZBIGN7s8oGu/gqAZDnwVN+Su/L4FTSmbQj2xtHohQcsrWA01YJbh70GJz0P6qvX9FjXPcFpZAVNf8WgsMcc/h21ZtObYfaNTIENZYc2+Z5lFjEOCcPG/H3ogW9YXoO1BkPHIaZXGvGU7ToZrCiyFVS5xTBoxnRmzVe+/8X2DkvwPhpRlMUkhp64lX/kxfyd3VD+wZGOd7zrKhZqxXea+xsFFBsOzDLRmsqwC2Ldem2GkKfRp3nGQGHKFcMRhKptwY/C12l/w== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:01:43.7199 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9634b75c-3144-4c3a-623d-08dd07ea4c37 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4352 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In order to migrate away from the use of unparsed to detect invalid flags, move all the code that actually clears the flags from callees directly to vxlan_rcv(). Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 071d82a0e9f3..1095d0bb2bf9 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1562,7 +1562,7 @@ static enum skb_drop_reason vxlan_remcsum(struct vxlanhdr *unparsed, size_t start, offset; if (!(unparsed->vx_flags & VXLAN_HF_RCO) || skb->remcsum_offload) - goto out; + return SKB_NOT_DROPPED_YET; start = vxlan_rco_start(unparsed->vx_vni); offset = start + vxlan_rco_offset(unparsed->vx_vni); @@ -1573,10 +1573,6 @@ static enum skb_drop_reason vxlan_remcsum(struct vxlanhdr *unparsed, skb_remcsum_process(skb, (void *)(vxlan_hdr(skb) + 1), start, offset, !!(vxflags & VXLAN_F_REMCSUM_NOPARTIAL)); -out: - unparsed->vx_flags &= ~VXLAN_HF_RCO; - unparsed->vx_vni &= VXLAN_VNI_MASK; - return SKB_NOT_DROPPED_YET; } @@ -1588,7 +1584,7 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, struct metadata_dst *tun_dst; if (!(unparsed->vx_flags & VXLAN_HF_GBP)) - goto out; + return; md->gbp = ntohs(gbp->policy_id); @@ -1607,8 +1603,6 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, /* In flow-based mode, GBP is carried in dst_metadata */ if (!(vxflags & VXLAN_F_COLLECT_METADATA)) skb->mark = md->gbp; -out: - unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS; } static enum skb_drop_reason vxlan_set_mac(struct vxlan_dev *vxlan, @@ -1734,6 +1728,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) reason = vxlan_remcsum(&unparsed, skb, vxlan->cfg.flags); if (unlikely(reason)) goto drop; + unparsed.vx_flags &= ~VXLAN_HF_RCO; + unparsed.vx_vni &= VXLAN_VNI_MASK; } if (vxlan_collect_metadata(vs)) { @@ -1756,8 +1752,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) memset(md, 0, sizeof(*md)); } - if (vxlan->cfg.flags & VXLAN_F_GBP) + if (vxlan->cfg.flags & VXLAN_F_GBP) { vxlan_parse_gbp_hdr(&unparsed, skb, vxlan->cfg.flags, md); + unparsed.vx_flags &= ~VXLAN_GBP_USED_BITS; + } /* Note that GBP and GPE can never be active together. This is * ensured in vxlan_dev_configure. */ From patchwork Mon Nov 18 16:43:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878810 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2056.outbound.protection.outlook.com [40.107.223.56]) (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 4FF921B21BF for ; Mon, 18 Nov 2024 16:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945720; cv=fail; b=MURnAuz+RvEJpSC+3GrSdVGe1oRvPoortLtC/Or/RqT+rvPM9A8/2Nd1oMFXdc6FOZh9E4cTkbl8ETtLvcrQFAFQSqJU5dxA2SV94htD9O1h1+PEKKuQffv88vjzJi52POv1FpmLaD3KsXs8uy+N/eOnQTUM+oThsKAPLxnXtHw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945720; c=relaxed/simple; bh=h70njbfsfbU3z6wmfeazJL9VONBruywQ0hUKZq3yrTI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kcrUpQhWebwVRSfZ2/nBo5PRzn8RFEQ5oA4b1Bbis6pH4uJpDjUuV8q6OAEqCC+VaVx9dEvpUtnxsTaF9BGxee87raSfj5eLbXGzg6FiTq8+YmO4k7axfPQlMc0Z7VbkfTRyTxJlqMyU9dV/nwkrmHi+HUfNbwuRswzgedrI9gs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=j7mEA9BI; arc=fail smtp.client-ip=40.107.223.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="j7mEA9BI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OAHuYuOU5TzDTYEnrP0DEgpQ7GZwMnO1DkjPGD4T/xWt30tmF0+Jlp5maCEEpH5AwacJxVLMgm2kuve/eefLCVFZTLgNf+/EYTmGA/TMMI0yQB1SPUC+6XqX26xI4bmUVpeR926tm68UkyVGOOH2sKDaW591fe1zXJE3Y1kPbd/n5GcHP5f6RGlpA6XLWiyUDnhxriTExpMnzGyH2pEW/UWOxpKsvvdZT6QoA5qLpGFvYMUdDEYZnhlytd4RMnDpjW10GITpk9GrrWCHZTYm1TNGuPyddgUlpBzR+kbnFwnC3oC5lSPqOLJKxpoi1UVjdcjXGXQXtXDyfQC4t7TyOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HQsqCrrDzPw7D26r9pB4xSObMzjNa0IJwvr1QTHxFlc=; b=ArU3hXq1rdCrsuNuNlxLV9Ivs1YppbkwPw5motnt3L2+ajYbFZhOXLZxrkf3ivav197xjCtjTkH1qZV8jZ70DPu++uVeGMcw36vs7eo5HTsFOdb9qT8qtnB51i/+6pbuj3BMG5fjWf1nD/xuvQbG9rTXg9vGOVSXxiUq8FaCzObpS9R+92rG+smkHuVFNt+VBRFwfdgdHvfDuAjklwanvclEBakgL9ZR+hhRsILKE1YG7spOlguCf7MOwG22O4o00vO53vErqsHk5NAQSN+zNXuFMUT1yV9aOASR6PXfYO57q0AuqRmM8bdpe0J23uNA8V+95uaRIrztbOAVOshaTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HQsqCrrDzPw7D26r9pB4xSObMzjNa0IJwvr1QTHxFlc=; b=j7mEA9BI7EaAgRiVdjVNy+mDXnKUk90RuHAe1GZxn8cI/KFRtGU6I6Hir97hgTQiL+9JmOibwrOpTYnBprkpdIyfKnFQr8mWendWswqvkJAXKp89RlZkbSFuUdsWmXr08Jpwr0AHhFt0bu55r5hxPIM+blP6bAESqsCF0w1NgZkTzX0FPKHhKvsaAFGAVqBfEYHPTgx1D1DwXNxSLeXW1vAO7lC6NmxHbCIGdqSqpfsiD1OSwX5AFayl2VhVPEaN+eq4fNt4r1+Ilu7dbsaEZ3Dj1Z5f5Ct5FXJiOz+C4axS5/kJziIdndOs/L/cNhFnZX5KkjcJF4x8QdrcLnE13w== Received: from CH2PR10CA0015.namprd10.prod.outlook.com (2603:10b6:610:4c::25) by MN0PR12MB6270.namprd12.prod.outlook.com (2603:10b6:208:3c2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:01:51 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:4c:cafe::56) by CH2PR10CA0015.outlook.office365.com (2603:10b6:610:4c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Mon, 18 Nov 2024 16:01:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:01:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:20 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:14 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 03/11] vxlan: vxlan_rcv() callees: Drop the unparsed argument Date: Mon, 18 Nov 2024 17:43:09 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD79:EE_|MN0PR12MB6270:EE_ X-MS-Office365-Filtering-Correlation-Id: ffb8f202-3122-4113-de07-08dd07ea50a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: tdiuUs+W96p38F/3ENgicb2LFSY0RzOWgEvFgFJlgGqz4ujpl25DppDclvdAwh21mexvS0cAhmceXoe7IqxFhpFfHx5bMLLnTXLuIfd1wDEGaokcgmJu2CHS+I4/cPVrFLng349k8BJ9JamRKDqZJeAgTSpuAkT3bnqU0sOF0LxOfYpvBuDifJ44ad4BOYKwPeFpMdOk0U1iUz6LtYxgcaaA03bozU5hdVKiuDkqsBMNCu6ImQukzcf11PY6tEGZpr8ZHPtc637HZ+wu3ksCfi7uLZNFnI1TkkA3Pq9ulSFBzVdfGIOxpe84boc0nHcWeuugtw/ktMHsy++OAZoVrQAVLd4TcdoHVhZEH1E5GXlCK6MZ55dMXWA2CT4eTK8rqEoXVvGgKYQRMBZMRQiefqYif9Cn4k6py2a7ZjJDMx0oH1wm1KqaUq6GiNRFhfyc3deSZDw2PTl14FkU6A0AHMVHkNiL8tjkAupjs2CEStJmOSZyD6RIkkjbvPHhtSdfAkUc4srB6C1o/bMrvfak2hMaR4tJQQqkBC+WkoonENxWZq/ZavJj1N0KcxQV1ws+Mk0C3YgO+HqbUIY1ANDoY0Oy72Y6IEHDLXJsSfZjyNX8EKVI26sRtYqmwI+ZCxbCJqlYSZp/6gUlbdjmeXjurE5nlKajhwdvyRiVt4QsZhYpwzYJ+SkP/RGIT+9/QRie6dFTg3o7gLvlLZIW+mco+q7BY3HRvDIsqobjHAi8rLsulAGod6njv7McBfb24agdMJmL7T9mALir9ogKLzeD/ouQy0yCOp+XeOIFLiR3noYHEh7kMebbMrQcbFooCKnnVy3oq9XtbrkvRdCQ5dC/jncT3mMirSXhcOeyrCjVF4hOlRC8Mila09iOY8Cz27aBrSWy4IPE3E7Ka6ZZslytIsGAzWAPdZNdFIA35TOLbx7WaU/6ddkFPpaEYMsujBih+//AQMPVDXIsztXinfV6D9nbsu+snHGP1C5UXJ59T5xad2jthgZEesmiBrvZE66JJRTJVEXG2WmQYE+BijlOK8/EKtcTUMy1GfAYqTcIPeKqFhUHO0hDJtwM+iZC616+9246UvglEWtsOodCWLPR/36w/5qhrbEDv6InpV5Q0iijT8kGcitThPbG4R1YxY5yQVbDE7XF0R3n/mkVbAyasDVxrB+Vp1S/MSPsd4HlD7x62IlEUmBCX0IXWEOIF6XcQEc7/aRw2hxSP/xPPI1hIAmdKg/T7Sb/Crr3WH2ziETAm4nsq8V4O+Kv1qj2kv97Arx++pn70adouPvxh0EfxrD+bupCzXujsInZUVau45LpF3Gau60470KIheBusMMthUojR3b8sSymedC8ubQB5tbMq3AJFCU1+dz+8iaXarZoYSNcCyDPzfujlf0tDWywUtlHdVmOW6jYkvfEYlE+Aw== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:01:51.2042 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ffb8f202-3122-4113-de07-08dd07ea50a3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6270 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The functions vxlan_remcsum() and vxlan_parse_gbp_hdr() take both the SKB and the unparsed VXLAN header. Now that unparsed adjustment is handled directly by vxlan_rcv(), drop this argument, and have the function derive it from the SKB on its own. vxlan_parse_gpe_proto() does not take SKB, so keep the header parameter. However const it so that it's clear that the intention is that it does not get changed. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 1095d0bb2bf9..835dbe8d6ec0 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -622,9 +622,9 @@ static int vxlan_fdb_append(struct vxlan_fdb *f, return 1; } -static bool vxlan_parse_gpe_proto(struct vxlanhdr *hdr, __be16 *protocol) +static bool vxlan_parse_gpe_proto(const struct vxlanhdr *hdr, __be16 *protocol) { - struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)hdr; + const struct vxlanhdr_gpe *gpe = (const struct vxlanhdr_gpe *)hdr; /* Need to have Next Protocol set for interfaces in GPE mode. */ if (!gpe->np_applied) @@ -1554,18 +1554,17 @@ static void vxlan_sock_release(struct vxlan_dev *vxlan) #endif } -static enum skb_drop_reason vxlan_remcsum(struct vxlanhdr *unparsed, - struct sk_buff *skb, - u32 vxflags) +static enum skb_drop_reason vxlan_remcsum(struct sk_buff *skb, u32 vxflags) { + const struct vxlanhdr *vh = vxlan_hdr(skb); enum skb_drop_reason reason; size_t start, offset; - if (!(unparsed->vx_flags & VXLAN_HF_RCO) || skb->remcsum_offload) + if (!(vh->vx_flags & VXLAN_HF_RCO) || skb->remcsum_offload) return SKB_NOT_DROPPED_YET; - start = vxlan_rco_start(unparsed->vx_vni); - offset = start + vxlan_rco_offset(unparsed->vx_vni); + start = vxlan_rco_start(vh->vx_vni); + offset = start + vxlan_rco_offset(vh->vx_vni); reason = pskb_may_pull_reason(skb, offset + sizeof(u16)); if (reason) @@ -1576,14 +1575,16 @@ static enum skb_drop_reason vxlan_remcsum(struct vxlanhdr *unparsed, return SKB_NOT_DROPPED_YET; } -static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, - struct sk_buff *skb, u32 vxflags, +static void vxlan_parse_gbp_hdr(struct sk_buff *skb, u32 vxflags, struct vxlan_metadata *md) { - struct vxlanhdr_gbp *gbp = (struct vxlanhdr_gbp *)unparsed; + const struct vxlanhdr *vh = vxlan_hdr(skb); + const struct vxlanhdr_gbp *gbp; struct metadata_dst *tun_dst; - if (!(unparsed->vx_flags & VXLAN_HF_GBP)) + gbp = (const struct vxlanhdr_gbp *)vh; + + if (!(vh->vx_flags & VXLAN_HF_GBP)) return; md->gbp = ntohs(gbp->policy_id); @@ -1712,7 +1713,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) * used by VXLAN extensions if explicitly requested. */ if (vxlan->cfg.flags & VXLAN_F_GPE) { - if (!vxlan_parse_gpe_proto(&unparsed, &protocol)) + if (!vxlan_parse_gpe_proto(vxlan_hdr(skb), &protocol)) goto drop; unparsed.vx_flags &= ~VXLAN_GPE_USED_BITS; raw_proto = true; @@ -1725,7 +1726,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) } if (vxlan->cfg.flags & VXLAN_F_REMCSUM_RX) { - reason = vxlan_remcsum(&unparsed, skb, vxlan->cfg.flags); + reason = vxlan_remcsum(skb, vxlan->cfg.flags); if (unlikely(reason)) goto drop; unparsed.vx_flags &= ~VXLAN_HF_RCO; @@ -1753,7 +1754,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) } if (vxlan->cfg.flags & VXLAN_F_GBP) { - vxlan_parse_gbp_hdr(&unparsed, skb, vxlan->cfg.flags, md); + vxlan_parse_gbp_hdr(skb, vxlan->cfg.flags, md); unparsed.vx_flags &= ~VXLAN_GBP_USED_BITS; } /* Note that GBP and GPE can never be active together. This is From patchwork Mon Nov 18 16:43:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878812 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2059.outbound.protection.outlook.com [40.107.94.59]) (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 A00A91AF0A0 for ; Mon, 18 Nov 2024 16:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945730; cv=fail; b=fdzfikAoZOlAhu8zUxuIIM1Yi84UuhLc2zj78bhcL/6BxJ5cWxIeRY+Ouu7OBE0wiP8gtineXW3BQo8EqjDYev1kiC928WHyeKQAaeHsex7PC3VCmMhRgQK4mcGQ/dTUQXX7/9AuEXf94cjLHCARUUO75sQ3s3dLFcOYCPN4zME= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945730; c=relaxed/simple; bh=n0R6ny29ZLCyfiaHx7UDOoD9mhDKecWoBAvNTcEZqBU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cjn+EU6GXYNb7kcS89pOckyB85Fun3so8fyRMb1UzMNJK2q0G6gvVac7z2aPL9LI6rTBJrCDlPD26mS405p7oBwf4sNP+5vIlPGnqo7onGQODY1ZyNbmx9mukseGXEOYYc5FIGd/PkJGVJDceI4RdWVbv5ZhxJMgjDA76jxSV+Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=meY4WFos; arc=fail smtp.client-ip=40.107.94.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="meY4WFos" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HWvtpx6svDFO8jm80QHOHaMMvOaqVjV0ST7spO8vDHlIijBI+US3Sxr/HKdFfpNui+i06gDKNGzSo8ELBYj4Y2vxwSV7wKDCeRk352nRY2scxys4cY+YTZ5deZW1vU8je8kWINDx8aUTHDNcgGecIup1F+NM7GfP6LH8z7F9K4DPCOnikayJR+2NA4B7ZxF6FnXVCBFFGQdL3DxuN132sH9eyGtqeNFHhiv8D0IMlmM4HnX0rUGDCa3ShhtDZDMA18JmyoQ96oJ2ytCGnv8JZeBavvGXg3fc9pS7vtryXHHc2QZniVSK01ZUifLNUDvGmEriKFEWdkmIFr/qe1wodQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wIHi01/Z+YtIIm7cT62DBMYhYScRuMQ5r6lCsqLvdPA=; b=bzq8A1UavoNrd4TQnrttMEa9HNwLHX5vD25FuXUSImuBx/sDyNBygeFJfMyigEY8iWyJvjaL269mutsZyurK9cXllmEdSkALn9902JPqzUMRHoaoWVqcZcLvJi0xzwIuavWwYGG9lHEFrBkntL7oJEogIjYb8J5ooBzKFHqWkdg7w/h+YZbPBgenyPAVyUg1s5A/IVHKnW3g/MBYT+yNQ8pYzfogdxXCyQ4qPD8HJr3WEgOlKdUQWrEaWdCRc5CAZhrr+0PXZNnTn5/1k2FTqv0PFXdv32aYvNQubw50Lizqgp4R3PuJoxgJ0e8hVeJhrtYCslM3Ko0yjD0MlqU9Zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wIHi01/Z+YtIIm7cT62DBMYhYScRuMQ5r6lCsqLvdPA=; b=meY4WFosWvaxLcCFjXleqJA159tcdsyVcFKvySqvV5qGN1ckp8eNJKsN5lf78mYI/fT43Mag4wcO4S8BileO3B2cVBh7gUEYkW0r4DPnHnwPGbC1GuMOY9InszM5wXi4CsqX+EXDvWB1s/iQDRQ4fzCwgc8bHenA+DmwJHms11WDaS7I3XwJdRFBa/i3UvafRyPCOVxrtab7TdrwDTo76E7YXhnXmfihcAffxPbJ++lMNqrssRkbp/Y/84GGciC5XJt4XF43SQ6hjEOequA/wLKEfm9ga2N2NGP0767ltuL/SncpYEG3VrpGIZw2We4d9SjgqlCDVIEJSqWVtL+Sww== Received: from PH7P221CA0034.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:33c::11) by IA1PR12MB6089.namprd12.prod.outlook.com (2603:10b6:208:3ef::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20; Mon, 18 Nov 2024 16:01:55 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:510:33c:cafe::6c) by PH7P221CA0034.outlook.office365.com (2603:10b6:510:33c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Mon, 18 Nov 2024 16:01:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:01:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:27 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:21 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 04/11] vxlan: vxlan_rcv(): Extract vxlan_hdr(skb) to a named variable Date: Mon, 18 Nov 2024 17:43:10 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD1:EE_|IA1PR12MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: e2b7a089-9958-464d-344f-08dd07ea5213 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: audaivTAEvOw2gZNDLT7x/aHy2gLAawGauqWiHUbh0CL4vGn1bFFXBZFCxL9CwKjGGSRE4/ZfPQZXEl/euVc2G5ax5wz+in+FZ54QYCOMutLM9eG9ZMoOGEqkTu5AatsR/fj6N8hyX1lF6rp2+3KImq6Y2OV/+/y8x8Yc/NRSE4106ypd0RhMisylBTPoLao31+/ewdSgueYwQxs/mvb+8btazFY6yVvo0kVzu801Jn5WM1W9AUeWQlnBzCj+uREkzHeW4vcgDrrbMZV0BlMQbX+LEGksN0mPNcNpSz9HvCLoPVZzQO6ycs3lhfQbNE3VDuSaHtHzoa0IHe6xmCPr3/Wd+Xuyr7HC8fWRZkONfohgMAAokRdQJnOycxa8VjeElQJeNnM+TNnzx/POQ2nePCfSZm6rwkNRMvIKIGd5kwNaNOCLixhkT53r6y5kRQV+fzVDZSSscQ/8xFWml88j+miucAqMrhzAKvVdkgIUTlWJMC2diPRn0wu8di407jEoc01+GM6WbvqQgWOLiFti5/xUY+TPy4TFstHqc67IZXCf/z9/odo77n+z7ljyUCXUEjJ/9Xae6M0gLb6Mo2lB61Az00aJs/5Jo3QQ35Yt4VGpanUhWDj+q8KXXlSdxh0vf+f2T3EvbOdh9+ZCJqcGp3NWGtNCw+rj1BTXBeNjRYZG/vrqAGUsAs50DT+sLvRiPX2cktqDUvIhy7TDsXF8VBKsKHoHjdxqswQvjm7rmwQSp1oeRwgwsyogQg5L+HzyD601FLMIEjnPJ5HwonmZRIKupkq2gowIH4GQC/NurEhUoo2SzhYFs7i0MiUsThoJyD6T8rGES1yXoG+PNcci3ThNtqN9uUNvTcYg39YYwjSSgqpazbjNv6jNJZBUOXnWqpM6D2mN1gKaAiEt1BOyy6+bdTxGGH4tiCwtG3sy8GiJBh7w/9/1o++vxr4wge11hwraJo+5BQe9ROiBrgF/2NudfSjxw9j8CqPW+TYYOfu0X4ekpI/O1lu4IFjv4m+X3uEP8W5dhBOEPD/8B6jJ7X1vrd1zPu0aBq028pT/W+UTdfG46NowpInIigbqRRKu+HlOnWSYvLG7spX2Qb+CnVnz/XW0jfFd5ouc3CLpk/LtDwWb1LTZ32pvnq0U/2J8vcY/6HgRk0amqz9rAWz/J0U7I8ByTq6Q0KHAiFTMTYZC8tj4Y2kwD25Bb+8zbB4vUMOBlkgG7ToUNKYVM7c7fttrmG40xS9d3+aoEZoVtyqkwVHs7SSvsmlPeFTKuF2+2LLDizeIYpjTZ7kCnD3n6ou5rbCt/3zN7FW+7E8YEGAWyOmy5mzuacD8G3wicLz/g0CWtCHfL+Nm2TakzjDZkLdXA6Dw1BDMrQ+OQ+eoz/qEL3WaRh1ZMghAKjbkIZkhjLzztBNAqdXe1h9DUgrPQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:01:53.5960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2b7a089-9958-464d-344f-08dd07ea5213 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6089 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Having a named reference to the VXLAN header is more handy than having to conjure it anew through vevery xlan_hdr() on use. Add a new variable and convert several open-coded sites. Additionally, convert one "unparsed" use to the new variable as well. Thus the only "unparsed" uses that remain are the flag-clearing and the header validity check at the end. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 835dbe8d6ec0..95d6b438cb7a 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1667,6 +1667,7 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph, static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) { struct vxlan_vni_node *vninode = NULL; + const struct vxlanhdr *vh; struct vxlan_dev *vxlan; struct vxlan_sock *vs; struct vxlanhdr unparsed; @@ -1685,11 +1686,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) goto drop; unparsed = *vxlan_hdr(skb); + vh = vxlan_hdr(skb); /* VNI flag always required to be set */ - if (!(unparsed.vx_flags & VXLAN_HF_VNI)) { + if (!(vh->vx_flags & VXLAN_HF_VNI)) { netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n", - ntohl(vxlan_hdr(skb)->vx_flags), - ntohl(vxlan_hdr(skb)->vx_vni)); + ntohl(vh->vx_flags), ntohl(vh->vx_vni)); reason = SKB_DROP_REASON_VXLAN_INVALID_HDR; /* Return non vxlan pkt */ goto drop; @@ -1701,7 +1702,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) if (!vs) goto drop; - vni = vxlan_vni(vxlan_hdr(skb)->vx_vni); + vni = vxlan_vni(vh->vx_vni); vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex, vni, &vninode); if (!vxlan) { @@ -1713,7 +1714,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) * used by VXLAN extensions if explicitly requested. */ if (vxlan->cfg.flags & VXLAN_F_GPE) { - if (!vxlan_parse_gpe_proto(vxlan_hdr(skb), &protocol)) + if (!vxlan_parse_gpe_proto(vh, &protocol)) goto drop; unparsed.vx_flags &= ~VXLAN_GPE_USED_BITS; raw_proto = true; From patchwork Mon Nov 18 16:43:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878813 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.88]) (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 2BE2F1BC066 for ; Mon, 18 Nov 2024 16:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945730; cv=fail; b=cBxnH7XFuLt4j5CZb8BF9SpBX9p6vGy0n0rT5UiA6QB/d1CMOQK2sEdcPQtA+tijEmKuFXUHga3YBrcFnIT4J0nHOd0q+7rcjreHplj8TwPBvpylkiz5o44gI66vX8Hh0S8dHMWG4gpiq/ZcUs3ZUzcDqLkOcFW+V0U2cMMM/wA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945730; c=relaxed/simple; bh=2hnXyh3K1cmsarmkOXR9hUbg8TjY/2S+QETD6EZymkE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ph9SCFOJjCFuARNKwXTPHnt+1CrUduhcAilkUQ23/m8hAnZDqwLUltMcQWLYiRHBwpuW12LJQHhDOur9JM42EqIrnNUgwutNL1ESUwZN42zphXAK7lTLutoou8CFkILkoNjjOp/8MmDxu0bW0Jgr23IUIfCQTLQmLCyLuDxCW/s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=V0k8MckE; arc=fail smtp.client-ip=40.107.244.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="V0k8MckE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kWhA18z9bIPJ0FGJBZEaa83hTjOZiKwNJW7GRh7UwFIcPOcCSsgvdH7Rm2gW6SBDsSV2c12uBKXpELr2XpFhr/LU3s7lY4iO5FhouDN7PluD7VIIzLWHZdjntO8jvMmDOGDTTOsPC5BMfnbuGr7qndWVBYQ9/ahk9EW3qBfiuUVfYSrRV4jNmCJlbEFsgiSz31ErjlxsLB/4NKCWUE9GLUuZ6GEOdOHB1wg9aoQQiuD2ixvI7f/uEeIcD10plwjFy8BM8r00p6OSr56FtrEnX1ToqhGm7uNHVrgqKuQtuNqsCXozjWqRE2Z1EMTjw2+mvp//U3LlN8bLB47iRXK4cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ajpJazY/JHq7XMCujwZjg9t0iRJ5gk94BgNuGapVCC8=; b=yCqVfQQRGZfKKtFwVMr+QA38faGCn8ZNHFms3pr/OsgHKK3XxTZUaQmdO02ND3tLr5N+JzISnLzBP3pErzVLT6SXdMpz4K1pQlbKyQHrrBFdCY4plZoTt1vu9vTM4obXtSSQ7gm519mkn10Ju6RfuZDMc5GiLDwbvDn/Y6gT4DBu7aMaurtcyZ6K0nXYJYEhqO2goXOelccAp77kXt498BCboCW0G04Kxud5jBBRxZ9Z/eA0AVqxD2lwgWy8n/38mO0O+1+JQ4FTYnQfMTKn9WUe5GoCZqM3AxDfdX5g1iy0C+ILarAjJcH1hJ2BoePXa0oSkK82m8thLwoJr5/WNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ajpJazY/JHq7XMCujwZjg9t0iRJ5gk94BgNuGapVCC8=; b=V0k8MckErBv9nZSbau1pWq8BDO0UU32iH3/DEUBoovXbOd6g3SyqRMqAFmxbCaOTRGiQzkt1SSgleg77+OmSYj5juY5xyxCcAr7OWL66oOljGxV9qLtFLFlWARd03X7+9H6qZ/MVnPH2XQRj6XOOfEn5PQj8GDUE+3sMQz64Gl7h+LlRpvmBF9f4OEEFjACawDlefAD3G3g7SIku7+ALa3vHMaxkDYV8374c9eFBSZaTM2Vg+28013XM1JspfG3WBV07vKwTDs61Y4xMlLRYdx+XXLy9J5KVuUPczAz5DiJUDOOGKt68YBsu3OkEN9bK460vMjPJg9L9NOcMKiarig== Received: from CH2PR15CA0020.namprd15.prod.outlook.com (2603:10b6:610:51::30) by SA3PR12MB8763.namprd12.prod.outlook.com (2603:10b6:806:312::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:02:00 +0000 Received: from CH1PEPF0000AD74.namprd04.prod.outlook.com (2603:10b6:610:51:cafe::f2) by CH2PR15CA0020.outlook.office365.com (2603:10b6:610:51::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Mon, 18 Nov 2024 16:02:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH1PEPF0000AD74.mail.protection.outlook.com (10.167.244.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:01:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:33 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:27 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 05/11] vxlan: Track reserved bits explicitly as part of the configuration Date: Mon, 18 Nov 2024 17:43:11 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD74:EE_|SA3PR12MB8763:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e6d57ee-c000-4d03-6958-08dd07ea55d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: z2eSGsiKVltvRnZn9qOeL/7jA0AaVBsFAGg5crU1yO+yOuuurfDyrUkbmRprN+txBbYToocuQsCC5y+2YT7XHGJSzgCr/kkxqbFcpwn5c3hcfLHassJJBGZog72WgH9+5Pnt66US/Ca0PSe7XrEXaBpVMePhdpN6I0ePvhfV8medx5GDD/Y6OdAq303s/AqomnS0rwimwfJ+z+qIDcukvOV7VEIgJbU0Oc5iKRDVWOsbPE9dg+MNBSbwOaQzyL+6HXXGzbZuCdTutRSKSbJe/16/hEN1oTstAzkT3fuEULA+OYhs9fZHFB8PbdMnjMkTjf46KdsETY6QhZy+2pmLFbG6ZrXGk6gO7v3RUCYQsjFZyCdlG2H0mOmCie20lyfm/BLbbb0GTDaNfmJt7+dpFaafgsSg8z17dUgzS8cgA4YE4DJhZtikscSEFDp/l+d6AaSjdezdwKS6EIBBkWZWl7IDXaao+UXl1LtTjnikCSm5ZwCu5vHPr5o1hVrPomoQGHgL6IjEJRIZMz1YV65AyMFDn+Yogzf7644YRpwCuRNzBz0OAdcy9ndO8WKwlxwj6WxIOXlWX2XkHfcQb9zlhT+INeX+KyuZlKqtz28Zccnf3CvCuFNjXwZz2vwvc/t72l26WGLTHRecDKAsZE8Kyl344iEai5OlYGXIj4Ni4zpgZWmylACSEWmFQI3NuB+thVo1B9yPA67bgtvNNH2RFZkx5rmpMdN+XqNlzFQxCNSTG3l4XL3l3gER01H6/MAda0tv8C1DrnvEjXrvvVYNtsD5Xo0rg3G1HTw8JZPl2UYGcoTAm6Bc+i5GfOU6sjAbBIWOcQ2izgLLvomgo4an7dompPpzoQGZm824tCdRYhlGEp93NMrpo30ZtywWNa734TGYq/IVhhymQARoPoOFsS8wTZNpxuaC0c8LkmANRQzM8oZTBDq0G9JeZwCMHLbWpI+Noh8dTqmGvjSKYTHW5TFkQ373dl2vmbVJ04TtwNfd5EKPmoGVC+fQrWf67PBVINCWvF0F1asj39PkQprzPB/r3X+jgBGuZQzKnY5TcHYi93hiWgq/x4mzq8hrB6+woIzbKLz4In1mnoKi2WmfFRKP+Dd68zufE8BGEn/Q03RrCt2FsLsN39MQl81aX5aLdCLPQVSTZEUGvh0GJ2bQndlNSGzsCU4gqRV9W211PSzsCPvEuQ1J/KM3wu2C4XM1pn8tnWjPVi3l8gbjlSADcf/CNhizYRyVNzyBlQ+ttPn4xW3Q0tv/F2DZJ0+9syxXGdi9uYQLgbpPrK3e7UYQpY+h9FL1t+O59EtnTtRE4gKY/SevBL1FHO2tAAEGxdnChR49kelodL4fK93qrtkJy57APs4wn7WTD1FGg/F140SHKzKi1EAoabkgTmuX+Rtv6fLXuy4lnSgL4cNihx6ArQ== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:01:59.8691 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e6d57ee-c000-4d03-6958-08dd07ea55d0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD74.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8763 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In order to make it possible to configure which bits in VXLAN header should be considered reserved, introduce afield new vxlan_config::reserved_bits. Have it cover the whole header, except for the VNI-present bit and the bits for VNI itself, and have individual enabled features clear more bits off reserved_bits. (This is expressed as first constructing a used_bits set, and then inverting it to get the reserved_bits. The set of used_bits will be useful on its own for validation of user-set reserved_bits in a following patch.) The patch also moves a comment relevant to the validation from the unparsed validation site up to the new site. Logically this patch should add the new comment, and a later patch that removes the unparsed bits would remove the old comment. But keeping both legs in the same patch is better from the history spelunking point of view. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 41 +++++++++++++++++++++++++--------- include/net/vxlan.h | 1 + 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 95d6b438cb7a..d3d5dfab5f5b 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1710,9 +1710,20 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) goto drop; } - /* For backwards compatibility, only allow reserved fields to be - * used by VXLAN extensions if explicitly requested. - */ + if (vh->vx_flags & vxlan->cfg.reserved_bits.vx_flags || + vh->vx_vni & vxlan->cfg.reserved_bits.vx_vni) { + /* If the header uses bits besides those enabled by the + * netdevice configuration, treat this as a malformed packet. + * This behavior diverges from VXLAN RFC (RFC7348) which + * stipulates that bits in reserved in reserved fields are to be + * ignored. The approach here maintains compatibility with + * previous stack code, and also is more robust and provides a + * little more security in adding extensions to VXLAN. + */ + reason = SKB_DROP_REASON_VXLAN_INVALID_HDR; + goto drop; + } + if (vxlan->cfg.flags & VXLAN_F_GPE) { if (!vxlan_parse_gpe_proto(vh, &protocol)) goto drop; @@ -1763,14 +1774,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) */ if (unparsed.vx_flags || unparsed.vx_vni) { - /* If there are any unprocessed flags remaining treat - * this as a malformed packet. This behavior diverges from - * VXLAN RFC (RFC7348) which stipulates that bits in reserved - * in reserved fields are to be ignored. The approach here - * maintains compatibility with previous stack code, and also - * is more robust and provides a little more security in - * adding extensions to VXLAN. - */ reason = SKB_DROP_REASON_VXLAN_INVALID_HDR; goto drop; } @@ -4070,6 +4073,10 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], struct net_device *dev, struct vxlan_config *conf, bool changelink, struct netlink_ext_ack *extack) { + struct vxlanhdr used_bits = { + .vx_flags = VXLAN_HF_VNI, + .vx_vni = VXLAN_VNI_MASK, + }; struct vxlan_dev *vxlan = netdev_priv(dev); int err = 0; @@ -4296,6 +4303,8 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], extack); if (err) return err; + used_bits.vx_flags |= VXLAN_HF_RCO; + used_bits.vx_vni |= ~VXLAN_VNI_MASK; } if (data[IFLA_VXLAN_GBP]) { @@ -4303,6 +4312,7 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], VXLAN_F_GBP, changelink, false, extack); if (err) return err; + used_bits.vx_flags |= VXLAN_GBP_USED_BITS; } if (data[IFLA_VXLAN_GPE]) { @@ -4311,8 +4321,17 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], extack); if (err) return err; + + used_bits.vx_flags |= VXLAN_GPE_USED_BITS; } + /* For backwards compatibility, only allow reserved fields to be + * used by VXLAN extensions if explicitly requested. + */ + conf->reserved_bits = (struct vxlanhdr) { + .vx_flags = ~used_bits.vx_flags, + .vx_vni = ~used_bits.vx_vni, + }; if (data[IFLA_VXLAN_REMCSUM_NOPARTIAL]) { err = vxlan_nl2flag(conf, data, IFLA_VXLAN_REMCSUM_NOPARTIAL, VXLAN_F_REMCSUM_NOPARTIAL, changelink, diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 33ba6fc151cf..2dd23ee2bacd 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -227,6 +227,7 @@ struct vxlan_config { unsigned int addrmax; bool no_share; enum ifla_vxlan_df df; + struct vxlanhdr reserved_bits; }; enum { From patchwork Mon Nov 18 16:43:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878811 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2088.outbound.protection.outlook.com [40.107.237.88]) (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 CF27D1A9B3D for ; Mon, 18 Nov 2024 16:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945729; cv=fail; b=GdHc78CmW0tvK1+UQlrS2MCvSsdN5ZtR7J2NNu+kJN23cRb9Fos/lJECRKtcFlGq2yODWss8AsgrHSBLSLuiKcS2TZU+5Po4jWaQR7FallK0A/QPkr32Qx8sRvp1kl/0Gprdm08OrBP2Txb7qYmfz9mYRmUa0BUU1B3r+A15TMQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945729; c=relaxed/simple; bh=HDMoNnZ6FhtSsVM0KrqivYsjyvMafx/CKgEy4FGjMzU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sDIpEWTaNAQWOg1uBnvmM63fEyc23N3Tecw844OtzA9oMh9OqBpudV2ToDQ46/WzTpBjkAHFT6vnCUAsYzH3qV2frXGeR98ev6lMQ/ugdhh3EAvperV73xzEZ3eIHQL1WC/iohn13juW45C7q0U9DExfQU5p8hrzvY3aCTEoNP4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=q3Sac94T; arc=fail smtp.client-ip=40.107.237.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="q3Sac94T" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HwS8dEesz0jhu/WHWq/LHT5pz4Lox0OL0dGIw9V1X5NqLP2yCLJ0jAOqBFGPLNr1KJEbIT4mvkKkCj/b5yvug0Ayav2+kZjRSV2QcyHvYSkjmBjL/kExkXZJrV+32FDsYOXrn29vM/A1GV1udfLeUneUNSF/xhhXIsJ6AqE9fYzLTGk3OKnlbTXCqeMAeZCTe8sKfb+EtBXAJia/f+ukVjoiU0e6Yt0U+ku5f+c3iJx+mumR6FB/4W7ua0UKuEk5fE/gEUD3FTcW+Y9DUWCmh74uO+UtgGa8Sh2bVM/mmqVHZUIpHH+W+aSjsn3l38z/+41/m2HJBNuypDjj9POF/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LoiKy0CQ6uGThGpMRKVTIpVebOI9aXMKGCcT4EYGorw=; b=YIMcTCA5WbrZPXiRrxsKXiZgSz3LvHxqDx3czx9OBI+c7OgW+ux13rXar8llHEGCwG6rmP+UEvQZ6vNdJrAgNQewAKvZgNUgFRc1RStF5DyYCLBuRKWqtIN8IOgvXFWjrZv3fzgFlEb+SX7djpKTBjlSKjjSbfsiNhngJm7S2rB4B+P0cWVhaWcPY11i0bPDdGE2bc9dwLrxiKz+k3Z+p1muP05c4ZZybXfw3fYCh9Hoob4ItDmWaFno09pPLpa/PfSM3rl8roni7bQ/k6EIh3e2ItDaBXkghvXLxhxVgjbSQqBIkLsvZsXcHU1Pj1fUY+ClrnJL+6q+9rXmAQFO3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LoiKy0CQ6uGThGpMRKVTIpVebOI9aXMKGCcT4EYGorw=; b=q3Sac94TKm5cQHrda2c/2zvHk/4ARRFIquDQbR+sm4t3EVSGjGnDCjS1TbcOaj68q1ApaSxU8hU2zkfHEYyPwM/UtZLZBMNAdtLtWcNrm+OLMClIZGnkPpH7eyqmZSmGGZ6KwB9oW0j6VDCL2C+Xjm8u27of7TZwbqMN1emphZHvmFvLFfeljTzKv9pZPBefYVOpqPCOSpSdnmSq6EKQ5RlwlpCmEzSsfxGsjJjoINLsCaEXSXvX5mdQEUm2oG9EFu1AT9uWQ0bid6+amOtkT/o3o7UfrmMqNkSbz3saI89FCLpbbOB4w09xo7PR1YqwYpu1VTfjY8RA/CHKlJEOWQ== Received: from CH2PR10CA0015.namprd10.prod.outlook.com (2603:10b6:610:4c::25) by CH3PR12MB9145.namprd12.prod.outlook.com (2603:10b6:610:19b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Mon, 18 Nov 2024 16:02:03 +0000 Received: from CH1PEPF0000AD79.namprd04.prod.outlook.com (2603:10b6:610:4c:cafe::45) by CH2PR10CA0015.outlook.office365.com (2603:10b6:610:4c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Mon, 18 Nov 2024 16:02:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH1PEPF0000AD79.mail.protection.outlook.com (10.167.244.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:02:03 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:40 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:34 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 06/11] vxlan: Bump error counters for header mismatches Date: Mon, 18 Nov 2024 17:43:12 +0100 Message-ID: <03306b4ff6cdac1f42c3259a38d610eeb014ab03.1731941465.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD79:EE_|CH3PR12MB9145:EE_ X-MS-Office365-Filtering-Correlation-Id: dad3799c-f493-4000-7154-08dd07ea57f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: +vC29i9QYsYg0YlP5AgiqZ6UaZn0+c8EHi/4eaM2eCiMDg+2X9hmZPFceV/zp1EtSjnTAZ43Bzq5dS0ZlfPtcV32z5Hv0hR/lGYt3I3EJnmPcjl1fq7BROfebvD97ijW0/IVQqSH5Ew/GuKk8vk05IoHT4nkt9cbZk1tQLdMDBfckQ/P8lWH+RHr2wWHKpjk5eTBcRxSNq+pmkwdLYw8XIxRU52nxK+043k9O5NuK8kMj5j0Z1Hu7GG/WVMNQXtnlC5niJImQfzF6Yj/5MtZUo/qJKs3Xgoo9bJQGZFMs4hlpANBpQYlritX0j9XcuP3tPgWGxOdkVOWxZzuZ8Ulby0e1oNArOC2xhP3kMvEfQf3vZ8Mh9E2x6vhkFEDf/SzD5uwewPtPjYs8l9DZGxJgu9W0w4ANGXZn9lKD+TKIU0c+hqU5bVHc2Jg65Z7aiibpfCl8av9lMOD2hdRmXUjJVwEuv/Cqo2zclKfSLhTRLJVEsRbrvnyoLLWQC9J0VwLs6yfXGrhNPmJyDCyfdHXCfMqs3IfQICZDc/PM/R3vifTn70cUkmEQZLq64Vn+Pfvqg54Yp0DMtHVLPZW7SDVhC4Ma2lL72NzmlcB6nEVvPVIPM8DE+ZrQabyb2Acg23UqJbkkyZ7n6MX6nSRyoQe/dd1aFKfOIrKVq/YfucC6XroSwf3YKoPsw3mKJmcvx0S28YuaQCGh2QsOoJ3JAzi9web+tjzb2tGTOakug6S1S2lBnfB9z47JoL3mhrF/FP8GXL7+xG6v+nfHCm0tssLAKJ25Xjrp4tMsBZ+3aXApwZJc7qrfxzq18tUbWfRfl7gWb+COnn0WRaKYcfIk1VTLIc5Jv2/KwpQLFuZ8txO/l6m5+pySca4BHUDsHe8ALhq5ZHJ1EHdYhCKQy4kCWVDL+eF3BmM3/vCr/EsRzgNMapN8JPDkceLnq+kojS7NLC3Kg22Nl+zjDQ8lHoqqj8/5T1DpiSUMXTiw3418tbiJ1J0OaN0w5gWMNWJ+e730gLUsuBRE9IxN9cFKVxntWhc6pyFkU0TJ3YI5YvNI69Auh2lrfn1EC5t/by/kEPdEXWDFldyR1+rSnRJuJJFYW5oBe9sb2qxwzTqLqlNsyG9NO1i+diFy9SrQXUsetrmWdbaCPFgn8PmAYkTIO2Vp06reRmlORELlqt4E45OFHFiPu+IlZaSt3aqv3vBmvM8Yui0EsVq6ZfoIvGB9+aDmOekEI99KgTHpfSjpA9nkEY0M40s5V7y/RfQ91LJHxEFdD0UqFG/q2bX8/l2i1nRGrz0bNf/rghVdFkJRuOqxQsuCvrJgfRrPiK3nP1O6Uf1myIoGkT3sHzEkY9ed5BtlXsrzMrv3pL2OLkKQTfMrQ+/wKPxgHl9M3BGu1moSexmpgyXHZ5wYVaFEFNNio0i8MEjuA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:02:03.4229 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dad3799c-f493-4000-7154-08dd07ea57f3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD79.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9145 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The VXLAN driver so far has not increased the error counters for packets that set reserved bits. Iso t does for other packet errors, so do it for this case as well. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index d3d5dfab5f5b..090cfd048df9 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1721,6 +1721,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) * little more security in adding extensions to VXLAN. */ reason = SKB_DROP_REASON_VXLAN_INVALID_HDR; + DEV_STATS_INC(vxlan->dev, rx_frame_errors); + DEV_STATS_INC(vxlan->dev, rx_errors); + vxlan_vnifilter_count(vxlan, vni, vninode, + VXLAN_VNI_STATS_RX_ERRORS, 0); goto drop; } From patchwork Mon Nov 18 16:43:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878814 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) (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 93E201BD4E2 for ; Mon, 18 Nov 2024 16:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945732; cv=fail; b=Ovpny/YN7/EAc3iVmvBbXvIivk0xE4E26gXiYKybpzUlkrKuOAwOcAdVhJtTevl2LbcSXyc2tSqCljzW1V8slrv2tXRu/daEpu90nHE55UiOD59S21tP8jGLQxRoZdK3eU2l5rBuih9rrQwmZ62DbNN4DnJhHCe7f4ve70KUV6s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945732; c=relaxed/simple; bh=iJ4aaw5HTEFuCTFZPIk6hZooa9CSigFar7TsonG6a5U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Smfch345IUt+s8tsZSTgaQODoPPpJYMfgNEQ3TulJjDfrUypKNyS0QiC0NsKhdlqM+nJx9Ev8XAdBO+pRlZEdX1G69IhHwZNqy3M/FxCMFYzpgKk7+Eb4Ghj58lye3uR83bSZUFFlldTmsUech7L8w6DzDM5Txrps/ts0zP6+E0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=daqzuoaU; arc=fail smtp.client-ip=40.107.93.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="daqzuoaU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QD80XCQXm8H23efjfFMXqVuRYNFYyOy1RMkSOJftkfPT71bfOd54oNOE/tBBcn/Dz1clfs2MzDHGjToM4r4eP5aAHwRUwb3PTR3V1JiwmkoxJQtuu8D/T3KsSjiyV4tQwv0wBQ6qE9yNUWytCKGaLDh5vY7uhY6TlLhvt3+sPf7VYrcSYzkcd/+L/1HAUKYEtqdwRKLey650kb8LQsLf19R3+9Pu2qFwsGMWTWyEEUq6rp3MYOADQanCKA6+23akyTKQiYFbcf9pHg81kjy740WubdtDwErIfq1svfo93B6bC7xR31y9wmOsDWvQAGyQA5tDZmPG4RuI2WYZyTwrRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LghsmdqwR0uUilIDKT3uJJ1lfVCF8vhRuCoy490rGSk=; b=u7Qk4ld3v4Hlb/WHKSGFzE1lMyqgiGxy/rQrTiTvXbckAsDVHFDSjig2qVaXFtJibQZMW1BH2IIsYY44CQ1jvZcfqnF4FpOhXlhKw/jalaE0vw+jc72kNjE7UAXDwN5Ic2cTe7695yAPQ9xaMAEdG9//n5spD2HecUhul2sYonnl6XoPQUv9LCnfvlqZTeHvhc3vGnTsNEbhj3Xep4/QPPCzTCgZRAvGdsFgRllqaDy/pFPLHCwSOux2F16eHrYyOG9X8oyhvtiP7MrcrBq48dd/03BsgEUOnYvkzK64xVl3beaZAWVtw82jzZTOqZO1p7Ipv/5g4s8c+rWjEUfIRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LghsmdqwR0uUilIDKT3uJJ1lfVCF8vhRuCoy490rGSk=; b=daqzuoaUUu9tC0RzNf3uizKeevEq8NY6hIMcT6zrGuPoHa8u/FzdlumR9b75buA/8MzTow9QKywTtdKEiGf7ZJHW6VpALfci0PiVExckdBjqdiGMf7IOOsVmPnJ7VTEhmAKTK2MwrmKuTpna6IeQG0NmOcYs9neYb8TjCF3GyPD4IQ1q2TVjCJe+OEAutHwwaL/7nTFRsAWqLeh9dDRA0Q4rL459JC6wrPjWobtdK9wr2TJIL3x3tbj5yf3gEFCCuhRzThIvxtP7A26GasQRTp2Q5t0vwQUdIpycrdfP5QUN4LtZj/v2LOpxPdgfNdYhCE68PrrDV2dMi9bo8PBwQA== Received: from CH2PR03CA0011.namprd03.prod.outlook.com (2603:10b6:610:59::21) by CYYPR12MB8964.namprd12.prod.outlook.com (2603:10b6:930:bc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:02:07 +0000 Received: from CH1PEPF0000AD77.namprd04.prod.outlook.com (2603:10b6:610:59:cafe::ed) by CH2PR03CA0011.outlook.office365.com (2603:10b6:610:59::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:02:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH1PEPF0000AD77.mail.protection.outlook.com (10.167.244.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:02:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:46 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:40 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 07/11] vxlan: vxlan_rcv(): Drop unparsed Date: Mon, 18 Nov 2024 17:43:13 +0100 Message-ID: <37b3b793970baea64d4ad306eeacd18d9d3bdd55.1731941465.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD77:EE_|CYYPR12MB8964:EE_ X-MS-Office365-Filtering-Correlation-Id: e9be2031-da8f-41dd-2420-08dd07ea5a40 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: prwxwCrw8y1/KaCxmbICVSquD4CrfAuDKJQdzZPVo356D8Qxo09gIyfagrEvDkvKkVqTpz5l60hSYE2jz+tOAGMQGL/siO12ZWSZULftQPG4yUr5H2HTDZcao/wLzOx0qgD5l4oymwTW5xDZckdOKtbu+b9LYnMgCjI7b4bW8rMFfNDmTl+0bnKdrnL1LZM2ka6xIZR4zrEyFEjnBv+ve528bvUxAUGcjzJTd3i0bf3meJrSWuAzQcgtfWNG4WBQVb4BcdN36DMak5YniI1DaEFXyqrQy/LDPd7Z+PZKi9L9XA+x5/WyEQgVlYUyfr1uhu39ivAZeY6i9+zU+cbI54/w3a69z4qrR99EItOxIspddGqcQ3O87jvDFe4sTrdfgJXkANFF+nGcYcPDtTjHXlxQ23Xcd+kzOH3Bphxz3BxmugvUCpVEFBjYbpzCSBGYpnVgcRpz0EsmxAndM0GglOGQUd+6Sie3MXCANblOyGeZ6mLLjc5D2+3EDpDM38qzcqpPnKzsNQI5ceKi4jjAYqcfAfloF9EpdaFpzyOe5dBQQZ48ixbtVg2igFsUa+z5MOfvV1DdE0AtCKk1GtkSpHe+xIijD5Muw/mVxVEOo914rGW6zsllupVRNkVoYtXr6v3Jk5MZadHkn1DWVox77d5Fz6qmERSBFqQO+lGscNEke6mjYvTj4XBTpT6qBWJioiAulrn4iBconr1nNrCEYpMi59ukVdzlF5MOmAkntHEYYoDkBmGVvQjonlkW4iBUz4jPKgf2NF0jjmujRl6UnJVl3p+3506jGxMAVEwYg0ulpAWh1zjwQl5UCYY1pMJ1AJMyeEdIWBjiLN0klg0J6ppdvRdguM7ggkZasqqCGrgnw8x+EPnQqd+fppy+3zKOctiXVzEgYvBfaxEqDrwKewAzgK1FqzYRHgtppHMTSHme1w+lCCDHBnzUn0fQQgFoJv1o+MnDYgwcro/AWT12xVkZTNJpA94RXxIzrvdjwMfAPF7e9C09baTWd6skvZMTLp/mEjXzv1CYu1LTAbe1ZRDlLuXk2Z9jgl8IlDThMI1yhPipZsxi4c0pb29sJxfCXO3vWzA9z1x94m4mWxkCaN41+rYDMjwbSXp9xXA6OZzvctL1UmJXTs1eC21F2eOdwM2sxUfMv5da67qetQ/Ji2atl/UpKZ1d+s5IoUXp+2jBATb/Z24KRVUV7GGljKskPabINlBIJZcIkzcm68noG/EyfliReczf3YrhxbFqpU2XOnrEcuMF5pcrzoe/RLcUt34aVduHIbty2MnCsJdySzMfBguHT9Qn8jYnCbDprb5whEC8Zz2jJ5KnVl2F1Hjta1wgMpYySjHMF/mypEE3C9fHXy9raa+rz0e3+Ks6OR5dU3yYOCGp12MQpG98PXW9HVrRVGwZEFOoVl0M51eAhw== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:02:07.2810 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9be2031-da8f-41dd-2420-08dd07ea5a40 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD77.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8964 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The code currently validates the VXLAN header in two ways: first by comparing it with the set of reserved bits, constructed ahead of time during the netdevice construction; and second by gradually clearing the bits off a separate copy of VXLAN header, "unparsed". Drop the latter validation method. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 090cfd048df9..e5c7b728eddf 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1670,7 +1670,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) const struct vxlanhdr *vh; struct vxlan_dev *vxlan; struct vxlan_sock *vs; - struct vxlanhdr unparsed; struct vxlan_metadata _md; struct vxlan_metadata *md = &_md; __be16 protocol = htons(ETH_P_TEB); @@ -1685,7 +1684,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) if (reason) goto drop; - unparsed = *vxlan_hdr(skb); vh = vxlan_hdr(skb); /* VNI flag always required to be set */ if (!(vh->vx_flags & VXLAN_HF_VNI)) { @@ -1695,8 +1693,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) /* Return non vxlan pkt */ goto drop; } - unparsed.vx_flags &= ~VXLAN_HF_VNI; - unparsed.vx_vni &= ~VXLAN_VNI_MASK; vs = rcu_dereference_sk_user_data(sk); if (!vs) @@ -1731,7 +1727,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) if (vxlan->cfg.flags & VXLAN_F_GPE) { if (!vxlan_parse_gpe_proto(vh, &protocol)) goto drop; - unparsed.vx_flags &= ~VXLAN_GPE_USED_BITS; raw_proto = true; } @@ -1745,8 +1740,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) reason = vxlan_remcsum(skb, vxlan->cfg.flags); if (unlikely(reason)) goto drop; - unparsed.vx_flags &= ~VXLAN_HF_RCO; - unparsed.vx_vni &= VXLAN_VNI_MASK; } if (vxlan_collect_metadata(vs)) { @@ -1769,19 +1762,12 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) memset(md, 0, sizeof(*md)); } - if (vxlan->cfg.flags & VXLAN_F_GBP) { + if (vxlan->cfg.flags & VXLAN_F_GBP) vxlan_parse_gbp_hdr(skb, vxlan->cfg.flags, md); - unparsed.vx_flags &= ~VXLAN_GBP_USED_BITS; - } /* Note that GBP and GPE can never be active together. This is * ensured in vxlan_dev_configure. */ - if (unparsed.vx_flags || unparsed.vx_vni) { - reason = SKB_DROP_REASON_VXLAN_INVALID_HDR; - goto drop; - } - if (!raw_proto) { reason = vxlan_set_mac(vxlan, vs, skb, vni); if (reason) From patchwork Mon Nov 18 16:43:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878816 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2045.outbound.protection.outlook.com [40.107.236.45]) (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 D9D321BD9C8 for ; Mon, 18 Nov 2024 16:02:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945749; cv=fail; b=cLXRwpVuaLl4xu4rBIsJsnXhevlsEkqycdnPMDdi/rPwaZyuT56ZANL7ZXgMuCgf2J2kTnhmUl/ELOQfK4jCLvM1qjZ5iMnQVHT5uqEKewJKfVFs1nimEuqv2QKoOeR59vY6SlJl2yoRPHIVsSfjkR6z+UFMRwaKYBCviZ4kE1M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945749; c=relaxed/simple; bh=CMM8GEri3fzYowwTwj9mR8hQ2lcNici3nttmfuF3re8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NHKKGOLnj1MKvh2d1EEGHVmplsE6TfA9ui7QLj2vi/GBPJv+sd0HiF5I62Rr6v5lKp7SjXYy0OTz7TR58qSCkb3P+dghmkcjgnKgcDgOUa+le5lj34ZEVaU+UiJI6Sgh5Ot1Yo6HUCKDbNeVKNIL7tbCnlgl7I6Az2o/jq2AqVk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=JXiDdsof; arc=fail smtp.client-ip=40.107.236.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="JXiDdsof" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rzLiFRfuukIpZI/QTO3/mD+1k7jpCKK+tUjytG8XeTKZ01kC0M+jN4IWTCtBDWwQVn1I8Iqo/eySgVmw8mqNs6ZXXtX+xn0z7P3IZg1mkdd2z6eW86PdvSDmAlHdgaYZSg7jXdLN5bhoQHjPDxzgPZTYERSn4wbH3do+onONUaS7jfRnKxursGdsrha4EZfDxLxdFwrMdDAxQx80jw/OXqd5+Tl3qAHlCs9msnhOiO+z4vC8crBynlL4s/DxjTX0idr9I8ddvupyNF8b/DLV/0TgApwHdIbTEamEik1jru7bCkeRh27KAMBqKOknFQQljKyP3fL1aliSPQ0xRVqc+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=7rgVkuNK/eO4lOoW1xNYnnmYkrDa21FIY7tODJBvevg=; b=ZV8qNfOgfJsGcHHE3ml1QGHx1tu9pWdnxkYx0tQhFS6Tj70xwb9GDY9laHOb1ULPeiKcDlWzgx7nF13SfQV8ohuJR8v4q53CgbXXGI/W57DHD+XIiN0msjrMF/Uo3igGg1/w/93cldHjRujsUJIWCVBjaMXn4+70y9VVTWeq7JTJk2UTt6oIin59acRwPp8B/rqRXW9pV520YI3AHzdmnBSHYCK5nVRC+qkhbOD/FglcALdjju9HyCq7J0BbQ8FIaZujpKybnQp+dbFePm79Egr6xRgNafsNlVXPJxrTlRJ1wsMprSp8jWqGGlQ3Z1C6yjGfkUggP+XzP0WraBgf9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7rgVkuNK/eO4lOoW1xNYnnmYkrDa21FIY7tODJBvevg=; b=JXiDdsofKyVsq4Gu99LZDL1xJMlwF1TAyqRUxqKal+afs5q8JvXXojnUfuOk1Mt4NiKGN8uS7g8fTRkVvy/xQ0Kr5kKO31NuICyvuCBaUdXhUR4Rt5I6JNc0FwX6LFc3V791Fj4Mhu2Qo31IzcvUor8stkJxC4WX4tYMrm7/IUQSHaIDvgLvOEXvTFdLYb9TuWf1sYPozsNGixosb9KssVJWu13URxUyd9MUvp6cuSf5CiesAb0SY6pccJhZCJdNiwneqX3XykHmo/NhHtXMGp3H592LpQApbsfxrCXpSuxI3DSuOH3MvNi3DoABIGPquXi0lIOosYe6W/VJK7CH3w== Received: from PH0PR07CA0034.namprd07.prod.outlook.com (2603:10b6:510:e::9) by DM4PR12MB6374.namprd12.prod.outlook.com (2603:10b6:8:a3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Mon, 18 Nov 2024 16:02:22 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::9b) by PH0PR07CA0034.outlook.office365.com (2603:10b6:510:e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.20 via Frontend Transport; Mon, 18 Nov 2024 16:02:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:02:21 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:52 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:46 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [RFC PATCH net-next 08/11] vxlan: Add an attribute to make VXLAN header validation configurable Date: Mon, 18 Nov 2024 17:43:14 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|DM4PR12MB6374:EE_ X-MS-Office365-Filtering-Correlation-Id: 78e3afff-bc47-4710-18c6-08dd07ea62a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: 1riTPF/7vbKRITvrmlxfypE6D4nezPlFPmUfDzupub4Wyu80kY81BDJXCxha6ufq9I1L9GTuLmcLRYzK4dYIbkRVnZoirIACoU8xbe6c3MBvga2bX8bV+VJJ+7P4ELYyR9FUzGWbcIKUWjEnzgbQBXJE3U8K46QGWxwoGvcoZt8qYJHj0FRV4jylKwWr3sowmRCCBMep+nc0PzT/830j6NPRdcYFk+h1C8zv7PRqaty+NVdyEuFsl7EhyB3Cf4gwIjPAb46VrkD7CxyNR/4bYsO6UnaLEXxxwIqOv0JSzdEXvF+4DvEzGeFW1xlZ5D2K7I+4Mlud5nlR+cBo1xzn/AxdBdMZRSrWebgElPoWNujiuJVRsOtaS8TufHwyoQXxl27H+swVq9E++Lc5JbX0ovPaFKDUjxsdcT8g4PF204Pyf9AnD2Nnx1lxRwXSwoAgM+PsbkiL5ZzhZBwMeoogCk1lwzxsibmWAH9GCsPBVE19SHmlJmoAU/XAyckuvsMWOoSoVrEP5EJLrhR5ZHhJQJXuNtujycOrx9AEF1jthBfsS28JJejEax7VHhmBNvyjUxxyyl4+q5938shzcJDJsUcTU8XPaRi8al3CCDcjGsWdxLHPSh8O6H2ajQAlXPfRR5pWxJVlaWBLenoZKNITrkGLiXiCtoIPHBpuOklnXXnDztF6lAkYyFTIG32ZiiDpxNOPkjvfwVimJBztZfaDf7InNd0bqmaTve5DB/pf2/7IkGuvVxgadIqtA0ndP9Dij9oHBXAWA0aFiMiYUoWkx1+0zbBRULE3IAWRPChkxhsGTZr+M4W/3+78CuOmD1TSKkG1eqrmaWfUhrqaOAONl+44bSw9/FjDDXysjjoiKVfb+FyGJk37qnv67D9RdPkUizkr5A9RWtIiYhV+XsX7x69jmBqv/Kbd4G+cx6IOkBcjQIJMg+URcb5UgxdaVYyywFu3zoIvt3vZXmhUZBJGLjHd68lc91e7Gbw0fLS09urdr3gsko5OU6bSvo+fYDFuqGDuvsXIC3gct2piMis9Cuq+Owm8+LJH6Phr0JXKs6D/KR73v8Mmzp4x1McxvtIR36zFfAuDJ5PMfPXrmpJF3CgQULlohbrK/GFntbUeDv/3XcmvFk/af/OfJMAwBnNn4USYaV2q1HyoPe9+prXwjleOULkrVEBrvj5UUlzsXokGekhiDEM3ABxGQPfJQkmWZs2b5HWXXbsEMTWBi1CtWWmxk6mWAQg8P9AfHwzapbfQUcdBZHVPcsu1jUWnPtqFMca2+cmgN7w2uJwy9DjuOvOez221GgDEuSY8iMMvTqUOFx8VKCkzHrCK5/nFp2oi2evh2j+k0/8WzLWjDqnrOxfg5EIpcMe1z2UA6wHBJlwBDwGGupOueCzpny4f40hkBBlOCJOf/yCUBKQ3PFJ4fg== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:02:21.3916 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78e3afff-bc47-4710-18c6-08dd07ea62a2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6374 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The set of bits that the VXLAN netdevice currently considers reserved is defined by the features enabled at the netdevice construction. In order to make this configurable, add an attribute, IFLA_VXLAN_RESERVED_BITS. The payload is a pair of big-endian u32's covering the VXLAN header. This is validated against the set of flags used by the various enabled VXLAN features, and attempts to override bits used by an enabled feature are bounced. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 53 +++++++++++++++++++++++++++++----- include/uapi/linux/if_link.h | 1 + 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index e5c7b728eddf..4aa9bacf4a2c 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3428,6 +3428,7 @@ static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = { [IFLA_VXLAN_VNIFILTER] = { .type = NLA_U8 }, [IFLA_VXLAN_LOCALBYPASS] = NLA_POLICY_MAX(NLA_U8, 1), [IFLA_VXLAN_LABEL_POLICY] = NLA_POLICY_MAX(NLA_U32, VXLAN_LABEL_MAX), + [IFLA_VXLAN_RESERVED_BITS] = NLA_POLICY_EXACT_LEN(sizeof(struct vxlanhdr)), }; static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[], @@ -4315,13 +4316,44 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], used_bits.vx_flags |= VXLAN_GPE_USED_BITS; } - /* For backwards compatibility, only allow reserved fields to be - * used by VXLAN extensions if explicitly requested. - */ - conf->reserved_bits = (struct vxlanhdr) { - .vx_flags = ~used_bits.vx_flags, - .vx_vni = ~used_bits.vx_vni, - }; + if (data[IFLA_VXLAN_RESERVED_BITS]) { + struct vxlanhdr reserved_bits; + + if (changelink) { + NL_SET_ERR_MSG_ATTR(extack, + data[IFLA_VXLAN_RESERVED_BITS], + "Cannot change reserved_bits"); + return -EOPNOTSUPP; + } + + nla_memcpy(&reserved_bits, data[IFLA_VXLAN_RESERVED_BITS], + sizeof(reserved_bits)); + if (used_bits.vx_flags & reserved_bits.vx_flags || + used_bits.vx_vni & reserved_bits.vx_vni) { + __be64 ub_be64, rb_be64; + + memcpy(&ub_be64, &used_bits, sizeof(ub_be64)); + memcpy(&rb_be64, &reserved_bits, sizeof(rb_be64)); + + NL_SET_ERR_MSG_ATTR_FMT(extack, + data[IFLA_VXLAN_RESERVED_BITS], + "Used bits %#018llx cannot overlap reserved bits %#018llx", + be64_to_cpu(ub_be64), + be64_to_cpu(rb_be64)); + return -EINVAL; + } + + conf->reserved_bits = reserved_bits; + } else { + /* For backwards compatibility, only allow reserved fields to be + * used by VXLAN extensions if explicitly requested. + */ + conf->reserved_bits = (struct vxlanhdr) { + .vx_flags = ~used_bits.vx_flags, + .vx_vni = ~used_bits.vx_vni, + }; + } + if (data[IFLA_VXLAN_REMCSUM_NOPARTIAL]) { err = vxlan_nl2flag(conf, data, IFLA_VXLAN_REMCSUM_NOPARTIAL, VXLAN_F_REMCSUM_NOPARTIAL, changelink, @@ -4506,6 +4538,8 @@ static size_t vxlan_get_size(const struct net_device *dev) nla_total_size(0) + /* IFLA_VXLAN_GPE */ nla_total_size(0) + /* IFLA_VXLAN_REMCSUM_NOPARTIAL */ nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_VNIFILTER */ + /* IFLA_VXLAN_RESERVED_BITS */ + nla_total_size(sizeof(struct vxlanhdr)) + 0; } @@ -4608,6 +4642,11 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev) !!(vxlan->cfg.flags & VXLAN_F_VNIFILTER))) goto nla_put_failure; + if (nla_put(skb, IFLA_VXLAN_RESERVED_BITS, + sizeof(vxlan->cfg.reserved_bits), + &vxlan->cfg.reserved_bits)) + goto nla_put_failure; + return 0; nla_put_failure: diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 2575e0cd9b48..77730c340c8f 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -1394,6 +1394,7 @@ enum { IFLA_VXLAN_VNIFILTER, /* only applicable with COLLECT_METADATA mode */ IFLA_VXLAN_LOCALBYPASS, IFLA_VXLAN_LABEL_POLICY, /* IPv6 flow label policy; ifla_vxlan_label_policy */ + IFLA_VXLAN_RESERVED_BITS, __IFLA_VXLAN_MAX }; #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) From patchwork Mon Nov 18 16:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878815 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2054.outbound.protection.outlook.com [40.107.244.54]) (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 DE2381BD9C8; Mon, 18 Nov 2024 16:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945743; cv=fail; b=SirjdEQwXRGwy5CNlYEYG0dj+IcI7s4rB6W+wObZrJZSi880QTa/nLmWyK38kn1+BGv4wIpdHSe/Se0jnKF5AB36FU+enyeSSBw9hwPh1j29PCQQUv992BTaqKZIpdG8cY9G8zIwDcShM21qzy178qfrlisnoWxbWfQ+gnJ5CHw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945743; c=relaxed/simple; bh=cVfKjVqLaxBjvU8xsYDqwvrVmkq7fEKbZK6IxdezcGo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fdY3/z4/6B6BRDDPlwBYzV+f0bLCar4tKVD2eeZNZsPgGKTaD7kccQxox+LzszeYJMK1X/eZKREwXbgwaHppbhRvhYU7MYagFfNq65icUCuutc89I6rY7AO7I/SQtmxJVmnXy0n/2JioVw79l7SKepEdllZy0G7A3u64Sff9Tq4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=UAY9d2Dc; arc=fail smtp.client-ip=40.107.244.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="UAY9d2Dc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iuM6vRtFoHLvD/EbCKDIw4kzwZpfspfPwWszcR+ad9MNVcfzeLvW7HJVqRu+qcwT7I4+YR6ctg8/rikMZ1uyawsD0cyiMq+CKkeqZ4PG6HO31oQdlNYNxkix3JdhbVX1ZC4R9OyWWEVmTgEVfo3Dy6OVIYBnzKbqnhiyupYxesgRQHeAIlwEe5lSjsQ3Kiq57K/SbTR0/FATnMsUBj0dUHtfk8Y6l2cNQFLq7JAPpsUveYJffIOjZX3N+DarG32tgEU9wMjv8tKx4BBY4J7LIInaDjGHI4DUtsJlz2HjoZ9m2D5XRLf2szXI8qXN0l7uBK/DDurmJJ1N1EJMPCszPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DVqdvTshHxNki3bZ3TKLjG68UTcnAHsRVq2A6Gcb6kI=; b=Sxi1rs+p4owKYwfKReeezEPskG7XkRjYmzA3ISsCyd8U7byBLejwuFpdROgkVKtcDNoXx+Q9IeoVOfOlJ9v143Xdwnb3veqMHQkjI2+yXxWzTvYxforalDjYN0B/RNnSC0RD8o0NMiOHZdMCeO+t21Pjdmy9UxLfWcg6x9LFubNioZvwyM/8fIlTz6lU1Ya8aE0G8ug4YQB9pOaWSxWs5j/foSYqJVATkB/grT3qkcluKI39oo3z/EY1z3YVlJvSRnH0m6v360e2GnDhohFhPGZyMjnsstjTa157VnwL+d9vsbiSuZmhfiiQJyLpQRwAc541kwp0QvpAYpD7wrER3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DVqdvTshHxNki3bZ3TKLjG68UTcnAHsRVq2A6Gcb6kI=; b=UAY9d2DclhTTRl4IiKShJMLvIdKuzLk48CP23YIkrNkh3Jjx0vkfOCCXXW76VJP08kNlb0DrI/prMLCKcYMjABSkV8CYwwkUrUV+yUO3V6Wyqm6F1Z92kiAnrJpJOibEI43/2DWlqtNB/bDYnxj6M/FlRwFZiIkkZCnwZ4Se6Tdl44Z5TGXF5V4No7FfuL6ngH3eJ8sQCBsEIX0qCeLbKQhQag2dambajn4NvnRJnHhrBz12dxAohMn59b+qnjNiL2PIrSS96s8Soi6u3PSSmfiVmAg4F5aSpypg3moljUWOkAIQ4bRwhMB0T3S51kArIOJBThMgHAD7E/gSOpJ0NQ== Received: from CH2PR20CA0001.namprd20.prod.outlook.com (2603:10b6:610:58::11) by DM4PR12MB7599.namprd12.prod.outlook.com (2603:10b6:8:109::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Mon, 18 Nov 2024 16:02:15 +0000 Received: from CH1PEPF0000AD76.namprd04.prod.outlook.com (2603:10b6:610:58:cafe::b9) by CH2PR20CA0001.outlook.office365.com (2603:10b6:610:58::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Mon, 18 Nov 2024 16:02:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH1PEPF0000AD76.mail.protection.outlook.com (10.167.244.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:02:14 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:02:00 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:01:53 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [RFC PATCH net-next 09/11] selftests: net: lib: Rename ip_link_master() to ip_link_set_master() Date: Mon, 18 Nov 2024 17:43:15 +0100 Message-ID: <8d336cf9b91f5faa99051c75655a1c0eacaaac72.1731941465.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD76:EE_|DM4PR12MB7599:EE_ X-MS-Office365-Filtering-Correlation-Id: 4170f378-9598-490a-ab1d-08dd07ea5e7e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: kdUgCBkOA9iax9jCt8lbS3C45vBXjrNSdvjwM+grIZHfEjgCTWsBMChgw5bg2KieOIFXSMsOpvzt1ZP1VJ0lc4nZ2eeTFVLCwk1fpf5rSysSZI0SvCVgO5TpTNDqiT4in6If6F7PYfnKXQy5ZjfiEWVfXybEItEL+ZwIc5RYm1v9jsEqUaVoEOh3GlRIpCVQKkQ/2ZjIy0t6MeMtW0UEFbzFPpZ8Y+3rJfFdKLVQRkCrHcojT3FI16xUDvw0G1nPiYY59xLOigXR+QefeHUn0BuJDSkW1YfbBpFBcPoYKH7MQWfVvSX81QQ3zP5AZCn3SFhWBXvOA02m0ZRvNmvlbeLgwyYm/66f85B6+erW6ZtF/i9UrPUgOTtXeMjpBp8H0RffiZx7lFT6kJJYQ4WapI3Gbs6lS1J/rNGWe7DK97OcNJFgu0dUhET5h7MSAoxbKmzlnvVhR8fpb+nPxiorAPz8bQbWR5BCAsmYmhnQfdfB4AvK6jQN/g13xL4A8k7uSLe6g78D9ZUfJQwtX3KQUF+NODBlflVTLfptvhslWLPW4hht8ojIgHV1iqyMebj0mPVPFgwbefglWT+6pYD7wlMbbg1TapQO3cKwgsZyVaqlN8j1Q8NPP8DqKFuctMFRvhnS2CHIZOL13vjGQVAHyAB66m7mUggvKzRSWiBuNWUTInZoPvAIS5cewEqNIlucm8N5oo4gcHCm/3ROqfpG4AYjbSe43Df2Ba+mzhFHXFbg+OXBdTYUa8omhPSbealbWmq2YWQdd7lu0UJf7OMHVp7+y18BQKrf1rKZDFyP+RdZffK7S5XguVddWespmebo/VIfWOHhxk5l4RWWkxUoatRdxTegTvc+gtOpbi5+LMSYc3gz9sqzhTHTfq9GhJefTHFMqYQo0wPwhf1S3DPsWGiDzX5G689/pKfzq0pGGrq5BlbgZVRUR3Wafi5eKvrM7JIbb4M6yOfQseK+66S8Wx1Ra7ft4u9338s/WEBTRTfG9GVAs8yEZ/BmwE+6MxSTcV74ihynVLmciLR5dy9JUoyybKyL5rFa+uUeu2Ssih/y/feC+8DRI/2tbKgEft7OitLFCgCbevgRy+f0eBZwE7+KWEfZYs5TxNRf6MeeLjddV41CNV7en67GBEEoYOaiHKvfG5XygyGXAhHibzyzsScrHAQNSvs8i7f0gMVA7Fpi9Zd4CIlhQUlPfn0Wmy9LaYbQ8ciL3dWX5LyQtoAR23e+rPRRg6Y4s83HXNE5dgzsScnYhZMlJ2uWj0AxTAq2OSlqmyQq/PCs/wvPCnSHXr3ZhjD/C91vZBMT4+Sdo/4LSj+QIc/Xke2adkadiKKBs+C8XuEeLfE/apeDXtPsqTGmqSKgzOR6l1EbudjmocI8W5wNS+ornffFlfsGegRpWxleR6dKMIhHvxwx6/m2uw== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:02:14.3392 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4170f378-9598-490a-ab1d-08dd07ea5e7e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD76.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7599 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Let's have a verb in that function name to make it clearer what's going on. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: Vladimir Oltean CC: linux-kselftest@vger.kernel.org tools/testing/selftests/net/fdb_notify.sh | 6 +++--- tools/testing/selftests/net/lib.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/fdb_notify.sh b/tools/testing/selftests/net/fdb_notify.sh index c03151e7791c..c159230c9b62 100755 --- a/tools/testing/selftests/net/fdb_notify.sh +++ b/tools/testing/selftests/net/fdb_notify.sh @@ -49,7 +49,7 @@ test_dup_vxlan_self() { ip_link_add br up type bridge vlan_filtering 1 ip_link_add vx up type vxlan id 2000 dstport 4789 - ip_link_master vx br + ip_link_set_master vx br do_test_dup add "vxlan" dev vx self dst 192.0.2.1 do_test_dup del "vxlan" dev vx self dst 192.0.2.1 @@ -59,7 +59,7 @@ test_dup_vxlan_master() { ip_link_add br up type bridge vlan_filtering 1 ip_link_add vx up type vxlan id 2000 dstport 4789 - ip_link_master vx br + ip_link_set_master vx br do_test_dup add "vxlan master" dev vx master do_test_dup del "vxlan master" dev vx master @@ -79,7 +79,7 @@ test_dup_macvlan_master() ip_link_add br up type bridge vlan_filtering 1 ip_link_add dd up type dummy ip_link_add mv up link dd type macvlan mode passthru - ip_link_master mv br + ip_link_set_master mv br do_test_dup add "macvlan master" dev mv self do_test_dup del "macvlan master" dev mv self diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 8994fec1c38f..5ea6537acd2b 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -451,7 +451,7 @@ ip_link_add() defer ip link del dev "$name" } -ip_link_master() +ip_link_set_master() { local member=$1; shift local master=$1; shift From patchwork Mon Nov 18 16:43:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878817 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2059.outbound.protection.outlook.com [40.107.237.59]) (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 8DE9D1B6CFC; Mon, 18 Nov 2024 16:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945762; cv=fail; b=swBCqnUoM27593FmGGUbFIddb7D+THUCgg9kqCaRcR4GCXMfe1GoOiukeQ1ks4aMZhWZbGDa7/frX5Hdp4hG0VLm+z1QukMkEbXDc4OH0Itez0IQZBLgCI44Pj6rt37hDYY8t1UiCQ3qGBj3kFUmWJvpscY9ayA6PNnXK5DW/EU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945762; c=relaxed/simple; bh=RUmjpS00KQPThj9efFSMqJlPjLPKYyp632VyEJwERTY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B4Y5jlVJhlQ4+77Suq/8HUZ5p2FpOLWX+kEVaSSHjdwcuww6mWMoKlSTZtREEKcRWP/Lx3QkLVTzlo1NmGPe5WXWuh3xmAfKqNbJwLNFEBFjXb2WkTsd2ZtVJx1C8Xcdrroau0XLDjTmpXhGdXUQrDcYvMbiNZyYeQBt49lxJz4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Ei2Fk602; arc=fail smtp.client-ip=40.107.237.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Ei2Fk602" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kzmwg7UIdCUDhQW27Bu3VuuxKKYku/Puq4yfY8wcCxsNqy5yI01bpw+tHrcq3IK4w4RbjIs/3d0dJsVur2FdPZntR73xP8jERX2kVR59bheV0avHdyv0jyrHsyMAOQFhOcV/uVXTNHuBOm1l7KFwZnTsItC5v7eluE9LZVsqHAyITg143g8ZwTdH81DrQ+G3kSUNs51OugckMvlm6VNzg3c6JEVfXjIpHnp6LXueQvBAsr0LllRfelAUtAZeW+ROeFSzwPGJlJfH6V8T1u6WtRpNSe/lplit3AvT2H+yqdcRmatFqI90svOLR2joLGogeMkvTWw9iJtKSCCjz6U55Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=iemher0mO6qrlOQ5kx+Fwf3R18yaGpgpyBN2/v8lXvg=; b=e0b2JiNZ6WpIM+Sv4K0RnucIMqVQ8WS5/WHQ0NOdopE8c+QtnXvVQzxsbLz39h9MJHbNqFwk+On151Qwgm2H6uVMOhJRIuC0fNJCOhc7OtksvJNMBvo0spx4YQtkbRC55NY7Qn4VwXSQEVPFEg/13CRZpasOHqOpadPnMUm8n0d+ilgmo7gEoJZEMnXkjpc/5qe/URgonPs6Iu7EEW5b1KsGQJ/xxEWfe/yeyhsivCOvEtS2mvLNKIiFXVp7sfXCBhrinwPH3zTNUPJwgpSuWMGGVWmQsDv7JDNzJDwZEV7fZmWWY8ebnCPRcoHt8yb8AKZ/+va4Om9LhRlU4cfwHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iemher0mO6qrlOQ5kx+Fwf3R18yaGpgpyBN2/v8lXvg=; b=Ei2Fk602UZkajS+rsKUuBHMSx3xUHvCrI3+mlzJHryFadvcd8AQ5TbQ9K+U1/TYX+faavR6TaszORZRp2LHPqEsuefLDGEP/xR1Ur0CabSjfHl2HqI4NV8blPs6MtxRbYuUHfngCQELGMRzJEXa6T5u/HtqW2eEJ/RpHEthV1HgVq6ZSGeWK+6YB4zbs/N7tOwyoLiPSWVfMeGVwKFezAqoTWNeMfIU2hqvFxhdFcCE8XDihJY4WWeVq+iBFBuLZIiDfApyMMwMSUihwHhRK9+IGUL8IFYnz4ZBRFy+bQv7LjN4N+wQBdITsFwF6gXwhvUyoxizVponicuijUrUyzw== Received: from PH7P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:326::26) by SJ2PR12MB8876.namprd12.prod.outlook.com (2603:10b6:a03:539::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Mon, 18 Nov 2024 16:02:35 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:510:326:cafe::87) by PH7P220CA0019.outlook.office365.com (2603:10b6:510:326::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22 via Frontend Transport; Mon, 18 Nov 2024 16:02:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:02:34 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:02:07 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:02:00 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [RFC PATCH net-next 10/11] selftests: net: lib: Add several autodefer helpers Date: Mon, 18 Nov 2024 17:43:16 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|SJ2PR12MB8876:EE_ X-MS-Office365-Filtering-Correlation-Id: 36682764-62bc-4234-86f1-08dd07ea6a58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|36860700013|376014; X-Microsoft-Antispam-Message-Info: LFkJQ+luQcaoCLPldT/9PhEaID9RZ1sJ8XWw4KuZR5fqajINJvQzmv6vnzsLv3AOKFdB0YxOEo3H6M8ErPzX3CXmkaja1khuQScFiZ3Zfia1AaRfdHW+dMjTMQ0MHA8+cOg0x5l/mA9E0DXG6muQoCahCWr8t+NCSvMBsrufeJaX2wOnkWJh4Bxb2rEhKzV+0tNobaVvzR1B8FufTAhlwo2eTxvVHBsy9LNXYEzMglnts9OjmWcW+6a4WzypM5oQWb/3BIRQ9i4HAQ/bj8biELWqy1P8P6ocztf/CSHxmm5eiJZyRMPHCor++y5ZtIm43IfpoUnXlMqTtVCHHwRom3f1I6nrs7jGU8T4zkqUa7nS4VfNsTk2oJNOz9xzyQvlyPezttVdwLIuUw4mR1YK8GrNrH5WDQCMZNaqBBjgS2YCqCAYHBzSp2kI8NgqZqehqIB8FpO8VkSQMPVw37ZBGk/vIdTnezCDTnjP5BAHqOXY4XoWyi64vc6VM0u9NkWH1+xTLcxvT3YOXh2Bcau7VMfL2En5bKB+TAnwmFuuMoyFw5Yq7Mr+UXevKdcDDyo6WbR/NNM3im737bv1x/MisIJaXQwf926SjrDBxU6zj7oItJF6KGTw54tFTi0M9pSF2BIdorFHfvG4NWuVBsdHR74P1kjfzDw7ex6+K5w78O3CfR0/YqCjGGP04jycdfVJw0G2mQmxb3rKWouQZdvrZvLn+sOMQuCSeATSLLRGe/JnSF2FDF1PuwPAE/j3aND5mzStpMHfbtqdDwuHStzE8FzA/PjZ+u9wgatUkjA6tpiHCx3rVVya2suPB/uHjJk4ppgQTbKVRKmkS1G1BPTufyUiN76RPNCeWdcjN7MqndG87eX/VgIkSaXtYzuuYWYOHHTw+7yONkpPLuQ5BuGAl9R9vKMQBHStosfVr0FlTDqxNuaixJ9iSRzMXvVzAUhXNrzES8+LlKrCMBpakks1KQEorsf5g7O1b/O2xfcWKHrmnBDFEzSTjAk7/e45emEadsGGcRWMa+H4D35hl7H2Q0UY0CHBUH/t9/SSr6S57pdtJVsMzomnSLUjyWIKF3CryoZycJ2+ECMt7FOjG5MSG9NvEDif3HNQ4vr6/qEKT5gPrsIiTCAjdcrK7t1TnCJ8dTzkgaZ1S9p0eVmab8csNOrs0kaxZ6od6HchYU7SPIPuxpl3Gdt65utKoA8rD95CCDpvfluhEnpo9yY9iErnRQlhYR5rRi7723iay4TW2jiySuFWv4TqFOSdzruLGWhIs/q9H0fOpjOuKR1gtvICI3JP2SaeQjnwHz9bRIjoKedwvgs0auvHecB4/yKkNFxz3HzLNkd1WitSD00+0TsycKlvD4rBpIXZ3CTji4OyEvKol/9MAcNRp2d5UiWoe/XcGkC+HQ0Ei4A+oSXKKUhEMA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:02:34.3157 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36682764-62bc-4234-86f1-08dd07ea6a58 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8876 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add ip_link_set_addr(), ip_link_set_up(), ip_addr_add() and ip_route_add() to the suite of helpers that automatically schedule a corresponding cleanup. When setting a new MAC, one needs to remember the old address first. Move mac_get() from forwarding/ to that end. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: Vladimir Oltean CC: linux-kselftest@vger.kernel.org tools/testing/selftests/net/forwarding/lib.sh | 7 ---- tools/testing/selftests/net/lib.sh | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 7337f398f9cc..1fd40bada694 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -932,13 +932,6 @@ packets_rate() echo $(((t1 - t0) / interval)) } -mac_get() -{ - local if_name=$1 - - ip -j link show dev $if_name | jq -r '.[]["address"]' -} - ether_addr_to_u64() { local addr="$1" diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 5ea6537acd2b..2cd5c743b2d9 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -435,6 +435,13 @@ xfail_on_veth() fi } +mac_get() +{ + local if_name=$1 + + ip -j link show dev $if_name | jq -r '.[]["address"]' +} + kill_process() { local pid=$1; shift @@ -459,3 +466,35 @@ ip_link_set_master() ip link set dev "$member" master "$master" defer ip link set dev "$member" nomaster } + +ip_link_set_addr() +{ + local name=$1; shift + local addr=$1; shift + + local old_addr=$(mac_get "$name") + ip link set dev "$name" address "$addr" + defer ip link set dev "$name" address "$old_addr" +} + +ip_link_set_up() +{ + local name=$1; shift + + ip link set dev "$name" up + defer ip link set dev "$name" down +} + +ip_addr_add() +{ + local name=$1; shift + + ip addr add dev "$name" "$@" + defer ip addr del dev "$name" "$@" +} + +ip_route_add() +{ + ip route add "$@" + defer ip route del "$@" +} From patchwork Mon Nov 18 16:43:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13878818 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2070.outbound.protection.outlook.com [40.107.236.70]) (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 88BE41B6CFC; Mon, 18 Nov 2024 16:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945768; cv=fail; b=D2PaLTEHLpbe9TcLBWaa1lnnGaB2qUVIQosmgNHaeyApEoczwCpICvIPUSxdQ8rJO8ZsogQoIkrUF3ZDBPq9xUawfIC819knlwyoSE81vcdaZ9wsxcttIXXQNtuUHmlZSLwRGA0swZfXyDGhyaQX/y3+oaXYmesXUOpPgdyxuW4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731945768; c=relaxed/simple; bh=sa+vZ4cO2nKVCAsPHtSng8OI9lMw+dXg1EIFqUVLVto=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rQbQsKUwXxZry6bsO97x2nQ/Ehdb01+opkn42RyN73fGa38kkTXEtaF4BGGUONBKawxAoBQ/aw8hksPvZOujd7kZ9U/LHlAmxhJy5pOKMsq8t+FHLBv9hc3CQB5I4nECb+BsUgDqZo5p3D3wX0XkaJcVpMi5CDUgbk3vCsgeh+U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=UmPRUkd5; arc=fail smtp.client-ip=40.107.236.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="UmPRUkd5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wK7liPe1gBKAasHnMhCs2sTQelfMfJAvAzRtTduoSavfabo5JwHMY7/zRpro9TewZDerIrcxI73m0EqW6BhELEI9jlmil1MLiw31jSBF8JYgESkvnwd87gd3A2BpWB1C4WedMBsb/tyhGe0DJCVxwVopNy/Do2K3sO8zaUpaV4+TtkWDJ5eI7WVGoGSLXbMpNYPO2dIT3sPKGbEPpeC/XqVStSHhT9GDMwHCX5mDJN7OhUGHGyrU8je0b6buszFoB8liJwShbxYheb8nKiWOWmrSdO1lrlvJKkBEmOqKIC7juL0XoR3Rt9vHt6kWwgHNMQOGib3rCw+Rzqg8nOljDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=oZq6qzGt8ei5DmYVubXAiDaB7Wew5c75RnjQVh/liIA=; b=icIOsqZw0I5gdaGkLoVITgOggCMNV24wgCN2FftyYyl3wjjTawTYXN4G6/ywMNmJuOX8ibMrhcjbw074gIeCOBcUpE6H9Z2dg01+umiAvrxcgBIlGTsMZy257bqsi0nZzoeKyRhS+KTshIPBEq8CqylkKwrtNqfPFfO0hwM7emZwj3hyhQvL+v1+yws4PqwFAMw2NqmHZxywGyTHKjrOmvcCbb8E2YOxRnoD6sydEx2r/eC/IivkRHpEpugQQzlnuhtC1eWT44Js9MShHh9nCsoxHm5tF5TUaf+9YTS5JRSxrHVUm3MDvVm9+y/COs7bAcYUCXAPl71Z+km9qJIbBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oZq6qzGt8ei5DmYVubXAiDaB7Wew5c75RnjQVh/liIA=; b=UmPRUkd5NP+hiMdUnIeXqwBGDJMbP/SPDWLLWqpBHrZw9+6/ahiq0Tp7o686r8qf3b1vVKEEeMBXRg9DiU4fXE8BYZEswSkf7bhGBUCHVICc/D++Lmji/z3qQmGFPbc4KCkrILPHA06johwXH7JN2CH1Y/WP3n/MIO9sPTe7BkI2c4fqs+YDXGUguFglDMO/YTM+IxpX2LRrZ846KulmOSzHb8DbpP0Fs8CHWSxY90d0hghxw5vqjdv/XJwdvMAtM9II9fQtL58GPg6NFPfr7xbRxvZeHDo8BoUPD6H6dPNepxRREQZJkLAbE/fOzuUkojdZZj/a/PPrkYSoJ8S8OA== Received: from PH3PEPF000040A0.namprd05.prod.outlook.com (2603:10b6:518:1::51) by DM6PR12MB4249.namprd12.prod.outlook.com (2603:10b6:5:223::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Mon, 18 Nov 2024 16:02:39 +0000 Received: from CY4PEPF0000EDD3.namprd03.prod.outlook.com (2a01:111:f403:f912::1) by PH3PEPF000040A0.outlook.office365.com (2603:1036:903:49::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18 via Frontend Transport; Mon, 18 Nov 2024 16:02:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EDD3.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 18 Nov 2024 16:02:38 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:02:14 -0800 Received: from localhost.localdomain (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 18 Nov 2024 08:02:07 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [RFC PATCH net-next 11/11] selftests: forwarding: Add a selftest for the new reserved_bits UAPI Date: Mon, 18 Nov 2024 17:43:17 +0100 Message-ID: <19411b7f8657ba2ded8c6d257223aa5117ce5344.1731941465.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD3:EE_|DM6PR12MB4249:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e8605f0-b26b-4b0b-cdfe-08dd07ea6ccb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: zSb9xsTa3gA3WL1Ekdd4lJ1ChwfArh4U0Ck7XPHYdaYGwhHuqitVl4EWDkPEMiarzum3bdh2FLlhU4n8nW6ACbOMBpZsj5EJR20JTCtPY3AOyIBi/Qw1BZebWC0V4Gz3cPP7aL8Fd5te3q0hbKYnFWNNdzcAcLwgKJbXhwWmdE8E55un/PdIexa+ZVMhFIReXIE0MLJ5shl1hthCj+YZWYDrMxrZL9Vge5etDtDsgcFrH+QJs5L5qgFy5WfKRQKv7mfyCLrbX0HPHi2sUBG3AEd5oz0XKs+AxfOq8y+tedvK2tciMWjhhBtVLNhisNAJp93YiNx3wXrsrz/SlZmYSpRQhw0GFJr3T9fKU8Cp/brrGXN2zJpNPa3M2TafMce9XPMG9maPPiw7CtEJZ58zmQGRADqnh6LMPHmH3a6ZFjYM0B9+jD9N+GM6zuLaQLpkm2ugcuSJnhBaeNdEEkN5tU+/PEwiFkIDi5scwheAfZqpSmhZcXM6VfBdnAUM17SMYpxrRFhD11Ne4k+jp2q2inTGFr/dgiGtVBxMySsS6F37xSJdlfcBOmFbGnYhLI/N8LYFTzv7BrhqjW5JhHaW03luYONtQOpwWe/uS81LPd6V680FdGohK3os+QOBCrUQGieiKWQ5RG4fTlX+ZPkLnWnePZCRuPRJ2zn/znBL28mQxtMF5/xgJwaSTOPQG6Wn0aBlOMFikeZVJ+t55Lv0NtZd1kKwSzCouypNSPm4fbHZt5Y97hZf7/dElLjl87GM+Wf/uBmQs7gJLDHgMTQxCyLIXX06sCsyNfqS6AxlfECIErFJRN+U2chATxpTPS3QGCErNsAoVLEJFBk0vBPxSr5eO77jcjqZ+Y2sTa1orFfNdJpbSZ/wKCGYAK0l05r5YLjE17c+26qgcmCXcPKAuzn9W9d/gDg9M4RuNtfOsDQsAfu5eG31kLEZmHZ14sBRy9Upj+qId9w1jXV/G2tyM5WZlgqAZZGlvGNe916dy84w6s61E0dz3GIPAaDCeiWJD4AmT+wgKxEHyoXM5yy7wb7GJZz9ZgvSDyIbNX49bp92TriVjSyHzSvZYIgHWnWbegzWG6Lf4dYi5DocglApJz8WuzGq2USp0Z4+VcCoqNqwL06Qz9fQYTmVME8zKqGwA0/h5Z5kEkONqy1j+pzXx90km+o7feSArpDGaFMtsyTGAHP/n9QusytaLrY0SxU4ChV2XZhvxvaoHPgbtkWnhYThzGzwaJ///6CeZSD/V5bTcjBd+kKz5E5POjr0QjoSUreDL4hmNi+jzZy11UibXma9T/KAgwGlEkF5Jcm3VfEWZs8FWReGMBPM683h4ALJDgErWtK68kvWaG/KP9HkKsIfTXeomIxZqR0gVcv2hCVjHKL3fyRwn5gHqSzRzIayn89iQgWJg5SlaI9dDTv1yA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 16:02:38.4266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e8605f0-b26b-4b0b-cdfe-08dd07ea6ccb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4249 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Run VXLAN packets through a gateway. Flip individual bits of the packet and/or reserved bits of the gateway, and check that the gateway treats the packets as expected. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: Vladimir Oltean CC: linux-kselftest@vger.kernel.org .../net/forwarding/vxlan_reserved.sh | 352 ++++++++++++++++++ 1 file changed, 352 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/vxlan_reserved.sh diff --git a/tools/testing/selftests/net/forwarding/vxlan_reserved.sh b/tools/testing/selftests/net/forwarding/vxlan_reserved.sh new file mode 100755 index 000000000000..46c31794b91b --- /dev/null +++ b/tools/testing/selftests/net/forwarding/vxlan_reserved.sh @@ -0,0 +1,352 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +--------------------+ +# | H1 (vrf) | +# | + $h1 | +# | | 192.0.2.1/28 | +# +----|---------------+ +# | +# +----|--------------------------------+ +# | SW | | +# | +--|------------------------------+ | +# | | + $swp1 BR1 (802.1d) | | +# | | | | +# | | + vx1 (vxlan) | | +# | | local 192.0.2.17 | | +# | | id 1000 dstport $VXPORT | | +# | +---------------------------------+ | +# | | +# | 192.0.2.32/28 via 192.0.2.18 | +# | | +# | + $rp1 | +# | | 192.0.2.17/28 | +# +--|----------------------------------+ +# | +# +--|----------------------------------+ +# | | | +# | + $rp2 | +# | 192.0.2.18/28 | +# | | +# | VRP2 (vrf) | +# +-------------------------------------+ + +: ${VXPORT:=4789} +: ${ALL_TESTS:=" + default_test + plain_test + reserved_0_test + reserved_10_test + reserved_31_test + reserved_56_test + reserved_63_test + "} + +NUM_NETIFS=4 +source lib.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 + defer simple_if_fini $h1 192.0.2.1/28 + + tc qdisc add dev $h1 clsact + defer tc qdisc del dev $h1 clsact + + tc filter add dev $h1 ingress pref 77 \ + prot ip flower skip_hw ip_proto icmp action drop + defer tc filter del dev $h1 ingress pref 77 +} + +switch_create() +{ + ip_link_add br1 type bridge vlan_filtering 0 mcast_snooping 0 + # Make sure the bridge uses the MAC address of the local port and not + # that of the VxLAN's device. + ip_link_set_addr br1 $(mac_get $swp1) + ip_link_set_up br1 + + ip_link_set_up $rp1 + ip_addr_add $rp1 192.0.2.17/28 + ip_route_add 192.0.2.32/28 nexthop via 192.0.2.18 + + ip_link_set_master $swp1 br1 + ip_link_set_up $swp1 +} + +vrp2_create() +{ + simple_if_init $rp2 192.0.2.18/28 + defer simple_if_fini $rp2 192.0.2.18/28 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + rp1=${NETIFS[p3]} + rp2=${NETIFS[p4]} + + vrf_prepare + defer vrf_cleanup + + forwarding_enable + defer forwarding_restore + + h1_create + switch_create + + vrp2_create +} + +vxlan_header_bytes() +{ + local vni=$1; shift + local -a extra_bits=("$@") + local -a bits + local i + + for ((i=0; i < 64; i++)); do + bits[i]=0 + done + + # Bit 4 is the I flag and is always on. + bits[4]=1 + + for i in ${extra_bits[@]}; do + bits[i]=1 + done + + # Bits 32..55 carry the VNI + local mask=0x800000 + for ((i=0; i < 24; i++)); do + bits[$((i + 32))]=$(((vni & mask) != 0)) + ((mask >>= 1)) + done + + local bytes + for ((i=0; i < 8; i++)); do + local byte=0 + local j + for ((j=0; j < 8; j++)); do + local bit=${bits[8 * i + j]} + ((byte += bit << (7 - j))) + done + bytes+=$(printf %02x $byte): + done + + echo ${bytes%:} +} + +neg_bytes() +{ + local bytes=$1; shift + + local -A neg=([0]=f [1]=e [2]=d [3]=c [4]=b [5]=a [6]=9 [7]=8 + [8]=7 [9]=6 [a]=5 [b]=4 [c]=3 [d]=2 [e]=1 [f]=0 [:]=:) + local out + local i + + for ((i=0; i < ${#bytes}; i++)); do + local c=${bytes:$i:1} + out+=${neg[$c]} + done + echo $out +} + +vxlan_ping_do() +{ + local count=$1; shift + local dev=$1; shift + local next_hop_mac=$1; shift + local dest_ip=$1; shift + local dest_mac=$1; shift + local vni=$1; shift + local reserved_bits=$1; shift + + local vxlan_header=$(vxlan_header_bytes $vni $reserved_bits) + + $MZ $dev -c $count -d 100msec -q \ + -b $next_hop_mac -B $dest_ip \ + -t udp sp=23456,dp=$VXPORT,p=$(: + )"$vxlan_header:"$( : VXLAN + )"$dest_mac:"$( : ETH daddr + )"00:11:22:33:44:55:"$( : ETH saddr + )"08:00:"$( : ETH type + )"45:"$( : IP version + IHL + )"00:"$( : IP TOS + )"00:54:"$( : IP total length + )"99:83:"$( : IP identification + )"40:00:"$( : IP flags + frag off + )"40:"$( : IP TTL + )"01:"$( : IP proto + )"00:00:"$( : IP header csum + )"$(ipv4_to_bytes 192.0.2.3):"$( : IP saddr + )"$(ipv4_to_bytes 192.0.2.1):"$( : IP daddr + )"08:"$( : ICMP type + )"00:"$( : ICMP code + )"8b:f2:"$( : ICMP csum + )"1f:6a:"$( : ICMP request identifier + )"00:01:"$( : ICMP request seq. number + )"4f:ff:c5:5b:00:00:00:00:"$( : ICMP payload + )"6d:74:0b:00:00:00:00:00:"$( : + )"10:11:12:13:14:15:16:17:"$( : + )"18:19:1a:1b:1c:1d:1e:1f:"$( : + )"20:21:22:23:24:25:26:27:"$( : + )"28:29:2a:2b:2c:2d:2e:2f:"$( : + )"30:31:32:33:34:35:36:37" +} + +vxlan_device_add() +{ + ip_link_add vx1 up type vxlan id 1000 \ + local 192.0.2.17 dstport "$VXPORT" \ + nolearning noudpcsum tos inherit ttl 100 "$@" + ip_link_set_master vx1 br1 +} + +vxlan_all_reserved_bits() +{ + local i + + for ((i=0; i < 64; i++)); do + if ((i == 4 || i >= 32 && i < 56)); then + continue + fi + echo $i + done +} + +vxlan_ping_vanilla() +{ + vxlan_ping_do 10 $rp2 $(mac_get $rp1) 192.0.2.17 $(mac_get $h1) 1000 +} + +vxlan_ping_reserved() +{ + for bit in $(vxlan_all_reserved_bits); do + vxlan_ping_do 1 $rp2 $(mac_get $rp1) \ + 192.0.2.17 $(mac_get $h1) 1000 "$bit" + ((n++)) + done +} + +vxlan_ping_test() +{ + local what=$1; shift + local get_stat=$1; shift + local expect=$1; shift + + RET=0 + + local t0=$($get_stat) + + "$@" + check_err $? "Failure when running $@" + + local t1=$($get_stat) + local delta=$((t1 - t0)) + + ((expect == delta)) + check_err $? "Expected to capture $expect packets, got $delta." + + log_test "$what" +} + +__default_test_do() +{ + local n_allowed_bits=$1; shift + local what=$1; shift + + vxlan_ping_test "$what: clean packets" \ + "tc_rule_stats_get $h1 77 ingress" \ + 10 vxlan_ping_vanilla + + local t0=$(link_stats_get vx1 rx errors) + vxlan_ping_test "$what: mangled packets" \ + "tc_rule_stats_get $h1 77 ingress" \ + $n_allowed_bits vxlan_ping_reserved + local t1=$(link_stats_get vx1 rx errors) + + RET=0 + local expect=$((39 - n_allowed_bits)) + local delta=$((t1 - t0)) + ((expect == delta)) + check_err $? "Expected $expect error packets, got $delta." + log_test "$what: drops reported" +} + +default_test_do() +{ + vxlan_device_add + __default_test_do 0 "Default" +} + +default_test() +{ + in_defer_scope \ + default_test_do +} + +plain_test_do() +{ + vxlan_device_add reserved_bits 0xf7ffffff000000ff + __default_test_do 0 "reserved_bits 0xf7ffffff000000ff" +} + +plain_test() +{ + in_defer_scope \ + plain_test_do +} + +reserved_test() +{ + local bit=$1; shift + + local allowed_bytes=$(vxlan_header_bytes 0xffffff $bit) + local reserved_bytes=$(neg_bytes $allowed_bytes) + local reserved_bits=${reserved_bytes//:/} + + vxlan_device_add reserved_bits 0x$reserved_bits + __default_test_do 1 "reserved_bits 0x$reserved_bits" +} + +reserved_0_test() +{ + in_defer_scope \ + reserved_test 0 +} + +reserved_10_test() +{ + in_defer_scope \ + reserved_test 10 +} + +reserved_31_test() +{ + in_defer_scope \ + reserved_test 31 +} + +reserved_56_test() +{ + in_defer_scope \ + reserved_test 56 +} + +reserved_63_test() +{ + in_defer_scope \ + reserved_test 63 +} + +trap cleanup EXIT + +setup_prepare +setup_wait +tests_run + +exit $EXIT_STATUS