From patchwork Mon Aug 23 01:56:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 501755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDBA5C4338F for ; Mon, 23 Aug 2021 01:56:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAFDF6124B for ; Mon, 23 Aug 2021 01:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234757AbhHWB5b (ORCPT ); Sun, 22 Aug 2021 21:57:31 -0400 Received: from mail-am6eur05on2043.outbound.protection.outlook.com ([40.107.22.43]:18787 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233258AbhHWB50 (ORCPT ); Sun, 22 Aug 2021 21:57:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KMICNXiiisLnbdHbfdLhw1NUdB0Br/ASLBv4iN4HMNl68go0lZ2/Z+0FuxKuH/b635UWBN0hcjBDWcMXMucvm0hXmGmWbVzVP6CiVG8fPbe0lrsTSm2a2lsLqN26o2O8uqEZ1jywcpYlHLEhbTxNjGkFsb6acc69PObBzM1nULL3gyefoio/FAUUqu//26cOE/CdpMZjzcyeRcc9+Rxr9kZVmxKudn2y3KvhB7e+f3lGkgjlTFh+KVBV8O6dAu4TYbICAF64hLXJqlPRAnHoV7mwYbGVmGF0igtcSI9h17wGMesv6tecMnNwi7w2OCz2zCjGu4CWIt8bqwsBBesoyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/ks2B929a6yqzlDOB+s0CkqfoQvNY6f862lSYf+lQaY=; b=S3wR9WpQtPkOCcJg/St9KjgdjHJsCEaITuBYHlMXhid3ivSIFNrP/649oAj6lEhsZB76/8Bid963DzshiHpp2JDfA/rUyQqiQ1laz/19hN+vhK1dE53TkXx8Sb5drGkrs+zPlXx2bbNRML8dtedGAHaaXlJ9Buf9w8556O4yZVlynXokx93vpgoikr5H9t4uY/slQqIMEBhQXY8YPPZSVZJplbgHHW4dgYx8NTURGHEYf5304QuJws3gFIeqQKWoZ2+yGjLLjsJrsbJKr5gHueoMMRPaigOGD1QWl4zkgzB9Yx+lbPEUzJjdRYW6kLE/xloRYhp8hHDOT2WVUyaVgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/ks2B929a6yqzlDOB+s0CkqfoQvNY6f862lSYf+lQaY=; b=fuXoW9ErAX8V3jIYtQg3k/Nj3hLho4aFb28/UrBHKQ/6pEYEVKpN9fmuaq/nZBfBqNoVuJBFvXK2O35lTVCUZD9CugIqk6aXhEgQM7gqR8fQ2JBq7pY21ziU/DmuCqkvvzrpvpIi2QMIvR7BJesDMlA6L8dWlaDGDbygE9V8Da0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Mon, 23 Aug 2021 01:56:41 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4436.024; Mon, 23 Aug 2021 01:56:41 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , =?utf-8?q?Alvin_=C5=A0ipraga?= Subject: [PATCH net-next] net: dsa: properly fall back to software bridging Date: Mon, 23 Aug 2021 04:56:31 +0300 Message-Id: <20210823015631.2286433-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: VI1P193CA0002.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1P193CA0002.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Mon, 23 Aug 2021 01:56:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d70347b8-c31b-49d9-27fa-08d965d94039 X-MS-TrafficTypeDiagnostic: VI1PR04MB5696: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jUVr3nnqX+XmNKXimWAfTihw1WeOusQ9OXplvnXY47RiAusdCH0GZN1LD91yq+Zs7ixdd4VemVKWz6Exg9Dqc7T19VXEjAFYAJVtLcydPvgKl/+7bbGE1AjKn/pobMvNFg4y+6wWRqHN1K0qRt2Bmq1KkTZb8w0VYQcC3evJxNRqPHl7Vf1c9b7N1StBh3QcSliPWfckLbz/5Keev11yXJFdEhCZwR9lvxhZuA9SxpHfNaXA/lPIwPJgl32qFjl+OTmMej8NDCxG35l8EbAn+YhQkRE7C2HcAxfGlvLuZ5fqd2YheAKb/S/Cc4gfYh9tB5bJ6Fg67En3KrTzSzA6dOH/0CAhurJSvHP/uVez6XZtRSiN2ySa3nW4aEKYhdPMIVTkKKB234mSY8LfEuvirgMTGa+GWeMl75kGI+lXxsdDCo+VSBkG5PGpgEigcKjgljCCoHL2baovsH0Lqp8vDyVKBkhyezkEePBDKagPWdbXl+GRao9NqV7T61x/fZInFp/52RYn8Vm48qCkXNhFwhwgimWAeJQbAsEPPXClPYumprrSAmh6ZBRRrp1z2PxLFpsN+ATeODZDHoAiNnzs3zZmvPkl//0GC1J+vrakIhwLkYie6QnRQsFexyaq8ZnTkDUoobqs1R4Ricts0b337fhR8DRc2KiLD07EA/Qf114GeIfd2bbRLcrm6ojHED1PdgDosq21UBkL9WnVgf9ElA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(376002)(346002)(366004)(39860400002)(8936002)(8676002)(6506007)(186003)(2906002)(54906003)(83380400001)(26005)(52116002)(86362001)(2616005)(956004)(38100700002)(44832011)(38350700002)(5660300002)(4326008)(36756003)(1076003)(478600001)(66946007)(6486002)(6666004)(66556008)(66574015)(66476007)(6512007)(316002)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?nn5ZgEJ27dcfAIKzOvDs56Vmm?= =?utf-8?q?JWI2hvQeppVTTkt6ByUwW0LUUtJW+AhlrTacVM9HS6Zl+8UA2Gb2qH0R?= =?utf-8?q?Z9tHmm1Ie4PrwCHsk45jjWMf6trIz/MGrRcMiUZdpiM33d7PX4c/wdJ4?= =?utf-8?q?P+BMIHIJOR1u4+WT/Pr/sPTAu1o6lmHUL9xQaCeLNqQnpcz5ilTCJ/wa?= =?utf-8?q?FrMZPsa5zG8wET10h+5zLw1inlycpvCDojjpMA2Z/Oet4eQbc1uul3YB?= =?utf-8?q?lW9hhLEX6Z1pw5M3SH8vRH9AJq+9jM7zrQAX/hx7qunY5aWwEB3yHt2U?= =?utf-8?q?oiDAj5qXBVAFQ6T7KQtfKKuS5+C3OfRUcgqtJg2FAI3H6hgHvzJ2alJm?= =?utf-8?q?Uou4y31R94VenaiTdLBnaNmLTb12oJ3iERBkKkS/0t/wnXmEcGXHHCsq?= =?utf-8?q?zNM3dhr4BeEEUSWl6UgPiXKURlSOdqfAytG7ZEhfJgora2cdkMgkHPUU?= =?utf-8?q?YOGLu7oAraUvqw4+aKHtxgaXXDdnaKo3d6MUlNpJ2l4xrYCCGGpT6b88?= =?utf-8?q?6N+jPpeed/4vOm4/o5VGUD4EH573SfC2LarKS6reYDXFz2/AUzuPXB1Z?= =?utf-8?q?nZ3PXVIQqnpZSAL/26UDwmGy5JUOuSNW5NmNp/8TjGCChT2TJxcvj63Q?= =?utf-8?q?T4KqVHOJdjiCo9lvwM+DIyeq7VsEyOHa6FjfEdTXQvv7g9rPUfHUTeMd?= =?utf-8?q?s3BSv80M3wtXOfQ9wmsF1R7dzrlpH00TTEF8nFI/w8exzaS6sSY12oIb?= =?utf-8?q?+30GgCEKnsBeq65sSBkW+oBeuFz4JznIYGpfydqW0EetelhBzYtvVRER?= =?utf-8?q?LLBiQwfsUz6lTFh0A54jmku4JFh/7iC4K/hp34m4D4S6/QgFfyQQuaNi?= =?utf-8?q?DQn96x5ykXQfQdXQXRsfC9FE2vEQHp7sisiacOgC9Rcafz+HJxlZdnb2?= =?utf-8?q?TlOC5h9zgTV8xHX2Ve3HThNOuecWIw7LMGFdE4Q7+W5g6LIRqtQ2RarN?= =?utf-8?q?8WWeGa43AodJje0AWpqXaoNPJe6hZvPQRbx8oXF07KCwkQJP24XjC35e?= =?utf-8?q?/s8kPDImWt1Ue21pr8UVVVVZoqGUcjg/vD1Bfd5FqTWeiOu6BWwxMsRI?= =?utf-8?q?TmRHP3ZguThQHwMqvfupf1UGUykt3uIO/9eH33YVldUBf9p+GjQuedP8?= =?utf-8?q?+rrf2Uc+W8/AyqIBCI1HO5tL3sWfsG6htZgbfuc/dmidqkBJ35L1MTro?= =?utf-8?q?wSWk/aYJQrgmlFKnoQ3rIsnVuR/8qJTcUvDz5KbDacah480YOKbMA8K3?= =?utf-8?q?MBc8KJ3s/xDj68TaooSazLtKQzQ9/EPey/r1eyJpTskEHVIo0k/h3yDl?= =?utf-8?q?akYizlancZDmNsydTJkYlA037rMLia2?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d70347b8-c31b-49d9-27fa-08d965d94039 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2021 01:56:41.1191 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JJMgrzBMWZENvgoXPksp4YuwqBX2vZP5f8PrimbY7MgLeDanEDIKELZUPqhXBDN9yldV7qRu/RamHhTdyVDy3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5696 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the driver does not implement .port_bridge_{join,leave}, then we must fall back to standalone operation on that port, and trigger the error path of dsa_port_bridge_join. This sets dp->bridge_dev = NULL. In turn, having dp->bridge_dev = NULL makes the following things go wrong: - dsa_default_offload_fwd_mark make the wrong decision in setting skb->offload_fwd_mark. It should set skb->offload_fwd_mark = 0 for ports that don't offload the bridge, which should instruct the bridge to forward in software. But this does not happen, dp->bridge_dev is incorrectly set to point to the bridge, so the bridge is told that packets have been forwarded in hardware, which they haven't. - switchdev objects (MDBs, VLANs) should not be offloaded by ports that don't offload the bridge. Standalone ports should behave as packet-in, packet-out and the bridge should not be able to manipulate the pvid of the port, or tag stripping on egress, or ingress filtering. This should already work fine because dsa_slave_port_obj_add has: case SWITCHDEV_OBJ_ID_PORT_VLAN: if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev)) return -EOPNOTSUPP; err = dsa_slave_vlan_add(dev, obj, extack); but since dsa_port_offloads_bridge_port works based on dp->bridge_dev, this is again sabotaging us. All the above work in case the port has an unoffloaded LAG interface, so this is well exercised code, we should apply it for plain unoffloaded bridge ports too. Fixes: bea7907837c5 ("net: dsa: don't set skb->offload_fwd_mark when not offloading the bridge") Reported-by: Alvin Šipraga Signed-off-by: Vladimir Oltean --- net/dsa/slave.c | 5 +++++ net/dsa/switch.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 78c98882039e..c5715f9ec8b3 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2151,6 +2151,11 @@ static int dsa_slave_changeupper(struct net_device *dev, err = dsa_port_bridge_join(dp, info->upper_dev, extack); if (!err) dsa_bridge_mtu_normalization(dp); + if (err == -EOPNOTSUPP) { + NL_SET_ERR_MSG_MOD(info->info.extack, + "Offloading not supported"); + err = 0; + } err = notifier_from_errno(err); } else { dsa_port_bridge_leave(dp, info->upper_dev); diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 92a07d96c0ac..d311cbfc7035 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -92,8 +92,10 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, struct dsa_switch_tree *dst = ds->dst; int err; - if (dst->index == info->tree_index && ds->index == info->sw_index && - ds->ops->port_bridge_join) { + if (dst->index == info->tree_index && ds->index == info->sw_index) { + if (!ds->ops->port_bridge_join) + return -EOPNOTSUPP; + err = ds->ops->port_bridge_join(ds, info->port, info->br, info->bridge_num, info->extack); if (err)