From patchwork Mon Aug 23 02:10:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 502217 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 7444DC4338F for ; Mon, 23 Aug 2021 02:11:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4654661184 for ; Mon, 23 Aug 2021 02:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234767AbhHWCLu (ORCPT ); Sun, 22 Aug 2021 22:11:50 -0400 Received: from mail-eopbgr80058.outbound.protection.outlook.com ([40.107.8.58]:24870 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234692AbhHWCLr (ORCPT ); Sun, 22 Aug 2021 22:11:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FtlVjdSDhlYKCk7ulz6kvm8xT6wA5il6IuUvGuhDgjOnQdAwSBB5CaXVZtx/vY/k6I5bBbPNPDqUBxXQkylSrISq1zyFOCRDBa99o3ryZ7OYGNq6byucPPvx/koHS0ZnvEz+WDZb204Ek6lyTB9A5hS+OSvIKiy+ExQVq22VlnLKC9vFC+3dSU3Cqa6G60fr26ku4PDnBDNqLvVvhuocqJlrMd7+sYx5TUnqEHZfOHhx2+uhfpaa6UiLcp0t3K7qh3Fp0lf4ATR33f426ivMe/2d4IpNimFcst4EclaIFg+GEbmJvfDBIAKan/KIvXoQSY+hpLwXUMjl/EBihUnMkQ== 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=4OmkCD/gneWNH2iXR7MG+JtDIvl2BKDPpfM2eCZ4kLg=; b=LOJ0Gts4X4v+bmYC7aEFFVH+Qi+x1rO4As47XgAXph8rienMeyuNnxPr3AaHA1esij+Ck5C/E32OOILTSxIoMbK2auU3tlcu+sV58xjhgdVEHKo/Gzob5HjZ1fc44vX21gnkUIc6JsP4xQSni73F1p3VvIPPKBoQd3PXg5c+xryTqDSmmlDIApeKS9BXdjD6Tm51+PAb3uBZePFcv8/tJ/eoHdRxi5t0JclMUZ5b4KK5myUkjFd7HFqECIpjjA8CZuowGaBgRY3erLddGjYnlDuwzviMA9GzApu8QQZ8z0L2nOg3xDOR+aF0Ywxuf8RiVgxGrBn4v+RN58O2H3uPOw== 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=4OmkCD/gneWNH2iXR7MG+JtDIvl2BKDPpfM2eCZ4kLg=; b=euq/llLmN+0lkAUAKY8KkQJdmkT/B6Kp1yVSe1trVsjeg+ZMQ/oNekp7T93MHbtgChWlcqxWljfqGj9WGP7nib4Gh3J3rTorKq7VIwUqLEzPVZqi266NBTarQF/lB8kqAXg81wepn5gm9o5SGVVCvWHFMJ303c082LSpbFQlxew= 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 VI1PR04MB5501.eurprd04.prod.outlook.com (2603:10a6:803:d3::11) 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 02:11:01 +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 02:11:01 +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 v2 net-next] net: dsa: properly fall back to software bridging Date: Mon, 23 Aug 2021 05:10:50 +0300 Message-Id: <20210823021050.2320679-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: VI1PR0501CA0047.eurprd05.prod.outlook.com (2603:10a6:800:60::33) 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 VI1PR0501CA0047.eurprd05.prod.outlook.com (2603:10a6:800:60::33) 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 02:11:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7851802c-2c36-4c9e-fcb6-08d965db4114 X-MS-TrafficTypeDiagnostic: VI1PR04MB5501: 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: hXYftoBZ3Nx9Qe8AdmHO41ATzF9NrxE4g3ACtE0okIsP5zyC4S0JyKiejMNM386rWFqeMQw3f7eVyyyJYCW9tGZRGNQslCPKVmEz0QQHe8+3CCxZ1eICJcA8Au5eNFv53c4BnIP8GCjPvvIkt8+HRq2uiLTyvyy1CYQ8aqcH8oOS2KdfdIYgwGGnm38LxZLVTZy/kh9J7VN0AvxebG9n7KWQEDDEPLvxNNFcv5kStpBTdHk4wdmgemVAz5JwZcsuNXg5pA6sdg584C3DC5DSS6SsrT+asIACoZoXWC6SHuUaRcnqPZWjkESoQPlG9xBuJSuvVnascJLgrSZaTcTZ+yugevs76qLGwoVdeA8q9uEdAGLQu2vGarfRYzLNshbNyOZAeA02aKWvFDhA6pyEPFiHOJhs6WxM0nHJrjcgZkcI1Txz65Z8TTzdp7ylK2r4SWqjNL1jup4Z9821qV7gb/whVR80SGO9Q5h+rwLYDiAWEZNiGI88rnfryxGjfucavusA/VhiKNoNX4moQgiLau3mFVG08rEZVR0JFAcn+JJuK9/mpuqlPs35wwLq+BvOlr2bH+KFiCfpWEVkx22tvF/gjQyBUntV+GKHZaNU6FNDSzTRQcEsq5jptfrykcedqtiM6hCLGziakpb5AbkAQxLZ0MZcoVhBwSHKu/84YIb2oi9ndvj7EM/jlTu3GDotfdWnxa6WraGYWjZDPW2JRQ== 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)(376002)(346002)(136003)(396003)(366004)(39860400002)(54906003)(36756003)(478600001)(956004)(316002)(8676002)(8936002)(26005)(4326008)(1076003)(6916009)(186003)(38100700002)(38350700002)(2616005)(44832011)(5660300002)(66946007)(2906002)(83380400001)(6666004)(86362001)(6486002)(66476007)(66556008)(52116002)(6506007)(6512007)(66574015); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+VZSdhCFvxa2ismSZhz+NdTL5?= =?utf-8?q?i2cvERGWnqjiS97iC9QDVBmLRerB3mHXUSd29bA/TEds47VhXe7MXdRu?= =?utf-8?q?AUJKol2ehvZP3l984owoD3QpBuPXNaefqyjR+LYbnIvLndFBWhKQtgwu?= =?utf-8?q?1zJIj770Eua38uz1OQ8UU5/ZzjZtc0JLa17SG45AxpPFbKnJRLpXj3Pu?= =?utf-8?q?ze/YDiBSCheEye4OeQ3+ok+HQ8ZLxhiEKLoEC4NMD4tYVfBlYrBsuaiq?= =?utf-8?q?iYBe8PZ5dULw1fO7ai9NoA+K2DCLWSvM37WQI8o2uZd1TsTg3a4sGIZ7?= =?utf-8?q?2R5oy+tte+2yBZMdbKoLj14E6J+G7zUsHeUwiJWOQqAskbZDnqXSiRop?= =?utf-8?q?K6BQmByW24QRDD04nT6qIOrS+oeQPMoNU7GR8ygTENKuTFBDvL4DvnPp?= =?utf-8?q?bQYw6bTdUYJFY+11Q9ilK8KegOJrC+mG142CvDtzLnqRb2eTDgNwr2Cd?= =?utf-8?q?wvF8+bPALuZnBj9FJUK/i/zAtJtZFaY+flTjEkFc3txPEmfKp0YqLRsA?= =?utf-8?q?33BQpoHw14B5ZYnXoLZ3P0MZmgPJcrZ6+xKkV+1Ig/EO0QgdHH9xMbAy?= =?utf-8?q?qhXxxRwCgZdaPfpM83MjmR+zhrwIaAkLZLuaIslkwTXXbLfhx/7B/fAz?= =?utf-8?q?A8wlxpcVfh2mb6F6rvFHTFGrBhLiljqLjor4zl16bxIIHVKB0hxInXXM?= =?utf-8?q?X6HU8o9/mufAj332226XP3OmeZLuH6bcwuD7EUNa6N6mSA74uQDaKad8?= =?utf-8?q?n5Ks1c4N/pvbAj2frQz8T6otDxpBRnLjvSmad5P+xdbARq5/2tLvPAdA?= =?utf-8?q?JIhzMGei7J5GUFw3aJ+SjB+mnmpc6zkZgIM8GVxgD7BdjaODkusCOxuq?= =?utf-8?q?W3l5VXpSRmYoTa0ZA6XFoBGzYfJ566RRQoaObEia8AOPd2Kuc5L96+rX?= =?utf-8?q?0pqa12FfgNNemfFQLOhyh8TkgepVAiYBAJmuchJggLngJKdoM5chEoaj?= =?utf-8?q?lHo5ZWlBhMr/oEjm53YX9qC0XEwjHuyb4uFCcs2kFPMtUHnFCGQoLRNw?= =?utf-8?q?NHxTDM27O0rmXKE3kIyX/U28XOpwOFXvA3QsNG3OcHzPKQllxbc3//XA?= =?utf-8?q?G5PDjgi0TOI3JTLBMJ2umBpDJUoj+f+lmh5dleJFo1BBeayJ8rgG/Ioi?= =?utf-8?q?srGTr7j7xCOkKp7WRPPUYCsJIpdzrHZRbd/FNfVT9GrvGA7Ul9CsVc6F?= =?utf-8?q?6oeXfu5YPtTEBe4snLuZ16AVR4/D99FigyLRxtsB3RM9YUKWoe0XQRGe?= =?utf-8?q?I6g9UnDXZ10pbi0KgaUHlO+NueMpVB7F02f+ZdWSZez4QG04llzYEqaz?= =?utf-8?q?/7hezR1WRfT9ou0+O24dTDwlJhUJ2Mn?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7851802c-2c36-4c9e-fcb6-08d965db4114 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2021 02:11:01.4972 (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: TLf/O6WVI2nF/VGufKN33KIRPbi0haXa49YEJuksiFwjFzoyqAltP8kOtWa99N4NOfwEXBvEJmUcNx6PSLEgtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5501 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 eb9d9e53c536..f785d24fcf23 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2009,6 +2009,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(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 fd1a1c6bf9cf..dd042fd7f800 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); if (err) return err;