Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp953347pxp; Wed, 16 Mar 2022 22:29:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYBIfWCQqxjY+emoSB7QJohamY6i8Tjx9nQvMDNiVax/gn/5is+vV5EkLu9rpjeag5I6QJ X-Received: by 2002:a63:490d:0:b0:37f:2705:9d07 with SMTP id w13-20020a63490d000000b0037f27059d07mr2392332pga.306.1647494957145; Wed, 16 Mar 2022 22:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494957; cv=none; d=google.com; s=arc-20160816; b=qAJjO/0U3p7nMVp1MKRFzFdttMllD6kdIOHidpaV5L2mKLQoMSXYaNYaX7k/yFCT4D LTkgi4CES3bUM4tmFhP9d/9jWIzhSewlqs9+qjFPLZ9kJfpAxLuDMDgn3BTKvhtKPjQL plKr1Pcec42hwDd7afrGjvvxdECJhPBJvU5Q2u8/T+9EchbhiGQlU82ew/8wBq9klGPq mjUSFY2nx3vNED/ZSGKst9CkExxXg6ZKZhPB0hDp8ImKZKRp2cbEJUvrc1ewX0imaIKL YdPzWcEWOGUwYqDFdhg5byuLb3TFCeT+RfwTxuh91L2bC9/piiyAFAnD6w2bEFrsBQsv p2Yw== 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=nzL1DPOauY6xrdeyfpwRODojKdw/bFm68FMajovYo6g=; b=0MvHHhDgF8Rt/+Yvjqpsg+hzDa/JZTvzH4eBHL8OgZbQErTHnH8IxSm1W2jg5wA1Yj ACYrZ1ty0z3SBH6Eapwz3xMDIqKGllNKVxiPggpTu4ukXQ5Ck6oc5tesPi1CZ7SUE3ME 5toIBZleUV7l/tOfW37c6TNgVlYuQ/wIJe1Q9sxDLpYcDaQVdKFsTg9GGui2wHt8ZF0u TemethQ3BxSzTkC8D0btjeEmDNSIJ7QGItWOki17tglTd4aYb6NiLTBjM1Qs0RR7XOOg myFJ4ibN51Au5BxUANUlSMdP/OKCrnu1s2nwSgqi3z9c5xOu79sSaanX+ubHYuRT0Wpc C2sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@blackwall-org.20210112.gappssmtp.com header.s=20210112 header.b=aPQtqBpj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h14-20020a170902f54e00b0015195e2aa37si4057381plf.55.2022.03.16.22.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:29:17 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@blackwall-org.20210112.gappssmtp.com header.s=20210112 header.b=aPQtqBpj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0BE7B22FDA3; Wed, 16 Mar 2022 21:30:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346855AbiCOJyP (ORCPT + 99 others); Tue, 15 Mar 2022 05:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346854AbiCOJyM (ORCPT ); Tue, 15 Mar 2022 05:54:12 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 999E4CDE for ; Tue, 15 Mar 2022 02:52:57 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id qa43so39710868ejc.12 for ; Tue, 15 Mar 2022 02:52:57 -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=nzL1DPOauY6xrdeyfpwRODojKdw/bFm68FMajovYo6g=; b=aPQtqBpjqL26lRUuA67dWSdBYZ+P/OnQD5b5DPaPCNVFC8mllI1F5Z4DrykGC7Nm52 NYVARAcB6EKihQiU3nR7auLh2RMcX5iG4aZzNurSihePLSCDNafmV6aDnPt7iohqmzPT i+1RJQbOuQTUsiLaWuynMdfIp2D0pEXMbRgq3gppylA50fxe/er+TcNS8B7LqPy9DwNd xK4POQpl6tAPqXHcYYhL9RoWDsmggj0qIBO3em3KQdtOCCzH995aYYhNiMf7y+PmHirW gmes5oNZhwRimfcWiHSC/2oYzvBdzMMM04H84ESMBLL84WRaxdlbwsUak7eTTugCNdve PEXA== 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=nzL1DPOauY6xrdeyfpwRODojKdw/bFm68FMajovYo6g=; b=iB0LWXT7QoPghJLzoyNiL/nb9UxPpdAcxunzKTzlJFZEtU62e6CHDPl9Qw3KElAlHI zGZBTgY2X//yaZWbjfVebio3VnZ/XALzvPdt8V62nyCTu7mDAF3tBfemt/bOZDexYfnb UDGFAi2os+Edm8hYCyGaVSRfftoe41QvYUeaaGqumAsZwX45AUxOwFtFeD1GgAp+KbeV 1u62C9W4p9J99JFXZ0ejxWMmwGvsPNQ+XfFuoTRwiFOAUMcRlYLzRZU9C7z/tqasBYcp 6j36fY7G6uqZdv9qsd+tRPe4TGilf5wkcgS5LiNzUn65qyigNQJWwNs4ajL2gflKX8gY Ys3Q== X-Gm-Message-State: AOAM533FQhdRHnXSFT3TUxGRaKpaxy/JqUtZKeAAWADe/uRLtQuiNlz1 PkWiQF5nj6vANeqfVCj4coTPTQ== X-Received: by 2002:a17:906:d555:b0:6da:ac8c:f66b with SMTP id cr21-20020a170906d55500b006daac8cf66bmr21422702ejc.107.1647337975509; Tue, 15 Mar 2022 02:52:55 -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 a102-20020a509eef000000b0041614c8f79asm9346624edf.88.2022.03.15.02.52.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Mar 2022 02:52:55 -0700 (PDT) Message-ID: <5c05d8b8-9c40-e38d-5c4d-e25526407e51@blackwall.org> Date: Tue, 15 Mar 2022 11:52:53 +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 v4 net-next 03/15] net: bridge: mst: Support setting and reporting MST port states 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 , Petr Machata , Ido Schimmel , Matt Johnston , Cooper Lees , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bridge@lists.linux-foundation.org References: <20220315002543.190587-1-tobias@waldekranz.com> <20220315002543.190587-4-tobias@waldekranz.com> From: Nikolay Aleksandrov In-Reply-To: <20220315002543.190587-4-tobias@waldekranz.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 15/03/2022 02:25, Tobias Waldekranz wrote: > Make it possible to change the port state in a given MSTI by extending > the bridge port netlink interface (RTM_SETLINK on PF_BRIDGE).The > proposed iproute2 interface would be: > > bridge mst set dev msti state > > Current states in all applicable MSTIs can also be dumped via a > corresponding RTM_GETLINK. The proposed iproute interface looks like > this: > > $ bridge mst > port msti > vb1 0 > state forwarding > 100 > state disabled > vb2 0 > state forwarding > 100 > state forwarding > > The preexisting per-VLAN states are still valid in the MST > mode (although they are read-only), and can be queried as usual if one > is interested in knowing a particular VLAN's state without having to > care about the VID to MSTI mapping (in this example VLAN 20 and 30 are > bound to MSTI 100): > > $ bridge -d vlan > port vlan-id > vb1 10 > state forwarding mcast_router 1 > 20 > state disabled mcast_router 1 > 30 > state disabled mcast_router 1 > 40 > state forwarding mcast_router 1 > vb2 10 > state forwarding mcast_router 1 > 20 > state forwarding mcast_router 1 > 30 > state forwarding mcast_router 1 > 40 > state forwarding mcast_router 1 > > Signed-off-by: Tobias Waldekranz > --- > include/uapi/linux/if_bridge.h | 16 +++++ > include/uapi/linux/rtnetlink.h | 1 + > net/bridge/br_mst.c | 127 +++++++++++++++++++++++++++++++++ > net/bridge/br_netlink.c | 44 +++++++++++- > net/bridge/br_private.h | 23 ++++++ > 5 files changed, 210 insertions(+), 1 deletion(-) > [snip] > diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c > index 78ef5fea4d2b..355ad102d6b1 100644 > --- a/net/bridge/br_mst.c > +++ b/net/bridge/br_mst.c > @@ -124,3 +124,130 @@ int br_mst_set_enabled(struct net_bridge *br, bool on, > br_opt_toggle(br, BROPT_MST_ENABLED, on); > return 0; > } > + > +size_t br_mst_info_size(const struct net_bridge_vlan_group *vg) > +{ > + DECLARE_BITMAP(seen, VLAN_N_VID) = { 0 }; > + const struct net_bridge_vlan *v; > + size_t sz; > + > + /* IFLA_BRIDGE_MST */ > + sz = nla_total_size(0); > + > + list_for_each_entry(v, &vg->vlan_list, vlist) { Note that rtnl_calcit() (which ends up indirectly using this function) is called only with rcu so you need to use list_for_each_entry_rcu() here. > + if (test_bit(v->brvlan->msti, seen)) > + continue; > + > + /* IFLA_BRIDGE_MST_ENTRY */ > + sz += nla_total_size(0) + > + /* IFLA_BRIDGE_MST_ENTRY_MSTI */ > + nla_total_size(sizeof(u16)) + > + /* IFLA_BRIDGE_MST_ENTRY_STATE */ > + nla_total_size(sizeof(u8)); > + > + __set_bit(v->brvlan->msti, seen); > + } > + > + return sz; > +} > +