From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 2B07DC43218 for ; Sun, 28 Apr 2019 18:48:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF79620652 for ; Sun, 28 Apr 2019 18:48:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k5b4YcMh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbfD1SsF (ORCPT ); Sun, 28 Apr 2019 14:48:05 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39925 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727170AbfD1SsC (ORCPT ); Sun, 28 Apr 2019 14:48:02 -0400 Received: by mail-wr1-f66.google.com with SMTP id a9so12494703wrp.6 for ; Sun, 28 Apr 2019 11:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yPHgkEnrVSI1hUBctPmTw5ai1M9rEf1pwTMexyMsFdc=; b=k5b4YcMh0+LpPcmffySqUbu4wiVUXyD1RXh5ul1Ehfc+vdoTWIkYxpMxUur/XMkNA7 QtpPhoPUSruK7NTEofHx7p6vNAblTroLMReJ/DvvITU/U2R5ERXCkaCtzJsAsIM2yQPc Y1uAOKMaKNQ7bNAc8cCkFBnMXp1MzvrQmz1KAa5I5e40DoszwTGGQXIW+dKnX1JCOu2/ NiArTe8tUsShx+OFRjFlI/XAWhNFa1mRAtIWQRSDVCbZT/rH/aTsJl4NBaHaRj6g7o+C Qs/pueV71K+Oy3LQ91WjYHVRZ5DVkPHUp/WkfTH7yYziJV8CvIJhIWBINMeHCUn2vFbn evfA== 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; bh=yPHgkEnrVSI1hUBctPmTw5ai1M9rEf1pwTMexyMsFdc=; b=lMQG7l6gtL48ugnXcEyMhn2vMM+a2lXJOUTQKaJEI0rW1BwJ10UuEfi+tKYizfEtCh dlJubS6gByl3GAbOkWAP86GkK/5EFrmtsua+aMtXEsAf+PqZHy9ejjRR8NodXy+H7bhc PdtfQn57yQGGf4pmTmgxk/NMseZ1vAtfqTLdWu6Elb4n4DHJmJzU3bb76BNBpQdEalK0 etItrXFPh6CPLvswvkhZz/kQyj/Hl+JG6Fuk93E7VN7TxAIqPB06BPGku7kXO8ATY1qI 35wlHeHLKnp31V5LTjc8zSCw+2e19TPsgZnAvb1f8dumfmXyLWEeqvvxptPHU+ADMiVi q7Bg== X-Gm-Message-State: APjAAAVDp46iwUpWDharUHeRItIZ2rA4sX6qSw7ZkvmiEg3eRSMkhJVx re66IJsOg+3knNxR+I5pxRE= X-Google-Smtp-Source: APXvYqzu8nWQUGqWPoa+A2OJSMJrNCiAeiakNe9Nrnm+PuqL5zTH8gL1qzXETtq63+jvmCK682VU3A== X-Received: by 2002:a5d:55c2:: with SMTP id i2mr2299054wrw.2.1556477280769; Sun, 28 Apr 2019 11:48:00 -0700 (PDT) Received: from localhost.localdomain (5-12-225-227.residential.rdsnet.ro. [5.12.225.227]) by smtp.gmail.com with ESMTPSA id h5sm12254910wmf.38.2019.04.28.11.47.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 11:48:00 -0700 (PDT) From: Vladimir Oltean To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch, davem@davemloft.net Cc: netdev@vger.kernel.org, Vladimir Oltean Subject: [PATCH net-next 05/13] net: dsa: Unset vlan_filtering when ports leave the bridge Date: Sun, 28 Apr 2019 21:45:46 +0300 Message-Id: <20190428184554.9968-6-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190428184554.9968-1-olteanv@gmail.com> References: <20190428184554.9968-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When ports are standalone (after they left the bridge), they should have no VLAN filtering semantics (they should pass all traffic to the CPU). Currently this is not true for switchdev drivers, because the bridge "forgets" to unset that. Normally one would think that doing this at the bridge layer would be a better idea, i.e. call br_vlan_filter_toggle() from br_del_if(), similar to how nbp_vlan_init() is called from br_add_if(). However what complicates that approach, and makes this one preferable, is the fact that for the bridge core, vlan_filtering is a per-bridge setting, whereas for switchdev/DSA it is per-port. Also there are switches where the setting is per the entire device, and unsetting vlan_filtering one by one, for each leaving port, would not be possible from the bridge core without a certain level of awareness. So do this in DSA and let drivers be unaware of it. Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- net/dsa/switch.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index fde4e9195709..7d8cd9bc0ecc 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -10,6 +10,7 @@ * (at your option) any later version. */ +#include #include #include #include @@ -71,6 +72,9 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, static int dsa_switch_bridge_leave(struct dsa_switch *ds, struct dsa_notifier_bridge_info *info) { + bool unset_vlan_filtering = br_vlan_enabled(info->br); + int err, i; + if (ds->index == info->sw_index && ds->ops->port_bridge_leave) ds->ops->port_bridge_leave(ds, info->port, info->br); @@ -78,6 +82,31 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds, ds->ops->crosschip_bridge_leave(ds, info->sw_index, info->port, info->br); + /* If the bridge was vlan_filtering, the bridge core doesn't trigger an + * event for changing vlan_filtering setting upon slave ports leaving + * it. That is a good thing, because that lets us handle it and also + * handle the case where the switch's vlan_filtering setting is global + * (not per port). When that happens, the correct moment to trigger the + * vlan_filtering callback is only when the last port left this bridge. + */ + if (unset_vlan_filtering && ds->vlan_filtering_is_global) { + for (i = 0; i < ds->num_ports; i++) { + if (i == info->port) + continue; + if (dsa_to_port(ds, i)->bridge_dev == info->br) { + unset_vlan_filtering = false; + break; + } + } + } + if (unset_vlan_filtering) { + struct switchdev_trans trans = {0}; + + err = dsa_port_vlan_filtering(&ds->ports[info->port], + false, &trans); + if (err && err != EOPNOTSUPP) + return err; + } return 0; } -- 2.17.1