From patchwork Thu Dec 5 15:40:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895621 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2044.outbound.protection.outlook.com [40.107.244.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 C3B0F221442 for ; Thu, 5 Dec 2024 15:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413432; cv=fail; b=iNLz43A34MaZM4MCQRa1GzAYEbRHQPex4tk57EDMc32H6j7OsANYsPi6xq8kPG3m72f8gaAuV9PC6ZOs/YYoCN2IbXwhzt8zjNtqUg9kY29+dtamHOY9xuBIKSL+PdXYOiklulWU6ZMkK3HLHP0/0HpJuSD4HasyD8P7GQBtS0I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413432; c=relaxed/simple; bh=l/hGMYxsV1+BQfKDPlXhHpfYVA2Zu60ZsNLIFrxMJX0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PfCW4IrgYyWHZC0vXAIA9nKCoR1CWk5A8ePaLjF8hgppKjRP0Zlb38lmxcmWYXydxlkO7f3CKEXhwX/viVG+W4CmsJcNlTzx3zcyEAPlCHjasaKXivNOC8OB5XzHFFoIJU04gVZA17xDgpcdU7QKhlKpIgkP/Nc58HEJLbauJvk= 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=tv7W9sEo; arc=fail smtp.client-ip=40.107.244.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="tv7W9sEo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BaGpe/i4pMECYMGwT9ofYwoWMcNKOS+hEJ1A35eMnGuP8uJq1HwFoeSFN7uQEXXkd2WozI7GlWfIm/GzzK1+PelqhnmH+4Q8CkWf+U73Qa+rOAhPVIBdlx2nj83ldJYK8V4Ha13KL9k0gom0ubhq9hWeChH3q5NYhNY+qW7JECV12OyyHXI0Gj17cLEr9lSspRLac6rdfSeQbV7BY99xdK2W7a5l+VRCHqC6WRsKZHS/5Aji/RAdkBRRYCBE0vlCGjS+vCEgaF4pAAgp15uVbDa3d5ORiQAB1Eq5LArhhEMoKLqueJNF129sr9NFCjBE+tbsgnz3zss5uAc5RMzKeQ== 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=JW/GRYfLFfomW7u06CId1bfH0ejF+qNwWhOq5l+KzwE=; b=t7PLjpsCqGxWDU+NnEUG3wXptU5/uR0KoddvvakgvO+aQVySyumxLz3LjylWC+4QKne28+kfKJK8Uw8f6HAufGmYWXX1Tot9vrMA0ITlc0NZiV03AOdf+7VafRtomgMSTccOBgpDi2EbTrwgvB5GGG8CTOVsgZBXuy8/hBQVDMY1TDzpSKHyuNWSMuhA7gjyLPOKtn0iaGe4bwSWi8IzWyK9m4V0l3EGct6YXi1zkRILVpEjNnpKpMeRLPjB61y6NAwpAQoKzMOI49tcaU9e3ghAFRTOTsZLQ/iSUA+AAMGRDJJkuaA685SnIQKWCIH8Vr/N/ovVTvc7T3MyUqh/wA== 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=JW/GRYfLFfomW7u06CId1bfH0ejF+qNwWhOq5l+KzwE=; b=tv7W9sEom3qTHlzjIBFLUW1vvKtBPFsYGAOwrp1oqbIVPdu5jjT2pynVsexqaQlo3T3h50YhheupjAVo9eCKfXtyDjgTSuNUlqFy9qlOrFODFRd4V145GIxt00bPTLCBQxTs51zPQeuyiOrg7VMu1HjSYpWSW3teUsmfkJIxF2BqDUCbeiSRt3EP89T2O5UWg/lWlus/P4TzeGiBV7JEz+MUvneZuytV1xYzCHlX1Np3HcB17IC+3ofi4YWw2WFlvOiSGDPXiwA09eYZNbmXhpqvEkLBwraesaDX7L/Nk3F5qq2WX/vW3LtDel3YQuc+8eXTteFfoDsaHdRB1cLYeQ== Received: from DM6PR13CA0029.namprd13.prod.outlook.com (2603:10b6:5:bc::42) by DM4PR12MB7719.namprd12.prod.outlook.com (2603:10b6:8:101::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Thu, 5 Dec 2024 15:43:41 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:bc:cafe::ca) by DM6PR13CA0029.outlook.office365.com (2603:10b6:5:bc::42) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Thu, 5 Dec 2024 15:43:41 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:43:41 +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; Thu, 5 Dec 2024 07:43:26 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:43:20 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Menglong Dong , Guillaume Nault , "Alexander Lobakin" , Breno Leitao Subject: [PATCH net-next v2 01/11] vxlan: In vxlan_rcv(), access flags through the vxlan netdevice Date: Thu, 5 Dec 2024 16:40:50 +0100 Message-ID: <5d237ffd731055e524d7b7c436de43358d8743d2.1733412063.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: DS1PEPF00017095:EE_|DM4PR12MB7719:EE_ X-MS-Office365-Filtering-Correlation-Id: e4dde673-1a1f-4c61-7dd0-08dd154397e4 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: FeMhSmeF02TvsWwFVLm58wuHmmemyjwc3aBDAsvJm52YF53LtXt92dDk4GtpnPcQhGUv+oxe+ryapOT786h/J92GLQXj7KDLQPewtkydJidJqxd25+fFM39QKMhR5nbpk6/ODTbhIz0oWw4KviEWxZWX+IOcNZfMCXh3gZa+kZPq3qrQ6HwoMZ2UJygMBnKcBUmMxKxpo4T/eSkRmur04hM68U78p/WYJVutf/HpsWQwlsn3zSNnnEiBZZK94gOa+C0ou1VdNYR0m5ksnfVi03i5xY/W/NRgenn9FaktO3r/KYnwD/3eMBRWozSmHWRz7jARu+OWrjfDOMj96NOcBWAlsZb6YxaFXv4yu4Wvx0t8in6a/ACqUyU7Il2EYHTAVzxfz8b7oHWIjY4HmYkqQM2XVIKzoAQSxP2puSKsDe9ppHWYRNP33rMnBUwd0X0Lwh1uoE3DoCP/TAa8vA1Q6juGoiBSnbXgfTqWb4QiGng7B0SgYW5PpqVTw/asz+35dyDEe4914LaNqmDVIxXMVKOVaYzYEe7h7Ha3WC3I7kbTJTpRN/lJOyXSczNtYu+1LJB/zhzRxSk/k8jUFic9NtcAVuLTyCmvgyZ+pgxHobzeAppc6LQ6VsbNCpmstuFSZuVuJxFqqEWqxn0/pqfYC/L/x1CuOwYZqIh2tZNFBusycZDon3kLkIy6k3DJSM7zmKZGSBKiPBASoT01eXD3Kn/lsTW+lQucLMNA2KCfesOaq++Z++ju+59o4kIXNhWnYyHFv6VOL+gsiB21IV4fR+QF/ORodzwpNfA0Rmyff0Bq/o1ifSjUKRJssbe+ZlMhQkwoaXO6VEtn8nO/SD6D4IqS/F/LxwmtJ5awgcllxBDJPZhSrtsbDf2EWb0SIRrbOY8vqP4aMfxZk9b/iOV+1Fwk9lMGKQKLkSVKSS9y0aJT2TadVUW+UflOnefzH3VUiVUAIGAxSR3GsvDNVBOd/3t/o9AKXJPWTYyOkmIdipWqzvRCs1/xBRMeLpIKGNPNuBspO78sLq9qlA6ZYf6QfDpfTV3vRMKn0N1EeITE89F0yiX0IBfYH80gnOriN5m7mVuzE9AgizTokVvenRa7L4tq30AOm/k64Gh+PANi2r8Pm1r9i9strOEI+pJK5O6OqfpYhR8CgWWjywfK0sm78YoGZJVr+dAZFNw0FUVRLkilITVH+H+fwCD99bnmKXsE26XR5dYb9MGb15otKyo8fha+EBfGlARh1FX0m3zsQ1FEDTxwtcU7/o7C5SZIVjDd377UZO2OH/PlbdLRY9ihdCo4qKKH+SvyGHx/w1vaZCYBWE59ua1BxKTlyTjpZf5B12KEsHrDrbfZUBG2qJhBjnIgXr3ttz4W30X2rpsVvlsmph178jXT/9schoZswx0mgoSC7FpA+QiPINxcfWxwg9cMq+Q0nVC9HvsokNvNGf6jH6EhHxpes9Hi60Nppxqa 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: 05 Dec 2024 15:43:41.0242 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4dde673-1a1f-4c61-7dd0-08dd154397e4 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7719 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- Notes: 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 4053bd3f1023..d07d86ac1f03 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 Thu Dec 5 15:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895622 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2063.outbound.protection.outlook.com [40.107.100.63]) (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 BD0DC22145F for ; Thu, 5 Dec 2024 15:43:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413434; cv=fail; b=fzgM0YS+LfWgnp8U28N9JXn4kzN7mkKy9rqjYyBjRGz0SwjGkbvY/Rq4Sr3uCq8N7bRQZGSAIb600D4mom81SnixU15+WBBkkbwYtYAw/FVqMF+fxPBL2E7+XljUMNDH1iseLMmbGdWMGsEmCw1AcVvmH9ZpnrQxTAWgXVv7BoA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413434; c=relaxed/simple; bh=PLEiiCE+bz4j72NlZOJc9Gu2rnJa8CZq/6UHEUHmJ5M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CdqGPWEFf5UZm0vdDP6B0QvSl+K8yHrnheVxe4nzyBniW/bCQYHm8bFVf2ZJIGobgebShY/1xYTVQG3Jk0eKTzBa50D41jrup2vjnMiIgF/TYKo72MIWnVyQbLF3n8RhK1h+xQ/uphV1yUwJDEgcSgPLNZiszpoF2bz3J7VOfr8= 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=YaoO7nko; arc=fail smtp.client-ip=40.107.100.63 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="YaoO7nko" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rI+mzoIswI3uN7HmsZRPKEVNuIE3w4QL4d8ZhLNUooxol/dK/RqpRI+P5Hruwg+ImTjWLMgn6Epc5t7bK/MLuGzsd9XaMc12Ah66WeHGuH9sA6qr6GQrRFtsXIHPEsxa8fHLOgO3CNt2D48XDelQjaRTyIFSi9eNxU7A01LpKf3s2u6oR2E8nUD4LW3LXW7Ob3vxYLccVDTDUNRC43VTZp3Xo7nUBhv4MtbRJYZ46o8tXBprSyqwm0opoxCzn0OxCqRCKZQ9mmTvnWr+VZAjjm1c3HGwbv3VRT/Kb6r82fal5j6Mrtu5AjOAjaZoICTnhc5YspPHS6QZe9/aJ5Hrrg== 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=V7uI8ayAsjgSoxg5qjXbGiIQj1i/+fyIShFwYiV88a0=; b=Sc2OwIU0SqIoANRArhKK+tLLMQnfsHGPtS/E563hZq+0Eku2qB+GC7k2G5l4SjqB6zMF+aZUE7UVm2e4aJcExqocVLGv0IIZiFZFp1Y/ZKZMkQx8S1VcvsEKx+R+hxp9F/g1Y7VgY3c0/osqNluN6EDn9C3ZK6u92iBkJoeblWp9x6IMejjFSm9aTWS3eTSh34/h12r24jYiUEbP3WsbGIfuKpg08lPhJKrgCby2Fc6LKVHQMYHQkfjEvqHhBIf77/BImh8B2xnMOiVX98+iBSqUtOOCP9Y84XgI5X4EmfeyX4PBzzuU4cWAa/ysjXPe4HjAKfD9qb2MWhMgJ/GiSQ== 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=V7uI8ayAsjgSoxg5qjXbGiIQj1i/+fyIShFwYiV88a0=; b=YaoO7nkoFy2kRcou+TB/lQfnea+WgYmVp/oCgW+4XWaSNd5g6vSOT/7Jov94LdhCH1JMpT+yQ/zv5rdIGy3kuhT4vxYIXjihg+ZMI5BCtiAOAWWU+ZDqtUH2Ykeg69CAVt6UfprX1Z2XbQoLfzre5TLLusdyM96gTuJTuxarYxfwVitkBySMf/JVMec3Oh/BLBIjtlMSKVDa5Ckm7w4W/LRbEPolnLaVBSdpSBJb9UlLUlMtF/aCzXejxDDtqZMJpqDHhGZ4hTiVqkg6Eu5jmP42laZzbZ8M8K43KpIJHvlxRaRaX1P3HK7r4yQwaUhfdbCX8rVH/PbFO1lWQJvF7g== Received: from DM6PR02CA0115.namprd02.prod.outlook.com (2603:10b6:5:1b4::17) by IA1PR12MB9500.namprd12.prod.outlook.com (2603:10b6:208:596::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Thu, 5 Dec 2024 15:43:47 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:1b4:cafe::a0) by DM6PR02CA0115.outlook.office365.com (2603:10b6:5:1b4::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.22 via Frontend Transport; Thu, 5 Dec 2024 15:43:47 +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 DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:43:46 +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; Thu, 5 Dec 2024 07:43:33 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:43:27 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Menglong Dong , Guillaume Nault , "Alexander Lobakin" , Breno Leitao Subject: [PATCH net-next v2 02/11] vxlan: vxlan_rcv() callees: Move clearing of unparsed flags out Date: Thu, 5 Dec 2024 16:40:51 +0100 Message-ID: <2857871d929375c881b9defe378473c8200ead9b.1733412063.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: DS1PEPF0001708F:EE_|IA1PR12MB9500:EE_ X-MS-Office365-Filtering-Correlation-Id: bd09eac8-f1f2-40f2-94f0-08dd15439b38 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: G039eePqndu9ddlXHYOAdQBA2WQrXRMwR4e2YGm6W6sUWKIyLi/7XX2aXMoZlSww8MJz1GCNe2GIGQeRCtAlpg1xlEq62p7Gh18Dttpg/s4ey9+TRlu/wbjPW8PfY9phInCFQvvAsy/oDwrWkvsucju2q4pXY0ky1CIox9+k3vgLmBzK3WLoIk4SUBuf5R2yAcEJ+cK3lasgnTFKwtWOWAbCRUMFFCrBtJ37zZZPP/WeoWnU0S/s4IK9MwVTMRwZ/XzNkYE3zh5AMZ9xi+1+CDSAD5LQccfsdctnROBqlS890f5enOPZh8CVvXitarDFyhkOj6klJJwQsCjrJBKN83jSRrCFfrhn7vPjmpqT9u1rJ4fEDkuEinkJaizQrBgY8i97cB7xzKaZUGNpIlk2oJYjIQtvb2h3aTIC0gUulEw1CMHfB1bMSO05MX5bIxAXUTolsmLFJUauP+gP7HxkpwGpOxURkfKtlwv+xYlyVLkVZ2mtY4M3lB+XSSbhjE+GW4RAXIG7UdE30yy5HRBQH40v75p+9H+FnvkDt/IzkcwRhN9OBpAqvjIQuE9GJPcQj0JcwX+k27kIpI4r9tCk5vQAGqRfgSeCwrBpGKK7hQeclnZiFqAEMCMgKxFQp9FI4YKBRxDUgQEes7P//WSf3gYXYtVmONy8mQ6KM9WjhnDCpmBX0R0uMVrj42LYN4GrFP7Xv7AQtsIqO3GHFMl3cbSRufwuRsOwPcejtVLECR1o6WWMvBjycLxG2XV2Z9sJDkXLag/TErISlO8IxXk3niJuAgVHLmma1+lpyE5uUFhP4G7g8iRP3H/uXlUrqFT9D7ueGh04gCmH4DnBDGXg12abWcHqboLf58YaNS8gOBJO/nPfQNW53DlX3zfkgAlCfM07zzq0C0txoJATQCmMyS2v0TeW+qPrvQssvyUOzKQep6rK7+ZN8WoU0Zy2um+PwZ8oMCVEvKMzc27UEgq9dvM0gE9259O86kU/Q0CJhKP++yt7F9F4bzADMd8h2DKxLCYp6XFk006Pm4qbHiMtxCyzZYevFLQQaxwTR8YKTuOOpNTLqLKwy5pH7u5RsABJLTosR03i/Hg5f4zeIb/4VQnxaWPtrpBgfsxO0x9SoFSfWaWjnNMkC+NQLJNbEsntSP0LvMm5Bv9b/FAX8TRUDSvr6uYLz7E9nyQTDC0ustgc+ui3ElqStSmh5o942zyepg0rrlcsYD+F/yZ4I+RGwBITOresb8avLRuaEjF59kU8tlaPh8YdparTIFtD5CfEYg9gKHaNv2uyJp2XC2ODA8zczH/Oek8DN7KzoPSveQ+P+E78uILFjEG8b2GcWI86Yy52pYmSSLrSVbORkZNifpz30ZgLTRIpNR4xhBHCU6I5FWt70wvKO+yOf3tDh0MBw9hZtq7dlE9Fr364h4pG7wsjqjRkyj4ceTHkVnePJuVvYa9xQAjYcpu4vGYgUgaL 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: 05 Dec 2024 15:43:46.6240 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd09eac8-f1f2-40f2-94f0-08dd15439b38 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: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9500 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- Notes: 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 d07d86ac1f03..ff653b95a6d5 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 Thu Dec 5 15:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895628 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2047.outbound.protection.outlook.com [40.107.95.47]) (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 6D0EC22145F for ; Thu, 5 Dec 2024 15:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413442; cv=fail; b=DNo1MD94uw6HmQIexXEUp4w75qBA9T4dSDtsyR47M2mb+ZabJXnJnYWw3DeCbI+igvvstvhDpBpAXFseSOkEYOb2zMvF+SznBhWIJNhpJELi8l1tI8g5fVrjsxXAzrOLXmK71PRFRG84cD5GZgsx6sGX9QKTpympSWqgxXEQEq8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413442; c=relaxed/simple; bh=pYQ0hiUONS+43/z9LeVyuG6wkPCtiOF9M20tP43y8h8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KPjPOV5Ni8Xmqjmq4S0Yw4mc3jKO4po3emk+9Y2ykib6x3Byc3L0iP/ml1WkUz5tBsocAX+7rjWwDZ+GpjMdq24fBci/6YJRotDZ3n0gGcbWLJ5tcbF31VnU6FvKliWQpVvT73ZB7D+sAJseWLFlds5tUHJCLtJMTKEqhW9FZJ0= 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=DEaHWapD; arc=fail smtp.client-ip=40.107.95.47 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="DEaHWapD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M7ZOvwmRBqia2v5Uu2w6aUyoBompRZv7Ye2lntc6jOQFHO/o+myd4WkoqHZl2onSMGnZYljFyiRayx99vGyezhDKV+LIrNHxUpEyzJOXvp+plf93to1EwGIoajycDUZCWUS2Nn2ESOjQ26jJMMmFeWkG6r/KGLvD9zNnHBx5h7bLVdhCHZenBenmlQk8OIaS1Zks7SqH/GNXrG1rTtdGgN7TGShZ4URU+id2CAfphXSXrvIrBoxz2Rs2H4k3hr4bmvbyGEoqccigfo9jAOY5BjoJ05OWR1hYaAXqrTwVbi3xZBUcJPRc3JWWuRw29qr2I06lN+xZLkKt5aPc5fqlKA== 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=/aesXRIBUtgBVqKpT46ya+61/FvzmggkzBKAlKkZqGs=; b=ApLB0Aln1Zz/KuoDRdkkHhIftEwzT88bkI/prt9EYqdpW+ShyPuSsZHnccMKtXjChbKSl+30uwrVwu195s8nii9aU0LCszIP4mAUZg4HCTiMfjoYGPox8M2rqnYldyvM+bELBYLYbvgHM4q+Wek+NbIJVWTz0GU0xcGQURvTqypjpEdh9OJlihfIwz/PcevocVQ6xyNmkebmzfhBHGMMgowa4Lk2nXPfRuYNmP2fLeOPxFt8APCP+j2dIsQ+AN43wYPCE/ptKChjSXkUrwPRUugmhVx6GA0OVqBauhZPZFoNUfWukifWVpxilTO/ZSvHZqNBI4dWKTEaviYRcc2uLA== 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=/aesXRIBUtgBVqKpT46ya+61/FvzmggkzBKAlKkZqGs=; b=DEaHWapD74renUmdW/gRBlzmi1mWfLLChKFg2E+M/FqIFvayzabnQFivuzH/ybs0lhWQF5e61BWiuyWZcPuZa0t7f3C+PFVrvZ5qCKxbVd+zAu1fuA1RHSB2QYULWgSPNK4n6c+i+i5TAViehAgOVUO2tUtkczikYQCwmhO5LF5cgImeuVezMY17MfzytoQna/BKzVT6YNZzGVvXphu/nEZdm98XVsCBiNHdL6oW1D3lyOWOlXhEBw627X6/E9uIQvGjGJzrWSLQa5H8+0FFwUlY1g8KD2uPg251Bp4T6Jt6oEMH3KlpzooSK5LqG5KhagnTY2nWYADQi0OGhtXpyA== Received: from DS7PR03CA0040.namprd03.prod.outlook.com (2603:10b6:5:3b5::15) by PH7PR12MB7307.namprd12.prod.outlook.com (2603:10b6:510:20b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Thu, 5 Dec 2024 15:43:54 +0000 Received: from DS1PEPF00017094.namprd03.prod.outlook.com (2603:10b6:5:3b5:cafe::81) by DS7PR03CA0040.outlook.office365.com (2603:10b6:5:3b5::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Thu, 5 Dec 2024 15:43:54 +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 DS1PEPF00017094.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:43:53 +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; Thu, 5 Dec 2024 07:43:40 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:43:33 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Menglong Dong , Guillaume Nault , "Alexander Lobakin" , Breno Leitao Subject: [PATCH net-next v2 03/11] vxlan: vxlan_rcv() callees: Drop the unparsed argument Date: Thu, 5 Dec 2024 16:40:52 +0100 Message-ID: <5ea651f4e06485ba1a84a8eb556a457c39f0dfd4.1733412063.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: DS1PEPF00017094:EE_|PH7PR12MB7307:EE_ X-MS-Office365-Filtering-Correlation-Id: 705dca1b-2aa5-4047-59c1-08dd15439f58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024|7416014; X-Microsoft-Antispam-Message-Info: s8TB08tQayawReHVzNhMklAcOnDpW95f+tuR03B1x98bVL9fJqqZqDHMFx4xCPXUStls3XreTzelnD/avhxBQGu+VXb7ooKRHaC0hiDQ5mtq0APQxdjlHg3DRVFqLc8jmYzDUULjKUmdfcS4kBqsUsBROLrrb1642lxT2DCdgH0by4DVTe0HMrCUEjxniU9CKk6T1yTbOQPeOL6G43lpbI3F/WxR4XhTa33/gr7v6cqtlTrFAi/LeMHVAo4/ZeukW4Sl5+HX5Jeh1kNgJRyhHgGM8RjJjExY7wguAgJGa7PXqbo4LXHqxEeOgC9SHZmkBch6Xj3Lih4AcRj3Upu1TiwcdGvDDRE5GAfUc1T5MVBAgmYEze4ILwKBm98mNJRx1+7SJqI0jzDf0mKjE4ghPbVYuQaokN3KXReKuHbLKYZ+pl4rWUc1IDLLdwjJA4HNKqnh2/k3qFtludGmZIIx4YuNjlpVhYG+6/nMSsPb1QYuHL5bH++VwjFUptxm7RQsKxN9b0xfJ2n6CtLmb1WJC+f4jysxJKJlmzpvmKq+vBTaQzzZoGUsvAvBQe85te2Rl/GygpLMTSqdp9drnfM8qmL88TN91CoyS5rEJcTAAoN08TOLHUsn5acSr69vxIoQSliobFbLKlTFp6OxhOozNNdGoMlZcsSm2lGDZXAIJn5/7/mQM6n11Y6J3XvU6x9NRBHQQeeJGrS8FM1f3B5DZDZfcHP8oHv+2wa2LkgzjDTb+0yXYwvAvxpQFjAIPe6BwslrbN2rnBeMcic93l8EaO7XQOt1E0tmGsTZ73oz6CQfNX+zpWXNoYrPjLyyie1RdYMRtURYd4kJ5xvuXDF/KLEjGAaKSCFLzMh9MLeCNNFyKz2GaYFKbZocXQbUiYHleBvtdlo360S32Jh88EpiMz2VPl323w9Y47U9TQJR0AKpw+gJDZJTE5YQqKzWWYnAo4ENIkbOxkhwrCbqQh5JKSpN1rDthwgSj4RHHK83sCOBs22UYng7zuQVVMF2TViTk2d1p522aDtdcXl1ZdBw+HBkua0K04u83zqWJ0orPfCJifNahLlFha6HejRJ/TSa+EPpWZgfeOX2BucJNsbsVd9egfrlqdyo/Qq7Vx8C8h+kocXoHgQimbVgBEsKIlQaRn4YtGUbrTECPbMpYMuuZ00QJ8Sz0CSLPmVJaGTrACpnALKFjgbHMjFLoVox7V8MaC/73j9LfsuZBQ0dXGeTM8r8MmeTc4VJMerr1r5zudlJF8+1X63mazy1kFLoHcA589DWMOgqHXBkWRpdBrLjy7+cLCkwrRPuFvWp7Om/iF+Orl0sjw1cb3RZDQAtO91XLV43v4IQ+du5tGfprZhBoxlBRFJ4BdCBbJIqyevzhy78c1+uReZm28BWVne+2nbFmBqbfnxDfRSbAO48DKXU0CsqbNVNfX8FrtVfIYt35pHAUlxXw5S3a1Ps+C40k8Ez 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)(376014)(36860700013)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:43:53.5275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 705dca1b-2aa5-4047-59c1-08dd15439f58 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: DS1PEPF00017094.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7307 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- Notes: 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 ff653b95a6d5..4905ed1c5e20 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 Thu Dec 5 15:40:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895629 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2072.outbound.protection.outlook.com [40.107.220.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 EEEA6222568 for ; Thu, 5 Dec 2024 15:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413445; cv=fail; b=Ewf1AoQ7tYYxZlIvvqwu6DI+df5Sai3vysSPJYZiufU77yLtWWVxr5Z+WQJaSQvYcMZwSEqePcdEF/daCRIXs4/zhK5qghRLKLvDOsV1Yxf+3BphXxHrCJ5ont8HIU9X/QNj9zOoHbu1IFwOb3TlRjhgQZZKggd80gACngAgTII= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413445; c=relaxed/simple; bh=fl9ReNOQ49ijU8XnRf3AgHatzeL6YYoJ0y4O95CUc2k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=byAl5Htazm5h8sCaNt4N10VFKozKXYNE9ymIFh6wMK1AdsQ8VLhUQw2gF5O5pxuioT+U3f7xUvtha/ZGRf58/uNKKjGGFEvjzukY4H+fpkwoet7jJl/pgzHFdqj/dSTK5LTVvVqEDhZ4RdG7YVRuOWgawYmBPFhlDevml+m5os8= 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=upViCKvR; arc=fail smtp.client-ip=40.107.220.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="upViCKvR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DTEqReG5zhy1P1WVGGzqtQiDpqp5IcMPDyJnPULpQ1y5G6/aCHRS7/jJzhZBWZFy/QXaWJ0cnjcE55b9VKlLpeIh4RRMo7yeif6DMlMm1D4+qewVwHhQUkYBLefVHhzHVIuETqQgleTh8BELkq/eCAdt/Hy6xK8ylrNQJW5tLYxaaSSI71J3Y5ZtX+oc4ePU7hphjC30YDoyuSXgytr4vi0/5hjmObG+pk4MBudLnmRNZqg02D1MmN1Jc7MfsH/1kSi73+41bnKK3ZEUWCPkeo3gqvWdqxUUMCaG3msXgD+V6wym0RpNnLXeUrsSW26HbnBcy4P15+L5j1H71+ThTg== 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=NcwhpM17a1BbHMHgsknwcWdF6ZbnNiXn27D68zYlWNM=; b=y/UCRybhmioICkKFpIpKCT6MungAd1bd4QmrDjBnGU+bpCLNaMWtfKGpGXLM44ezI0SF0aTBqSqScOv0Vfss/t6REgUUcP55C+5JlTiNxsnodFjUehGQZdstO1KSH/P5m0NUNqIMSd0+5tJencHZfIlEMiw/7UpZR30APuyv84iqFD3gGGgquqdNaRnPrNLGmwxJ9IEu10zx0oeudet4o3BRgbXeOfCOZPgnM2efK6Leu7ksewkugnRctEiQcXGmjVqjkHa2SkhInol8TCIqQYxeZW6iBGcFmpP/sp55EnatbRTN57y5BReAYG8apzmUN51ggTD7IUvfd3t7jlsycw== 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=NcwhpM17a1BbHMHgsknwcWdF6ZbnNiXn27D68zYlWNM=; b=upViCKvRaZp8bEDQuIndKM1gJ2AFX3tXJQ7RfIBYvl55/n61aiLHxec2bj7Vsn5F5xE4RYaRX6AFoOzBeGCm87aXsRfPNO+mCDgcRv1+Hy5NFMxYwELDLA3QOYhqIZEg0H5U+sT0HPitV1M3FWBU0lyIiBHMaB8e6QKhE4DoHMzulj7QZsdG9VNVbv6n8xTndic2EPLHgnosiiUkmDbzbJBRSig6xVVlegHc8oeySYwHzZUQjPa7MGPLfNl+ehhroCsA7FRrJ1AwLENElF3OEIZYoFCCg/FOng/455Aw/hYN62GcvnibjYqlm4jW08qOlPkO+bTkh5HoQOJcJ6VCEQ== Received: from MW4PR04CA0334.namprd04.prod.outlook.com (2603:10b6:303:8a::9) by CYYPR12MB8891.namprd12.prod.outlook.com (2603:10b6:930:c0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Thu, 5 Dec 2024 15:43:58 +0000 Received: from CO1PEPF000044F3.namprd05.prod.outlook.com (2603:10b6:303:8a:cafe::70) by MW4PR04CA0334.outlook.office365.com (2603:10b6:303:8a::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.19 via Frontend Transport; Thu, 5 Dec 2024 15:43:58 +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 CO1PEPF000044F3.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:43:58 +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; Thu, 5 Dec 2024 07:43:47 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:43:40 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Mateusz Polchlopek , Menglong Dong , Guillaume Nault , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v2 04/11] vxlan: vxlan_rcv(): Extract vxlan_hdr(skb) to a named variable Date: Thu, 5 Dec 2024 16:40:53 +0100 Message-ID: <2a0a940e883c435a0fdbcdc1d03c4858957ad00e.1733412063.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: CO1PEPF000044F3:EE_|CYYPR12MB8891:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ff56120-55b2-43bd-6e49-08dd1543a238 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: gQ8Zl+mdNMjGk6bMYMaEVr9gBXS7ux2bspArs7t1tLm45lVXhkoYkz2DOUNGi5ZJnW6kUYGsSdmILGnRkrVXGIvhTMYvDLl3M1GXHPHPyv7zR9ANkZCfczQXA+Y+akO7iC67K60G0c+luabL94rAGuQ8nduzYkPzKPHysexVzLj4x+0qwZ9oUAVEVO9yA1xIHPj2RXplQWrQ1P1CLeTLCi/oA9RASx2mygjsm9dhINfEpHqJjtLcRr5tmVU/MDcYCYwDrYGL+0rxeIsy88tE8hk/wuBqTz2M82aEPBAkb1UeG7kijRXyj7ugJiNFup32qgzrXUhbx00rDtL2jV/Uao5dCJYi1V8fok9gqXoS3bThKDUG3sUYpobYdCCPRu+ZmyD8s+yYckoZ+0rMFknT2zyXNic9Xl+AA5Wr+WCkMCRIRMiKneifjVFp9a8PSO50n5MNTOO1crPATQUr3AtdgPVi4Xmt1ulpkJF8HHrev2tfKgCrqVyBnTfDRsMycc7CK9CnfvgPTUAhomw/8A9Su3FUtizehPI2GZ3DTbK0S8Tx5yHgI1iNPPaI3ovBmKqpgAH3sCqy1Cbelxir43wqXgGmdk6VceAtfLdB68ImEkb1hvoH35IwCxA8+GR7HBESi3WuLvhtwdilTVuZNp9dbS1lTxBLUtaa3NUhHMkirFplqpcT5w5mWI3sQONw4h6jpKEqGGQ2YIwGpHH1xS0/WPt5REPvfw1eUMrhgYJR5k4vm3psQKaf59VNRp+yVbYkVTwjFFfbTjPRJjijjAjEGMXi0tQmGWzUaz4ywH8CUh8/HGYZf33nLbEN3GKoSqisCLhhDBvGNh882k87bPKrW0ac5HshJ2y4FAgnFJBzCQ1AwojbcSbLGgciFopFDZafGoq0qTIjTItfKbrcM6124wz6Q6YxXflDMDl2hsZxEBOd4t52cBR2M4arr/WGcyXsYQu+mGuVahOQhcL/SLNka0nvRXelCgCDSL0wVcuJrSUWM5Z3t0l1HLsgkjD086fh08UHWjipMbNBl0D1cbXPsf0EHfvJn3AHFp37DnzY+N3w0eE49hPZ0ZyYBDvTJD9DQyyXVvQuUVgkJpIx07GUQwrVKrPSK/be+F6OGZ5zg5Gtg4F4VYiIrfYVnHCOE58vnfrKSFq7TQqE4UkOS13EfpIEM1ziduDbjVha44xZ5hYFONg4Lu8mgzpupyValgPrw+aC+TMxTdJ6mwXBI4Pw0ihClWsQLJMGtfpBQItSrr0XXoqnZ6JUfR6+s/JRjQUziec5K8wHNtXBMhLNUYbI5v4wAmUQgMvcdd9awtw9BPZegPMwCCbmcYYzr5rtjRx/0oR+b5FnCXQHZFpB8Qi8a6fwI65dAxNiPrNjWISS5T3Ae73YNW1V+UwsvSUQwMk9knkomLrqBpSp7GELp1XwCul6AUBKPt6TlKHALDOhC16zG6mAiyq23D/ez7SsQ0XA 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)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:43:58.4609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ff56120-55b2-43bd-6e49-08dd1543a238 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: CO1PEPF000044F3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8891 X-Patchwork-Delegate: kuba@kernel.org Having a named reference to the VXLAN header is more handy than having to conjure it anew through vxlan_hdr() on every 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 Reviewed-by: Mateusz Polchlopek Reviewed-by: Nikolay Aleksandrov --- Notes: 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 4905ed1c5e20..257411d1ccca 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 Thu Dec 5 15:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895631 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2048.outbound.protection.outlook.com [40.107.223.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 0725C222574 for ; Thu, 5 Dec 2024 15:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413461; cv=fail; b=CEyzXjj7huZjb3YkNjFCvC9Xl0WWOiUQWM66RQ6yfjX6O/Zs1reQ55Cymw6jkeAqbNNvJeA1bHVVyklVydDSiaPI1Hi1sV9d9auU6gwesi/TtaMzeOJ6eer0D4gemSIPiVs3wvS7+s4KjlT0MdYERPtQ450vKrDt5UDsf/A4sVA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413461; c=relaxed/simple; bh=1ku2EMo6yMHEg5+ip+YnpKpoWv8rx2QkdXEUbVgim0Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iY98klb6o/a2b7J5LzbYDjmRZa2rkU6eK7eeMM4NQJIjlWJtWnypVG6zSKh8HvD9KXAyBRd9Ucvmwg+dWDRVjDwv2ajteAyWVGQJF/9f89FcYUOcDtro/kYn/Q6+lpgilg+LuMOp+N1v3pVEQPVkDBngFlPIdp7QIQzWoZDYnTU= 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=kbP0+n2t; arc=fail smtp.client-ip=40.107.223.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="kbP0+n2t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cJ4KfzncYuTWiFNki2nhdoMsK2RlWLuJggMVdKasRWa3pTJTXFMOR6ubxDpWnAYNd3z5qxdX8BWoHkaumziuWcDwhsVZSeH0eNGYCUXfKTnREEd/o5tYzOb8dJLd7YfOu2QpUyWHMmwDFAP3pMVNnpM5cIqPyE3JPg3FFbtUSiVIJxZHM72dnF9WjBOUxHesTbttjjo59VOEkyIVkr+6WzeXR0z89uV04c2Ln2jjBMQ9M78e+j+UPccsQZOVfAU1SXwAffY44sPtOmOTqRzcibhnEgu3FVY2hhl8lFDGC2Caugm0V92FJG+cw3OucAPLILqB5SBXwtszUSv7bdurMA== 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=gO6UD/APZI+e8FHC377Ht/AVvyYItDlRhst5ibeJ5z0=; b=v46jRbvp5Cim2Ywn3srfk3+HEfVroK9fMz/uEOIaqf5lIFFEMWE9PTqnFLv4qZ6nVBwkLR0Tv88+pIpsF3w5TLn3sAJv+BTH4HC8hyJR18s7ztDN7c3g2jHLredpwjDpvC1BlIn2kW9wH5No9xxQGB/CUwJJqJCUoG1xvV3zngSOAAUopVTJMC0SFgDdOahzpYhIfidzebKiEPS88IgsJ2+LgfkSXB/0eNr411+Ui033b5iMVYmrXf8RiCNyndkufsdNew9rr72IOazFIpCLxp5cyLEB7AJtZsbj+GdAgcSfptdFqnUAGrtR1/bmE9f4l70dWhMiLmMrpkqmuiEzYA== 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=gO6UD/APZI+e8FHC377Ht/AVvyYItDlRhst5ibeJ5z0=; b=kbP0+n2tn6MCFRbIv9ANPUBL7f0xUHHH1q41nPbEfANz54rr5TAeVc266tPC0UieVBV76YyhOgKK2GXFZGDhpm7qzKydx0aBF3G6CUaaiYb54oDyT7TYcRigRFL8gVSb1BwAOMwaS1NxVa8bYKTriAKYH0F6YSG4vxlkQAvUAYbEzjP+7MDidiRw/nLdTVKNEfbmwwIKQ5ezF2IWMWs0+Rne3sa4mRDQg1yWbXaouTxjoy8G6OHaGka9E4yyxPfH50Mn9lYhTLuSPfYgCpFHRCUFsVOuw/65qnzDfATMI3PxqjtKiZILdQbQ+4J1yhu4So2qBxBXdxvErdUbXW7L1g== Received: from SJ0P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::31) by BL1PR12MB5708.namprd12.prod.outlook.com (2603:10b6:208:387::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Thu, 5 Dec 2024 15:44:11 +0000 Received: from CO1PEPF000044F0.namprd05.prod.outlook.com (2603:10b6:a03:41b:cafe::7b) by SJ0P220CA0011.outlook.office365.com (2603:10b6:a03:41b::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.21 via Frontend Transport; Thu, 5 Dec 2024 15:44:05 +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 CO1PEPF000044F0.mail.protection.outlook.com (10.167.241.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:44:04 +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; Thu, 5 Dec 2024 07:43:53 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:43:47 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Menglong Dong , Guillaume Nault , "Alexander Lobakin" , Breno Leitao Subject: [PATCH net-next v2 05/11] vxlan: Track reserved bits explicitly as part of the configuration Date: Thu, 5 Dec 2024 16:40:54 +0100 Message-ID: <984dbf98d5940d3900268dbffaf70961f731d4a4.1733412063.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: CO1PEPF000044F0:EE_|BL1PR12MB5708:EE_ X-MS-Office365-Filtering-Correlation-Id: afd1fef2-3733-4e6c-72a6-08dd1543a60e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: a6P1zRK3FYX8uv54kJ+QysMLlK5ZIa8NiX2bWWYGC28Sz5adD1tq3GGwo1TtfBqTVePq/M2OeA70bFnMdLhHrZ/mREh2gcLM2uDrK6VBnvWCDE6wFQI+8xH0wCxrE4nJpEyzvmHW64LEngL8q30waboYBZaHbwi2bJRPUu7C0aw1DS5ujuKIuM7ozbzgxgIftHCACIubwupCMRHDX4TuJ/YSSTCqhmia24boRytvNO1udf8+FhRtnpC1dWUo8svmWnMYIZkFubFULGx2sxtjjW+dOzSIyt/nXhtmRVz80kjH2y/vo9DzlEgCmJvdGRR37tI/u4X2z6FdCKkvV2oMRH8idMaHvX7vhzpZaUlD5fS0APeAK0Ct4j/dBAmw3/BwbrmCWCdnnAjojsw9mr/hxreNoD3UYtprJeXy0OIhPAgx/1Bx95LmTsgHNdob6OQRFucuIw+ZPpPycMmiBGGaU7Sxo1KkZkr7XVyeVBjc+B/w8ik+Q0hIIkI/4BHddpgKD6WnxO/JxSJTc9idIhktsybT9pcNRKlED+kj/sWbgxLtXVeTcCAyfG1v8Divg9oV6qGvTdsb1+Yd9Dbiw6DMD0s2sy2mBfh4Vx/JlFI3QbuHTn4fqNijyW39oTWQNfw3usZYUAV0/g6TBzBq76dcg70/5whIE46AT3KLFgnt9H2FupJ0T9t8E+7IIwmhn58jzgUskeqdsVVEEVbKxSFBANU79ez0+W3QGvbzLUxxrcA/wfs0mO5k7DClo6L5MnKUttbCq7+E9VyiA8Wz2H55mc1XSCBwRpcVMw+zx8Jmh+UxRaKogv/Eu3UikZmSqXwQz5tAP7JraUkPNynIMc5pBvoX94fpU3mJHOWkruQC8hwuU5IQIW68C8Pmw2ODYzsk1drVA+lXgxS8FIiMnIjRoWK8Oavhay8MLCvMe02EKqwWy44JkVr8DvP3a8pjM8wXUDST8BAxfc6PWgdDAy8r+Jq6PYXovbdYd9D3qVzT9J6v5SvzcAMi2QK9of1nrzNk4Dbk579dOr7vRvVX7GhwSXPLN1aVwWFtQyLKZgEPkvlpLfyiWrAu1oQ1KUaMJ0+t8TnSoXqOJhbxNSyT66u77p34OVYV3Bd+4htVrgzgYyxS1o2CUfAbiRksSXblUXQM9eJwlcejFlPcfZwjFGPltSpFbdaHPkEI6m0FFybgjxx0L67s5TUax9pZYE/pO4k+tXtTTu8yIOwjX01L0/mKUy6V7LP0FO8Sm066/ysv/PYauoe4NxrKDORgvMrOZIO6xzIPfEbeQOXdCC/YJ/QnBiqWCRGOoYbBPvoDqUV+BWU5bB13ySnA2nX6Cz9q2u5ewhQk7gyHjufRaKeBG3pUD4pIwSGxbsG5T567OeWk2upybC18q38ekbZ2sTw6On461fMGtHEWPWKcLbLiM5n80pnf+IBAC0Fvjr1npus/qRHoHBAabP4Hu5FwdlezOVwc 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)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:44:04.8497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afd1fef2-3733-4e6c-72a6-08dd1543a60e 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: CO1PEPF000044F0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5708 X-Patchwork-Delegate: kuba@kernel.org In order to make it possible to configure which bits in VXLAN header should be considered reserved, introduce a new field 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 Reviewed-by: Nikolay Aleksandrov --- Notes: 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 257411d1ccca..f6118de81b8a 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; } @@ -4080,6 +4083,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; @@ -4306,6 +4313,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]) { @@ -4313,6 +4322,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]) { @@ -4321,8 +4331,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 Thu Dec 5 15:40:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895630 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2077.outbound.protection.outlook.com [40.107.101.77]) (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 6BAD721C9FD for ; Thu, 5 Dec 2024 15:44:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413459; cv=fail; b=Ugz6RLyureHXjtaMrssLfKh+i7X/y9lgqS743YHUCUq6zASm9FGskm/5EpOcrsC9rs7cxOakmuG0okLQtuWKpV+loWysMRXETVD6q9Ti++SXDKqxjchFR58Cj64fmTRNSeE04/lW0zWkgjDnJuXbB7yxtuotLVTnrnYdiFieOdc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413459; c=relaxed/simple; bh=KEyyWmR+1MTMjYgeQVD0qDDfb0uiTkQ6HLxpywT0aDQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z0m6WeSGPgczpIsvbvb6v/i3R9+IBTAmuWZyWCHTlj7ypjNunm6JXzRVDTMpruSBaBKGZlO7Pn0Arm3CsaRWzixXohhDuMsr842vy3tEHiOrX+yNNqtfgREkqBZKS7t94lQ1qkCjO8a2oHDqvAA4rkLmoeCa6x+OIoPS3LS+mCQ= 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=mKS14bcP; arc=fail smtp.client-ip=40.107.101.77 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="mKS14bcP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sInuwL17wSz5tW+8zUyEwkYh9L3wZWJ70wJZ0pVOkl/zB0AiuoI0qaYgzSeW9LoFVOY0IcVHIlVg7Clb+PEOq88WBNuMqEwRoj5ywm5VC6AFT2kky81+u9KuWvjow9gVte8nI8/NfH4Xqt187xfnNGGmi6KzuXGlP2mRoOWY+tAoWNsbQUKvaGMo5qytMG9svwGTzAo5eX7M2oWj54Q682Pqg34MWNFSMLCjsQ5rJEQSM8DXBEM9+9bgqijmKdQjypYdki1Vd4qraTKmNudD2IzjxBa3Y2cBqGNVgXoWoI/K2JKw001QpHNZDPnWdPcDo0TrmDtAUXL0Xu7cpRN1cg== 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=f3zCt9csEe3DSeoIpLsQVQK746Hs85nFnxWJlwlD7m0=; b=cJzahSH9VtyIrVAdOA5Ggx64pHwR8D0p0Y4VApUsacTpRGM+3j+8qj+djmxOHmo0goTkwe2Nk5uwEyBcKAyazryMFnci2mXlqNLeioZ/NRGUpz1QtBfJ6KCGYFtHW975DA9z6qjl8e2o/OB2iw7AtnJ0vcabUf+YAKKBmklRCYvXR0b2/orPw6+J5wehPG4Ow+1VjSLlngJ6mCEUOAibc6xhKSY9Yt6reoETLick4TjZBE9f8JYh1dLtBzGL9Kf/llgEGUVQB1HASAR2Cmc+JyVbLMKnNgRr2bqrhhT38dVI9O+lQ1YLy19Pjq9SKzgW6iOtDLTS74haE3a91vczZQ== 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=f3zCt9csEe3DSeoIpLsQVQK746Hs85nFnxWJlwlD7m0=; b=mKS14bcPNHdk2MWeXHbpwCoJ36R/0nmnwKFzgcRfWfaKQsYVcrIrKN0RghvBk2UClAA4tcgPq6hnWQp5j2F23l71pJPegHOWqKIpOCDXggMUSH9xhiBOoeQj3ohEq90ObXAX74weJNoKfKJz9XGlBEzk3CwIo+erLy9ny2i+byA6FV9lHjPDKn7SkFILKkkhgoh8AJc2p2aDyF8uXcR0LM7rWDH62o/60x++tl6Va6ZdJD0snJ8nnf/OH9bcYHA8Gw+lpcOBgetMR+BzsJC4+I8jnvjZzXdi9LhO30qgtdiRx3N8hZsb1qdNwDkELi5Cw0uvMKuOnr+o4AKtSLEElQ== Received: from DS7PR05CA0054.namprd05.prod.outlook.com (2603:10b6:8:2f::28) by PH7PR12MB7188.namprd12.prod.outlook.com (2603:10b6:510:204::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Thu, 5 Dec 2024 15:44:12 +0000 Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:8:2f:cafe::9d) by DS7PR05CA0054.outlook.office365.com (2603:10b6:8:2f::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Thu, 5 Dec 2024 15:44:12 +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 DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:44:11 +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; Thu, 5 Dec 2024 07:44:00 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:43:53 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Menglong Dong , Guillaume Nault , "Alexander Lobakin" , Breno Leitao Subject: [PATCH net-next v2 06/11] vxlan: Bump error counters for header mismatches Date: Thu, 5 Dec 2024 16:40:55 +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: DS1PEPF0001708E:EE_|PH7PR12MB7188:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a784ac8-7330-4dc8-55ec-08dd1543aa1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: Oz8M9Lb4Lli+gIWTwP1oFZ/AJhASNy7mU0D3rSWZi9M/j5x8W/kOP9gNVAGJRELMXXdeTGtg0YpA3qQp+CnF4TBjjtiWlTc5FwbHn2/+9ySZ+xkptl85fIcIayWPHBjODmW2YfFb57wl0BI5KKahLXXbubZGoSZQQwtU7EBwz/CKIZSYOvz4kHK4+TmwvBccCuRaisPWHmxMaH89eYWJnCZDHeF7LFEtjpYdCKq+NUV+Az25pJeu2UNX7SxZtgXpa7z21NHoPT18BjcT/mNtKKcsxE6+SlGS0j2VUjKkIOx6fof6J/4GwM3modNDxIp4bY0qvygNhtwxHDnyYJrEftmg5vmXD0d5JwqQKgL/kRUGiJenOCrf30fVrPOwqRq5TZs7xHgF36aENeMNg5ruQsuwAnlU0KNgrJXCtZP6swcyeu3B1ynPu90kuZUOiA8vnXeZs2sybc/wWG3H6k/al9HaHExVfiNXQTdR/x/4HH5nBEO0ahd/tlO+sRAWJyhRos698zC2n0IjXSTaMarhS6sQHFJTfesouQDxYvMH4IEpaNmJSxp7bBNIrzj6kPKXPqwMBqnCNzFuvipnZADLI9U+P03k0+3EQoPWSjlhhBLDJG/8YTfVE/A5WDCh97t9IMnN7xUbqPhMyGB7ekcfQcLf7FkpvR1OFnkC80VQBvPOuQOlhaOJCS3K1+Mf0Ni5tSUgQRNkZ1YOUGKSRqVnQDOPT1nOwscNUndzYMq6CEk4oRe4c1Q/lv6QXHk4QfOxZX2y9SMWh6G7bIt2nNAyMnSlInMd4LYq73kZSlco9Q7D7E9dBuS0DijrjCcAu9UW7zn2A3qHmfEcrF6pevj1W1aTTFxnCNUKUS6+CwLUHPwXvBoziwGoyIVIq6bNZvhvqY0tLMziO1t7LG8c8kWC8QIRqKxuuNwm8pT95rlGRRcudXFIFi6EbVnqsvPL/BaZEKnvfwOMI+JSxzNcpr1M1lZSg48KL/RpA2a+CSYcVaWo1ic8EvdxNvzoairZlEnBKk+Wr+/8nOcgxR8KkpuyqirW5AkwCLezzCvtiP0aorb7sX37FUZ2sb4tL6rnGGndLRcb5SahYgv8P6p78LQtSQfzKUa8h+oNBu0B9ceY2eR4Fcy/rR305FE5jS3n3xVKTKAnJaOZS9r/Xosp6ltUl7+g5DPMimJ7RvSAahcoehbwlTzelqup1QuGsCIgITVrk8XJCshTGgwvMPXLZnR+ws3QCwdEteJ3j3MleJ0cjYhsb71L/uqJW4GR1qHudF3lTcliMNeU8Wqn8v+eC2ijiV/FxJpo92arFJaRtu6jBL1gNGjWIh1XEEEFowZktgex8J6ABMAKxKREY4y6ccKq6N9RsEa03JaKCLko2fFVOx3X0OfGI7+fji+q8YLnKgI1Wlp/ZzI/fHNHv6LhtQszO7LM3CDuMLp3ilzf1/jwzOWhPGOlnlFiyZeROMZJ/lyR 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)(7416014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:44:11.5760 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a784ac8-7330-4dc8-55ec-08dd1543aa1a 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7188 X-Patchwork-Delegate: kuba@kernel.org The VXLAN driver so far has not increased the error counters for packets that set reserved bits. It does so for other packet errors, so do it for this case as well. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel Reviewed-by: Nikolay Aleksandrov --- Notes: 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 f6118de81b8a..b8afdcbdf235 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 Thu Dec 5 15:40:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895632 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061.outbound.protection.outlook.com [40.107.92.61]) (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 007B6222586 for ; Thu, 5 Dec 2024 15:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413474; cv=fail; b=WnQZHSpbfhizEUbKfEwjMGOTnk/ABXMb1z0Wy9zUSgnPLuLBYmVaJlEXtg/Oh0Cwrrbu1KEtD37k9iu7IV5fGMXY/Mj4TCBj8e8Xp0Uq2/igzeXmrV8xsk2PrrnQ4FEudcF9WQmhNbWa3kU33iaKm2NhB+XVopQYISZVif6Red0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413474; c=relaxed/simple; bh=YEHkgNLx/tb0gfgEQeQSwN8XQpdkOocjCoraYk9M8F8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qHvzNL8KcprqWqhBmxflPL74sSW90Z5vAqVLUcOW9VoGatVBnlk5XMmxpRvMJBjy8G8TJ4fvo5H7wUf4WkvO5HuGyLxXUj3514rckX7DaRhKubY1sQCLfZcU2KLvTY1tF205DVhbNPEx6OkwK4nsG5BloW2ZM22OoX6DaFz3Irs= 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=T5J0FLg7; arc=fail smtp.client-ip=40.107.92.61 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="T5J0FLg7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YyJaDRWo3rfcOp5cnJhs1ek29RZ9LMb7XQety7Mlnn4j5iZI2hO0lJO+/8NL6rs6jsGltyFwyCFFtJrvgcQJJIzrteoYB+r2v/0EsFAOTacjP+PR+e6+N8q8D08+cfv2dRITn0t6RZxUzxpOq40ccCqeIbLjHNSSopsZX7FyPPWHpa5X9NqvMUJl46v6pcfrsm8mT+T7E5BewD7Yc5NLaYSQbesqmRena3nt4gOmcUzMeRMd4UvCC3OucL+IRUcG3n8dfRnn2xeg6u9P6RB+KZmQcLlYU2pHu0h4PqxpoBe992hfLSFichZdkFc9/Df9oJSxE6noCboFfJUFtmps8w== 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=Ie9AdLveZSKME6RdU2O1lJU2FprlCLYC2C2NNUGm5T4=; b=HT9vgZmqOVSgbWa+K8U6hA86lJNJFVI5PeglKV0fbCU9uLriSX6VAk5sRGNhQ1H89oGlSFLB3myRPVF2LvE/hGCA4lus0+bjP+ccp4vjlBEQmDeGTVJowMtGGbYKj6Y4a5VmzCz9rHvLGA7el/BfEgsk95gKgWKUpvItAZTvndp8Z6rWJbMhW9FFGDRem3RWYKTvpn9uqYJTiGoS8nrGeaY8WyOZI8CiwSKEUJFfd+eVbrB4NJxu84gaS/oBG6vX72o3IiXeFUm/Ub5GcYcnSrHLL8hYD9nVARztkdqmMMrg0RBP629yQSeXrZiFtXtOuivHNEGiu1V/RsDu2nDDmg== 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=Ie9AdLveZSKME6RdU2O1lJU2FprlCLYC2C2NNUGm5T4=; b=T5J0FLg71Nbij93mC8/xSjJQcEPtlTmCKcXFI5MKWGgySbLdyuDf8gMe9IU81EsNpxACQG2g1kCNEKnY2BqBM+YsVhVJw+uGXnW7zf+A3mzU7lXq8AmeKjOo10iR8f7IA1fRXGD/nZrBOwhJDTu+30YA97Kc3CLIumjGB1Bvn6vnHkHjsJPti4FaXJBT3RZ9+prnVwnptKRbcOCuJvOrkDIDRi2ji7GGJDRSY1i3XDbE9tAmiUAlzt8xxz/Ca952fKM3TdAOcyiivF5VrchMWX3hXpj9h0v+la7wRESRBV6p8fIg/AkVdwAIW5lzE6J7h93azNR6meKnY1dF4VCTeg== Received: from SJ0P220CA0023.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::21) by DS0PR12MB7972.namprd12.prod.outlook.com (2603:10b6:8:14f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Thu, 5 Dec 2024 15:44:21 +0000 Received: from CO1PEPF000044F0.namprd05.prod.outlook.com (2603:10b6:a03:41b:cafe::df) by SJ0P220CA0023.outlook.office365.com (2603:10b6:a03:41b::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Thu, 5 Dec 2024 15:44:20 +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 CO1PEPF000044F0.mail.protection.outlook.com (10.167.241.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:44:20 +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; Thu, 5 Dec 2024 07:44:07 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:44:00 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Menglong Dong , Guillaume Nault , "Alexander Lobakin" , Breno Leitao Subject: [PATCH net-next v2 07/11] vxlan: vxlan_rcv(): Drop unparsed Date: Thu, 5 Dec 2024 16:40:56 +0100 Message-ID: <4559f16c5664c189b3a4ee6f5da91f552ad4821c.1733412063.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: CO1PEPF000044F0:EE_|DS0PR12MB7972:EE_ X-MS-Office365-Filtering-Correlation-Id: 255f1298-ab29-48cb-c5c4-08dd1543af84 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: +jscxwBYMdMjuSLcBAQy0wO5SkXkdvab7jq7FokMGn4PWo+xn6w99GNWHQXDCvVIZ/UqhlzOSwfVHop7SLYmGQZxawj2AZ0xKPnlbb/pJl/SGQ+Hxix5dyRxWLJm2+0BicyfDiFWZDvCs8B5LZQU7ehNDzWBzvR3vp3rmSJE+sEMjawB2SH9sl6aNW9Zfp3JFK8PnvwubwUrFHcSmOnWQdwQW4oq0QUvJGuYxiPnc6NUg6IAAVkpVbzmxaTHuUqlto3LKfgJkOVz6QAnLE+ydLGKx/OxXe7hGtU8PGqge13gMzWbiQeeUf8fKP6+M3gWcr2Twc90xZchELTI4B0Fed0IDjwQt41Fe9+fl/gumkdpQpif83H0GydrsaCyI6HmclwUlxgSNwI3bG0iJDpLI9Bs7UBgPdPg2vdH4+MGITwCRaFCJZKVLOtbJvWmR4zjmNfTHBHQ6ChS08HuhSmY1ih3RUyezK/sJhFzXfbmbjUu2GYtmCrxLSHtdxau/8lL420xPZoSCA3QNm+q/SIbO8QMm+umnvz5SdDpNpVEdVuzZiseObAB34WzSKnaM7i2YCW4PW/cNl2OraFNx5JTCsS6V71TyhH5CwDBQw4JKcMtvaSKPy3mJdqkLj0TUW/lxY8+sOnmzWitYCiYNPnrx6EZ7CBrxByScVXsUM7hsRGdsJamc+W+QCH1o9xEWt7lEg0w7aoN9dz0QVSQPdfW00iqtTymM6VCcY82HQ4o1WHavFb5zjbR8MwJOV1JNVbBi2uFGwAhQN0cQLxaS31qugFtMePdc789TLWD7zZJS10KON5OIAfOoijjcDlMHBp/O95XFF2Sr4+X1uTBqfpToPcJIrCb1ud8yHAqKNv5HH4+frT1OHCtkTN/Bfg32ZfIhou3nTRskiQIBLvuf7sa8xzlsS++FcW5fxw4G+fH8lTKejGWNe1slkvbkbfDivuk6WzNAxmW3OkrrnZPQuIJV/FQn9q519eA18DX/R6iP8ZsDyFKxgwqqnhlWXAco52xDUjU+or2NBaVC5TIH1HviI+rc55Cxu8guVXVBAHJMU0xmfWCbAPmjbpb4zLeJWbuXqAyxp+huibtoXHhsX2d9S57hqu9HiOV8elzU5LeX/QydQz0hqAz44Oonir8YrKS5VgdtT/AkEuOLuC9LM5EsbfzkGWo8c427FPUBEKjuspjRjayRRiMjX773xLWIy+OuXjXtgEYFF0Fr2FTbprN3kjvxlOgP5nbaWVNz0euc4QFuGHfD8InB4LXRdf8Kt2wnly4l9SuF9zdJojVO1QVeDQQUt1O5djTabCdn0EmIDU5GVHP7y7NdNv40tzSjclGk3PVF06je0leDj2ZKa1CcLnz/2wHTzh0jEVOV13+9FohEZEFIpqUV5qalGhysuk00XAdtBYEF1ckce3yAV+Q3h2qF+0XtIx/zKBhO5l+LorvTJdJSGJ49T90yVckGxsF 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)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:44:20.7247 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 255f1298-ab29-48cb-c5c4-08dd1543af84 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: CO1PEPF000044F0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7972 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- Notes: 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 b8afdcbdf235..b79cc5da35c9 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 Thu Dec 5 15:40:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895633 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2065.outbound.protection.outlook.com [40.107.220.65]) (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 1529D224AE2 for ; Thu, 5 Dec 2024 15:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413479; cv=fail; b=mcwuI1ciYHghWWnDYsIJSTEfwD8yilQc8kAdq6f+nJxSMTQejD5ltTid+5sv0qF65D2aV1VqLF45inAuur/p1qQT3CYWPRn2SqjmejEgFm/2p63ab13Av5l4/SPuL7rMJ4bKZn697xVs0eLa9R5YoM3RBljhlL20hdw1cx/aF3c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413479; c=relaxed/simple; bh=rfo6m9cx3Q1UR6Y6wDIRlDcT1UOgaFxN/W14kiMBoKY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tzV/82o/GT2urBbYljP3ZxwbHX/S2ixve2NQ8cQkVMw41sL2uKecfRizYrJcJ0p/6PBWGkvUnkSVeEbSjNRdmv2V27upG19sWi2wJHEaNy65sr72CJmfLbgblTbniocI0Eq6onxuxEqm7fY+EcAtNbkvWqC4rejKy8xB6hVcrV4= 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=Tz4+YlBw; arc=fail smtp.client-ip=40.107.220.65 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="Tz4+YlBw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GuG09KzbtkNzpHXIx19I1NioVKoJ05qWipRPRTyWwYHeqhZHiUNTjwL4Ry386SLSDnY368DO+SLvjf1eFLA9S0ORS07ebcnlEKdhqObKbvVtPNf0zzSo849asP5ErjLMrCLClIPpcJqHy5G/Dh0x5qydkcbEaX/QSioRKU9xaXhGeJV2fgMtiQQRefkITDEaOP0EjKIFIl56UBS6mhJcEYB9/KFgyFj48ZWX8TpnF9J4MTDfIzHazJFngG9Gd3n3ue/e16o2MhChGamOIvRYD4jrKnWSO2KC4qczZgCkEbTdl1MjIr2rMdl6yFg7baYedqkluLtlfgiOHln8h7/rDg== 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=+QpUgy4gHsVQVd9pjbzpiIxFZaLMXm3n4hZRSQaM7L8=; b=kukNSc+9B9Dg9S9hKXvEiS/w/QSPKaP7tnFDzZAbBfinFHzudpP00cW6vVHJWQgeP7oPfYe0mBZ/xwggqvblutlza/2Wa+2KqwBUbFCfjVRcibeKiXM+hyr5R/SMmLVGJh3OsDE+NQ9uInXvt5G+b94iOKOlRp3JCT22AS7qbEWb+glI3j6GYDxbTQpFiqQpJuIdLI9rMvigxbDAsXSGyL15lEUD1aydZW131joqN6TSWn8mndLTtJhgxU+D3w9BZKURjL2vTte3uwxer7S4gWh+ezALnErYbCmNKXL3g1hZo56/6bpJUL5MX8NKxHyHJq3ETXVcprjJkgYiW++NTA== 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=+QpUgy4gHsVQVd9pjbzpiIxFZaLMXm3n4hZRSQaM7L8=; b=Tz4+YlBwp8fbVSb4r84vnYVsyZGnA9uiTvmAjlHqS2V1p3KT7p+xIn3xjKccUV+MWY8Wlvf1FOwgwe1CyuRD7UQsokWI2Uvop2Y0f771995qnOEuLGPKRX+FHfiyr4Abbs4m+iT25rmavHd34r9I1dLaHOrhzdcyh/CrF6HdcA0hV/G68y9LAvpcTHyYRmcC1MhVLgxNck0tDIE2/KT27BCqswCVwzvIJ/Gh5eia/gPg6IeD4I+18OfIfiS7JM15EL8jO+rrycNqzLy6ifZCwxALL0hRZRH6jKa9U2DGH754iuVLbL5xr5xWOFM116oHxf+3vqNHxaAVLBEy0CzwJw== Received: from MW4PR02CA0004.namprd02.prod.outlook.com (2603:10b6:303:16d::19) by MN0PR12MB5740.namprd12.prod.outlook.com (2603:10b6:208:373::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Thu, 5 Dec 2024 15:44:29 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:16d:cafe::b) by MW4PR02CA0004.outlook.office365.com (2603:10b6:303:16d::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Thu, 5 Dec 2024 15:44:28 +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 CO1PEPF000044FA.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.8251.1 via Frontend Transport; Thu, 5 Dec 2024 15:44:28 +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; Thu, 5 Dec 2024 07:44:13 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:44:07 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Menglong Dong , Guillaume Nault , "Alexander Lobakin" , Breno Leitao Subject: [PATCH net-next v2 08/11] vxlan: Add an attribute to make VXLAN header validation configurable Date: Thu, 5 Dec 2024 16:40:57 +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: CO1PEPF000044FA:EE_|MN0PR12MB5740:EE_ X-MS-Office365-Filtering-Correlation-Id: 24a4eb5e-7bf4-47cb-322a-08dd1543b42c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: M2BL8K64D3xoGAh/PpOsiR39UIc4tEnqhX3TWumjBphfbPnacLsrt9kfxbQGYvT6Y4H6dYmAQ0UXbvXxprnqet+SvQqB2ZmHs75lklAZPhgZZRnRe2/3ElRUjoV3EPF3mnK0GYEazE2ZEpniUuKaQoWE8HL9Fl+uLTyqT9oe8Ylx5fVU3lqz6NlVKFT1T+Drg0UmDKr24AIxjGcxIOoaIHUdUtMrAQZtOBa9shZ3//c4/bC16yeuKxdqR8U88cnq44QnEZQWmgamsLZyq71UpBWjieS0ypNLkcXKfZ+ZBJHFnizM6STVNFd8xAS3Wpo7st5dFvfc1ydXWCMLHU385bdHD0DgEEX19nvxsQcW71f2U6jgZaElAAN4SdWd2hXKcuzDW2MTSwGGfLTlJBIcCeNx62uspXfVJTHXQMnx99e5Iap7qxFCGB4sAtLbqkoLu9S+NCTWefwzhNH7Aw/yw2QrIdBYTAS8lJ62Q6cRXqsCgSFTjTyNkYVBzpl1I9A2Azjsh4qRxNHho3VMNqmXG1wj3O+A5tsPLbL7WgtbWFdn1Z35JEKpf4iPbp2WvfRQ8CnHGdIcn/aZHPiTD5mPjFVhMtE8B+RpsfF3mnLpWsJF8Bi2VDj8ZOgTX+M2xGTRl45n1+1MCFOSpBQlHioUSIkicrqDdnlHlskd44c0qNfUCMMVNSs7+hezbzlgzuQxx8pwx+5v+4ocU/HkxfwPKYf5RIeym6zJx0R5IhyhJT+Z7eyvQoavw7I9mP8f2fiLH981DRJyhueNNligeE6NXEqdZkxVf9s5qx2ASh6o+6sIRmoluoUgYaAD+2qWv1gwzC0lg3O0cQAc2MlbU0TfHPN1wwT2YiIYEraCId3BMpznr2pBKUkygUcBb3OhYY67hZYZG/qnCu1Uy2YN+/a61NdV5lUf/XTjSYi0WxzRH+gB4Xq27Z/ENeWPEqxnjcrjSiBNEsWsR9TMJHxD4dB3mAmVNAJmJ+1pDKgWOoj4QjfPrUNworpRjulIXVe4D0p2E5D0xa2ahtqpQE8AOmcGY+GzuXdAyqiObEOHCvlL+xsTgqwBDMOxsX+tbE47NQVwrxWWl56F6JG+SWHfBYBcmq5hITwnyIjIo1wA2/9jyjpUIT8xgBWbtfzwNLjs+XrKgKMTrxqja74soKHUxSrKNpwIqFb+MO7KqW8Vy0Rwi+OETn0cb6TztRvm+9ARzw0Ici7yPkAmhae8B0hDuzQ6voK9sE3ldv70KUGilJHtBUYM/VF4RFtbOmp6yd6HiMwYvia9JjGi8vik8iHj/6G4jLBKgU8wmdqoWyfayYg3iYdSjBPg95ZSPAyxYTPKTPxl23jdBAuwIc+VHIv2WWcH/LItZWvvjeGzfwhqnjO2XCTCfrVZ1qTcE7UOFe5EVWzkNtahT73P1rtL0HBw5OecRqZMJoCALOPAMtKk5DGHtjA/I0l6mOgTa0dMycWcqmnP 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)(7416014)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:44:28.5172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24a4eb5e-7bf4-47cb-322a-08dd1543b42c 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: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5740 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- Notes: 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 b79cc5da35c9..38e967e27683 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3438,6 +3438,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[], @@ -4325,13 +4326,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, @@ -4516,6 +4548,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; } @@ -4618,6 +4652,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 Thu Dec 5 15:40:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895634 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2061.outbound.protection.outlook.com [40.107.100.61]) (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 4246E222586; Thu, 5 Dec 2024 15:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413489; cv=fail; b=JRkHVbNi9TJJWHgDyHhJrLVoSydK1RMKQG5rkOjeeVhF7lOYa01YG/KUaJrkav/VzWODHwQICYz9v0T1G9mMo5eCtN96mm1ZVlWTTzGv/yOgUMjGVbruaY7WrcKdxvQRwjo4OYakIcRiz3zBe/mpisZnKDOR0lJxwjhO+bR0svQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413489; c=relaxed/simple; bh=cVfKjVqLaxBjvU8xsYDqwvrVmkq7fEKbZK6IxdezcGo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J/l1/N6YLzpAAjdA/9Bjp5VnqJu1k1HHuOiFdW4IcdVlrzBY/VgLwfQDiMj1MPJbGFge1CaZQc2OT5KV9H6Wj5+LoQO/1x2c62lQ1TmeLCR1JOfv0WD/QMI7ppMaV9bOpBEUgt2a38OtmKJvDC2X6IJTOFoE3b8iF9trP0U+ylM= 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=HEMeELrg; arc=fail smtp.client-ip=40.107.100.61 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="HEMeELrg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z0TsGgm9/QeaUVOnh02sm/4ebxRE6jVEzMk7yZDpmuBSYU5674G0zbmGrEz+mcWtdZUUOaN1ntNtd7EtowT8RYRL4+zscnVmgBoXxGN5ID/jyGh7ZnZ1J8ci7fyC+2uYQwTCcAoJi+p8vGI6xx9CMIZP7Cec5gdwNLsBF71GiVcTGVWzvmTZljKjr01Q7cIbB37GTHN8JNnZ/szXtebGfxFsFXwHEWPe0UENU75RZd7HHs5EHVJhYHNnkWwXtvxd2VcypfIJOr8shMsUSaOsIo1dgiTV5XfHXogavwSxT3X/gRCo2LhkhId+HwzflzTcN43fp0VLn38XJSSe2qYtEg== 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=owimIt3fbL2Tbr6k8qr7p/OQTLNrfLtZwbOST1YYkNeEs5NchydMmJJrkYOq9z+prxZrseVD102XCYSjlSQbOBTKRbBU7SNRDgxMXeI1W00EZ3LzwwnFATg48CDR1wi4dZ697ZdHYSYuW79w8cMml9BZrROVG5Oca5YxYG4rNMYbXCVucs7cj71OdGnwDTNeMETnT7dJhJzGzS+s5Yl7/PWPCb/K4ftSKej4njf+He+Zj7/49FTaqvmxFnpvtFfSHscHQflfqyTmMOJeIM7fMm+SrDvt/Sqmrojv00kQ34LRDpux483sHbwCSin1rh8ZXB+dMLzI9kYNlY6EcU6/Lw== 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=HEMeELrgI/TXrgRTP7tlmzAyeINPJeoa77pDpwEUg6+VZPAx6A73qC4JjTKaiUp8DW6jCclyKFIyigVPECp6onDgMIIuIk2AvxjDdkDjPhhGtRgwqaL3eiMGENPitwCB1MihZKQirhicM37ETa75UbKHBCGXkWPx+NbkYAdYsXSfnITLWj7hCSpJ7E0zeH5S2TG8yJGI9VN0Lq8S3VzQcwU3/Th5UT2UEUDvTcZ3ZZSZJgWoWSFn3IOL+Kms7AFkhsCQsIXffOjPN/5C2qRcfjjlvQom1qTgYbwi3+wC+ZK4Ji3HFow4K0WvscwAXjIdQiaSZTM+cTJ3y9pEY9fOKg== Received: from DM6PR21CA0027.namprd21.prod.outlook.com (2603:10b6:5:174::37) by DM4PR12MB6010.namprd12.prod.outlook.com (2603:10b6:8:6a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Thu, 5 Dec 2024 15:44:36 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:174:cafe::93) by DM6PR21CA0027.outlook.office365.com (2603:10b6:5:174::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.8 via Frontend Transport; Thu, 5 Dec 2024 15:44:36 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:44:36 +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; Thu, 5 Dec 2024 07:44:20 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:44:14 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [PATCH net-next v2 09/11] selftests: net: lib: Rename ip_link_master() to ip_link_set_master() Date: Thu, 5 Dec 2024 16:40:58 +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: DS1PEPF00017093:EE_|DM4PR12MB6010:EE_ X-MS-Office365-Filtering-Correlation-Id: 2781b555-79ea-4949-2554-08dd1543b8e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: sKoBhp2z+QS72fEPO4d60fb7IvrJm+cZ5je4cvqsypN40xWOrkisqrjwg/aRcJv27YBJFSH20Fss8SFwFkrybY/jU8osGQYttOz6HfXcdavvSg3oO5EyizOKFmcgwwLnk+xFZsDlq5hGzEWfsIbUv1I9PgxuxvJB3jJL4/I6w4vryPpoTYnAvgIqUaE8tXEXJHhDw31FtARA/SQFdes1C66Qul06qpM6NVdVwz/R84Ij4A2utIRQqCQ/Mw2B+uP9eL5YIxXzSn/Owp1cUIsm8ceHPGHkhG6+OF7Z+Fq8DcIxyGhV9IBU+EdVrFy2auHx0P77mxeq5MGEJpiwkv/RVISaEj48u5DgweRd5DG5nbzX9jxx7VeLpyt4BpSDgGIwqwqGthIWvVCWCv6LV+LrZ5XrVriBd9lYLWQViS/V36OTEC8n0CfYx6TMtoO4vCEmPbbH4sR04i5FPVKBC9xBQEFi2z9cJ/jszG8eMr7K0vidEokzLB+8SPlxnxP+4Lv/nG+RBd/0mcfYM8+f6/jKMXFM04abf+oQq2yTyZd3UFDLpmrUBl3hB+ABeKQhDEsBjBHQauvKAlgolaPnCvPltTq7zc2vDT+ZJJL3pftskj2uIsCIHxvCYxediVl+I3Sp6an2JAJ6nglE0piow/YqkvXOEDcydr65eOHDwY2pU0Jk47LEhHAzh3uneCyBEhgcKW0hCG7C0zTByLfDyNNlvpDNuw1ifP8qN3HZNNl88DJWlqG3LbVuo29dekO9HUiwjNefSr0DyIb06NbeKn0qUASDV2bniTYqDgXJQELQ6yTV576LwASOdC8aBu+2Uo0qPhV5pjPY7Jeom5KjwAtUVPdZpjZgs64jYc7mdJisiidL1ZpOMfuYqZZ2Rl9SEhRQfb2Ocp0IDH+B7ZGKG0KxN571VGtJqU6+opPT877QqIsbWBq8suQzesmhATVEoyTmDlArQnicElioej+sw1CdMAx1OjZR2m7pWkgg2w/Le3IPRU1coelYEWz/M6PtDaAPVTtNByTg1LrAP1QnKE/VZMI8izv6DPNkhwwpgHq/McwRJk3SeODIPZ8eeEpgkeRyxVcQeFwrMUw3AekAvPQG4S9H3rfHFdxXkvOJqGINusNZ1mlw0rtIpaDHjTxbPYrpJk2kVBobaFev3NnWi/kI7TB+ZfqF5wFBj/Srq8C9aWSzHryD2sToeDkjY6SKnWY+5a78mUXmY/SbvkWOeD9vXsy9bqnRr6dIhjZVinpQYy5x1SGgFumhncZ3ZdzIUKztiXmtvQXotuDWGJP8vlIzkWWUtJ2c7kZjomZvLCiTTs489TK4hm0r9u0EaAmEJNApJEdYoARwqGURG+46nGp3Ou9ZWFzlemAN3x0CaSB09Pae7Ke0vRTk8twLoEZdVfxigGdp3W4fyKG1+vqrYlX3SrzSl52LyWJTmMdvhV4XCOdXt7dSYHZSoBdQ82O24d6f 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)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:44:36.3736 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2781b555-79ea-4949-2554-08dd1543b8e2 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6010 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- 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 Thu Dec 5 15:40:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895635 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) (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 BE9EB222590; Thu, 5 Dec 2024 15:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413490; cv=fail; b=IDfIviDP17TZSehP4TOHRARYxE69F9gCzCpME3bqcyPSzMcaEvOQCr6h11gEIC5EKa2OfOxGSCmfwW+c8Lj7u3D8Ftj3ei6+4l3yNutBRNma7KkNyJY1VVV/xui04WsQRcdxxNXnm52rxC1U0e9KxfQVq10indBC5a4n2GAafoI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413490; c=relaxed/simple; bh=RUmjpS00KQPThj9efFSMqJlPjLPKYyp632VyEJwERTY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IhxVByptLGE95e8kj5fxaenU2EqPWSGdCcCFXeD3AMcuu+TCdmaUVu0NoWnhEg5GCn6smNgeCejyGse9X8W4c1YnrtTr2zC3FSRYa8OJWtUTi0YFr88cTw2bcUOvd0HSC8plO54w1N4jq4karycdNaexvcSrgnki+AFF6f7KpAo= 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=N6uCRaid; arc=fail smtp.client-ip=40.107.223.75 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="N6uCRaid" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yOQgStL4ud6XbnN453TPVzKtfImBNVPPPiVxkREYUPCt/SYLFBzplYgFH0C6eIHQ4B1Aub2PJ8/vQolf33dx0n/YGxGnk/s6SeOXQoW2Y7s++hHtJTNP6oT1/xKLBjcgZO3GfqHMYX+OZ7KiksK2D0/Y8LESNTM5MLMb3C3axGQB660vVwOHw+z/eN6xlbQ9cB+cDsPpR0AxAg0RC4jEKDoRDrS8cGTmA9CmOOLc5bsX/KrHDKTE+Cgx7JQdW0vAbNc5PM1elGpZ0MuGTzVfUUiu5pcV+Pv/Ojx8ilVezaC0k8e9tS4kkEhHjjyU9JbaVtm3BItDQ1SCp5RoBfNl+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=iemher0mO6qrlOQ5kx+Fwf3R18yaGpgpyBN2/v8lXvg=; b=nnmVVVr2yj6GhrIdTt1CQGsx8Dbo4ithvBvzPMnInf9rAhW7ji/YVXqmJhBRsseKLlvLOHQ3W5x4qLrsC06h11NuaXjm+RXGAf+r/JetvZfZZs+IJvGYmm82q05vCxWc6fHx5wlEvzDVUVD1mJFZQQflJ+vXA42HOyxv//zNW3iRVk8RzK24QwOKsDCCRjic5v+SiU+Na0WWxIjcoslgOGoE+L2vP7QZ9utYeY/dWwydvujD1OrdVrMwl4CBvGyPGUnBsNR79qsRipKGtUYc6qKPv/VB8XxAfmXLwWrPla/lFa4Z7aRViSqBnSuNNHRTbgN7V/Q7DBIsaWlD09veBQ== 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=iemher0mO6qrlOQ5kx+Fwf3R18yaGpgpyBN2/v8lXvg=; b=N6uCRaid4EdFjrIt/xU+YSep6FeaqVFgbSU+DbJZJ/iJlMMMCImx81XKhFgPxSPTrOdTJR8JPfJ2vzFqkZLrz1T12Vqsvr/0pAKWZM/u1O4OMVsaQswPDEZwGhPstRT4BO/MDs4eM7GMD5mCHo9YJirea9waYN+IbNprEulJIdKOPxRtLEyP2GIj76xAWfYMzrfpcR9KBgrPKky6uYj5Do1SzVLUftQ9QRz9QWBwHGQaIZcFSV0P7QnZblccFgsLbqfxsTka9TXF1sh0Esmip5wnwrgN/0e73qbInBBxnJ9Y4waoDynbJUPSQ1bK2hqBIykY1TD4OJemvDGckPz67Q== Received: from DM6PR03CA0096.namprd03.prod.outlook.com (2603:10b6:5:333::29) by DS0PR12MB6533.namprd12.prod.outlook.com (2603:10b6:8:c2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Thu, 5 Dec 2024 15:44:45 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:333:cafe::3b) by DM6PR03CA0096.outlook.office365.com (2603:10b6:5:333::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.10 via Frontend Transport; Thu, 5 Dec 2024 15:44:45 +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 DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:44:44 +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; Thu, 5 Dec 2024 07:44:27 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:44:21 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [PATCH net-next v2 10/11] selftests: net: lib: Add several autodefer helpers Date: Thu, 5 Dec 2024 16:40:59 +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: DS1PEPF00017095:EE_|DS0PR12MB6533:EE_ X-MS-Office365-Filtering-Correlation-Id: e2144707-998e-46d6-92d1-08dd1543bded 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: Dq3aUKywAiUFleFHdZ6MKbdTqJ2GS0xCcjLihnkW6aEI5LzPaOrc9L6421kpiIub5Q0zZoiApMG+LGrm/8H8fqWZrQfCevYCI0X1xmoiNGvDG+Tqns9fr9Pty/3PvPIy33xyxWBY3RFVnJCHg5zwOhU/hXkFUyQWHL+9qGMkaJEUDz9PjnPqG/hs5IbagHUndVQPothp+eyQPkDEwAVG5gJ+XGPEtTdjTUMPUPtowK6GW8G2voRlEUeLOO1t0+xGD1qBGEZ0+KiMxRLMgxmLLQ5b5fTskDqjBrgUPaQ/0cTc7UtEm1D8ulqh1sqoHaLDIHHwNjV7iyOV9Dpi+5rNVJ0xzrnSu/fLfh3vRg8XhcM3mcjlms99Lglen86/z012mF2aMbqkpFxQEWYU74h+VdfjaJ52WKeIK6yNziWItFuE5X/o8mrnuuKyfdtLwkZFBbQj9ZzilipXYmzZKvRrdBkjNwekYBxr2W+TDFyyTpIsiHdp6SfvPTLPVDO5CZJYWoNmfWqlyBkbvpoZYELM1evtYCIM07kCUjhBheGUmG+5csHuE+YqoD1zeqs+aUorjbMHoH0DdurqK4LFk5nUZhaijs+ZjzGT6ulMazfAZY8IEEhw5ejX2s4r/rInLUMoDMh6Yuv7jQd8JRfU7lZ7gNntkhbIWLQNWZrdQ1u35Rbu/VCujoKERtlMndpO9aqzzrPfywPGzEL7V2VKh4+EzXAAAk6WjUFfOhbWzscyMb1IFliLU7m58mVWqXuu5TB7cQw24V5F5uan0wk+WNGDixXpMpXGxSRtLblyQBaYS2/sKsTExti5gJxCHWLF1kAItUR5vNX29+tdLmC+yhiBDRSpi3vB4aCAf2lF+NNH0CmOBts2c2REFSoOwOSwsninSPjzKPyY14D/x2UpNvzKCf+83eURy9u6YpdGEn3ODzVasqTCuHjPohWwhKIxv1t5p8D/f1C64OYiIrIAbsTOZ45zH3/TYjhbCVpYGD6EzArgLXnf7WfL5qB+v+7IODv91jhzOxWrLU1P1DbQTjJ0I4RtIeUtK2PZU/lmBxojCQReagT70qY/cOBuc+CI6pracWYsfmw0CEQLxJg0CC0gDVqd49db9uBEhKF0zTpNj27drdMHhvdiFoxCAE3PTQA4PUs6SinSAqE2/YvlNC8z8S9hZR5Elh+Fh2znNaIVoHCtNhF+++21bB5sqn2aVcI98KSM1hkAK2fWayl8KTEuoBybwegATiBwxmC1/6GXQKNFvaG/0UoqvhO7kE1MuvqR6/XESpE5LAKHfbJ00C4foJSQligKTo2bfE/70swj1o8tk0lm6pxtqBbJfpqG3COzVDnLmviw8XB1C0xrzbSJc9T7IfbC6TigrooFndHOkBqAeyoBI7lfTQkSaynSaHar4HRDmOL6VmU5MEoDcSaTZgeNH3TvoPyMsWfwZFKKZO7OBIK0AUd6ofJu9TBOeVyj 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: 05 Dec 2024 15:44:44.8371 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2144707-998e-46d6-92d1-08dd1543bded 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: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6533 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- 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 Thu Dec 5 15:41:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13895636 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2059.outbound.protection.outlook.com [40.107.236.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 A41E0225762; Thu, 5 Dec 2024 15:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413507; cv=fail; b=B9oGqoAd9vHZuISdIkXVp/oCCQ4WSSB+lJso9jXuhQCobTakVCbtZRQqWrr6O0/TkTcVBIUyt90ULfMpweR0+a+fwnRzcG0NUdg7E3o2cZHZICm7NkCvhhM23KjWtfT+QLedFM5ARo4g1pABHnuJyn1GEiXm41WRU7Pi+ORBNCU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413507; c=relaxed/simple; bh=i95+KLcasmBaLOXDbeCg3RBd5J9QMw5Ik70fOPsSSmU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z3ejEvPkRbUHtE/24117rPT6pOmJE7w9A8G7u/0zIDk/nyhZvdRV+jLoXGjn2/oLGQIS7XYz09COSKlp5VFmmzoiz3DljiuxPxSRq8bwMeWtUG8+GruAefTe4nXlvC1zxrCOZkn1dK+Av6m0V/WPS2BjnpUJwyJkuYVDtosxAM4= 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=Y7+Nwnth; arc=fail smtp.client-ip=40.107.236.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="Y7+Nwnth" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DhdT6WqlE7km2UN6ry2xxF9KlR5y89kHNaonpnbRbrkuF0rzYoR1+OY7TZQHDnbM6pf6bj/Ns4JFOnXcPEOKFKsvWD1L+nl/mDjjjpqWEy8BgHxVR7qJgjGjfjjPO+BBK8j4wai+VfIS1rnaa6Ws1+0RvJuihJU6sEBuFaMb7gncAE6ezNfFskcli9sWDJ8J+TD70Zoa6/KDvbhMsSgdEbLpT0Z84jbX2mz3COFB1yF4F+2ari2V6/zjvIf8XsQnii1AQqkEFunIrh4oLjVVyg5JYWRVqX1d8wxe8/UBJcJcJKRv+pBPur7d4Dwvw8Bq7vjuheFtVlEL/K5UHp+n2A== 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=ZGaF9TAhee8pq5tjJ8dDOAh0SKzCk8l2bVsDZ+NEXT4=; b=pRmP7+/uMLf43b5OdplX8iCUY7uqdVeo72BqkrkXOxburrUI9WjmLyC16Ggw3cO4Uxfd5myzkpZEUN/aJ/6p3bWZF18MkxCSDG2RrkjdiXRUDfN1VFfBkkDQGb0R1P2LeJ+ubuO4QyTnxRkZv/ZxEPfQLnf2/ASTQ3CiDR2IhNPjrXUW3PD8eXuKFqk7Z9b0MUwEB7sQn49ykFWhCS8p0cIvtQ8/1V3OdbBaSsTRL4KvstUl1C4W2EI1K5AKKXfB6JLxjICZg9qb5nVeAHrcba+Ig5HjT1S5469GiRqgdpY2lo7h5y5MKZfFxqxOc3N9JoPiuQ2FDl+Kp4X69SwWWg== 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=ZGaF9TAhee8pq5tjJ8dDOAh0SKzCk8l2bVsDZ+NEXT4=; b=Y7+Nwnthfd27FSKhwPmk59kGY3j+kM2HWhbVJPv4ZiA1v/9R5OBoFMuD/CNaUK76ITzS3uNrplguW+LGXaTxr8SlzDyYZutBeVGlW5iWyvLiE85ezrKGgjpwbW7+FzHzwo5q53Ell1JyDAP56znMfWHYhFxG+P9Q+GPm3wmG74dHgHLpjSFRXR6UWZZ87jb0r18p2otQcS4fNw0bUELb97J3hPuPZLKSqBEOS4QdgINjwL5D655LbzKHLTCekX/GEL5YhPoLQt/UqgsRNiluwV2zjbncf7LMaoACGzI2zOkhvBx8qqZM2lee/qB1Cr1hCF+SNdzpZVSSOXOi/JxPCw== Received: from DM6PR21CA0018.namprd21.prod.outlook.com (2603:10b6:5:174::28) by IA1PR12MB6090.namprd12.prod.outlook.com (2603:10b6:208:3ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Thu, 5 Dec 2024 15:44:55 +0000 Received: from DS1PEPF00017093.namprd03.prod.outlook.com (2603:10b6:5:174:cafe::24) by DM6PR21CA0018.outlook.office365.com (2603:10b6:5:174::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.4 via Frontend Transport; Thu, 5 Dec 2024 15:44:53 +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 DS1PEPF00017093.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Thu, 5 Dec 2024 15:44:53 +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; Thu, 5 Dec 2024 07:44:35 -0800 Received: from localhost.localdomain (10.126.230.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; Thu, 5 Dec 2024 07:44:27 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [PATCH net-next v2 11/11] selftests: forwarding: Add a selftest for the new reserved_bits UAPI Date: Thu, 5 Dec 2024 16:41:00 +0100 Message-ID: <388bef3c30ebc887d4e64cd86a362e2df2f2d2e1.1733412063.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: DS1PEPF00017093:EE_|IA1PR12MB6090:EE_ X-MS-Office365-Filtering-Correlation-Id: 79336d57-d4be-4fda-3a08-08dd1543c2d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: b+EMbThoD009GXhSh5k1XWHutEhJDPVWbUfTrtVhRwzpZrXoLWuYL0y7/yoTFrWiOKap7PK2p58O5P2lwN3D6YgaFpDt7k7rcxLH5YFyq8dR5KkLPHjyDGE8DfqnfHweCHdOvLkC2bP3tAn66XG3ex/fArIS6YwEOIam8S78O1PVe8tm8miakvsK2iargvuiMef6+tzGZzx7oCqJ1YwrLa2PZtyBwNmfB2cNPjFB/3EZCkLw3h6KjbMD+KLg9DCilqzwz3Ql0ltUvemNALVnacuZl/boqw8yV5HXjxOlJmOLMKEG0g5XuCj8vh4vcqu5QkjLvF8ggBmWZTZ6+XR6h1YmshoQ/XusZowz+2AfWbcZwgWLYVNugUOAPEgM/Tav0xJv53pAYUjGZ4Bm45cq51+jvV3oQpRxWBcd6YASwc59fC26LhXepI/CPckgkd+6CyrNRuXJg9oZpdoLTGIczkkIFXSsorsyZu2OQ5STXe78GdI9nt/KExFZVYcIGIdHaMJ5Z1duCIhtH5tefndnRfa3ejPCBpDnviPh01zVXYzEZO6DHUnUX7+HBQSgtgOP+LO1aHDpVFud7AxzM94Hmomw0UmY5LolkVDR+J0T1mQsabEkfusLY/e8FOB0ekQPBJlvBbtMCQw7jqyC+r5vaMEOBCmw8XY8rabInGziTLkMi0eRRMEX8Q0I+BIg5Dcuehfs4wnm7rXchQKux1EBLtA8mDo6ueoBJaKVkBB0pUsJVndk3NBfSBkC9yXrkAvJ2BdluySO8a5hOp/3A92674jBlS6VLpxSGjcrdxNsxcKK6f6vNAA0vGQcX5ZKEHm+3hIlSYMJJnlXG15c3xtA+ZoTt14VA0qT4oj70fVvKiI/Q+wjj/w+27HntjfdrPtXwPLf8w1Itztoj2a2pMWNLmueq7bpnQmzCP02LyTNTFtF/HFog3AamTwo6OUa0IQylBigqZD0GJ41LPPCw8mCUdCvOITb1joPXZNCi4toERgxSFVB5WDKFxZipErRK/szvLoPzMhT3WxYWpx5q37FHzK00bVgAbc7+J88mq9GszxUo12GiCmSC4gYNsM2kOec93nAhRMGsak/EyTEbGMF1ehAt/RDJdVjsSzKciXtGbqUQGl0yvXmgkCtnB/9oXTWNbV9ttinRISwKP9hIvLtAMGg773WuR0mCOLO8dKWl1zOS+xTTzT3PihDDkg37fxjKvtvOprRbOHP6T+Euo6HLoiLeVklz7mr4JTlKXBHBtoXruNPzAVQ/8+LiNp1I/T4Ij3SmnjST6EywSq3bexAmh5QhBzMglCnD12BkYwQkXBTH3/VjhvkoMBX5x/RMX4lKkKEz7ZVZ9RkRUzoSx1rMhJ4+kl03JOw8Y2eO8uRMJnS0DpaJpTYnQuCjPyY3xbxoLGBKFigqEmsZeSV6AAoiSa4UZ2Kn/rds3hZWQP48e6KGk5vSS3qcYknbLuWUXlR 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)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2024 15:44:53.0924 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79336d57-d4be-4fda-3a08-08dd1543c2d9 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: DS1PEPF00017093.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6090 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Nikolay Aleksandrov --- Notes: v2: - Add the new test to Makefile CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: Vladimir Oltean CC: linux-kselftest@vger.kernel.org .../testing/selftests/net/forwarding/Makefile | 1 + .../net/forwarding/vxlan_reserved.sh | 352 ++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/vxlan_reserved.sh diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile index 7d885cff8d79..00bde7b6f39e 100644 --- a/tools/testing/selftests/net/forwarding/Makefile +++ b/tools/testing/selftests/net/forwarding/Makefile @@ -105,6 +105,7 @@ TEST_PROGS = bridge_fdb_learning_limit.sh \ vxlan_bridge_1q_port_8472_ipv6.sh \ vxlan_bridge_1q_port_8472.sh \ vxlan_bridge_1q.sh \ + vxlan_reserved.sh \ vxlan_symmetric_ipv6.sh \ vxlan_symmetric.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