Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp382404pxp; Wed, 16 Mar 2022 07:44:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV/HSGqwrCNs+mkQX0f58VuBuElNIeLg+joaEz71sBeTj+4Fd46W0PJUFRlW0yTYQMt06E X-Received: by 2002:a17:907:968e:b0:6db:aed5:43c8 with SMTP id hd14-20020a170907968e00b006dbaed543c8mr263936ejc.636.1647441862682; Wed, 16 Mar 2022 07:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647441862; cv=none; d=google.com; s=arc-20160816; b=J/6JvVh06JEJKvOp3Dx17gZbD5KG//3bXBBCPFBPLAMk7ndUDORpXdg2TO/GbP9RXl USfHFvrzg8ykcXCKWVDzgTlwFwEf8BggFKhO7VMW2FqhYhJqS86CCH21yEzPmBIkDpVA 5ISgt7W44nPk/LwiRkcNZwONQDhIIooqihfU4f5QDUqyHgdiLH6+K2Y68S0PVvs0Eo/l 4n328C7MH2vs6rEPXHA5/HWvf8F3HObfJsFoE8MhBEDHpeMzPXOHZwfd41gnj58po1jy Rt21GOTN898mLIlp62wxIN3kjyji+kD1067aHNKmHlT8uGXut+0ycCToNYnF7HGDNoxD ua7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=yA1PUpNaaU438Qdsw8uGHv+PhN27r0uo54eSzuWIqzQ=; b=tWKT3HtAs6YqleT+Sk05Px/fF4YB9vmRBgEG1KyeZBqjZAV+Xs5sq6Ok3UGKtP4/9J RXZytme/SxutOA+Uxv5mW0yRUH/EHhPWJjYm9FoymO1oEFWmYz4u8T7XdtmLLrLKibaJ x1dWQnMdQGGjVXA4sLLtQinNeZRTBI6M6fVVAv1199jDSAYjPS+24lFzj0dlrYf3kHyg BmNeY8GxS23yF5bQPNFUhHLvd5Y4uwFPyOmzdThEqP2WmEYHCG9ERJ4VvsnoRiua6Vmx a8IMJSmj0nKtUrqlQP+RTlSddSgcKRaPx0pgYcRKtb9i9B2fxt25tAnhISV7IL8ghe6A Z4eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@blackwall-org.20210112.gappssmtp.com header.s=20210112 header.b=htpaPsBW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a056402060b00b00418cd7b1b00si1277192edv.572.2022.03.16.07.43.56; Wed, 16 Mar 2022 07:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@blackwall-org.20210112.gappssmtp.com header.s=20210112 header.b=htpaPsBW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238605AbiCNKjB (ORCPT + 99 others); Mon, 14 Mar 2022 06:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238601AbiCNKi7 (ORCPT ); Mon, 14 Mar 2022 06:38:59 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4322355AA for ; Mon, 14 Mar 2022 03:37:48 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id bi12so32864345ejb.3 for ; Mon, 14 Mar 2022 03:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=yA1PUpNaaU438Qdsw8uGHv+PhN27r0uo54eSzuWIqzQ=; b=htpaPsBWIhk9Lp3ysfhCNyhgm+tyrndaW4X+SPkjo07T6W2Xrp8HehI6a8dtpSNUrl xwjvNYJrhSYDpNw5E/EqLdB7nbtv7xyOS+2+ZExE0IQB+nNXd7QuqybibxP6RUb78Euf rO3qoG1KDMDprLNSe+8Bb9BbJYeIm+Ga1tRu1vGDSQPa1dZgBjTHqHsieI9rjJ7oOBdX yhk+uT7rgL2D8eClU+ekY429xN8a98zTxk3awCbkkmAGlMUPtfZkAJV+LEluk2LOW3wZ Ubg0mulQc8bUW6jYNO8yJar9xygAdjOJe5JJAL8iUd8dGpTbwAcBVtBWISO/ReuL7WCN WUSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=yA1PUpNaaU438Qdsw8uGHv+PhN27r0uo54eSzuWIqzQ=; b=YE26jBCEmSczT5o49rF+XXMv2sjCH/M951RjqT0jUDc7H3LivRt3qcL3NbQb1ctqfY ndWg/87lINP1TBw3RTaakNGhUjvEuCcu5Gv76mLbGQD8CyCVw8Loil3GQIb9goN3DrHD R7b9lCqf/koDq+WoewQRg+kxGPucIpDJUFlKMYmXioWsii9kAqzY0wBq2ibJ0WTYNEwG RRWu7U7DLSvIsvfSTgjIuG+xy3ZAzBqNdk0xMMjtxKZDAJnNwp3kQZvILPCAd6FdIaeU OU09r00uz5xfVttGGaXI/IeT6+Pgj9jDbU2jmUayOu6gwJDTMtardRjPy6rmn9N2nMJT C3Rg== X-Gm-Message-State: AOAM531vEhupShlDgm/H9uu0whHNssPdASU4TOFLDeOPv48QKfDpkjlA s1NYstdu6IWYJ4NmcTb1qj/N6A== X-Received: by 2002:a17:906:4ccd:b0:6b7:75ca:3eac with SMTP id q13-20020a1709064ccd00b006b775ca3eacmr17722806ejt.167.1647254266396; Mon, 14 Mar 2022 03:37:46 -0700 (PDT) Received: from [192.168.0.111] (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id s21-20020a170906961500b006daac87ddb0sm6636613ejx.140.2022.03.14.03.37.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Mar 2022 03:37:46 -0700 (PDT) Message-ID: <9c103a85-f0e2-77cd-9fc6-dc19d99b19ec@blackwall.org> Date: Mon, 14 Mar 2022 12:37:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 net-next 01/14] net: bridge: mst: Multiple Spanning Tree (MST) mode Content-Language: en-US To: Tobias Waldekranz , davem@davemloft.net, kuba@kernel.org Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Russell King , Ido Schimmel , Petr Machata , Cooper Lees , Matt Johnston , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bridge@lists.linux-foundation.org References: <20220314095231.3486931-1-tobias@waldekranz.com> <20220314095231.3486931-2-tobias@waldekranz.com> From: Nikolay Aleksandrov In-Reply-To: <20220314095231.3486931-2-tobias@waldekranz.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, TRACKER_ID,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/03/2022 11:52, Tobias Waldekranz wrote: > Allow the user to switch from the current per-VLAN STP mode to an MST > mode. > > Up to this point, per-VLAN STP states where always isolated from each > other. This is in contrast to the MSTP standard (802.1Q-2018, Clause > 13.5), where VLANs are grouped into MST instances (MSTIs), and the > state is managed on a per-MSTI level, rather that at the per-VLAN > level. > > Perhaps due to the prevalence of the standard, many switching ASICs > are built after the same model. Therefore, add a corresponding MST > mode to the bridge, which we can later add offloading support for in a > straight-forward way. > > For now, all VLANs are fixed to MSTI 0, also called the Common > Spanning Tree (CST). That is, all VLANs will follow the port-global > state. > > Upcoming changes will make this actually useful by allowing VLANs to > be mapped to arbitrary MSTIs and allow individual MSTI states to be > changed. > > Signed-off-by: Tobias Waldekranz > --- [snip] > diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h > index 48bc61ebc211..35b47f6b449a 100644 > --- a/net/bridge/br_private.h > +++ b/net/bridge/br_private.h > @@ -178,6 +178,7 @@ enum { > * @br_mcast_ctx: if MASTER flag set, this is the global vlan multicast context > * @port_mcast_ctx: if MASTER flag unset, this is the per-port/vlan multicast > * context > + * @msti: if MASTER flag set, this holds the VLANs MST instance > * @vlist: sorted list of VLAN entries > * @rcu: used for entry destruction > * > @@ -210,6 +211,8 @@ struct net_bridge_vlan { > struct net_bridge_mcast_port port_mcast_ctx; > }; > > + u16 msti; > + > struct list_head vlist; > > struct rcu_head rcu; > @@ -445,6 +448,7 @@ enum net_bridge_opts { > BROPT_NO_LL_LEARN, > BROPT_VLAN_BRIDGE_BINDING, > BROPT_MCAST_VLAN_SNOOPING_ENABLED, > + BROPT_MST_ENABLED, > }; > > struct net_bridge { > @@ -1765,6 +1769,29 @@ static inline bool br_vlan_state_allowed(u8 state, bool learn_allow) > } > #endif > > +/* br_mst.c */ > +#ifdef CONFIG_BRIDGE_VLAN_FILTERING There is already such ifdef, you can embed all MST code inside it. > +DECLARE_STATIC_KEY_FALSE(br_mst_used); > +static inline bool br_mst_is_enabled(struct net_bridge *br) > +{ > + return static_branch_unlikely(&br_mst_used) && > + br_opt_get(br, BROPT_MST_ENABLED); > +} > + > +void br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state); > +void br_mst_vlan_init_state(struct net_bridge_vlan *v); > +int br_mst_set_enabled(struct net_bridge *br, bool on, > + struct netlink_ext_ack *extack); > +#else > +static inline bool br_mst_is_enabled(struct net_bridge *br) > +{ > + return false; > +} > + > +static inline void br_mst_set_state(struct net_bridge_port *p, > + u16 msti, u8 state) {} > +#endif > + > struct nf_br_ops { > int (*br_dev_xmit_hook)(struct sk_buff *skb); > }; > diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c > index 1d80f34a139c..82a97a021a57 100644 > --- a/net/bridge/br_stp.c > +++ b/net/bridge/br_stp.c > @@ -43,6 +43,9 @@ void br_set_state(struct net_bridge_port *p, unsigned int state) > return; > > p->state = state; > + if (br_opt_get(p->br, BROPT_MST_ENABLED)) > + br_mst_set_state(p, 0, state); > + > err = switchdev_port_attr_set(p->dev, &attr, NULL); > if (err && err != -EOPNOTSUPP) > br_warn(p->br, "error setting offload STP state on port %u(%s)\n", > diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c > index 7557e90b60e1..0f5e75ccac79 100644 > --- a/net/bridge/br_vlan.c > +++ b/net/bridge/br_vlan.c > @@ -226,6 +226,24 @@ static void nbp_vlan_rcu_free(struct rcu_head *rcu) > kfree(v); > } > > +static void br_vlan_init_state(struct net_bridge_vlan *v) > +{ > + struct net_bridge *br; > + > + if (br_vlan_is_master(v)) > + br = v->br; > + else > + br = v->port->br; > + > + if (br_opt_get(br, BROPT_MST_ENABLED)) { > + br_mst_vlan_init_state(v); > + return; > + } > + > + v->state = BR_STATE_FORWARDING; > + v->msti = 0; > +} > + > /* This is the shared VLAN add function which works for both ports and bridge > * devices. There are four possible calls to this function in terms of the > * vlan entry type: > @@ -322,7 +340,7 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags, > } > > /* set the state before publishing */ > - v->state = BR_STATE_FORWARDING; > + br_vlan_init_state(v); > > err = rhashtable_lookup_insert_fast(&vg->vlan_hash, &v->vnode, > br_vlan_rht_params); > diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c > index a6382973b3e7..09112b56e79c 100644 > --- a/net/bridge/br_vlan_options.c > +++ b/net/bridge/br_vlan_options.c > @@ -99,6 +99,11 @@ static int br_vlan_modify_state(struct net_bridge_vlan_group *vg, > return -EBUSY; > } > > + if (br_opt_get(br, BROPT_MST_ENABLED)) { > + NL_SET_ERR_MSG_MOD(extack, "Can't modify vlan state directly when MST is enabled"); > + return -EBUSY; > + } > + > if (v->state == state) > return 0; >