From patchwork Tue Dec 3 14:30:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892543 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2066.outbound.protection.outlook.com [40.107.236.66]) (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 3CDB01F473A for ; Tue, 3 Dec 2024 14:33:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236409; cv=fail; b=j28wK16Rc24a9Fy/tC4m3DwVwDIcgqIN6hiXqNgQ97zfcEH3rRoFqWraKQ/WcITJk4sXwgXjEN8c/gdiqrXa11kY8DnMvcXY0Yj2REJ4oMRr487UCCL1j0sP1Vy6j3cR/qiXW1QywO7JSW1nT37dADTysaik3E9BeiMLtWGL0w0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236409; c=relaxed/simple; bh=gVD042tNwq8oKLWlK3ZioRMSmv5DowCb7/1j5JxG8uM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P7+WwMSr2oC9jjrpi55+FknRg59GuGbz6uYn+YYuttIGQAc+6JV7Zcm41UAi6Jx7E3TCCSbkYzQGCfulqP9oQEr6CRetd+S09sxPsUawo+UyooXjmowg7UjC682cevWuCBjXhXlfMrMGjrDrLPQw5uwUSS9qGZx4K4yGsAq070U= 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=a36W5TtZ; arc=fail smtp.client-ip=40.107.236.66 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="a36W5TtZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b7b8JhfGOom6XICoDEZBPiLAKKsiD9MlSVwjHi1sgMgCPLTyli8rlWA/GwDc9o0UXcLmrN51iw1ROX3QciBaOvxVk5o8Ix1DMZovbT3Unc6JJMykR8y3oo5q1e7yYFUX16LkcBNTpLsgSF33lpOV6jhMcmzR1yB3XFgVsROIrZe7BCPmIv94EYnTiRQv/K7+hBVZuzgmKt+ZkQ+Pltss6nsc3LHshc3pQVe6Aox6vJe54VFXmY7S6ZN5syQmcIeKXGdp2QybL9Nqk5uV1+ZcLdyAAjX4DlZMnH1ojf4sezp9ILa0koJGJPkjo7H4XIKnDKDFW3ikwxaabtwrxZrROQ== 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=TTITGDel/3gDf5ViIed9lSwMnl3wRcq6dSwfN1tseBA=; b=StOEHlUhTTU/OELkE043vGSdI1sucnZMm1xKggzFEHqmZ2flF84tUgihEecPi39z/RSzIkrx2QnaKQnyRwLSfzFIaZUiNZQeuc92poRncg5EFlLT5V9LHyKiNZSl00SMhyVKKNzyk/KPGtyCbEqooRnEi0qg9Bo4aTjjdzJuqyQLreCOno8lGbtu7LA1oEhmb2ySredOFdptvjwSsQkJW129MCQ+rRjkDeag4K/CXjxaRq8HuN68OnXRX8TA6DaldSN1UkUssisXSqPA/L1aiD6JosWnZP/Gd8PUFvWsrnPRf5jrcjK5p1Wauzi5+zERKiAsDo1afkvVoe63TpTMxg== 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=TTITGDel/3gDf5ViIed9lSwMnl3wRcq6dSwfN1tseBA=; b=a36W5TtZj8VEskX9/2zgd5bk/JEBfHEYCkLAKvW2JPhQ/BumPqsiMPnK8bAp2b+AuPT4VmYSyP6f1pAs8IcUbsQJJ3viJzpCowYx6+VznszSW5o3g+jvpfGX/TDhYbzhV4XXB5wcS8IGTovdxz07JO1OpVFsdcVr0Q6uGAC2K/F1UurfJvJ36TdvVDp9eYWFJh2+M0Bj5r+ta5nbypHbhW8VJ1I02Steu5eV79DG09Kmq62AFteslQ+dIj5PDTDyKvrtvCMr5XeqrhbTOoSylSHgDnl2kvAWVWN9KurkpfXi16pFkjyTPCtlSYAiQgpjT0LZCcnTw9HUr9OmWpz2Hw== Received: from MW4PR04CA0347.namprd04.prod.outlook.com (2603:10b6:303:8a::22) by IA1PR12MB8493.namprd12.prod.outlook.com (2603:10b6:208:447::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Tue, 3 Dec 2024 14:33:21 +0000 Received: from SJ1PEPF00001CE2.namprd05.prod.outlook.com (2603:10b6:303:8a:cafe::be) by MW4PR04CA0347.outlook.office365.com (2603:10b6:303:8a::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:33:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00001CE2.mail.protection.outlook.com (10.167.242.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:33:20 +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; Tue, 3 Dec 2024 06:33: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; Tue, 3 Dec 2024 06:32:59 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 01/11] vxlan: In vxlan_rcv(), access flags through the vxlan netdevice Date: Tue, 3 Dec 2024 15:30:27 +0100 Message-ID: <534fd8e3835d30c33bba3d77f26f017bcf6b7923.1733235367.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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE2:EE_|IA1PR12MB8493:EE_ X-MS-Office365-Filtering-Correlation-Id: 77ebfb34-65a2-42b0-eca0-08dd13a76f7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: Wp412NdwYD6D1KsRcFh5B44NXUwF31IC2n32ENmKeMpcrB6oC/ZijTBTWZ/MpJpWa/3LAl+uOec3HWyfB0khunBCMpOklNwV9aCjzmNukaS176PyCVhDVQxARtei7zNBZvUn+BVLmvRcSdR7cWD/QAQ6uMIZvslE1xvaC5j6xpvLFhMlrvxBMSIbOr4MZpgSN2anhvX0zvL1jk8FPNBZmrAoeH3AyWmGsRgQOcpbix0FKw54JSqynvFptpm9Oc8zJkIex5ML/jcDOCz4ytmxowgqxrKTdGi6jYpF7l8s1AmPOVmi5mQu05dS8m1kKZUnor/XXEQbvtfy0tuFrZbsOgRHdWMlZnmTB4gvWe8IkI+yQK3cAmLKxO8rjGf1rqiRerf652utAnUAs7ezqEMCQYeQHFnZvXQ6irDNApV+rQynsmoMuwrg18nh32ll/53TAOAM4H06YcwyJX8fnKkcAfUbhFl2EJtpp/xHWS9A2GTmLH5GVYk3fSywnSINJpn9HaEyqsqxehdsZB8eRSlGVkizu4KVVZxlPLMJdxp0mlyuniOO4yPDGzJFAXOewxNKHhWRQTmOk6Qjgei1L7iooHt3i9iQNEj6GhT71NNZ5lj3f/bPp7HZtUQuZeJWNjuCEcbcOwpE4I52DNBYEmOcoabFT2KXQ7yTDVGbz5FAtpyi7R/80XnNR24Y3Xlv1RZit8XrODfYjp68TzpGRDnAY3Wue2MWwk5IvhYOiy0EqGJ1JgKjRJGfvdqzFzfO7HUMcAUv8a5OjzpRE7xElRqEBuOP67MPz9lm6e5m2Wgcw1GgKSbpdskwii5GKF7Fv/qeEv59mc/UFB90Kty1TZ8M9rmLsxZjvJOuXcN20CZatr8WkyTX04xG79kSf6uR76xwAsDrSvf8C7w5B/WBQ/GaGf3iPbtTpk6uN/RDLONXYEGKHcs+rx0zjqF+5SuEXjzHqhQOHhqMnvVtv4i9mq/IcZCNchnBn5ueRmD689wgDAF7hNUKWZivgJ0w+kXZ9f7QMpEwGMiDY7iwnOz0K3cBJ6hG98j5VZPDYvIqybammTbMYnZvs+RrFSxHqNqcfnK+ws7nvg1/5xyQcbPBGT4yU6IB729p9m2lWWcHJOrhKaLHNWL47AHenzepglDZoYN6ocosW4M+4wJ11/SEka2AmAboyZsEEhCBRbSOYoOG/lVvqny9DVzu+letedjSeO2A9wj6mw+twh9HnANX9i9RAPdqjoNl0EuXe81o1k/iavorMthq2pKrdx3tWQ6fFyNTKpdUCYmEdZdQiQ0jbRSGyVfefEyNnmiZsQxE0TQZS5P3t7lf2ZLz742JqTonOFVhmwv17Xq+q9DRAMni65Jh/WvO1ULGv7AJA0U082iARgBjStGS271u0n7rl/O0i5zEw7+vzX84wgk8Az867uZ2rCSnA/FZPRSX5k4bCsxvS8YTnw8StzhG6/s9p5nzz/kT X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:33:20.6243 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77ebfb34-65a2-42b0-eca0-08dd13a76f7b 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: SJ1PEPF00001CE2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8493 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892544 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2047.outbound.protection.outlook.com [40.107.243.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 E49051F666D for ; Tue, 3 Dec 2024 14:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236423; cv=fail; b=MVlp2ftWwkGejvicn/M+zbXphWJRF0Bzxw+dwcUgeD4pyRqeUT8K+GuWjeODY0jbqg2J8lWVZnv8o49fuy/MVIn6k/ohWYtpL0unDQYDT6t1s/qfTMjHetxKn/f5mG9QoVtsuZqgRu5zKXiayomePAcfXBP7gVQXWIrJrKs+OMo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236423; c=relaxed/simple; bh=4GQJIgOr+jH+qEZ9ZRA7gqMi8p4z+BPjtrbe0NQqaZQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lRcJEJ+vS7jvOO3OvnTatQho/hdxjvQbQy/xNIezXDi3ZpXcNrKmbo3qtZdf6xMnOq59Ckb7iUC/rsyYGKtht3EFHuDOfu01LHKdp9R8rHLY10MDdZ3VTbZq+1294S/fvtLzowdqbG+Rm+QuTSGQjE98vabBc7d0au27AqESBR8= 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=NH9IxxRe; arc=fail smtp.client-ip=40.107.243.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="NH9IxxRe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qyWm2q6ZP7LhT3/3nLLjbzD6IgI3bACl5ypaqqY0vAOPSBbCQSLWRmj0HvUsgGtI2tLm1gBVRiIcw3/LN43eshF1fg/JOpdi5BkFm+yTgE76xV1437qj6CvQuww/9ud7Ytc/vOTbfRuiP8nszbtVTHW1PiZgofDEySSZV2Ya4eL5nLGB0Ki2WJ6P821/IdiSLZs7Xwlkui91MO0HaeQqLZLXE0Bp2c9i9uGf76zCGAvOyLrlu0aFcEhqOKYL7nhSXPBxcjg5xfqX02XUIG0p9OeqxHew5p+Vw3O1frTYFw6XbEkVX6HKSNMDKucK13h/5g0KuaIEzoXQO6kDXBVKVA== 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=UtiXRJGrc+4Q43BPC3VbY3lGq+9yXd3YB1cIMyWnEKY=; b=fODcmZ5p6DYbQMPrITKN/atOCikBe9jV86RcsHdrXGpXonLNzlMG6eJQkVdVgp4Afx9vEpLWfbtB0gjaaeItHfYuqSqDzXaHHy0tLkGgswE8he/xry5srEH9761FWLYQlTewCPd35R3gv4moDN1yuUlT2lz8NO4N61Fes1oJ4uqWRst8QXLZygZJ3502owCqTp1nGAJ0416GxZIEq1KG3IinsG6XgfuVGolSUWPEeLaQ128L3c5sbGf+bd0X40modIPIqTiajqGhq3eCvrnH46DZ3R6iB2ivgcesYMzw6niQk4sXaB0GFPHH/A1zgc32W1hMfRAHDVsEC9blg+qxTQ== 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=UtiXRJGrc+4Q43BPC3VbY3lGq+9yXd3YB1cIMyWnEKY=; b=NH9IxxRejQSLeCDUEaeRvfMyQuySMzRYhFHIQKmhHz6bXEK0yy0TrByQFS/FQhGBOR0RFdNGKiYEFhHXsqxdtUPcnUw7YNZiHJCBGixuUCnbYUW8qz5wOQf1zGwgxljPtlEdqKT8NwZ+uv/PsgF6oMCemP8Mxkd/DoudgMoMsfsXb8B11cfyIdHjDbfH0KyVYYXP3SBHIxL7ujvzHbOYmDVN8F4/00oZ+PpqgmhKXRJ2RK5jotTZxI/VDTLxUNYpIZHiNJupheuhMJYaefJ6ZuNxXzZaqKDfPkoEqbdGc1H8380O4L2zspLxi0G0LXg9nsFd6UrpGXLe6a1gEPlCaA== Received: from MW4PR03CA0219.namprd03.prod.outlook.com (2603:10b6:303:b9::14) by PH8PR12MB7182.namprd12.prod.outlook.com (2603:10b6:510:229::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.18; Tue, 3 Dec 2024 14:33:35 +0000 Received: from SJ1PEPF00001CDC.namprd05.prod.outlook.com (2603:10b6:303:b9:cafe::22) by MW4PR03CA0219.outlook.office365.com (2603:10b6:303:b9::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:33:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF00001CDC.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:33:34 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 3 Dec 2024 06:33:15 -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; Tue, 3 Dec 2024 06:33:08 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 02/11] vxlan: vxlan_rcv() callees: Move clearing of unparsed flags out Date: Tue, 3 Dec 2024 15:30:28 +0100 Message-ID: <4954b8bb05480aa5ac8fc4a417a196e18c2a0dfa.1733235367.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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDC:EE_|PH8PR12MB7182:EE_ X-MS-Office365-Filtering-Correlation-Id: a33ca949-05f9-4c24-9425-08dd13a777f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|1800799024|376014; X-Microsoft-Antispam-Message-Info: 7uV/aMXhgxhk48srWf+l0sWeHKmB7f5ppSmbzBzHyMw6XZRModet0zGlwBVbSBxi2qTIGMI2IoXPCAh6p+StwUdhWJ78kLhgkhtKTa0HCPm5dZK1vMQNbkuF2u0Ki9UAn9R3OeXmLPFhxJzGZ3COMUUw0iPQXSkTn2Mg0cFxlNQy55Qe/VJCT43rgppSKv3ikUb1YU4/Rd5yEjc71SOi07BPeheaDWK0pVALZx+tJRmmRtS/plr/2outMKV8R/K2pcjpV7Xk0IrxT9NUhvgWpBIu2f9E2eBzOfFnrlLKT0KC7eg6zDX+K6/+Rz6DxJhosheWrl+rkQHanpnu65kjY/v6urhqAKcsvgH04K/U3yPfdhBJ+CtgOE6jdLPxfKy/lfEnY3l2LKI0UyCNgqsKWlf1XlX1i81dG2Uc5tla9nielpn6r17Ap6eb/ddVz0I1VKnSGY2FurxpFC6pOaxdJRfyflUGHQh8vDR1+gfrl7xtDN+E3DDhjBN6iuK6qbIfI12bHdTNtXhS2fVRoZ0fossNQ1TUmwiW+i4ImwzutCOVYksAAJzqQHz7YLvPnZI9IqijAnSlucdZrGwi7uYv9R/6+I928a3Bi9vHFtpX/x2DvzWFCEJc/xdhmswhROfc3avq4BseIdBIIeVADEm97lQHxXWLV1XL3K2+fkUkl4qDVfSeetAeYbX9yCIAYz3GlxK6RGlq1UiTUyxNKGt396Laox6OuKd8f7ABkN+Og4UesomPRc7KJTgxivrSdrLV3fvsIKXgKqzLJa5++j02KycoTleeQLgBO8+Ee43Ej4eDiJ7UsSslaEfoxV7Z0Kxsc7Ut0F8ovCq4XkxfbUlPy7KyRWjGJMHrNEQ2tHNw4UeR176S2rQojJIY3283tkod1n41xCVZuGQ0V4Au2Ik1qKBT6aqwrsCq/mpepDS/ZRrAofefnEJWAWganZoiC6Yg93xscqghip33n5tGymmOURBRFxMP0LP9GZyEj0BPUtcvobtfHLi33NDVehv5Kqt5B8AXYYhiU9gDXCe9QGLBwnMUBFFZlPbMzfm0cotKLt0VnaAGTDRAwi5+LQoJGu4Oiezxv4YgYqQ2AtfaixvbVYlkONRB0VeulJP91XKh9KOelT1QcRZq96oafYWzeixFZW74YBGNm/nh9yxcm0owBaYAKDUQZpd03vXxYkprLfMwEceFIUBjgzKTHGKmbYakO5FFDJLTI2raNomueQUPdtKxaPOjkU9Y589niEJ7eeBjXU0xhhGs60PgD27uVsvxLQBQfbUcAouH7QW6tuN0fdoA4LarBgfDQbluoLVbZB6HxMLP+x321GJLmd/LZisTHAJHXzBsGGvtDru9NbwUqdlauGj9esNbsX8VIU5/oMCSn9KKDwXq7eIQAgqMAWKq15k9McrzjtEnBRjygR5RGhuNTpEXwuloHLMR8gEDTaInFiD4fNriFZfDW8Q3Jmy8 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)(36860700013)(82310400026)(7416014)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:33:34.8811 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a33ca949-05f9-4c24-9425-08dd13a777f6 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: SJ1PEPF00001CDC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7182 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892545 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2084.outbound.protection.outlook.com [40.107.220.84]) (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 9A9331F6678 for ; Tue, 3 Dec 2024 14:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236426; cv=fail; b=tUH19rU7xCD03gbRUed0oWkuxDeu1gQT/1DIMtodZhsM4XJo5eOzEgnuXgTHO7a5sp9d9OSLcPFsgTkWi0mG+RyEoc7RpjfhEe883poExNaClxLVRFORAJxXNfjODu4sCa1wUUCuz4gV5+gh6YK2ZMwoNIuyhaIS5zFW5hBIOwo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236426; c=relaxed/simple; bh=puIhedtgnUJxO2rEFJt0S9bD/HV0lyDPWWjXdJmYyF4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kU2OWMnBWuzZOMBV3XnCVf3dJWNJOrWn44cdRIHox1VmXzalYak51lrR7E2wLB8OgZWFUA/IWHF15FdbZt6hu1TmAZevFqEdHkuaRhNDHJi4G4drguBCxppfcMwnwKRLLL8uU0Ch6yH54eGO4nHEku094Fq90sfPRr8WHrG7WZA= 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=WpRIMG/I; arc=fail smtp.client-ip=40.107.220.84 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="WpRIMG/I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k+gkTFbysZSFCgLIYeC9StqCh5pD9bfqFaABiXhNB5D7hcaBc1UYvJVbsm3o/obuiHnMo1SVRWDcc+nb19EmFdjVxh9XWYAjwB6ugJpM+s1gU67rGIQ9w/A1/jo3GTCjmLBDZPLYaUVCMz6Lssdz3R8VKmvaAnuyK1yNpysW8YVLXU2rTB4Qp6klRfnTDhnLL0GY27Ics9VV9lO+Lx6QbZbNXRoDzSowIq4f3l6DPAreiRnYob9N7/O/Nd0ZNwMvAQlaAheJMRd844S9BwykJE3F9dz74+IzxbVCPP56d1u1mItlsUfKgcPPTapVFGLdugPiqwl/DahrEpAg2FFrhg== 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=ore/hU3zp+Byhib/gI1Qt+HFR+rjbqwfwomGv1BF08g=; b=oFjnlSroqgvJdbCaWbj93g0V+tMkzOphuuuhIDtbJ9F0On/L2QT7fH/3iTtODIfxfkZIsw4gd667ZyhRMBeEio71dePgelpah4IpQjeJXDSYfMTqddQEH0kSI8PTz9XlyVN9dwqnuiVEMF6iuOFuA5DEnjyhmZacHVXsW1vey+oc4MujnOSgQ5I/4zdfIWNjFioOeAEJoO0gLuhD3aclTLY2Y/MSf/UBdXI3zKiJr2xCydq25kuLBxNzEZijMEniveBi9Q1+kb+UATMuUFk6UDeTFW+Vp3IZKRjoBSP5aGFTJ+fz2met59Jww5tfgTTwOnKbpfq0+6z5KTW4oNsETQ== 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=ore/hU3zp+Byhib/gI1Qt+HFR+rjbqwfwomGv1BF08g=; b=WpRIMG/IfkDWXMEBas1NkJhH9CEOxL0PNtvQj6jZWXUYhbcu//VRwdywpCY/nEcuXre6ANaYXnNtMoA/micsupAWl14APb9nxD51+9m2cPf83zPZtfshecYR83RJ/Nj/kK5QNvPZb+Tg9NnOxrCx9CU71EwinZZY8Fs6u1CAvAXdwsifn09FGTHt/uuOCaidCxFfKI7C6VSe+UteRai3rpoaGuhw+3OWCe3Mr0TAkkgy/kJs4zayXLPYevbvcjzqEtV6tq46EQefjOwF3XweXF1jgV9qZkDLIP6IcKu29CdiCeVg141ZmTc5o9wo1M+LEiWQsAHYh1lj+g4EKoJu2Q== Received: from CH5PR05CA0003.namprd05.prod.outlook.com (2603:10b6:610:1f0::16) by IA0PR12MB7603.namprd12.prod.outlook.com (2603:10b6:208:439::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Tue, 3 Dec 2024 14:33:40 +0000 Received: from CH3PEPF00000017.namprd21.prod.outlook.com (2603:10b6:610:1f0:cafe::e5) by CH5PR05CA0003.outlook.office365.com (2603:10b6:610:1f0::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.9 via Frontend Transport; Tue, 3 Dec 2024 14:33:40 +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 CH3PEPF00000017.mail.protection.outlook.com (10.167.244.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.1 via Frontend Transport; Tue, 3 Dec 2024 14:33:39 +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; Tue, 3 Dec 2024 06:33:22 -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; Tue, 3 Dec 2024 06:33:15 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 03/11] vxlan: vxlan_rcv() callees: Drop the unparsed argument Date: Tue, 3 Dec 2024 15:30:29 +0100 Message-ID: <447beffc2adcaf8ffc6a6d066e8d9c71db3c5f8d.1733235367.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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000017:EE_|IA0PR12MB7603:EE_ X-MS-Office365-Filtering-Correlation-Id: fbacca2c-49a6-4ca4-dffe-08dd13a77adf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: gCXE/FwY8uHyV7GjF7MmtO7scaTzQvGVrJV4n0XPPrnE8eJYiYZU1FlQ1+ca82u3NSexIzZp1Gneo/321B6USIfNFqgCwhKeJ6Ym67xJNpdEHMSI7FsZpGQLCMZS1MwKb5lQ5OOfXt/e0xmF99QBJBg0QPoQr5HkGXm8zAC6iiAv/nLrXXbY/rXsgn01tcpArmiqxR6yY1buiXXCuNGeXHp7+NkqcEBmimypBxG+iRL0Ow+R8Y/L9L1IMMkUBqAlOkamOLJeRVMtnQV0iD2gG6b09ywBYg3xL7xoVjKUfwUX/5ygc0s1c9gDh5WLZdBCwfXBx8u+k3z3F1XwKeg0Jfrd/LyRbVXzLWvhO2BblUZ/bdGSba1mhq4bZX4quVR0awyCQk2xm92fJEDC41AiRDFsgFqwQ2UsADOLCFU/Lb/taQcNsDu9/0rjXNJRMA36yaTUJiXN2gBrWteXSTC0yt6ocuqqUur0x4V0GCGaTOZ2Hi1IKQQmEZp3wcquep+I0/qH7vSwLRp88UkEBKBMMMcElE61qXpziAFdAG+i5pahY1sWaKkt1DSM88I3NOPTe/5VYnByJfVpIe4k8RlzvKH36KIuEyX2e5LsWgWGcMbYgWLgwPZsS323CL0/dL8j6DAG6L5RAWEHdQDGDNmR05CQXjiaC+I6FWGX5Yq5MzDPP03O38jIHLSsXjVOEw0Nrr5fNuvdhSpUxQfqntmlB1Sbwp0KbDv3kVnUS9wXDILy0TYoGVhFatyA9CsidMLmB3mDHoCVReWudCWZEH8XoGK62WCx26nFDo+lAaivXFlAUlwB1G/h7X0pH2l+Chb4YRrpnKPV82Eo/bUXh5dJ+f8QRrlsGWLTob8UMoHcS+FotvJhYaRTuPfnM0v2IDe6DxESYRaDRcHS8hx3rJRsOvgoxF4h1Sjqy0yveL4QNY1QYSvwdzVYh+QHxO9Cz6BVjeu3/EVggwxystGbiVSYIrwGB1n7YOsV4mDapyBeSaARSOLBTLpBzooWLoouAHTy7WJpTwWTRX7V+ncwZZrrSiOd1PP4EFyDDE7b7ZsC060Gibvet5RpuZW+SxCsCHW79Qz5l4wVTYkLxj9DhzqeW33DqRaWEQArI/EVwZVuPsQFZQAwdcDdsiv0BNy6/KYILLEd6y/bZWX/oauGjL+Ta73MzRz5sSILbJv+9y90i5JnORiHzmjlQxx+zxt+Pi50g+sGE8htyR/CUlG9hbtaataGiVsCFvPmrxVQsgD2QdNQk8q+XS1w1Hh9XKu9olzVgXX3s8aZpaH9cclWrA2+koZAW7cql46as1/yT4tPbc2aVrc1wYdWqOPlGLGBkUtvqzdlQpN+vcMPaUaCIJcPP1+w0upypmH3kvUtTGFbyGSh8/AIwsTeLHFaq2LuVjqfYbT3I6rcHtPqR2vgcxIqFUJuaTog3Mlv3nHMROWkckR9ZOSd4McRFkJwpSHytawc 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)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:33:39.6561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbacca2c-49a6-4ca4-dffe-08dd13a77adf 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: CH3PEPF00000017.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7603 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892546 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2087.outbound.protection.outlook.com [40.107.243.87]) (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 5FC341DE2DE for ; Tue, 3 Dec 2024 14:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236434; cv=fail; b=VlAdtqG5tqntOr0rGPU7GDAYxOZP6YB+MTARqXP7D6NnLHMLq8K1KLAANh+D7CLSpcCyGJ8rH5J3OUZOR3EtjqQVEr5UExlPQSt4YGfF8dc6SyTBr0kkEBKsxABZlMlGFPU1FKvVot3GJy8pNiJINAV+q2CgQrTkDvAcK0fwvPQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236434; c=relaxed/simple; bh=Ki34WqS/EMstIYWIphDnz6sxQu0buEjLc1aAWSgDkTM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i0yTchl2dl9PND5Da29D9jTNOaxpVcHjLKWZNlekMVovie+NWFuog6+a5j7lvnyi27hwfgaWha1H8Cv2Lr9mPC4GnwrhxSs3LTIpT6RG4vR3BS8uSRstJRAGX31GEUVIUvi80EWKY77Nl50kSsg+rge4iAEbgYMnHvcqkKJP+v8= 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=iMdsVFyX; arc=fail smtp.client-ip=40.107.243.87 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="iMdsVFyX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kWncgZAtw8A9VGDuW7iT4AD4/1tPAMnhV5PcvDGW/0uimnD2nVeAuOHBPsyHx5/V+uChv2nxx29WZieJFaDkGrmwGaPJeEFMu/EnUYcGeD8D9r8r5YS/5D60I4xJ0i17NdcDEqYuIItBYaaz5Yp9onp4CQYnCsIFDLnZOhX3ujCTbG6Hw3EY9nvUkgHI3iaSA40Qudtp/eFYsYrYX8EaOKkHYs52ngvvYHY469mt+9nvzLYxV9W8fGhLxlkonzfQrNv5FhHZxzodUxHefP2mUSoXLD8FvXv+3HK1YS7NUNIqwX5sFdYdsvuPAYq5Vd8aiFGdALENl4j6UwRAqN+G5g== 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=pG4kirMCXuWKuB+/aEVMWgu7OJOXrIZK2s+qV7ZAZBI=; b=Y0VKZOMIQ+kbgA2NSr1Ges3ZXz4FitWwjkvlfPOj2KUYniFvu/rTSASoXd480bVl3YzbY8lhCU7tbLL2oYVH2yTgnES+vlno1UlkqqgfLCyHXiLwktG6h5MUYojirCWFKz3cXLnFqb1hrszfYpR777ysWUX9yUcrMpnwLsCCY9qP9H2v/Y3B5TI+8cQMzfHi9NHQq3DPZedU9t6r+BNbcR7WqCEBmkbyczdhZfB+MgHUjlr5C2HxLG7BRiWneMj2VQmbwYZAsRiOzN51Gn4WcycLo+A4QiH6d4Jv9Ol6tK0fSF0k47hR491KlNo6z0QzjZf24qHhDLUNLY2SZTUafA== 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=pG4kirMCXuWKuB+/aEVMWgu7OJOXrIZK2s+qV7ZAZBI=; b=iMdsVFyX00KPr2+gOiIz2Ttpf9+wdBRdcBP/78wD+9z/hcPZP33bNjQ0WeKWCCLF6u9PP9Z3TVLGi6F4IUA9919ezTZtfRyi7wbal5+sl5VcDaMLIzfgSrbBAkquqQdwTMJ8uG0ki/zSh5XbZO4jLw9X2pZv63DRRcLOW6WGq3QZRmWD7y6nKWZLn7I9z6UgYc2g7D7ZKRFVC5pYxXcZnCep2LxNE1wzW0L39cjpi9Lhx7x/kNR44rHeJjg90BTG3YZ2RaOujBw1CgZJeVCwaHs84o6M5pNukeTuQ/icV0MoHb9wKQx5PC8PHrmQEY00UcYnIFSWJfcq/wMDFjLbtw== Received: from CH2PR04CA0024.namprd04.prod.outlook.com (2603:10b6:610:52::34) by SA1PR12MB7270.namprd12.prod.outlook.com (2603:10b6:806:2b9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Tue, 3 Dec 2024 14:33:47 +0000 Received: from CH3PEPF00000016.namprd21.prod.outlook.com (2603:10b6:610:52:cafe::a4) by CH2PR04CA0024.outlook.office365.com (2603:10b6:610:52::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:33:46 +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 CH3PEPF00000016.mail.protection.outlook.com (10.167.244.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.1 via Frontend Transport; Tue, 3 Dec 2024 14:33: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; Tue, 3 Dec 2024 06:33:28 -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; Tue, 3 Dec 2024 06:33:22 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 04/11] vxlan: vxlan_rcv(): Extract vxlan_hdr(skb) to a named variable Date: Tue, 3 Dec 2024 15:30:30 +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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000016:EE_|SA1PR12MB7270:EE_ X-MS-Office365-Filtering-Correlation-Id: ebdf0893-5449-4784-67be-08dd13a77ee0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: S7YfUxLl/d6e25TMNS/RvjcSHtdLn29hJuduXdfjZLp39J7qnoDJlu9yX0hRjGR9pMkdRDPf8/9yAkC980hGMR4kuJXjuTX+G/8OgAW+pMk4zlmN+p1ifRPUC1tjyZm2BF+J1jL0xkjdlHjES/hry6+jxE71ulZFhhgSzfzqNP+xWF89JsB/65xVrMg/ZxIk0s+ATo2ZvZPlhOP6b6O7nTkwEwVAf/RMHE7FpKXm2OebZv+siLlYpRmFe0sIqyWiLeNfCnaE6KtVLKa3VWphP/+2zmtNMi2zjz3t0cEOb40U4SbBK5ggnwJIEdH1kE81QR5t38ZLRZq+cCLy0bjfTdFd7Anoc7SN1vhWf72RRBaO5PxFMk2bFFjcOHJNMLiFl39B7j4dwwmo6svSL3flSAxmuQsRbB8JK8rSeeLBWmhBlYl4Wvzl3zoGEZlJAxyJgsL906IYPQro+dfseR69Nlfh+vKoqY9cQzVsjV0IQAUXWLIEw50EgRYbHxyyKGhMqzUgiP1PvlEd7RQsEjPp42QaOpz5ycNrbS/+0KC3M6oeUlmZ7pDvmvNp7rnCZSgEhG+g03oop20boVp4bcFTznIiOKki4Z2lT/BPXv5BjvwPrSELZ0Axg8Fu+Fnl33b3i4l3motVgPJzD9quPbSuAoXSUI+0bC4jY7WvLRptgI7JXOF5tPwW0gKC4Wy0JeV94JOb+PuDopn5gwG0P2zkn5T6MditMmLmgDtSyeJwziCCm7o1jH+SYNC86PDVxFujyMaL6FcJx36GAlhKdiSAxrjqSnVSJ5XOtiK2eRSqZtugaowOi2aWZ6ScbTsHRQsEddN4iBpqMAImxewRhYRHVR/ttW1AZIntM9pGzbBJtGLXSzsNEW1F+HD5Mb2Z04vj76DKWDoLKRRaNukqNXS6N+wBLWDftStlGO8sx47SHKyqP4mreIrO6J4P2fu89O0YjrEbZ72cdjqZ+AMEBsH38N7vD7ki5ryHrSnPmmZwHGqQFAcEqCYHsMKACoaHVg3zTBcBsMxLr5izGbyAMTz6U+aYl3rtafRgSARvE2b9yV5FKCEUqqvUdbmcH1iFGa0Q7GC/TArGh/7Hi67L7IM29hqQ0QhQ9MfjN7u0J/tSkwlxNO+e2WB5+YZQkuq5urH62Qh4V4cX7dSX/B2Yu5jbE4b52DyhzyhWUHSPX1CVQY6K6fYVlHMaHMFI+8rwN+7zLmW/KzY1tB5LKEIWNG8L1l1XBHUuNp5MbI76epTS/TG0KmGlAh6zOM6oHHwM05ZxJK/0HFoQ31DiqkfbkqCuNTLCVOMyhtMnOuOWYSm1KYDY9yZ2AK8QiwCGhNm05p9V3KosX8qLLqFk8hM5jKhtLco1BuXGScAz3fC3rsXM2dne6dlDPqLudurHbWbcQ58H0l8gUAS+TUOnBJd3W4BuwRct79FYLoZxPscow+tu43suWqGf/82fCoMnM3dzK3BE 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)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:33:46.3705 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebdf0893-5449-4784-67be-08dd13a77ee0 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: CH3PEPF00000016.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7270 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892553 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2065.outbound.protection.outlook.com [40.107.94.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 529EF1F666B for ; Tue, 3 Dec 2024 14:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236444; cv=fail; b=TQGGLN8P2IeNnZ+Akh4x7BaZ196Gc4TbIiXS1K7vQROvNpHsKqo1rc2N+EBo0RRFsevUsfeuhI6ETt062p9gBcN2Btqh/U5PSODKvF/aMmBxfD04zoAsvz9FO+5+hnBxkRZZAI32EtJE/t+sBxJu8yX0h7hZkSOpx13QiM3nND8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236444; c=relaxed/simple; bh=0QmFPrVoeljshE3RVJrLrbOfvHDE7gM+PG2kPH3o+z8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DJs0AHs1ySQ9EUrRRdKiOXl7loxhkh7bllXA6ACprRkJmu14d3SPK24zO/YFDnf66fXEi10j6nOBVOUK/sTqJb/3TvxPYMasIraDp110xjF/nnJMh5PXdRHmA6zJKD/d58h+1QxQXAk0vaJB/hy1sohiFFxilbDhJpngNyPDmUI= 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=etYd4pvC; arc=fail smtp.client-ip=40.107.94.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="etYd4pvC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y71/o8AfPTFRD1ttTAT3gJ+tUawtChMpz9RKLao7qsUGd1QD5EyanVC/Ruzsn7WgD9vUJSOowg/aoBzSWxaQGG82dybPEyHoQr0Ak5c7h3os9xFUB6mG6xinit5Ox8GQz2prS60bMIAsA+9fA8pe3ktpOff16VJQPlg3GbyrPP7G8J0XaPCfWnoDRxtZuparXJGRRBR4xDd1JymkvNAWs7pcmK2Hcdr1ajZL9hQxsrPqA6ROIOaSguBIQ/YJrlqneI7+kkHbtIen5+3XOJNCarVryiwdbi1gyixQ5zrVy4c5cz/sIULBn06Agh3xa7qUHGKCkqSjf2mHqOC9v5S3Zw== 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=KPCMipYqGYR39DZ+39R6SbaLySfENKqOpks0LSsdB1Q=; b=xl5NfV+fkbnU5fMTz9+0LvyG0z6ZBNJ1bn+4qWTrl/Rf6+tJuFz78MfvtBURewmeP2eOjkvgV5Hu9eILBQZFw4FB0jcqIH4Y2bGl0i6CbkVsiit4An/KF0HDQ0nCcFcVn5RaUW7WGAz1Ic/JyyNLhZ+P7fhjmIQ3dufcIeXYM0SqbfNKhUWscJ/tkuEpFbtvVCd1RJnVPO+2dfXh/1xIhB63NSM1oDK9gd6SuQNSH14z9qHHg1My8fQG0j7/RnHDxOipx+rmHvQ5YwkINcTmVENtdK1Lqt4/7BCesYyk57vuGMHQ7uSSALDRS5EyAK1v815xFIggUe1lFnvtKWKplQ== 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=KPCMipYqGYR39DZ+39R6SbaLySfENKqOpks0LSsdB1Q=; b=etYd4pvC5x9dTJ59dPfe4Vo8WXPUZQ0WPxpeiNNBVg6VdjsBgMPVHclkRVtKTmHosiOE3F2zwuu5TfDYxa2nnRfQ+xfYZos4KL5hpJ+QCvlPxevd0krxoCv6id6k9yDj2nMELK0DVVEWmsNkNBO1tcqrPPOb0wudh1d8GncWGrsQjlaugGYHJ7LB5m4x2EhSetzUEN65HB1Yp3jC5fC2vpgzBvo/3KWJA1O0I8d+cJR8ewzbt9X+YTPyoyZU8m/RQPyOKAcv4X4IPTXSGtYwP7ziE+wjU51Bikuqc3rSKJFvUjNR0QGbFmNsn9KVknHpyDAbBc/+kPBUAxBrHW7trQ== Received: from SJ0PR03CA0277.namprd03.prod.outlook.com (2603:10b6:a03:39e::12) by MN6PR12MB8590.namprd12.prod.outlook.com (2603:10b6:208:47c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Tue, 3 Dec 2024 14:33:56 +0000 Received: from MWH0EPF000971E8.namprd02.prod.outlook.com (2603:10b6:a03:39e:cafe::d0) by SJ0PR03CA0277.outlook.office365.com (2603:10b6:a03:39e::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:33:56 +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 MWH0EPF000971E8.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:33:55 +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; Tue, 3 Dec 2024 06:33: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; Tue, 3 Dec 2024 06:33:29 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 05/11] vxlan: Track reserved bits explicitly as part of the configuration Date: Tue, 3 Dec 2024 15:30:31 +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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E8:EE_|MN6PR12MB8590:EE_ X-MS-Office365-Filtering-Correlation-Id: e1401fd3-60cc-43f1-c4ba-08dd13a7848c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: BwuM5INChk3JovyRYodudxgDpyQ/OORhWzIdLUKlJ25WR+fpp3HPL6WduRgPlzJQ2uynJTZsAFYi+tKIJ881nMD62VP9r3WORDO+I2gP/5asr43O1ox9jzjS1Tee8fjxIuvFiXUx4p3mjmFPRgv4RZAwq/9/opX1nddIriPIVzniS5nvv2HdFJp0g5nwwIuI8PX+5+HtOPN31NEqrVjBne/E1dA0hi5gvO/DZlVYp7WVCgJ7aMD7Sb90kUoLxNa3V+KgDHjyriWvnsJW+plL/EPeBFgJHMqsmWgxUGZ0x4X4aHYOjVjmhe0ptfH3ZyTsXiWfvbWJljgQRWTEi9ozod+UrqsbH4d7RYXFcC9/XlfTYizgj2cq+587VWDcXbEaSy0gUigoogHpduta51FVesTh5T0YurJs2BRZvVxFsfkW/NCqcIXGqbOD9EJbKoQ+auI1IBag5h9IXwxpIcZP6kKG22tfQ9sp4T1g4Mhl4nALEDW7TyNdNfAESOxaKnJbvpTeOnjcbKSxQDNpSsqQmXIYC0zlcCZFK3NJWfoJsGeuIWZbbHbgqmo6bdnIq4amxqyBVNJLJ2Dth5qR1Af8uy79ZZzhnUyZPpFeVXCHAkN1PsEkTKiAsMv7oYakpfwMPW9QbUXIlOc2VcQWYzkojm9WRlqDyAtbFeaClTLT4HQNnawW1Zc1V4bBbH/kZgwVYqdvJyIt0u/PkqTzaBdtym52n6DeN/l9p4BMlNV8gKYotrfus3J//MNsbsrgPtUeTsEynlPpmLNhFWsqLodjg7Mh3PdMNnmmpdV3Z6d0bFa0vk8qKw9cwI8SIu1tNV/WzZoEGcohaUheQW4nrzynOD5+Nyjx2PmFoFewcKxFOwGg8bFXCeJnikMaBZDGoV7TlKvnUpjGEfSHSfy6CMRJG4eS9jx8veK3WES+2WXPyNDALLFDdxIsnyoFOslbuvq/1EBlWlJffIy/Ar+tJN4MR4sB6ssaL0pzK5REMHdnBpPiL0jpfKjbVnUlvHDQ5jKdtNezyb27wix/8XTL25+kbjRbNDPoHUsUixPsTqh6AvHWQ/maKlqmpaVMPD6qN+WijiY2gijQfsFoVdFvh66JiskgBOBB04cpgeESV042DPydxwBI8U2T/wQHQQq8zYrNanplFUviRKE/wsCDeMS12kngm16HqmCa6VEYnq/Ma8ar0LpxZOB3FVJeia2RXtpQ+Zmtrqp8AtU9sDTOuwVkqPhf4dBChrcfN3BZ8O+TQUY6weu6CDRktsQz+KHFb/1XGc9jnD+5laUYpQsa8rwWxFO0syD0+/93AOhzrgqE08dV/SyMnaRj4W38mz/DLATMQYIPQpR4+5/F6IwFnQ5qr8ZmxHWAfv+ZHFFWMx4PGjWF2orx0YDM2v7YOXdViOHk4jpd7pNPm1WLViUzfkbpfKMY7gvD6vhfNG/UGQIzb2YhG0vX+7qfrrGaVhDQM9bH X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:33:55.9512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1401fd3-60cc-43f1-c4ba-08dd13a7848c 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: MWH0EPF000971E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8590 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 41 +++++++++++++++++++++++++--------- include/net/vxlan.h | 1 + 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892554 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) (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 0B6DE1F7060 for ; Tue, 3 Dec 2024 14:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236450; cv=fail; b=d1xIQugYYCirt199gXDZOIuRt+l9yrAZjVJJKFN/TeaqND/W43uNKCwHgm7PTcPZjgp30nJMjGzNHH3Qg9tA5UFvybjPitmyptEfH7VIgn0qcNMYtPbzaldcIZTYh2NQuQnBucw56ILLqZSDcDiw/bi9wsoUcOJfuKHy6dCCdIg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236450; c=relaxed/simple; bh=Q3aJjk/vGT+Zq338I6ED/u91MH0bn6fz6fT2ugyytHc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LFVDlM0/QvjSS1d0hsadcPYAgOLUgnkUnIwGQP/Bv6UJOeW8OPQgFNFuqePozBTgjzzpmFCn8OcrcBI1qTwZEgjsUGdBA7ucZtwhrvIoQn5mBT9gdNXtBP1fQL1YUWQSMh6fvdv7LJG1B13O3Pm5oJfLBzP9WvgZezdAJKZ1spk= 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=SXMrSASQ; arc=fail smtp.client-ip=40.107.93.50 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="SXMrSASQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gevZXsbnfLh5XBKHrUiN/IeKhU/uFWu0fAF43q88w8owm8omHIEfWSxp1Dzj/8Y9v7JEzCwZN5u51uBjJE0oU5KvHcmyjH7FAoFf23oY2mMVdMCG8huRpU9VZhYVXxTupdWcpG+i8ZwBaHRT1bkKbNEh6CKeR73KuLMe4NIl4jhderFjCssmWjUctDmVn4pLWu5YEWO8azdLe2+nz17bP8usCmQtRNmSaUy35mLv6Z+K91wvvG9X+tO1qarAoIMbsrLRe/lOptasRQFn3a98QQ7bfHq8XRrZmAM1zbs1pFa+lYU0DsFzaOCneQb4nxmAUwSlMl+w+CgO1nw6AUoJfA== 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=g++9x6/WWOpx21Ct0wyRZir0Icn04lrIgiInhlZHoqQ=; b=cp/9eWaV2ccnGpqP20+37fEW0PKQjZugWiZayWYAc/gZSXiohLBO9KJeFfRYQENGU7TH8I1vmjHCjZsN8KG41kIf2RkVNarmtiliwhug4pLatp3jQ1YO+sJGRiIoj2tOGLh98il9/ev7qK8gXqdqEOjI/Tra/jpeNaZiEYEfoPU5n6Ctxx2Zhdjd2NiqfIcaQE8DsAsxERWcIernSbDHqdMjaD60l4bZAuW7cvqhd4wiQCA2/ZQdnm8eIzzYQLu48d+1ozIDc6HnE0/3PlTWxM83x/x3NK/0QHdnN24cQNBWcZ2RyqMA5Tv9iGc4uAH3Gbtb3riWQeMOEFj860iv1Q== 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=g++9x6/WWOpx21Ct0wyRZir0Icn04lrIgiInhlZHoqQ=; b=SXMrSASQwbfr0gRi+YhFgOCPiPtFsewkT2qTv5lHAeyYDTUMizvzGkGoMZMdXREatgAqyUcPqVlhjDjX3BkZJtStAZdB4S/0mDFZ7gT0Gn3FXu9sdrmqIqCku5lZ0tM8C/TAhUz9+z4l8tqK5VdRugMMZnWqxVPNu33nI9U5l42amYySt7qw35eSFqRXTNpOUN7ypvnC3qCXIMptqowgKIrKS+zOiQWP184q4YuqN5e1u2urpKgKcHky2FPtrLlXTcvHFnowxDBAe2KcA4cGUeEi8ZyjD/Uon9zpPd3vXGygHbS1rzLN+qRxVqSDEE2zRd14+vZEEw2M2Sn/GKdBPA== Received: from SJ0P220CA0004.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::9) by MN0PR12MB6103.namprd12.prod.outlook.com (2603:10b6:208:3c9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.17; Tue, 3 Dec 2024 14:34:03 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:41b:cafe::b3) by SJ0P220CA0004.outlook.office365.com (2603:10b6:a03:41b::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:34:03 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:34:02 +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; Tue, 3 Dec 2024 06:33:43 -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; Tue, 3 Dec 2024 06:33:35 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 06/11] vxlan: Bump error counters for header mismatches Date: Tue, 3 Dec 2024 15:30:32 +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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|MN0PR12MB6103:EE_ X-MS-Office365-Filtering-Correlation-Id: 713310fd-34b9-4a68-d702-08dd13a7887e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: zcLz07fPQRMZ7mca5XFIe+CET96VG0abZ6YV656c6XJuJandtf/ZX5zyHwQ5K5fSNIi4hRF/qtjDn3Dx6MT5oLFjU4NgHy89/rKRmnbvcytFO5IMUMv2z3+Ojc6qPcgN7eeHg2PdPYpvBrFAPO0+VAAM3o/B/FKTn+pWyEFauV7eJIFgdVv50TYuJ5acutWxzOS59vasdcAFt51lTlfqLz7P8SDJ/nCFGl1P8Smmn47cXF47iuA7WWEzrkr5Qm4weZ7bvaR5B2owigyB9zFNpscDHn7UjAqJk9bjf+8Mg14nqzww3wCLDlOzvrxWpMpbhpH7We3YZlT6htrtcfZjroKIqGYJFKHyCHiCDOZvW0ISDSDyoW8QPSnZz9LchxqLjEIMsMVd243DOZf3XjbVh1VjXPX+dst67pQsWQZKlPZ4XasptxU9UNnL7pyPb37XUYqKzyMOSBame2sezMPZBfBw7ZT9qrxAkH0Z1olGjvrNyav8QL3XBMcsimKyLhQ0IviZTaZoiOqWiE/t0FIiUw7OzccBUt8pat8Ye5AE//s1EQUTI7tfAWIw+pFTIYgm0+21lzbEdXkJl9997KoQ79E+R+tLfZsMvNLoawT6fgmnVLjaL5MVENZXBLeaUtOIYoLtronDt8pv/+JwN2XGbJw3Z/ZabrdZMrI8cK/LX4Le+B5h/bPRHo2prX8lbFr2wBp1krCqRQ6FOmdJd+5FpTAwXYYGqUi8uSxGPs4CPs0oEH4MDytxk55BmOCNPjtFGu93Qh8SFIDpHXT5ZT6z7A+XHLiK9Wbec9TmIheOupCC8bhg7HnWwKfcXqjVi4ti03EhRUZqq6aLsCMNGEEwFF8tpCeesiGvQYMZJWbOEVjkD83JpjDs6dhn6ZFsYqsgHX7OGxIft41yukd+zj3wUlrPKZXRlX7xDsjwZb7UDaXjWcOf8i5Yu1JjnkpdqUs2gQVR1bI9YahEkvOG/xysHl9NKfCuNUQ2Jrgmj9iA9zM3Shs06fmu/S8Vir3RJQDLpJbsMYhRWnROy3qD0iA20w93BdHlP9O7lTqdugnMOKHU9hUjLofRtjSRZut3eVhPu29MztH4eEPSV53QlIKD6qv7EJB+5D/7jo21ncVg66Eu6sKQOkw+FJUKMqLegaiwS58iTL5UD8Jz7cnFu3PE8ggUdlcY/ixJiSxUERdCcridikjcDmm72S7stLAFLRmlXIYgEABNmb0PrXZ79DE+i+uztZ1n3KyZic+lFfjolCvT9oKhf2F5rjC57ocHhf7E30mgKQX9jNQe5I32EjrIBfkKgf1kykkZf8VdYdSbzeNBY++Fi+QJbp5hCRzru+n8VmXU2kgE4dW8RfV53YlqzDiwz6MYCkSQJluDRs4C38g0OJd5jBzkmceUEeRUknItaYbQ1dil5SByCiJNjHxtqPqANwTYkiA05rrzjjDTpIBH/7u8SVvuH91NsxKo+KHj X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:34:02.5396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 713310fd-34b9-4a68-d702-08dd13a7887e 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6103 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892555 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2078.outbound.protection.outlook.com [40.107.244.78]) (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 974E91F7093 for ; Tue, 3 Dec 2024 14:34:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236456; cv=fail; b=IuslIWOW+aQyX/ayNauJwQR7g/ICJN3Iai2TRCaxhC+hFbEocWgMTZKGLlCWfgp47Jf1LL30kBwAEeOZNLHD/q1d3usEblabBvTVKWFWLNkVz+fkm/GuZqsmLZkgjPAxvrHx3opyaZBOHxrCdwbfku3qF6ZkejvyIdP+Bp1/s2g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236456; c=relaxed/simple; bh=RxcewKR0DN5QRSwdc82XfUmx2DDuwVChRJ5JAw42/ko=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jlf0o5JcvJq6efZaEOd4hp/NEa7teRdNXGunyykJT8LRJZOVrzl46fZDkixUL3PlghFt/A4ELVau8MaPe/ORadxfOclQ0LoJtKE/ED+Ff5/+tSYTp6bP7I72x/MY7AB0BqPWi4oU/mbQPAtV21P8+TBdxZ8sJyaf010pK/cnn7A= 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=Dxp8LEpQ; arc=fail smtp.client-ip=40.107.244.78 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="Dxp8LEpQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M9b2NBENpiLZlZNRalVn7SKpIhcSV0lQwOwjWzh6lcR2Nw9jwcPe6EJREU1qIVrKcf72THdyRcP28l4EgPTpiyUK8kNvpt96XKwqt2/wR+KnOL1HxlX2kwqhYYXouFaOCfZnINx/4Xp0MKZt3pI4VlAzUaNd5kRFan6UvupWe8p3wj/bcAhQzh7MDkg/TAExfCW9QxBA6GqwZ3lEdv2bhcfcPOzjczO3TQLdYolEgSxKORiekghk50kWHLON2SuEbqVVSgFANe92TqFv6qEa8x7mfOsF2wzd+PRilYlHDmX6aWKahsMgWIuw103Nei22yKlk3P6S9xOOAN770A+bcw== 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=UPATP31c5msu3dI4IKPzlhwyb3B2rGG+qBxUlaoEIcc=; b=ui6BAMUIqslF5ka77BBHeJYviABrlEvzRO8G1QSp+WvIrNJiS9F95JiRnvh0EC9PQRxV0im8hSThISYcfqVQntoGtN4MdJLu5Gq3g+RkyLgeBIwan/jvQ4/43jzbLDXzti2ODb4zPfYNVsQD+pq5ACi2HHP6es0ROQHz0qj6FnQDLsEUi5rKDYH1HmECzbxs0cpcA8MbPwdoOuIcKjMS+DRt1ZAPBZknKcDI+1iwSrAlGXk5djUBXvy9wFpQcOh9gGJMSzGNGiJ7zL5avb5cdNeXUCWVUi3NTOO4rbcAbTw58c2DoCHORnHEXfYsZyjkO6ctqmp1SepPKMG/A5BIoA== 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=UPATP31c5msu3dI4IKPzlhwyb3B2rGG+qBxUlaoEIcc=; b=Dxp8LEpQRd9kz3W/0PoZKNa6vYmxqT5c1weIqO+Zl6ntBhfNN5nZLcD4xTVE1ss5FnVawPA7uBWagy/iDTdWYW2lPNY7CEeRM0tfK6kyvlGjo/wuKkjBHV43WT7p8OhQu+dNWtIXXqbwTm90zZ8cOzi5GIJ5VyT49gA0pJXvp1z1Z/UvK6xOjEQUvkzeM9UE0OJDU6Tlg+sw3+v1mPDdbrY5RfBVANA3TRQ/Xpl7AP1Vazaid9piB1nGOf+LasIp4yxqMnVK298+KrZFgnDh4KqjS50H3pc6VVOmX+w9Qp08M5TWpx6s2AgmbazduYZmRSwElLXPeeFFgq0AWTYJeQ== Received: from SJ0P220CA0015.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::19) by SA1PR12MB6869.namprd12.prod.outlook.com (2603:10b6:806:25d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Tue, 3 Dec 2024 14:34:07 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:41b:cafe::30) by SJ0P220CA0015.outlook.office365.com (2603:10b6:a03:41b::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:34:07 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:34:07 +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; Tue, 3 Dec 2024 06:33:49 -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; Tue, 3 Dec 2024 06:33:43 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 07/11] vxlan: vxlan_rcv(): Drop unparsed Date: Tue, 3 Dec 2024 15:30:33 +0100 Message-ID: <82440b6b3471ed1c0bf01cca6be90bb4c9b413e2.1733235367.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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|SA1PR12MB6869:EE_ X-MS-Office365-Filtering-Correlation-Id: 61e04c79-bce3-444b-b4fe-08dd13a78b66 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: awtENVAPQU7EwXyfoj9uaJP+yIGdHo65GFZSbLHctSfKgj8wvBeKeykK3Eo+4IyTwTbmJmNnYebfXMPCdPx6/Q8nyjpk0UJ8+/tS3d65aRcDQrrCR/NdDQP1b5X+VCjjPHOk+qF5yH2pRbhAHGZ0Njo0dfLpzo/3vEqkCNdn+xSMZFxxk4EKbbxxh+Y902wk4C8A1bclyj+qLUcMYWvcjNMc70p4gUSCN/IfIFS92WZmvUlIZabSQK6lQRN3T5GLE2GDQSEfjACJaC/VqA77Uo5Ec8j3QTpd1VTorzhgtPxwLRmWdsSOBgYjhcVXF3rTggolMFAYJ5wjL/44gE3COriyAcmvf+IJZPW5Vti3oZZedpvUQEzYHD+3i3nnUeXBLdFohmHi+4WoMSxrk7XGTs8EWrFbos5cLGzSCImGB7WogoM4CkhtXgwozXZERJaWTAGUIyuzTTXC31N9ynaZPo+twucDWyFN4bILPkSZ7D1+PURknpMEtcOIeP2MfsKhsz4ZwvZeMsdgLxNG3y1XOZ6tUoFeESfwZ95e40LpUD5UzBK6M250cn/85vm2URNsum+KDuKeiu1v+VPi1dAgzw5BTcWwR62BaxpcJ+lK+v63OUWWO8UDdSNaDWaQ3MXJCIubzugSZvQ7uy0Cyu7Kg37dL6bBHFTgxB08ICkx9+jVtwNLmwECH8BrpDPWI+1nlz2Ha0p0VmQBdip4pQnGn+YyP7k3G4grpHZ9Cmx0JLOw6h5ztlxE8dJC08rmgGP0lTl9eCIoNbhbJ7gZbns0hWL6DjjTILfGu+AOhu4583dwoms6XE2hYTod6AqsmYMhoVc+rM6uFAtxXwSfZUJZWiljYeDWVkjHI5c+vGtFSovXJn1RLcujzaQiX1GJq9KPdymQftTOBfuwuVGFQnan3MLDAsSUSlvqC0pYtPDBjfx8Ne41XcvUvcsLr6QjhLO65guVu0FZ4yOLr+YFQEwkMWtCjoxIB9lyyVaw6SBt9ER/dYAVRFhk5mEmbBrbgxx8FDb4mG/maoeyiMRWoePaKXfz/0m63v5Zl3x7O0Q0r/mDT+vbC/B4HmiZwrwrV/81/dVMhx9yFxYdN9Pjl6kZVWXivqs9EB2AJiBt6Ksk2hKdidDCHKckPhhGBlcMUBPj1Z6ClEyXPjO4YD+mA4S8QUSIOHIMEFWBE8tjlOJbyINJSJ1qQ1KM75NtrUTCXyKEmrY8PIOacpTDJQ98urDtnzUweGfGDJ+L7jPEe/FWHjLLNmVvHn5iTE40A4OBobXnjHQ4kCT9KvvzXdYizdAV2sgwrul53Dl4rxxU4yfzY/AjCPcCj7ok2Rs7gM4VctR7QLgTSA08r1qV5KkLH9TyNOniPr0EGZZlp7OCp9Rv+dacjK8U1uEK5pghdfq3ZCqO48NKRPQJo/y+46WzLsxEtZmJxDM1HRMySeI2Uc1+AtaQB08HMgDW5tNxO6l07Hjw 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)(376014)(7416014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:34:07.4458 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61e04c79-bce3-444b-b4fe-08dd13a78b66 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6869 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892557 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2080.outbound.protection.outlook.com [40.107.243.80]) (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 4B91D1F4704 for ; Tue, 3 Dec 2024 14:34:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236464; cv=fail; b=LMff+1eUKWRqRoG5+5+jXtzOlK48wIbpYVQc9fdz6nDTK0+yVOfLNgo++s7saFA1wDaulPnKW6bb2G6v4dBtZafvB5XvwuCNkSrSt7DeA+V0GmZz2UtdM9fLp+PYTH9AfY2gMvokfRDf9yGsmR4PhKvVXpTMXQfncA72il18kIw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236464; c=relaxed/simple; bh=T8iT9phBv37iNdABTyeuE8eejXsAiPv0QYh6EYQB7DM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lln9ONr9yjaZQODtSnjetemND5GqDMZgjsqX4K3Bkti5IGqvb37FtM6HFdkkrwdnSBuH/jSkgpdvKD/Ezyi0ewbGvQUFEskWcZvO+jfpArtz1igeuIspp6dB01TpbGD9WgvBWjFuAGaRxIEJcKhLr2qzUpu88FQPWOWemN10gbg= 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=hwl+/sx1; arc=fail smtp.client-ip=40.107.243.80 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="hwl+/sx1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tlqCC+xMw/E7p1xsig1rLjz9c8hdATM0q5l1U9H96GofDSoS1qdseBOxRbN9M87hw7ZrhGFdR1UKvytbBb+zAEvCsPSUOa8nVq25IhsUdHLKWXfOLz6n60MOUyPpFroMy0qSRpUNQozElgzNNrcgbvLb6Z1FiubP+jzydFpx3sF7oxMfiu3nv/2xqNaVWY35dC+Z9Xt76PpUA9N3sn6MqJlBHbJc+H8i0Gkmhv55CtD/f9UE9nAhd0FzYTm3JetEsOVz6zZz21gv5G0i9PCLvZaBcStsuaun5q12O5GxmxEpuCh7mbpkUkEAWPoCHZPMCDQm5Bdag6cbr05ooI17FQ== 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=+emqNud73HhDRSXa6wN83d3Wv270bttByeO81HEQv4A=; b=Icnd6DXgseRzU8mfnkasiDy93kjeRx7KKZ9uBWSEZUyXr50xQagLcVK+DYe8pNaYzBkmS8DLO+Wzia2gzKYY0XNOz9kKdgB3thOAbU4YKyk1aXCw+a2OLkRCr3QioVmckIruWW5aMIhg1rvyd3oRJgrMTWIwCQzWeWs140BrFXYDm4nUikq0UYutuI8SxmtNWFHAZQwqZS2PaPTlhbwRKLLzkkvB4KnUUhGk7bhYcQLkYUQo5ziQqtvzxHL2TeFph6W++/ZG1E4/sstXb9Ux6tLteElzy00LrZZQnYwzhpgrqQ7fJKJc+t54sG77YeZUdiilbFmJrHicGwPUNJqY7w== 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=+emqNud73HhDRSXa6wN83d3Wv270bttByeO81HEQv4A=; b=hwl+/sx1RpjM9+Wlu2/a2YvYz+QpF3d54wOKosaU00X+482Ow451J0u8GTml34ZFAEHpICNMpT4krz1+GMOxOlQ8ctb3238CqIxex91KkhtZPKpaFLhUpf5h07hctgSpB96pE6a9AXL9+llmZ4W1MtKdAn2Ldrs6Y6FF+du9iBBNYvQKmK6UQLNoEbTOUZWW9y/iEwiKqNhNZEGYnk0GDM0lqiaWITi1nKO17hVE7fqpAg/lL034rCwjEsj+KS+uB2PUEEN9NIKi1RYYPFVazf47VPBvV9jNVYJrjQtL257Y3Hh9PNk4hyo9OkbT/SsIHEL19953ixMpj7UJ1rvchA== Received: from SJ0P220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::28) by CH3PR12MB8210.namprd12.prod.outlook.com (2603:10b6:610:129::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Tue, 3 Dec 2024 14:34:14 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:a03:41b:cafe::b6) by SJ0P220CA0018.outlook.office365.com (2603:10b6:a03:41b::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:34:13 +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 MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:34:13 +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; Tue, 3 Dec 2024 06:33:54 -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; Tue, 3 Dec 2024 06:33:49 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Andrew Lunn , Menglong Dong , "Guillaume Nault" , Alexander Lobakin , Breno Leitao Subject: [PATCH net-next v1 08/11] vxlan: Add an attribute to make VXLAN header validation configurable Date: Tue, 3 Dec 2024 15:30:34 +0100 Message-ID: <801cb1b16de3ac7138027d0fe9923a9abcfa7612.1733235367.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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|CH3PR12MB8210:EE_ X-MS-Office365-Filtering-Correlation-Id: 99a28ff3-d41c-4b36-3adf-08dd13a78f19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: +jEr4BlRZbpTLbABhKxyeAdcczAsyLRAXmk9s+hcNWWbgxhvlP1ZhAKPLpjhhIBFGhU5zfr3lDNftYV6oTZxnPkzUX2AIhyxmgfMpPQaeOYEQ15baElKyf7g+GVSO66BNtxiEmoc8vRBdAwsaNfcb5mPxZa+gtPhcRp0AeB8q1y6RK8VTUFbZZoaAkZltaalcrLAfYB4uvPyxSrwYq6jjjrcDoOm6V0xCWmvXKqI2IyXY6LrVYLj/E8+DyYRFXBOMqEyhShk/BjNRXRRICKYQhiShEV//xyCT18hxl+xrfA27zrrd/x49Z4aPWtxjOtiMMpJlkdf7SHpSdF1+lAOozDPuI44QV+DSdc3ejovm+DT1cy7Mu8PjUNVJXYT+ZUBjw77uNQm08NqHtjTgSwsNG1hpinYqBqu+DQUS1t/uLZ4Yoxlu77t+br4Ed1zA5Jee94GDXweJd/GRVgnrOal/F68G2C9N3qUBGioNo9GOX6Nd5J14nzdmOP8LWBoP2jqxjwLsvcSMzjCVSsSUTOhspFU3Im9v83ixmMVvGY9g39kZ6ibouaa6i9dsprv6dU/gkAXsoJyPPN+8wK4IJk2MibUdsrGRNfa9NWqWcEHV/Y9OgTzyX0OxZ/5iffGaGat6t4YvNQnBKmwoNkBQXXJcQg/bka8c9q5oisc/jQy/PaBtXuZ3SgAqTjjfG22WBbqlU28rGs8JO0RhvibDR6Zp3+/cK7JvegTW1rKwvwP79nJ0qel04Yu1Pm6DkiIyLE8am66L78I1Sp4ThX+lUSo+qqJUheApB4wCXNg4IQ2qEJza4YEhsk30rlrYBTroSZtplVRNWo+ydUOhYTtkm038tFoLaNsivbgk3viQp+EXx0DQ0yMY1aao0qHEyr6SYPp3oqRL32+8NN3rV1sR8LaUnbhpM0iLH/2ZYWX3sihnBhrOf7YqEFrIRt37qR6pobsngXiy0D3rRYegLPL6583s+iyJTm2TBF9L5aXtdGk3w4M1RdJcn0xZCmyqnRQcsSma1fYzfTBhuaRmNAqSGFfkXdLioAXnU1xroZ2ESrBKgS8vkkbqSVbtRe9TXFzLfkn1y9ynYIOnu5Hj104IhRfah5PC6cnHdUjBo3BoXNUiZP3ByUOWgv4TOMnU4Qk38uN7Hmw439uXoAKHBFMp9t83TjTsKQIuD93evOWHCQsuk/v/lPy5SMP1UoDgW4mmP+l9BvVOU0OSCaKXlX0PoC9345lsYUGDo0Nx80QhGksF5VZBvJHjQK+y3oorf33uE5y78mUzUTqQdqu8d+esAC8rPhqFqub+wmxzc2AGNh/LOPz4/qTkv1mkuadtssBSBUHA2UNiEIDucb87Y5XEGIPy0WY/oNCpvtn2qmq+E00w06fs0TF8i08s/xY519R/BLO0gu+pwtz6sYVwiPA/Pe5mZhdvPcYAblA7C8TkUqae79nYl0NjjyPn/DV4Gsc6pYH X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:34:13.6490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99a28ff3-d41c-4b36-3adf-08dd13a78f19 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: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8210 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 --- Notes: CC: Andrew Lunn CC: Menglong Dong CC: Guillaume Nault CC: Alexander Lobakin CC: Breno Leitao drivers/net/vxlan/vxlan_core.c | 53 +++++++++++++++++++++++++++++----- include/uapi/linux/if_link.h | 1 + 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 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 Tue Dec 3 14:30:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892556 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2087.outbound.protection.outlook.com [40.107.236.87]) (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 6FBEF1F7561; Tue, 3 Dec 2024 14:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236459; cv=fail; b=op+P5Ya0FapDmWs+Nxko2aQDWwTegYVlXsGdpUfKkflM1m4epTwHhHpn6aTkkdTEPdgRBWBy0/QeYCDDNRU6j2m1hoZRAaccPU975kJjT5crNvMvH1tXoHNqgNdnskfvA5fpPx4/xjC1hijuv1+axmV0YdAMhIILr74VRkvSZvk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236459; c=relaxed/simple; bh=cVfKjVqLaxBjvU8xsYDqwvrVmkq7fEKbZK6IxdezcGo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rxdw5q+Wj2ac1LmzHB13z+tu9zgUz0yAQrPR/pRdU17AGIYdCyhm4D70NCWaadldWzAs96U9GTy4JsqzTOMHGzQEqXkhQn9l7IE2MW3oehLTchTKt1Jt7V2+tIjXW1lDC+V0XXvtFEE2ap4QWOToVbpcZPpH1C5S+FNsnLVelTA= 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=CqYGXnWQ; arc=fail smtp.client-ip=40.107.236.87 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="CqYGXnWQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yp3ldFOG5Ihqli8QOJG4ISdOcYhxz255cLk6V+K93PtAOdikAZgRxT0YGkaKVaCOLLbtaOMKfmqfLZtgA34m3BvDiWRzAQCdyYxik3O6YWVjNAQpk+d+uTi4jwv7D0CXo+4sGCyBDV1E2ZcfdzujjeAEhSdomvNuiXSF6o/nrb3aer8hpmB4/di4SEKUjueOhCS4iwjQZl5GqQtcIHEiI3bIvjQceJO7lWI5rMYNrS6etQY4m5ZbmXt64uvOCYqVFfY+Q6FurgZSJloRupIzzwZtzYMsMVx8HPiU8KHO4NdhBUlg2EHYU5DVBtHKpKS7aMtQcPzL9hyXNTYs3mVeVA== 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=bZEYb9NB2krTMgvmxQTdu+Kb5oY/RaBGvUJtLvyC2hemTdoe90QbrKrRS+eo7/SpdV+wLV9BCylLgVUBzn7W5TnfOqWCFEEvs3BBwy5ytLqgxF7nCRaODMF8mXmYGDDO1RAo0AjF5lzE1r8Brq0LXEriSQXoySLXf96B6bViGyTdeaZ4k8AEyMj0s7QOUcv+X1y16muQ+kwxgLXYOshE3bt4aYh6iLEKnvMHfW01YlIqq7z+UKXK4HTUjofkq5+jOFUqwGpvXB/R/gq0OW7xX9AME++oyHchyvZxePohdM0sIbwgR1aWyjvc9hvPB42GImLovPsfHlyZcdtMVEFoYw== 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=CqYGXnWQ3Ms+ZIjAFCoaourT+pqfcCBlw3eY1+zw+e2UXcPWU6/Uj9rwSeJ8X0dmzazqOMHjz0Bh80e/d0j/tyR/MjmU2AUaxPtGkWc4G1AMKoUQQJi8Kat4BMi5eJ6B9q56MWVszg9RQxxDgRGOq8U9mqRYU8sRAz2okFu08FIzMADui7F6ToATSmxueuYzPQ2mbS5tX6HEiRPveNE52M/Jy1DNwasoJujLRJ5ByxU7e41b+j3GjFIIx0uYTcNAo4fYzPUqgaja0i3rLhLHMIAz5g59b8WB3gzKkmrQ4O7ocaXeZ21azM+iC5GNSdkVdTsFso4Arjx5Wi3Xjo6Yaw== Received: from SJ0PR03CA0081.namprd03.prod.outlook.com (2603:10b6:a03:331::26) by MW3PR12MB4348.namprd12.prod.outlook.com (2603:10b6:303:5f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Tue, 3 Dec 2024 14:34:13 +0000 Received: from SJ1PEPF000023D0.namprd02.prod.outlook.com (2603:10b6:a03:331:cafe::e3) by SJ0PR03CA0081.outlook.office365.com (2603:10b6:a03:331::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.19 via Frontend Transport; Tue, 3 Dec 2024 14:34:13 +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 SJ1PEPF000023D0.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:34:12 +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; Tue, 3 Dec 2024 06:34:01 -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; Tue, 3 Dec 2024 06:33:55 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [PATCH net-next v1 09/11] selftests: net: lib: Rename ip_link_master() to ip_link_set_master() Date: Tue, 3 Dec 2024 15:30:35 +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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D0:EE_|MW3PR12MB4348:EE_ X-MS-Office365-Filtering-Correlation-Id: c20b1ae8-d97c-4f40-cfea-08dd13a78e75 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: uCeKIVrP0Op7T+/FeGIBPEibBlgeN3x26+huP8LDDedseHDSw30miEHpdO2gAF8CDNZdp1fYOLdWjLyGTVTANYerrE0g3DuF0MGoBPvYyda151P8sQug4DagNM5yUC65yuCUXePDFbqEIK9hxCj/btSqgzmY2OTxm0tvo6F7A+5j6w3/rZLqyiP2SIThOp26/JPgObn/9KP1+Dxbnhjh1sllnAqsH4Er1q80riVmlN1REHC0+EOiirW2xPFnYE02fjQjVBWAXxkgwG6vHC+xEgWIa+VzARph08G+j/3i5Z85W80+kXfVTvVlX2uF23wLralAZqbNXSFS7KlSPANLpY0d3NzSGmUh+m8/O11BebOI07o4cGBKGAGWXYq3oYDHrn7YClIQKJ+nJE5o+W4T+gJkM3vicPUYfL3WFOFbqAlqs6TcG34HoG4QowcHVfurKR8oudeYvP5PNw6VRFBdOL5fia3qY4QfwhpFO1XbPabS0XYR4ffLK/BM1nRqCaNVshEIQbL3u8NZ36GN2k7kTH7aDeHANjVbhQIZNGN+IjaR1WQZ/M3NFyEMvrypgdblBu6S6HwZ5lztjWv3znBg5TVA60KGQGeX/bM3UMHV8aMsveMZFFSt3BE7YhX2CrZALjvfXlrPN3sBm5+sF2X8RSSS0QiLqyBatrirgGLh/9JIk8lMCW6fsbH7NhqjnxPh3qTNGa9idHy/3TPMxF0bTkjTYIx91wyFH0ejTX5ui9zz/lNGEeOyXY/9DQ9A/v8tEeI68r+Js+NbXOpJE2i4TD2BA9U+nxJb91o0rLshKz+Di7gyaZ9lwTWUbLCm8Ow29oqFlU2X+pn5rRHJBXQvz5lfUN/qXkffqUxFuN904uSJX/Q4yeIsrF/GtjKqdtfPkSoGGX5NmZ/GRbqnbmFBlaqf/dswUdQgTSH78fPVPxIvpNyHOq344/QlzYJ5xpR60K1ChFvrrBoVQ+5RI1s3a+bEb6jUxQIh7fRLEjkw0NTOepKT8MtHrDyBwY+rOCIeXIVXsPL8J0ZLccav3h2J16sMOZKMWtU3HCPivaynLfSJz4sg9YPKbsycVrO68OdWu2IHn+usn7SqTd6BpDuyU0nIM+e/o8Rd6q37CLXjGxGHonwLHTB9SsRnOTdfTLnis124Iww0sisFtLwZZxWjbf4/CyYX0SXgJswJ+VyrJCvjbSArbqelQo/+lzplEqgdzJrKpWlGxLSEZjhLoCBZLH7LTss3SiaYXwVCox0+/49xKNB2cw7niW/zQ7WB7hsL8GS3B37gXrGy1/6BY8Efd/8AwsLFiScCN5fFUKC40owooWr9+2TeccjHofBVUe8N4oodLZZioshv1qM6RwxMAxCMhXSJgPmJn9bqc7Pun0L+Ti5u2VgaEZumh6Dni0cHzR9f6ed/evJuDpEB5tOKNTCZXP18sK11wTPWpFlDGZClIZQS6kbSKizPZBx8GjnJ 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)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:34:12.5467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c20b1ae8-d97c-4f40-cfea-08dd13a78e75 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: SJ1PEPF000023D0.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4348 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 --- 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 Tue Dec 3 14:30:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892558 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) (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 9B8BF1F4704; Tue, 3 Dec 2024 14:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236471; cv=fail; b=HejtQxegdkbOxfXQnC6fSPxKEud/NKBygnEXwaAvB8sRlTWGbxjkNoTh84lJ4JbYwakkqxNnZLi0Gm6ioo/gDQClLVsfb2hjxh3ks44xzXFr2mTgC2M8Sa0HaAnAfhJCI1VSsWi4YHEEIdiZWr0qiW/QIxkAyI3tNCm658xvFmk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236471; c=relaxed/simple; bh=RUmjpS00KQPThj9efFSMqJlPjLPKYyp632VyEJwERTY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KgDWw3T5+CrreMuu3cdb+in4icT+FPtkpbTxvmz+tC+YIJREz2NNR/DgAxmPs1r5PGCO00o67gKlJbVHEOG1eizRg7v43yw2FxmfVwX1xNzchEcR/q5xyBWdvGKlltik8VdgcoGKXUM3/dwp2fJRvyVqgm2DTsLj2Yl3Vy7PVeI= 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=NynRPKFE; arc=fail smtp.client-ip=40.107.93.73 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="NynRPKFE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b6mwe1CckCOnb9OG+xb8aoTiy313rHwlngCEztfmT4AP8YpCMFXOCBejtxaBXSpLrLzy3UbMEHE0HB3cdL8Z9v/90Z5hfK7vTWoNwj785mlPJAoqzPHRyeLpSMLNv+Wi7/nKOFBEAVCpzIZQ5l6vv+0cvmd+3tjliRD01QrJe9Ofze/djGe8EFZTLaRmUdWXgVgsdHqcXfGvcZj1GBXUiIMUcSEP5z6yt7bOtjjjcNsixBNujeXSH6AFuHq/G7eVydGNxeKll1lwt7MAlRekVcWxNpB+d0sKXrDJnt75cASEK9/cFwJEKxhJLTSkp1wU4ED8CLEBI/HMW9HYui1tbw== 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=nbPEJoeRgQgVKoglvxU5qJlsK3I8CpLLp2bRlWs4+7/2nLK2j2BmyMuRR3ARKu30itmyYU5I1hqfSZOWp8qG2GfGn66/oOBGCNyn/JTkEedJIhoJ9IS9ionTdfuEN6vsOaP2C7T2ipfQEIsLFL+gxZ1nqV0KKsP8EM1dQzhHY9s40Eemyku8PMHDSK8o7lxP+BO++bcQq3UtKSlcOWESrA/fUtvkAktDA08bajaT6WjkYJXtejNAuk7LzHb22Z9RQCSHp67xRh81oJ5ObIZuSEpR9whV56AQ8BRDbV1QWHDn3j5Y3Cy0ogBXt/boA9TGys5RTdc5WoRFr1azxSu59w== 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=NynRPKFEISn1RRJXqbmWt5rVDfo4IY8X20a0AnURXS/DsY7XRfTluizxI3GDEF/S2sXGzPSXYxileoKvhzkq1Em/Hb5nAdpCJDdSlWYJ+FIzyQqkr2juKqie7LGrW0FHyAzUkMrQjQ1/rIUmxrCEqvJtBCqWOQfCmvxFcGhdWjt9o/6XyyFKR3NPXg5OqTK3vCrPL+o0LrYvy2M5BTcMNmz9vPko1p252jn5HPG9dgI4OQWlO/eGMGHSsdXDsADNCbgISSexMezudRYo0JzroGFvpVHmJTIY9NR/6t5AtoH/Zf6ATmeK72BI8mo1m9RIraUGkTEqfLDDI+BlVkQpyQ== Received: from SJ0PR03CA0149.namprd03.prod.outlook.com (2603:10b6:a03:33c::34) by PH7PR12MB7377.namprd12.prod.outlook.com (2603:10b6:510:20c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Tue, 3 Dec 2024 14:34:24 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:a03:33c:cafe::b4) by SJ0PR03CA0149.outlook.office365.com (2603:10b6:a03:33c::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:34:24 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:34:24 +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; Tue, 3 Dec 2024 06:34: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; Tue, 3 Dec 2024 06:34:01 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [PATCH net-next v1 10/11] selftests: net: lib: Add several autodefer helpers Date: Tue, 3 Dec 2024 15:30:36 +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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|PH7PR12MB7377:EE_ X-MS-Office365-Filtering-Correlation-Id: 90241221-1fa7-43cc-fa98-08dd13a7955a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013|7416014; X-Microsoft-Antispam-Message-Info: mpGc8zrvwKSZeLANWT9Xi1FXfRvboijZ8oCRKnj+ZgAePxVMv/Id/OGZ7DcBFTlPCI2OWLF2Eq9KDUP+sa6yvX27PodQ/ORCVK6oIPaJfIng5g65XLocEOlaW9AD2Os5PaG4eMbt2Zd/HC0H0JgOExdv3J7K+K/v/IF7lDb7EeXFXDcMerYXSEKl4cZSkPUK7CrfFVpEwvvZa5PmB03rWKWMa9JhSLF8DVKZZx2OAwXREUnbUoO8qEK7+SW2hQH1JSkInIushnrfJk5wf7frFpN3z+soXsqYCPvu+ic0AZQcNPp8H0gNhhjGEJR8FY1wwVXxyuK6w6sEWi8qc/bKMG0SG41SWMqECt8npBz/JIsHPtpvnimRQ7etUMQf3d6iQHipKV+oGzTsmSVPX8TdqXEf8OvLOdG9+tCQT0zkOeeQfBUs/25nSwPeJAHlIbplFxRGQdIXvHbzoyHgV6j5J5zYGagQiS+w+634h4VifHNNTMBiI/MmliuQzdY4ztzhua4Bc+PoleEej2USEW/u5F0eNk5KJ27CJc7WzcCt8GsVrwplVjQxYFf9wQhH95ZRvHMswnE/GznVu7FWOnfujsQcgE7gBBW9dqdCPlY9EfDapPNn28cdA/NfJMo63zap828t0np0vENgjFuagYEmMNnYuPQDyOUELTCyV6CHVwYjOgtKtnHPxGkj0ZN3+N+CP16OcWU8LB1UOIB+Bj91oL1SsHZqIGJnV7j0xF+cRazR0nHGB5qIkTY1X56KVcEfivcJsWYFbAJWL44JuOyHJNAExdU5VXA0m9ZFz4hLUW2fSKcU2VPGIfyibPoQ5jl6KmLx4QHqjjlJ1pAL4y43dUCwdElCGkr3XM5Haal3Og7hKcfS3vSlZ4HHEyqjqHGv/YkZKilWLtihM0+jn0KN5J15kn7nRhT3HRixTPVniDegrSO316YOK06oq29Ox1ufWZk0yy3n5mcUqlTjNZCvACEWLOz1zY6EuZ1DgppYLBxzttV//s2teYWTW7lhLARohk/1zfca/5nSsz99d6B8U/dxNxGtadZzOQtihPFkYaWoALcjSodHl4zjSL3BdHepBt9Z7TzRiu6+0jg8SndtI1kLKngsb5fXBG1mrAYx92eCvAABkr/OUMG3IQfxvl0GOxiK/qTkgxVG1u34KjsLFHf+QxCsXKsFZtT6L2Yctdqba/kj8E+FmQjBGnaqj+/lEHql4Hvz6dV5hFk70Iv5a3ZP3j0zdJuAN+v+VnT4xT5AOzk2SkNWD3jtV6oWs5Q7Vsyga+IL132NRU/LyY3fWbT+7yPe/Q6n3wGS795kw8f6DwO4fjhhQe5zCIH1CiOYFE4A1sBe2X90l1I4hDCWAMQW6vtlWgrdCQ2uJkItX44iXg4KNkj1/4GMp4JdBUAPSPjQCy6gse9kpRW3yz54SbqpIjdAXO7kYf40LNIxeBnZZfvkJEUUwL/cqt0ONfE+ 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)(376014)(36860700013)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:34:24.1462 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90241221-1fa7-43cc-fa98-08dd13a7955a 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7377 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 --- 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 Tue Dec 3 14:30:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13892559 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2060.outbound.protection.outlook.com [40.107.212.60]) (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 C2D2F1F666B; Tue, 3 Dec 2024 14:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236486; cv=fail; b=TjN/YzgOfKF7+y+tJf/foTecxji9S5Eal3nDxVMpGb2Jp5r5qeHTGPH+3QfIe+p4FyC5t2vBTAmy7lZUVwaeM6zJ8MpXaSY/Rxm5DBwa0/kfYaxXhA9FJT6xOL+5PT8PAhJpTjbi1ykAD9UcsKLHCue0OzRvtSt92tt6H5HIKfU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236486; c=relaxed/simple; bh=sa+vZ4cO2nKVCAsPHtSng8OI9lMw+dXg1EIFqUVLVto=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JubTmNMo4QjXdIFXZfgsYYt0cJV0lcAPx/1WPDAZPmOym4CiKg9UnZdZ0HKKHJT2Hpas4CguH77QgmqL8xPZG7gDPNP+8JP15WDf+28yTJu6xHs7D3qpbHXaGrCX5VIGSHt9ZQs9UzRGjezk68caJoKz1qNU+PlfinFmaweaB4M= 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=cNfgrxUu; arc=fail smtp.client-ip=40.107.212.60 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="cNfgrxUu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vOi/mNTlmBL6uelMLKqQWdoQ2RaOhhQLHRqz2Ovjz5ZQSaucKW8UFSo0gOeSSz3y1GH+WnN+N8FZ+Sjz2L3WQEZ8XUBBg0e/Q/03+GgJnp4fvdmkbZJjKxf1S5ttmmA4+4WEsfSYqIQ7BFN9Ktcn2Y6FcuL4AMyhbMwdmvResqPg3YcPduXGFPr5WzVrNyJ/Qb3/thzuiEAHbiGFBhyhvbqoCeM8qv9G1FN5dx5yJffVlREyRXi8S8A4pLYwkCFB3VoPV7Gy1fLuGJActPB8ReUJIio8NYZXEyYKUIt1KzB/klS2WZqd58PrrSNuZmynmgIaIAHOzwlKAgDsRzXaZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oZq6qzGt8ei5DmYVubXAiDaB7Wew5c75RnjQVh/liIA=; b=NC8K3whIOc0sqSG2XTJCnFysf4wHe+oghlmkYYxEMuEcdFO1s8iGRLyno+eqrmRfQ9HG4rVn01MpYDgNjsjyGImgo0RQugrWIxF+HiMEyxc6wQqJGed2XJzq4NWxDSUnGZoXAPy8bX1+iVne2vgNpaq66iHS6YdZ5oNm2SehuvSgxGp9oqGJHRxFrfMQoQJIfexh64pd+JxfrC6cf2ap/viI6V11Bhn2HII7MZB6evR24merR588AbCOzJ3S5OMiNYjUAiA3q0Qie7rPT9mVUrefTXus3iaSInUyGTQXuWh2RaEFpcFTZNLj/noskjX9g6DCBwX3Iii332QgVRL2iA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oZq6qzGt8ei5DmYVubXAiDaB7Wew5c75RnjQVh/liIA=; b=cNfgrxUu9D02a+LcYkMbAuVl3tc4oBfyyQQIDyMPhf1EUn0XQKKjwuF5qTZd8MwkGpcgBXmdibyEqLgiOJhhZ83PxxJiG+uf/fzpFu8jfqreVFEjOOXgxwr2TjWAPEActWPlJ+Ps4tNJU2d6Cj72OZD87oronSCmoHqoy5KwLgsi+Rhh5zepcszoLicANbE9TJyb3SzfaLFvnpp2oYuOKjWBJpx+ZaBu+qwlQzPWOCsjC4lYPacRxLKoUmMQhVAYclK1U7vRn+0ZLLdsB8uW2EqkkxsDk2TgOkv2oZPdJdyr3F2GzjPA1VGe65SGe0cZ7zA8WVXzOegFhDvA8Q7P6A== Received: from SJ0PR03CA0298.namprd03.prod.outlook.com (2603:10b6:a03:39e::33) by SA1PR12MB7442.namprd12.prod.outlook.com (2603:10b6:806:2b5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Tue, 3 Dec 2024 14:34:30 +0000 Received: from MWH0EPF000971E8.namprd02.prod.outlook.com (2603:10b6:a03:39e:cafe::9f) by SJ0PR03CA0298.outlook.office365.com (2603:10b6:a03:39e::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.18 via Frontend Transport; Tue, 3 Dec 2024 14:34:30 +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 MWH0EPF000971E8.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Tue, 3 Dec 2024 14:34:29 +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; Tue, 3 Dec 2024 06:34:14 -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; Tue, 3 Dec 2024 06:34:07 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , , Shuah Khan , Benjamin Poirier , Hangbin Liu , Vladimir Oltean , Subject: [PATCH net-next v1 11/11] selftests: forwarding: Add a selftest for the new reserved_bits UAPI Date: Tue, 3 Dec 2024 15:30:37 +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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E8:EE_|SA1PR12MB7442:EE_ X-MS-Office365-Filtering-Correlation-Id: 6dee7c80-d745-4ed9-b93b-08dd13a798d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: bq5mxEMOuFjia2f170TIXttdYoLWidLw//Gb5RCa4UVdDCRdgZHwkIeKLRpmICHYZn/udmAFyGMBveiqX+4VfVcI7wz+nE8sjs6fiuSksY5Tjr1pnursv+O+fYYbA2WNfTF6mCY25VlEhruWjYY90k8XMdr4rGUKbUOrVbyTqBlEHWQfKw/DzFaYqQIdcl+ZCftf8jxx6zp58rBMdWpaZK3gO9mBWTLbN6t+8nPFt4AojwwXt98Y+Hf8LOhiAAdyHaHG0bsUc51jQ6Bf4LrFME9JP2lElMoCVLuH76T9utHZ8ea3R1krtvwj+avuOzbq1ocpnGY9tW1w60EfFttMDgrobPNYSJKCtEIOMRN6kvOvH5c2FgUw0wbaCx7IPfANfCUtBvc9sqGxcJ2nHKiJYS8qtMfSoTFVqxAgDpK/h48HTjKgiFm8iMQ4InbrCnNA521cJ2wTMhd1cXeMPwc2IMCwK6GsCIydiVv/pkp6yZvgCTeMbwFQvRWYzOpU1hpJbGigSO8BbbqoziTkrtg7z2dzBHNAjGDwSLfqogAgJ+5UEN4DG7T7J/Gf5ap9qYObuUG0gU0J3eKXJG+wZhuhSsAu8CW+zIXFkXX3na+SQ9NxToXCrnNLGM5odGGiY1nts9CCPC0kmvZ11BzVMJZwK1qnyM5OTOdOBQYnBNDzI0lcAdSuTSgEl6NpaIR9IbtEq1jErF6uC0xuW0Pev3uK4IHQGvOGDRjTiiYbmxMI9llgAI5wB9faNI/TXM5WqBqdE1BW/wgDXP15M3mwM3DgUJVB8trTEZA22guZGABHtV/ePXPdYaYGHFY0jdbxlVr+JQ0C87613+SvY8p96+Bm+qpnykqJIXKJBpPTuUvLsmZ25+aki9KzDD4vjy8MUpya5HPzjsB18XxkgnSCzwApVDRxYXeX2nMlkR3jwg0dew/EQTsjCkAJHIZpQ6dd/qkqiByGxVF+QbywCIpu0ZOFk+HlkoEm+6C2k6hDlTNR6sn/Zb8qeSlLY53BTO7IqX30CsopmvN5Oe61bNhQw/X1R2hi+zH3wotg8lboeE8lG+pXYdA/hYNFsgDg82fbSla1oho5Nc8+dFBdu2Lrice29ieWsXuwPlM/mgCiBTU+axjmQddNPbJVDW2Bq/ezqDXlr99wSNQLCtpT7ze+NZCAe6TZzgYI3HLhVlkSuKON3+oon3zaDaZ+/UIqHjhin8KHveu7HgGtJkfM1s0DNN8FJaTqJyzWGV0Zwzdmn354LdyQF59et2Z8KCwRMsxdBqjJ5Y+PBdIiU2JEv+JfEqJIBuTS0qBUbXq3q99XTvbObsmw+w4AqUPZ5wSLYsc3x8oz2967Dko4sTgWe1c9HMkg/M3gqtp1IT+rkbqOqngKjzbukMvg6GqY90QPvUXJu7pKOQx1lqGYRQjLKOwX3QTbdGy7nIgqFKRAuL+KK+2tCW7b54mjkvKOVaPGy/oIf9gI 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)(376014)(82310400026)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 14:34:29.9354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6dee7c80-d745-4ed9-b93b-08dd13a798d0 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: MWH0EPF000971E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7442 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 --- Notes: CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: Vladimir Oltean CC: linux-kselftest@vger.kernel.org .../net/forwarding/vxlan_reserved.sh | 352 ++++++++++++++++++ 1 file changed, 352 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/vxlan_reserved.sh diff --git a/tools/testing/selftests/net/forwarding/vxlan_reserved.sh b/tools/testing/selftests/net/forwarding/vxlan_reserved.sh new file mode 100755 index 000000000000..46c31794b91b --- /dev/null +++ b/tools/testing/selftests/net/forwarding/vxlan_reserved.sh @@ -0,0 +1,352 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +--------------------+ +# | H1 (vrf) | +# | + $h1 | +# | | 192.0.2.1/28 | +# +----|---------------+ +# | +# +----|--------------------------------+ +# | SW | | +# | +--|------------------------------+ | +# | | + $swp1 BR1 (802.1d) | | +# | | | | +# | | + vx1 (vxlan) | | +# | | local 192.0.2.17 | | +# | | id 1000 dstport $VXPORT | | +# | +---------------------------------+ | +# | | +# | 192.0.2.32/28 via 192.0.2.18 | +# | | +# | + $rp1 | +# | | 192.0.2.17/28 | +# +--|----------------------------------+ +# | +# +--|----------------------------------+ +# | | | +# | + $rp2 | +# | 192.0.2.18/28 | +# | | +# | VRP2 (vrf) | +# +-------------------------------------+ + +: ${VXPORT:=4789} +: ${ALL_TESTS:=" + default_test + plain_test + reserved_0_test + reserved_10_test + reserved_31_test + reserved_56_test + reserved_63_test + "} + +NUM_NETIFS=4 +source lib.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 + defer simple_if_fini $h1 192.0.2.1/28 + + tc qdisc add dev $h1 clsact + defer tc qdisc del dev $h1 clsact + + tc filter add dev $h1 ingress pref 77 \ + prot ip flower skip_hw ip_proto icmp action drop + defer tc filter del dev $h1 ingress pref 77 +} + +switch_create() +{ + ip_link_add br1 type bridge vlan_filtering 0 mcast_snooping 0 + # Make sure the bridge uses the MAC address of the local port and not + # that of the VxLAN's device. + ip_link_set_addr br1 $(mac_get $swp1) + ip_link_set_up br1 + + ip_link_set_up $rp1 + ip_addr_add $rp1 192.0.2.17/28 + ip_route_add 192.0.2.32/28 nexthop via 192.0.2.18 + + ip_link_set_master $swp1 br1 + ip_link_set_up $swp1 +} + +vrp2_create() +{ + simple_if_init $rp2 192.0.2.18/28 + defer simple_if_fini $rp2 192.0.2.18/28 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + rp1=${NETIFS[p3]} + rp2=${NETIFS[p4]} + + vrf_prepare + defer vrf_cleanup + + forwarding_enable + defer forwarding_restore + + h1_create + switch_create + + vrp2_create +} + +vxlan_header_bytes() +{ + local vni=$1; shift + local -a extra_bits=("$@") + local -a bits + local i + + for ((i=0; i < 64; i++)); do + bits[i]=0 + done + + # Bit 4 is the I flag and is always on. + bits[4]=1 + + for i in ${extra_bits[@]}; do + bits[i]=1 + done + + # Bits 32..55 carry the VNI + local mask=0x800000 + for ((i=0; i < 24; i++)); do + bits[$((i + 32))]=$(((vni & mask) != 0)) + ((mask >>= 1)) + done + + local bytes + for ((i=0; i < 8; i++)); do + local byte=0 + local j + for ((j=0; j < 8; j++)); do + local bit=${bits[8 * i + j]} + ((byte += bit << (7 - j))) + done + bytes+=$(printf %02x $byte): + done + + echo ${bytes%:} +} + +neg_bytes() +{ + local bytes=$1; shift + + local -A neg=([0]=f [1]=e [2]=d [3]=c [4]=b [5]=a [6]=9 [7]=8 + [8]=7 [9]=6 [a]=5 [b]=4 [c]=3 [d]=2 [e]=1 [f]=0 [:]=:) + local out + local i + + for ((i=0; i < ${#bytes}; i++)); do + local c=${bytes:$i:1} + out+=${neg[$c]} + done + echo $out +} + +vxlan_ping_do() +{ + local count=$1; shift + local dev=$1; shift + local next_hop_mac=$1; shift + local dest_ip=$1; shift + local dest_mac=$1; shift + local vni=$1; shift + local reserved_bits=$1; shift + + local vxlan_header=$(vxlan_header_bytes $vni $reserved_bits) + + $MZ $dev -c $count -d 100msec -q \ + -b $next_hop_mac -B $dest_ip \ + -t udp sp=23456,dp=$VXPORT,p=$(: + )"$vxlan_header:"$( : VXLAN + )"$dest_mac:"$( : ETH daddr + )"00:11:22:33:44:55:"$( : ETH saddr + )"08:00:"$( : ETH type + )"45:"$( : IP version + IHL + )"00:"$( : IP TOS + )"00:54:"$( : IP total length + )"99:83:"$( : IP identification + )"40:00:"$( : IP flags + frag off + )"40:"$( : IP TTL + )"01:"$( : IP proto + )"00:00:"$( : IP header csum + )"$(ipv4_to_bytes 192.0.2.3):"$( : IP saddr + )"$(ipv4_to_bytes 192.0.2.1):"$( : IP daddr + )"08:"$( : ICMP type + )"00:"$( : ICMP code + )"8b:f2:"$( : ICMP csum + )"1f:6a:"$( : ICMP request identifier + )"00:01:"$( : ICMP request seq. number + )"4f:ff:c5:5b:00:00:00:00:"$( : ICMP payload + )"6d:74:0b:00:00:00:00:00:"$( : + )"10:11:12:13:14:15:16:17:"$( : + )"18:19:1a:1b:1c:1d:1e:1f:"$( : + )"20:21:22:23:24:25:26:27:"$( : + )"28:29:2a:2b:2c:2d:2e:2f:"$( : + )"30:31:32:33:34:35:36:37" +} + +vxlan_device_add() +{ + ip_link_add vx1 up type vxlan id 1000 \ + local 192.0.2.17 dstport "$VXPORT" \ + nolearning noudpcsum tos inherit ttl 100 "$@" + ip_link_set_master vx1 br1 +} + +vxlan_all_reserved_bits() +{ + local i + + for ((i=0; i < 64; i++)); do + if ((i == 4 || i >= 32 && i < 56)); then + continue + fi + echo $i + done +} + +vxlan_ping_vanilla() +{ + vxlan_ping_do 10 $rp2 $(mac_get $rp1) 192.0.2.17 $(mac_get $h1) 1000 +} + +vxlan_ping_reserved() +{ + for bit in $(vxlan_all_reserved_bits); do + vxlan_ping_do 1 $rp2 $(mac_get $rp1) \ + 192.0.2.17 $(mac_get $h1) 1000 "$bit" + ((n++)) + done +} + +vxlan_ping_test() +{ + local what=$1; shift + local get_stat=$1; shift + local expect=$1; shift + + RET=0 + + local t0=$($get_stat) + + "$@" + check_err $? "Failure when running $@" + + local t1=$($get_stat) + local delta=$((t1 - t0)) + + ((expect == delta)) + check_err $? "Expected to capture $expect packets, got $delta." + + log_test "$what" +} + +__default_test_do() +{ + local n_allowed_bits=$1; shift + local what=$1; shift + + vxlan_ping_test "$what: clean packets" \ + "tc_rule_stats_get $h1 77 ingress" \ + 10 vxlan_ping_vanilla + + local t0=$(link_stats_get vx1 rx errors) + vxlan_ping_test "$what: mangled packets" \ + "tc_rule_stats_get $h1 77 ingress" \ + $n_allowed_bits vxlan_ping_reserved + local t1=$(link_stats_get vx1 rx errors) + + RET=0 + local expect=$((39 - n_allowed_bits)) + local delta=$((t1 - t0)) + ((expect == delta)) + check_err $? "Expected $expect error packets, got $delta." + log_test "$what: drops reported" +} + +default_test_do() +{ + vxlan_device_add + __default_test_do 0 "Default" +} + +default_test() +{ + in_defer_scope \ + default_test_do +} + +plain_test_do() +{ + vxlan_device_add reserved_bits 0xf7ffffff000000ff + __default_test_do 0 "reserved_bits 0xf7ffffff000000ff" +} + +plain_test() +{ + in_defer_scope \ + plain_test_do +} + +reserved_test() +{ + local bit=$1; shift + + local allowed_bytes=$(vxlan_header_bytes 0xffffff $bit) + local reserved_bytes=$(neg_bytes $allowed_bytes) + local reserved_bits=${reserved_bytes//:/} + + vxlan_device_add reserved_bits 0x$reserved_bits + __default_test_do 1 "reserved_bits 0x$reserved_bits" +} + +reserved_0_test() +{ + in_defer_scope \ + reserved_test 0 +} + +reserved_10_test() +{ + in_defer_scope \ + reserved_test 10 +} + +reserved_31_test() +{ + in_defer_scope \ + reserved_test 31 +} + +reserved_56_test() +{ + in_defer_scope \ + reserved_test 56 +} + +reserved_63_test() +{ + in_defer_scope \ + reserved_test 63 +} + +trap cleanup EXIT + +setup_prepare +setup_wait +tests_run + +exit $EXIT_STATUS