From patchwork Mon Aug 16 14:57:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12438749 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 4AC83C4338F for ; Mon, 16 Aug 2021 14:57:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A78D60EBD for ; Mon, 16 Aug 2021 14:57:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232677AbhHPO6I (ORCPT ); Mon, 16 Aug 2021 10:58:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbhHPO5v (ORCPT ); Mon, 16 Aug 2021 10:57:51 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C36CC0613C1 for ; Mon, 16 Aug 2021 07:57:19 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id bq25so22257496ejb.11 for ; Mon, 16 Aug 2021 07:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WwnW+GWJajN/nHK/Uu8SXGjaStKjr4BPobqUYTEyxn4=; b=hHDIhLqQj6tIa4w4qVJf800brqAuVR7rfr+AG9ipbfVi11s4nScM+Xibp+zDBVAzii hkuPeCjHsZ76AvynBapL8kF5odlTh+GOYV3RmrFzMiVTp6OGizUh7XLkDgJg/0+30Waw shC1D7SpfqudW6TBOtRVs8KoP1WtmJUbp8UCIgYkiWKAFxkd/8KzKcfIA1kdVCmbaxVs od1nxE3C5Ntg/CsaSs82plPxuYsT5V8PiAYsREpXB1FsLaqU6BX9nH4MGvalMe26FGCe wgHOj8zgTjecbISRYIBn+sMHQ7/pDvJ3yC4gDGkylHK1BduQ1Xal4OIF2lJrml648DzN JH2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WwnW+GWJajN/nHK/Uu8SXGjaStKjr4BPobqUYTEyxn4=; b=flhTQ1i/A33pL7fjZbn0s8EdmpjyHuAMaz9rnRX9wrJPD2UsgC6MOaHKbTkMPqYztH EX+ZTuq2wIMIFI+7FrXWD8a9sTdD9CsUOi3/DQaVc72UDigiw7fmHvFMOT5QQJuEqvqA vl84/MLCfIBH0nZQ+H+WsZWFJZMwL2YQ5wlHdadh32t5h7kJabYxEe6w8FH77StS9Fx4 V60ZEslFYhmbpTl/rKRJN8UcUs/1eNMybOwnuzUx9tLJIpN5hrGwet8k4hDQjvt0bYYe zDwfVCvJE1DIdpXDSO8zvg3IbiY2jtP0rIOJ/gfrNHIwtO0IBIyez2tGtLS2gu3vnnkW AohQ== X-Gm-Message-State: AOAM532D4TDe41Bc0Yygka9WtO8oZu1QCVkBoTN7UV4T869k96UJxB0f M0aV/wzOL9ql0CADEQTOSMxY9/wpuWxDyTwE X-Google-Smtp-Source: ABdhPJxqMtz9zZxKS+mZkhGaAszppeNwrGy17MtcxbPLFXs4I2+RGIMmU2ef/7QEnl9dmxvJ4xrbzw== X-Received: by 2002:a17:906:4b42:: with SMTP id j2mr6762196ejv.437.1629125837966; Mon, 16 Aug 2021 07:57:17 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id t25sm4946076edi.65.2021.08.16.07.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 07:57:17 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 1/4] net: bridge: vlan: enable mcast snooping for existing master vlans Date: Mon, 16 Aug 2021 17:57:04 +0300 Message-Id: <20210816145707.671901-2-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210816145707.671901-1-razor@blackwall.org> References: <20210816145707.671901-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Nikolay Aleksandrov We always create a vlan with enabled mcast snooping, so when the user turns on per-vlan mcast contexts they'll get consistent behaviour with the current situation, but one place wasn't updated when a bridge/master vlan which already exists (created due to port vlans) is being added as real bridge vlan (BRIDGE_VLAN_INFO_BRENTRY). We need to enable mcast snooping for that vlan when that happens. Fixes: 7b54aaaf53cb ("net: bridge: multicast: add vlan state initialization and control") Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_vlan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index cbc922681a76..e25e288e7a85 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -694,6 +694,7 @@ static int br_vlan_add_existing(struct net_bridge *br, vlan->flags |= BRIDGE_VLAN_INFO_BRENTRY; vg->num_vlans++; *changed = true; + br_multicast_toggle_one_vlan(vlan, true); } if (__vlan_add_flags(vlan, flags)) From patchwork Mon Aug 16 14:57:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12438751 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 378B4C432BE for ; Mon, 16 Aug 2021 14:57:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1603660EBD for ; Mon, 16 Aug 2021 14:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232426AbhHPO6O (ORCPT ); Mon, 16 Aug 2021 10:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbhHPO5w (ORCPT ); Mon, 16 Aug 2021 10:57:52 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86239C0613CF for ; Mon, 16 Aug 2021 07:57:20 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id v2so16492100edq.10 for ; Mon, 16 Aug 2021 07:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gu3qPVqazrfPsLrdaA6zNjrUNMRsdA16rRPDc2bNkUw=; b=FuV+Ic3USr2PZi1PnKLkMugVAAt5b6+5NCSahnq3tBRmBe/bcNvT2wFZVSDo+FzS8D cM5uGmbJq7o1jfdbiMacajfbGNb1f5R+Smvdjtzrv5N0gitZG+KFycHfxnQWU3eQrLRB 6dd6lfis26okjtBo811z5I8wcdLqoIVkrBaMuwHmp8CTl0GsaIy5JWFL8X5SxWM36hqG o2w6cQecfztfIUAS9pd0m0xmUPAzuu2HMUj1Uq1StplPP9WUozgBq7wwXYmgcA2PMVUc tcnvz1IL9FhSnI2v0GR3HBY3541g2J988f3/Cjq2nyQ8wXz4b1/FSZhSZGinCEHG+XQj Lyww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gu3qPVqazrfPsLrdaA6zNjrUNMRsdA16rRPDc2bNkUw=; b=cgBstoI0sH9FHGjI5m6KKXgFVWpD6Jz+WX7XZ3QRQ4815bDO9TcRCCgDIUTrgtL68D 2klX0GObzvMqQaEkljKqJ9J8LKbc5Uc7WAa53Z+penVf0Kc6rB7tytJyWLe25Fu+PLgE fv1OK6vZWlm02j6/zThMstYrtEenRj5BaZqamBHwX8CqJy2gtrXBKVpoN2xqi2k25/+1 2jYVk78wzSKzCe6Jf2l8u+M69qTeCawiUnBYTJqncajKJwpE+rKs7+aPUSP/uI3dUtOm Hg6v+1303FawC0uBz5siInOzO5SYXsf2HuPrBO44qszYAvIkqTtVASXRP5cJMwCRltDv vR5w== X-Gm-Message-State: AOAM5300i6ldGnzITBv7R7k1Ddzz5Bo/WA5gZsd3coGqH60phx/mvuru 8s+j/HeNc+jp9m8l85EhiECgPVbPp7zgkgw0 X-Google-Smtp-Source: ABdhPJyfgtxQkZ0H+1ivIO/PeQ3LyKrGyE4V8lSLn5Iir/ILYPFes8w0JiOPJ/cwAAoZX6yFwfbx8w== X-Received: by 2002:a05:6402:14d1:: with SMTP id f17mr20183567edx.167.1629125838855; Mon, 16 Aug 2021 07:57:18 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id t25sm4946076edi.65.2021.08.16.07.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 07:57:18 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 2/4] net: bridge: vlan: account for router port lists when notifying Date: Mon, 16 Aug 2021 17:57:05 +0300 Message-Id: <20210816145707.671901-3-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210816145707.671901-1-razor@blackwall.org> References: <20210816145707.671901-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Nikolay Aleksandrov When sending a global vlan notification we should account for the number of router ports when allocating the skb, otherwise we might end up losing notifications. Fixes: dc002875c22b ("net: bridge: vlan: use br_rports_fill_info() to export mcast router ports") Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 30 ++++++++++++++++++++++++++++++ net/bridge/br_private.h | 1 + net/bridge/br_vlan_options.c | 17 +++++++++-------- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 389ff3c1e9d9..0281453f7766 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -37,6 +37,36 @@ br_ip6_rports_get_timer(struct net_bridge_mcast_port *pmctx, #endif } +static size_t __br_rports_one_size(void) +{ + return nla_total_size(sizeof(u32)) + /* MDBA_ROUTER_PORT */ + nla_total_size(sizeof(u32)) + /* MDBA_ROUTER_PATTR_TIMER */ + nla_total_size(sizeof(u8)) + /* MDBA_ROUTER_PATTR_TYPE */ + nla_total_size(sizeof(u32)) + /* MDBA_ROUTER_PATTR_INET_TIMER */ + nla_total_size(sizeof(u32)) + /* MDBA_ROUTER_PATTR_INET6_TIMER */ + nla_total_size(sizeof(u32)); /* MDBA_ROUTER_PATTR_VID */ +} + +size_t br_rports_size(const struct net_bridge_mcast *brmctx) +{ + struct net_bridge_mcast_port *pmctx; + size_t size = nla_total_size(0); /* MDBA_ROUTER */ + + rcu_read_lock(); + hlist_for_each_entry_rcu(pmctx, &brmctx->ip4_mc_router_list, + ip4_rlist) + size += __br_rports_one_size(); + +#if IS_ENABLED(CONFIG_IPV6) + hlist_for_each_entry_rcu(pmctx, &brmctx->ip6_mc_router_list, + ip6_rlist) + size += __br_rports_one_size(); +#endif + rcu_read_unlock(); + + return size; +} + int br_rports_fill_info(struct sk_buff *skb, const struct net_bridge_mcast *brmctx) { diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 9b1bf98a2c5a..df0fa246c80c 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -952,6 +952,7 @@ int br_multicast_dump_querier_state(struct sk_buff *skb, const struct net_bridge_mcast *brmctx, int nest_attr); size_t br_multicast_querier_state_size(void); +size_t br_rports_size(const struct net_bridge_mcast *brmctx); static inline bool br_group_is_l2(const struct br_ip *group) { diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c index 49dec53a4a74..a3b8a086284b 100644 --- a/net/bridge/br_vlan_options.c +++ b/net/bridge/br_vlan_options.c @@ -362,7 +362,7 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range, return false; } -static size_t rtnl_vlan_global_opts_nlmsg_size(void) +static size_t rtnl_vlan_global_opts_nlmsg_size(const struct net_bridge_vlan *v) { return NLMSG_ALIGN(sizeof(struct br_vlan_msg)) + nla_total_size(0) /* BRIDGE_VLANDB_GLOBAL_OPTIONS */ @@ -382,6 +382,8 @@ static size_t rtnl_vlan_global_opts_nlmsg_size(void) + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_QUERIER */ + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER */ + br_multicast_querier_state_size() /* BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE */ + + nla_total_size(0) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */ + + br_rports_size(&v->br_mcast_ctx) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */ #endif + nla_total_size(sizeof(u16)); /* BRIDGE_VLANDB_GOPTS_RANGE */ } @@ -398,7 +400,12 @@ static void br_vlan_global_opts_notify(const struct net_bridge *br, /* right now notifications are done only with rtnl held */ ASSERT_RTNL(); - skb = nlmsg_new(rtnl_vlan_global_opts_nlmsg_size(), GFP_KERNEL); + /* need to find the vlan due to flags/options */ + v = br_vlan_find(br_vlan_group(br), vid); + if (!v) + return; + + skb = nlmsg_new(rtnl_vlan_global_opts_nlmsg_size(v), GFP_KERNEL); if (!skb) goto out_err; @@ -411,11 +418,6 @@ static void br_vlan_global_opts_notify(const struct net_bridge *br, bvm->family = AF_BRIDGE; bvm->ifindex = br->dev->ifindex; - /* need to find the vlan due to flags/options */ - v = br_vlan_find(br_vlan_group(br), vid); - if (!v) - goto out_kfree; - if (!br_vlan_global_opts_fill(skb, vid, vid_range, v)) goto out_err; @@ -425,7 +427,6 @@ static void br_vlan_global_opts_notify(const struct net_bridge *br, out_err: rtnl_set_sk_err(dev_net(br->dev), RTNLGRP_BRVLAN, err); -out_kfree: kfree_skb(skb); } From patchwork Mon Aug 16 14:57:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12438753 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 D1805C4338F for ; Mon, 16 Aug 2021 14:57:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B638860C3F for ; Mon, 16 Aug 2021 14:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbhHPO6Q (ORCPT ); Mon, 16 Aug 2021 10:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbhHPO5x (ORCPT ); Mon, 16 Aug 2021 10:57:53 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8265C061796 for ; Mon, 16 Aug 2021 07:57:21 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id bo19so26843206edb.9 for ; Mon, 16 Aug 2021 07:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S6bka7n7gUza4xP2Wps1Ishfu8bAYgf2m92TklQ/eyQ=; b=Dp0UXPFRjuNbluIqPUYBwYXP+Hmd9CJzy6JUb+ZgHUOu+EUptSSow2GN94ev2kNQmN J+c6exU8gLXZ62x42x7FNkBZdL3VNxq2S0nB/RlrvpcnNgHxd2mgkA2qC6JBBzn3Gfgv vVjcu4l3Z8lsC8Fj1Rh5h0huBYC2YNVE2fi6Ptwf3LqCV9pQaQQ19CPSVU3lMjAQBs+e rSh/NN1M7Kgm/J3P0HfmJmSzZu7AzY/Mz0FcMeGNq68pqWoHHRzu8a73004lty22HLQD Bj//aRqcMrwKhmj3/RXzrrd3SnbZOCPI9SH7Za1iROfCqCV4Wn/YRczGAKnBIt6g6Azs rJDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S6bka7n7gUza4xP2Wps1Ishfu8bAYgf2m92TklQ/eyQ=; b=NI4EWA2tb2zPfU19ltGP7y7U0LO8gYQoDXYMVCMRithGSJTMkBE2KPwhwbe5+DrYr3 FsQe8AIitO7LjA6CrmA8Jpbhda3WQRh8wJr91z+adEwZwlapP8+i+9NsP+Pk9YmxynYe JktmGCBlkdOHZMkB63y7hRhPDZ5G8NImoZIABlDKz6dnWYkgwtRz0vpTrohmQYQs2HK8 2V3S6fPernTp4LiNUBJgUatY3DVk6MlHq2eW1vg289xwjuTRFV05SMWMfKDkiMuDHCBe 7zAmimY+XPq3TqR6b2JH4+5AbJkixbIzTv9iGwhjrDjpFlay88cD+VSHfKGRMJuq0srJ 6RXQ== X-Gm-Message-State: AOAM532AcRP/xzx+ssdD08NlTrmn20SrmG4lFhXPYrGMXPUa03GiTopu F88IZsE/F/hL/vqNILwPxuLXtS7kCgHKVrZd X-Google-Smtp-Source: ABdhPJwMaMudg3C2wRC6jctJ9HDF1tZY7UC7wq8/5vRVBaVJAVoIAkZsMScqqTZI34HUF7m299ClBw== X-Received: by 2002:a05:6402:13c5:: with SMTP id a5mr20272952edx.132.1629125839806; Mon, 16 Aug 2021 07:57:19 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id t25sm4946076edi.65.2021.08.16.07.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 07:57:19 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 3/4] net: bridge: mcast: use the correct vlan group helper Date: Mon, 16 Aug 2021 17:57:06 +0300 Message-Id: <20210816145707.671901-4-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210816145707.671901-1-razor@blackwall.org> References: <20210816145707.671901-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Nikolay Aleksandrov When dereferencing the port vlan group we should use the rcu helper instead of the one relying on rtnl. In br_multicast_pg_to_port_ctx the entry cannot disappear as we hold the multicast lock and rcu as explained in the comment above it. For the same reason we're ok in br_multicast_start_querier. ============================= WARNING: suspicious RCU usage 5.14.0-rc5+ #429 Tainted: G W ----------------------------- net/bridge/br_private.h:1478 suspicious rcu_dereference_protected() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 3 locks held by swapper/2/0: #0: ffff88822be85eb0 ((&p->timer)){+.-.}-{0:0}, at: call_timer_fn+0x5/0x2da #1: ffff88810b32f260 (&br->multicast_lock){+.-.}-{3:3}, at: br_multicast_port_group_expired+0x28/0x13d [bridge] #2: ffffffff824f6c80 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire.constprop.0+0x0/0x22 [bridge] stack backtrace: CPU: 2 PID: 0 Comm: swapper/2 Kdump: loaded Tainted: G W 5.14.0-rc5+ #429 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-4.fc34 04/01/2014 Call Trace: dump_stack_lvl+0x45/0x59 nbp_vlan_group+0x3e/0x44 [bridge] br_multicast_pg_to_port_ctx+0xd6/0x10d [bridge] br_multicast_star_g_handle_mode+0xa1/0x2ce [bridge] ? netlink_broadcast+0xf/0x11 ? nlmsg_notify+0x56/0x99 ? br_mdb_notify+0x224/0x2e9 [bridge] ? br_multicast_del_pg+0x1dc/0x26d [bridge] br_multicast_del_pg+0x1dc/0x26d [bridge] br_multicast_port_group_expired+0xaa/0x13d [bridge] ? __grp_src_delete_marked.isra.0+0x35/0x35 [bridge] ? __grp_src_delete_marked.isra.0+0x35/0x35 [bridge] call_timer_fn+0x134/0x2da __run_timers+0x169/0x193 run_timer_softirq+0x19/0x2d __do_softirq+0x1bc/0x42a __irq_exit_rcu+0x5c/0xb3 irq_exit_rcu+0xa/0x12 sysvec_apic_timer_interrupt+0x5e/0x75 asm_sysvec_apic_timer_interrupt+0x12/0x20 RIP: 0010:default_idle+0xc/0xd Code: e8 14 40 71 ff e8 10 b3 ff ff 4c 89 e2 48 89 ef 31 f6 5d 41 5c e9 a9 e8 c2 ff cc cc cc cc 0f 1f 44 00 00 e8 7f 55 65 ff fb f4 0f 1f 44 00 00 55 65 48 8b 2c 25 40 6f 01 00 53 f0 80 4d 02 20 RSP: 0018:ffff88810033bf00 EFLAGS: 00000206 RAX: ffffffff819cf828 RBX: ffff888100328000 RCX: 0000000000000001 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff819cfa2d RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001 R10: ffff8881008302c0 R11: 00000000000006db R12: 0000000000000000 R13: 0000000000000002 R14: 0000000000000000 R15: 0000000000000000 ? __sched_text_end+0x4/0x4 ? default_idle_call+0x15/0x7b default_idle_call+0x4d/0x7b do_idle+0x124/0x2a2 cpu_startup_entry+0x1d/0x1f secondary_startup_64_no_verify+0xb0/0xbb Fixes: 74edfd483de8 ("net: bridge: multicast: add helper to get port mcast context from port group") Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_multicast.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index e411dd814c58..c9f7f56eaf9b 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -221,7 +221,7 @@ br_multicast_pg_to_port_ctx(const struct net_bridge_port_group *pg) * can safely be used on return */ rcu_read_lock(); - vlan = br_vlan_find(nbp_vlan_group(pg->key.port), pg->key.addr.vid); + vlan = br_vlan_find(nbp_vlan_group_rcu(pg->key.port), pg->key.addr.vid); if (vlan && !br_multicast_port_ctx_vlan_disabled(&vlan->port_mcast_ctx)) pmctx = &vlan->port_mcast_ctx; else @@ -4329,7 +4329,8 @@ static void br_multicast_start_querier(struct net_bridge_mcast *brmctx, if (br_multicast_ctx_is_vlan(brmctx)) { struct net_bridge_vlan *vlan; - vlan = br_vlan_find(nbp_vlan_group(port), brmctx->vlan->vid); + vlan = br_vlan_find(nbp_vlan_group_rcu(port), + brmctx->vlan->vid); if (!vlan || br_multicast_port_ctx_state_stopped(&vlan->port_mcast_ctx)) continue; From patchwork Mon Aug 16 14:57:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 12438755 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 DA1E1C4320E for ; Mon, 16 Aug 2021 14:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA8A460EBD for ; Mon, 16 Aug 2021 14:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbhHPO6R (ORCPT ); Mon, 16 Aug 2021 10:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbhHPO5y (ORCPT ); Mon, 16 Aug 2021 10:57:54 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F1DFC06179A for ; Mon, 16 Aug 2021 07:57:22 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id bq25so22257754ejb.11 for ; Mon, 16 Aug 2021 07:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cEF4JoMHZEME1+G2CZln0Yotihc+zLCjsCuSYLc+j3Q=; b=ZjYbNocK7nQUZmK7tS1SYFaF524im4zpkYuIBe6PLoxPdvEg0nn2rcea6i9NgA8bX4 5WxNZdktA5V1y3KOperLhnJRMWBEby8lRcK9l7YLqU355DpaS10sNON3jKYdlBXK8ytZ jcDmlbG/jOEGCna1DpdOLm16+JkjTsG1COKe/bBUmDBZ5Puj4LqLXK45s9LdVVItgSaS M8AU97MS3myCmrlBPZ+iXOeShvRSHzWI7WtrziFO2XoQv24HwBVQD9wl0A5CCtnsoMb2 u2DlHGrvkSDUt3nAQmJ4Oz37oB5aH27bTak8L5rH0jBRcM/dBPzjZ2AcfcmnC3KJ48Is 3kRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cEF4JoMHZEME1+G2CZln0Yotihc+zLCjsCuSYLc+j3Q=; b=VCydjqOo/LvjJ6myL5k/rbCQxyCHvEnxTp1aFlkQC3X5txq0vQlYnFBobp7vo6R1zP vM6oB5N7vqEhzARWml7Zm95KT4crnhS1JHiS0O4yA8trQtRlfcarFcyM4k6eiCS/vpFz bCzuuUZ6jw2xXnXPBKSy4xT0LrnlMZtcsv9Yb7GHLRMtrEYcNcHQQDcXzMPRPnTCiPOp 4OGcMiaZgtHmLgF2fbrMmpIhknxdffI7yhDWxQ3JRnmNZ1GfmoboBKztOx7gtTPEJOFr mX9Otywv4fL8tc90uJgNN0+rkoBfN4F2gGcAbvWWpCRuhzFkuG2y5NI0ex2SGCs1z94d 13Fw== X-Gm-Message-State: AOAM530jIzFiS5y6gyT8N39OZbD45eGuebhadu4CmkJHtdCKmcf/kcmg uEse4x+E88MaFQj6/7nwGQ+gE0f/5+Khg06w X-Google-Smtp-Source: ABdhPJw5OWKOOio/+Fe5CZbS7wFaCnTjZadQPBOSc04Ep5jRgCDHhWafz0loLdIDYEaFv5/2YsTkTw== X-Received: by 2002:a17:906:2bd0:: with SMTP id n16mr16446539ejg.132.1629125840736; Mon, 16 Aug 2021 07:57:20 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id t25sm4946076edi.65.2021.08.16.07.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 07:57:20 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 4/4] net: bridge: mcast: toggle also host vlan state in br_multicast_toggle_vlan Date: Mon, 16 Aug 2021 17:57:07 +0300 Message-Id: <20210816145707.671901-5-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210816145707.671901-1-razor@blackwall.org> References: <20210816145707.671901-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Nikolay Aleksandrov When changing vlan mcast state by br_multicast_toggle_vlan it iterates over all ports and enables/disables the port mcast ctx based on the new state, but I forgot to update the host vlan (bridge master vlan entry) with the new state so it will be left out. Also that function is not used outside of br_multicast.c, so make it static. Fixes: f4b7002a7076 ("net: bridge: add vlan mcast snooping knob") Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_multicast.c | 5 ++++- net/bridge/br_private.h | 6 ------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index c9f7f56eaf9b..16e686f5b9e9 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -4074,7 +4074,7 @@ void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on) } } -void br_multicast_toggle_vlan(struct net_bridge_vlan *vlan, bool on) +static void br_multicast_toggle_vlan(struct net_bridge_vlan *vlan, bool on) { struct net_bridge_port *p; @@ -4089,6 +4089,9 @@ void br_multicast_toggle_vlan(struct net_bridge_vlan *vlan, bool on) continue; br_multicast_toggle_one_vlan(vport, on); } + + if (br_vlan_is_brentry(vlan)) + br_multicast_toggle_one_vlan(vlan, on); } int br_multicast_toggle_vlan_snooping(struct net_bridge *br, bool on, diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index df0fa246c80c..21b292eb2b3e 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -938,7 +938,6 @@ void br_multicast_port_ctx_init(struct net_bridge_port *port, struct net_bridge_mcast_port *pmctx); void br_multicast_port_ctx_deinit(struct net_bridge_mcast_port *pmctx); void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on); -void br_multicast_toggle_vlan(struct net_bridge_vlan *vlan, bool on); int br_multicast_toggle_vlan_snooping(struct net_bridge *br, bool on, struct netlink_ext_ack *extack); bool br_multicast_toggle_global_vlan(struct net_bridge_vlan *vlan, bool on); @@ -1370,11 +1369,6 @@ static inline void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, { } -static inline void br_multicast_toggle_vlan(struct net_bridge_vlan *vlan, - bool on) -{ -} - static inline int br_multicast_toggle_vlan_snooping(struct net_bridge *br, bool on, struct netlink_ext_ack *extack)