Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5457800pxu; Tue, 22 Dec 2020 18:39:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCBd/7STZF0OL8VA6ZWU1I198SxrFiYqjHK1prhKVnk8xeOfodwedR0o4TI5Kxo4X+0omR X-Received: by 2002:a50:955b:: with SMTP id v27mr22606679eda.324.1608691166673; Tue, 22 Dec 2020 18:39:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691166; cv=none; d=google.com; s=arc-20160816; b=g2h++ddXjh6BOHkRXHY30C9839k5rdkpq/5Pi7nRE8NhOqMGTZgeQdrcWxbXnWZ6L+ +6GUBdBVaWBulQF2KRxW0fP3zInn7XURUbkiLRMCCiIc4bc9owUhKWFNHsWdXntE3qa3 Qhp2JZbxAplhVW7fl0bl6E3WzugCUc7bYThXbJDqgtQepIseuK0kbAxmuGfsjXmhkDut gknNkqiaPoUgdA1J8mUgz23CtqfkUUPMsDEbZSAwcJ/n8d5qBGihYzAdSnA1pDPyzLwG tq7mJzwr92R1utgdTg1NpP8I9DCE9G/GTCdaktHvQXTFw2Zm3JdThXXPJ+7ecIyI9+dI SDaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wFI8Xob4/qXoOOP9F8OesX8y0CPVX55DMeaHNQXJkjw=; b=BTnBFYvIFx9oG6C+zzl2Smwv5TjYKDV1dFwYTatBpQOoN/YtZV+Fri3htPF5owzJTl TP45NOXAJl2w3TQgn71xK5dJIwdP591wR49yPwq7FBKTbvX7qvFofeVmAE1T56lPwi3U bIwyVkKa1lkcOAhEJMX+fBK8Ju03XIGievdMfbKdq3A9/h9QzmrdLJotDEZCr8Apd+Zc HgIFT2r1RKSBlYDO/iPCCIq8sWrd0GFGVeyZg9Q0vTstO1fihvtXaz4b/FVpoE3CVjO5 hvlTOrgMunncAgiOGlIG3xoqTVM/xOObtiIAXjdMzEHQKrl043OdjUrkPB/YePw6yjwy Zyuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ey/o/sKM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t11si10085488edv.337.2020.12.22.18.39.04; Tue, 22 Dec 2020 18:39:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ey/o/sKM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729233AbgLWCi1 (ORCPT + 99 others); Tue, 22 Dec 2020 21:38:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:51318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730137AbgLWCYJ (ORCPT ); Tue, 22 Dec 2020 21:24:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8A38622573; Wed, 23 Dec 2020 02:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690233; bh=FhMaO3I4ZyBUQeH9GBYad+uCSyIo2S9KW/Y6O7Swvwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ey/o/sKMGEwO9Y+NGC9WCE7zxzyzOXDX0GUMgfEN8H+4VhRp22hTBDZ/xhfskD2c+ UK34wuEysTQWiBcE6W3mIdATYaS12ZwND8DJAN3yiQwXG0HEPLI7uqRdKtDnUbwOeu HIiPv0qmG7ZVrq5fWCMzwufMbUaVlzvcU8pF+y+iux8NvQXV0Z9MohFUDj2F6pjy8J j6EyXzJ+N+NMYkHu+SocGv7g9LfU/5fWYkhFiBvzXUruuxBTYPVLXk7glO+Mv39lvY motLYXwxN5OAcF622P4cYVWjdYBUFOUJW04M8rLK4EO1TosGx+yjWyyDFNGDsFwNQc M8E3/coeN422Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Danielle Ratson , Petr Machata , Nikolay Aleksandrov , Ido Schimmel , Ivan Vecera , Jakub Kicinski , Sasha Levin , netdev@vger.kernel.org, bridge@lists.linux-foundation.org Subject: [PATCH AUTOSEL 4.14 48/66] bridge: switchdev: Notify about VLAN protocol changes Date: Tue, 22 Dec 2020 21:22:34 -0500 Message-Id: <20201223022253.2793452-48-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Danielle Ratson [ Upstream commit 22ec19f3aee327806c37c9fa1188741574bc6445 ] Drivers that support bridge offload need to be notified about changes to the bridge's VLAN protocol so that they could react accordingly and potentially veto the change. Add a new switchdev attribute to communicate the change to drivers. Signed-off-by: Danielle Ratson Reviewed-by: Petr Machata Acked-by: Nikolay Aleksandrov Signed-off-by: Ido Schimmel Reviewed-by: Ivan Vecera Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- include/net/switchdev.h | 2 ++ net/bridge/br_vlan.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index d767b79918871..197ea127e29eb 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -50,6 +50,7 @@ enum switchdev_attr_id { SWITCHDEV_ATTR_ID_PORT_MROUTER, SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING, + SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL, SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED, }; @@ -67,6 +68,7 @@ struct switchdev_attr { bool mrouter; /* PORT_MROUTER */ clock_t ageing_time; /* BRIDGE_AGEING_TIME */ bool vlan_filtering; /* BRIDGE_VLAN_FILTERING */ + u16 vlan_protocol; /* BRIDGE_VLAN_PROTOCOL */ bool mc_disabled; /* MC_DISABLED */ } u; }; diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index e24a74884768c..2df788104b5a6 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -723,15 +723,25 @@ EXPORT_SYMBOL_GPL(br_vlan_enabled); int __br_vlan_set_proto(struct net_bridge *br, __be16 proto) { + struct switchdev_attr attr = { + .orig_dev = br->dev, + .id = SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL, + .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP, + .u.vlan_protocol = ntohs(proto), + }; int err = 0; struct net_bridge_port *p; struct net_bridge_vlan *vlan; struct net_bridge_vlan_group *vg; - __be16 oldproto; + __be16 oldproto = br->vlan_proto; if (br->vlan_proto == proto) return 0; + err = switchdev_port_attr_set(br->dev, &attr); + if (err && err != -EOPNOTSUPP) + return err; + /* Add VLANs for the new proto to the device filter. */ list_for_each_entry(p, &br->port_list, list) { vg = nbp_vlan_group(p); @@ -742,7 +752,6 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto) } } - oldproto = br->vlan_proto; br->vlan_proto = proto; recalculate_group_addr(br); @@ -758,6 +767,9 @@ int __br_vlan_set_proto(struct net_bridge *br, __be16 proto) return 0; err_filt: + attr.u.vlan_protocol = ntohs(oldproto); + switchdev_port_attr_set(br->dev, &attr); + list_for_each_entry_continue_reverse(vlan, &vg->vlan_list, vlist) vlan_vid_del(p->dev, proto, vlan->vid); -- 2.27.0