From patchwork Fri Oct 25 13:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Herv=C3=A9_Gourmelon?= X-Patchwork-Id: 13850748 X-Patchwork-Delegate: kuba@kernel.org Received: from PAUP264CU001.outbound.protection.outlook.com (mail-francecentralazon11021079.outbound.protection.outlook.com [40.107.160.79]) (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 AB51A3A8D2 for ; Fri, 25 Oct 2024 13:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.160.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729864014; cv=fail; b=gdEwMKjalcj5HAWeOgOG4FAXRjAB+yCVIitU8NGSnuxcULWbqGX2Jsgix65tu/eGWPOa9KXs189OPcHu6UZTC8B755UXPxgPtQAYxrlfBPAcuABSO0zwLON2T6Kbug3oW+JKEFwD3nDQVO7HOG3uLx+8H/AjwiVGUo9M4UPMcE0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729864014; c=relaxed/simple; bh=OzJJG8dXRFIKPZyiy6gQ9v8bv4GUf/wd438Jkx8u0BQ=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=I14fv7Tjwbqo4QhvsoKhmJ0wb+Ps0JDmJowKtZTp1KUquS0zpD7dqTwQJALt/uY3BTZxnoxwfqKdmKGnHC427hSlkgAHCO6nuPjIMTW04RloNLw0V2xKKwC3StcRb80IzuaeOmTtceo8kqwfVmKq0UbyuU0fcyk2nkwHN0DOodc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ekinops.com; spf=pass smtp.mailfrom=ekinops.com; dkim=pass (1024-bit key) header.d=ekinops.com header.i=@ekinops.com header.b=h9sv4XzH; arc=fail smtp.client-ip=40.107.160.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ekinops.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ekinops.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ekinops.com header.i=@ekinops.com header.b="h9sv4XzH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DZc8HweJr3yPW/5OvHjmKMQTRch6O9UcvEr4nt/Tw7OiNz+hWoEMxUGzF6G3m00YaIotIfkVRcEK+9xdcrYZBNU67Zqhb7LlJF+KHL3zDrQC8grvBMPlkHjY6FFxeRk8YKwi5+sVxxpVJcwg1RtcjpUOLixPOYrdX3SU2FxoCmUx6bi02UUzSHomdEdxBS/R7582S/QmtRD9nU5+bUNPwKNW+QRETZiOuvVP97EnwEyfG4Azy5v1VVBQ5taxpBN8YkR2GhZ+DuTQuCs8XJovt7bmvfDvb3vkM0QQ6dEqxMOBa2ej1i1ysevbxuS/Xmsh3MzZCmZu5a1gRag9C5+Bfw== 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=6ko/PtOO4p06Rkg+7Ck5AXzSX2PRUauMGMpxcTsweqU=; b=dQ7qzD/PX4QsdBxArdfNM2GfHDDG6eGCO/5ELOERitUVB2vugZj+pY+YNqOHl9aIgmcqCrohBFpDJtUQEQPUQXjvYDU4BmHMg6NyohIOz9lfcR7+VE+uTVN1l8rrWAp64aghAbHmeai2naKQWDL6Sk/H7LZaY1EANwW1N4g0yzDbWN8uUh/YTb2PhbXbSprSP/O0FCYE8AtmM5m3bnMTueJQJNL/ibNcRjHt9OcYaZ3MIKZEhYfLUX7/X8+JM7rN1Dz7nZGBji0r29DSb3bAlkw6niGzX14eht+TPZtKpEetOeeDdGJZa5lQsl4L5V68yC1uF4dDSK3LElohayF0AQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ekinops.com; dmarc=pass action=none header.from=ekinops.com; dkim=pass header.d=ekinops.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ekinops.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6ko/PtOO4p06Rkg+7Ck5AXzSX2PRUauMGMpxcTsweqU=; b=h9sv4XzHgC4vWyl6e0rwnNlRUGOCvCsAy7B08461oQdf/BJWaDlVkOAp0A8ukTIWJVgvINp/80Lfgh2zie28JFrDbkGBlnshHlC+fMCjpfIlUy/cRg8hd7EJf7bviXPb/fH7wpXM9IEdCDnj7cmhZMjoqeXYeEHlXYCPWkTRO78= Received: from MR1P264MB3681.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:29::22) by PR0P264MB1579.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:169::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Fri, 25 Oct 2024 13:46:48 +0000 Received: from MR1P264MB3681.FRAP264.PROD.OUTLOOK.COM ([fe80::1883:57f5:6df2:32af]) by MR1P264MB3681.FRAP264.PROD.OUTLOOK.COM ([fe80::1883:57f5:6df2:32af%5]) with mapi id 15.20.8093.018; Fri, 25 Oct 2024 13:46:48 +0000 From: =?iso-8859-1?q?Herv=E9_Gourmelon?= To: Andrew Lunn , Florian Fainelli , Vivien Didelot CC: "netdev@vger.kernel.org" , Vladimir Oltean , Tobias Waldekranz Subject: [PATCH 1/1] net: dsa: fix tag_dsa.c for untagged VLANs Thread-Topic: [PATCH 1/1] net: dsa: fix tag_dsa.c for untagged VLANs Thread-Index: AQHbJuKS0axQvm9UnkuMCwF0pdBIEA== Date: Fri, 25 Oct 2024 13:46:48 +0000 Message-ID: Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ekinops.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MR1P264MB3681:EE_|PR0P264MB1579:EE_ x-ms-office365-filtering-correlation-id: b0c7e4d4-0d20-48f7-9eec-08dcf4fb78e1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?B6S24IkRqSKczbsiTQoXB5B0TJ?= =?iso-8859-1?q?b28VtVdzoJt6DUaeecV6KouL99PcWqNhG6QGHk9+CI75L1Q0L+V4wKViazFN?= =?iso-8859-1?q?5pCM/3hk16q48dcOI9Q4fWTm0152YZwWOnVCEBDXmOBhjDKok6hhExCTBU/A?= =?iso-8859-1?q?IxBUPGlAFHwqv9aBH8JyIPf5aMTsdjfa3VnKS7irlKZoOOvN8JhfeILewifI?= =?iso-8859-1?q?PVHxmNUX37M1edMVj5K8g5+8Os/j89e0yksAxyx9p3FeTmQsSWT0saT2z6Ef?= =?iso-8859-1?q?N8eCOSMhaWZz/kvjyA66X3vj60CQ8kydvHup/jyg9515hy9eMdd0VXj6wjxZ?= =?iso-8859-1?q?/ywF5j5cLJxBo9rWTtjl351huvP8aLvtW+zvjXfMyE5hD0Gr7XqNb+N/k1li?= =?iso-8859-1?q?33LcRLgQmBib/2OzF3LkTLOSGJtE8j22WWa4m/DZHwSoVP9ZLJViXvgb5mlm?= =?iso-8859-1?q?EUTadhFoTJCCz5R8C+j9GMcESjZRSDh4wiLZQx8c7CLW4fFK6v5t79nYI0IP?= =?iso-8859-1?q?JbOwd2U3mBQCbfl3xxjfd7R99ufOPLmiKhD2mZ6n3P2D59QH6xUQR+VfOFHs?= =?iso-8859-1?q?ALaNwY84KjAS0ybu0A1MYJZZF7dQpf72huKWTyHs7X2KqDVeSFGYc11GFQXs?= =?iso-8859-1?q?dnZk5PHP2cpnFw434RtplDZRP3iKqMG7QHsKDuXfxtZtAPQuGo9+klg69p7z?= =?iso-8859-1?q?0NnKUQ/sXqRTUxqo4OJ+g9ST4lG9CjSGCllOKAyulOKKgkj3AsCbFdtJHgGs?= =?iso-8859-1?q?C8L5Aq5mal+jY0q6FI9+vOCzjAGQcxj+xl/h+JWr/X8xWbsIvM9kdI+cSgDu?= =?iso-8859-1?q?3JlRSUwDvSU/0B/BKtVbwRUJcGOwVRGJ94EB6Yi0SIP+JhxK/UZ8LwZY1qds?= =?iso-8859-1?q?ZfcvgawzhNe94XUKV+PZB/87FE2CuMa5wbhB7YN6Xy+xJF4DNo4XfgNaiCeT?= =?iso-8859-1?q?JCsc34+E+p3B40EYJDgrbnsRIU6pIEUAho+OvbNR/6zyrAJMK9yufsOOrLR4?= =?iso-8859-1?q?K09fw8j2SwFjksubmRHiuUCOKpFLbrOVh90AjV53ECZqM37Wc5dEcQe0QAV+?= =?iso-8859-1?q?Q8BbVh33J/BW8ayAyqzQpIYgtDzSbCOdsh1JDO7S7q+6l/cPGXJbTgYy4PiE?= =?iso-8859-1?q?nSFeLE8JmkQ36X53pWtxTUHBhTCazI/YY2mMSBpOTjAr8YUZGTfCGiiUaFky?= =?iso-8859-1?q?/sQRU5vPw8xePFTsQlovN06a2hE3msrj/lbfYLfU5x3iUXryCmJa6tSTUWCO?= =?iso-8859-1?q?Zb+ZSKqECKSh+AediShhdkIWsT+3Udw7sYaFbCPCAhypNmQNDP7ouYiQLhBE?= =?iso-8859-1?q?h+29/bihrXD3aWJX6j47nF6xm4RoM6Se0uYzMgObvyuvjSNEyAdD/jA8P1zB?= =?iso-8859-1?q?99YaTJZbG9uTLgvZTLSfseTJIWa+ZVA/yzzT0vhNs=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MR1P264MB3681.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(38070700018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?3/ussBC6aDecSrxH/Tu8pj6?= =?iso-8859-1?q?LS4P0T/8ynzgenFeTDIg6ROgwMEqCwhbnymlZYNGpM/zxFLsDbRHygfKu+3O?= =?iso-8859-1?q?5/fUqrGI4BFffnn8Do5XRR4tU08R4ndwpgC+d40UiFOT7ShoF0UcTgerZEoG?= =?iso-8859-1?q?XzZcy43rUbQDiyKffwBX9V1Uv30K+TLb1i73v3B8ofae+XhCIBRYC+EOBaZy?= =?iso-8859-1?q?bC/wQZo8F2oB27JhMEV5wVIvkdfg+cb26id+5XglhEGC+ykcRiY4t9D8sWE4?= =?iso-8859-1?q?Rk92gvGEI8ccieVSw9wz/U1TFqBhSN3Wl1DKMR5bpurxCuGc8jaOdIvizyBu?= =?iso-8859-1?q?kOtvv/cxPRMrFRQqB9MxmYo1eRPSu6LbHN5y5+AguPej4KaXbzZdwlkMJKM8?= =?iso-8859-1?q?vDcbAYORPvBV5gb16H5vUpMDzsaSf44HOtSBbH/glU2YjXfxHS8MEn5SfV7G?= =?iso-8859-1?q?PRq6BHh3080U/DAmRWSK+xAFWQk/96lkEW17fNDro0znXZyEOi/T/B7S9csj?= =?iso-8859-1?q?12QhyTIIDIDyvXGNOQqqFgsM0gcBtn99zwNKF7/SOAkNgEqMj8+KFQ3zWnPU?= =?iso-8859-1?q?g3O4errY8KMujLTNdVqUdirM8egxr5I9l5hvDwx+ZaMhYpa0O2sw7baS+0ZQ?= =?iso-8859-1?q?8po6oGazuE90PFpNBzppd/GLH/e75kdjZgP2RaH1qof0hTLAybfNwLW+vmCr?= =?iso-8859-1?q?DcTJ862C4QmMFid3RmxO2RTJKMygUbFjGeCT40AfmHD4AMdQq6Tm83bksa8B?= =?iso-8859-1?q?XsnEiF34hrm8FAueNEniCZhWWYiRl5Idq0zajzvQmISoEjiVjgJS1A8sFhfV?= =?iso-8859-1?q?XsVYtRX6Sx9VcLE/zMzap9Xy9+aTHgaC18sPtq1q9aGUV5eCnvKZBjapmS/M?= =?iso-8859-1?q?Vxk4dkuvK3cA9MNggihkwuWEEUm8QWoulQ1ySmioD8uj8ugcL9KlnsmCVJNs?= =?iso-8859-1?q?8vhLtYSNo0lKVFuHYPwiPP3Z8+8DhkJc69n09G6oxwrpq5Fw3dITVgTeF6lI?= =?iso-8859-1?q?u7uBUrGNpyFfs256GsOQFsGb6w0keJmpEK0nU1GCf2tlpor6s7oYsfIBA3xS?= =?iso-8859-1?q?Uj+j6exGX0INieC13f8NdfPhFYATKpJktGZlaP8xzd8WXvJFWwkJzXI2gQ7M?= =?iso-8859-1?q?G0fx9TZJDAaK++F++QUradfnI4fgcs95bJzBJ5hfK6wIzsj//53uquDJHDa1?= =?iso-8859-1?q?c3pCKPxHv1U2h7q9/K+kWX7y+vMG3mQM6e8h+tRnhhMs2pa3rwaeffOVaF/R?= =?iso-8859-1?q?2RWlX1Mj7O+Ibz62t1/BdZxpeCvBlKXZSOtBSshi+YM+4o3IBvV7abhRmDp6?= =?iso-8859-1?q?iNvC80N/FvkKdnvi5xGzEf+502mXnLK6zgPqeySv2TIukesZtw7RVMqxyXsu?= =?iso-8859-1?q?mZfBi4Q4sjuxYlCOmitFr510W848MW9iyjCPRPRoGyvrTYdgDfvhwrqNJUFp?= =?iso-8859-1?q?uWS/Fo3XHvnUUJsyNFpTsROVqW5SxjqQvNfFZljakJGmbln5bU77gCJqbjBx?= =?iso-8859-1?q?IlUZeNhBiPXr0NbW+lMSFfUpbRQMMRDmmDEiI4FCPiR7wtNoia/6f4FNXjW1?= =?iso-8859-1?q?SRFs/asC7gjjAduaCz4bD9n1GlL634HaBuW7XMWQGLM6Ce3ewVCGI6389Z0d?= =?iso-8859-1?q?B6tDwHtttcZVQ0u8r?= Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: ekinops.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MR1P264MB3681.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: b0c7e4d4-0d20-48f7-9eec-08dcf4fb78e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2024 13:46:48.1181 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f57b78a6-c654-4771-a72f-837275f46179 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 9r1AJgFcVVX5vrC906H/a7wfUO3xr/+sIWCz12Wna5dzvysEa8wNXMQnYSdFB0dVgqzIjMj3Kj1DyGO8zOA2VP61Xyel7Bvv7wwrQQuiI3Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB1579 X-Patchwork-Delegate: kuba@kernel.org Hello, Trying to set up an untagged VLAN bridge on a DSA architecture of mv88e6xxx switches, I realized that whenever I tried to emit a 'From_CPU' or 'Forward' DSA packet, it would always egress with an unwanted 802.1Q header on the bridge port. Taking a closer look at the code, I saw that the Src_Tagged bit of the DSA header (1st octet, bit 5) was always set to '1' due to the following line: dsa_header[0] = (cmd << 6) | 0x20 | tag_dev; which is wrong: Src_Tagged should be reset if we need the frame to egress untagged from the bridge port. So I added a few lines to check whether the port is a member of a VLAN bridge, and whether the VLAN is set to egress untagged from the port, before setting or resetting the Src_Tagged bit as needed. Signed-off-by: Hervé Gourmelon --- net/dsa/tag_dsa.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index 2a2c4fb61a65..14b4d8c3dc8a 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -163,6 +163,21 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev, */ if (skb->protocol == htons(ETH_P_8021Q) && (!br_dev || br_vlan_enabled(br_dev))) { + struct bridge_vlan_info br_info; + u16 vid = 0; + u16 src_tagged = 1; + u8 *vid_ptr; + int err = 0; + + /* Read VID from VLAN 802.1Q tag */ + vid_ptr = dsa_etype_header_pos_tx(skb); + vid = ((vid_ptr[2] & 0x0F) << 8 | vid_ptr[3]); + /* Get VLAN info for vid on net_device *dev (dsa slave) */ + err = br_vlan_get_info_rcu(dev, vid, &br_info); + if (err == 0 && (br_info.flags & BRIDGE_VLAN_INFO_UNTAGGED)) { + src_tagged = 0; + } + if (extra) { skb_push(skb, extra); dsa_alloc_etype_header(skb, extra); @@ -170,11 +185,11 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev, /* Construct tagged DSA tag from 802.1Q tag. */ dsa_header = dsa_etype_header_pos_tx(skb) + extra; - dsa_header[0] = (cmd << 6) | 0x20 | tag_dev; + dsa_header[0] = (cmd << 6) | (src_tagged << 5) | tag_dev; dsa_header[1] = tag_port << 3; /* Move CFI field from byte 2 to byte 1. */ - if (dsa_header[2] & 0x10) { + if (src_tagged == 1 && dsa_header[2] & 0x10) { dsa_header[1] |= 0x01; dsa_header[2] &= ~0x10; }