From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
andrew@lunn.ch, vivien.didelot@gmail.com, davem@davemloft.net,
idosch@mellanox.com, jiri@mellanox.com,
ilias.apalodimas@linaro.org, ivan.khoronzhuk@linaro.org,
roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com
Subject: [PATCH net-next 07/14] net: dsa: Add ability to program multicast filter for CPU port
Date: Wed, 16 Jan 2019 12:00:55 -0800 [thread overview]
Message-ID: <20190116200102.2749-8-f.fainelli@gmail.com> (raw)
In-Reply-To: <20190116200102.2749-1-f.fainelli@gmail.com>
When the switch ports operate as individual network devices, the switch
driver might have configured the switch to flood multicast all the way
to the CPU port. This is really undesireable as it can lead to receiving
a lot of unwanted traffic that the network stack needs to filter in
software.
For each valid multicast address, program it into the switch's MDB only
when the host is interested in receiving such traffic, e.g: running an
multicast application.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
net/dsa/slave.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a3fcc1d01615..33f6b88b6fd6 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -68,6 +68,39 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
return dsa_slave_to_master(dev)->ifindex;
}
+static int dsa_slave_sync_unsync_mdb_addr(struct net_device *dev,
+ const unsigned char *addr, bool add)
+{
+ struct switchdev_obj_port_mdb mdb = {
+ .obj = {
+ .id = SWITCHDEV_OBJ_ID_HOST_MDB,
+ .flags = SWITCHDEV_F_DEFER,
+ },
+ .vid = 0,
+ };
+ int ret = -EOPNOTSUPP;
+
+ ether_addr_copy(mdb.addr, addr);
+ if (add)
+ ret = switchdev_port_obj_add(dev, &mdb.obj, NULL);
+ else
+ ret = switchdev_port_obj_del(dev, &mdb.obj);
+
+ return ret;
+}
+
+static int dsa_slave_sync_mdb_addr(struct net_device *dev,
+ const unsigned char *addr)
+{
+ return dsa_slave_sync_unsync_mdb_addr(dev, addr, true);
+}
+
+static int dsa_slave_unsync_mdb_addr(struct net_device *dev,
+ const unsigned char *addr)
+{
+ return dsa_slave_sync_unsync_mdb_addr(dev, addr, false);
+}
+
static int dsa_slave_open(struct net_device *dev)
{
struct net_device *master = dsa_slave_to_master(dev);
@@ -126,6 +159,8 @@ static int dsa_slave_close(struct net_device *dev)
dev_mc_unsync(master, dev);
dev_uc_unsync(master, dev);
+ __hw_addr_unsync_dev(&dev->mc, dev, dsa_slave_unsync_mdb_addr);
+
if (dev->flags & IFF_ALLMULTI)
dev_set_allmulti(master, -1);
if (dev->flags & IFF_PROMISC)
@@ -150,7 +185,17 @@ static void dsa_slave_change_rx_flags(struct net_device *dev, int change)
static void dsa_slave_set_rx_mode(struct net_device *dev)
{
struct net_device *master = dsa_slave_to_master(dev);
+ struct dsa_port *dp = dsa_slave_to_port(dev);
+ /* If the port is bridged, the bridge takes care of sending
+ * SWITCHDEV_OBJ_ID_HOST_MDB to program the host's MC filter
+ */
+ if (netdev_mc_empty(dev) || dp->bridge_dev)
+ goto out;
+
+ __hw_addr_sync_dev(&dev->mc, dev, dsa_slave_sync_mdb_addr,
+ dsa_slave_unsync_mdb_addr);
+out:
dev_mc_sync(master, dev);
dev_uc_sync(master, dev);
}
@@ -1395,6 +1440,11 @@ static int dsa_slave_changeupper(struct net_device *dev,
if (netif_is_bridge_master(info->upper_dev)) {
if (info->linking) {
+ /* Remove existing MC addresses that might have been
+ * programmed
+ */
+ __hw_addr_unsync_dev(&dev->mc, dev,
+ dsa_slave_unsync_mdb_addr);
err = dsa_port_bridge_join(dp, info->upper_dev);
err = notifier_from_errno(err);
} else {
--
2.17.1
next prev parent reply other threads:[~2019-01-16 20:03 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 20:00 [PATCH net-next 00/14] net: dsa: management mode for bcm_sf2 Florian Fainelli
2019-01-16 20:00 ` [PATCH net-next 01/14] net: bridge: multicast: Propagate br_mc_disabled_update() return Florian Fainelli
2019-01-17 13:47 ` Ido Schimmel
2019-01-17 19:27 ` Florian Fainelli
2019-01-16 20:00 ` [PATCH net-next 02/14] net: dsa: b53: Fix default VLAN ID Florian Fainelli
2019-01-16 20:00 ` [PATCH net-next 03/14] net: dsa: b53: Properly account for VLAN filtering Florian Fainelli
2019-01-17 16:36 ` Vivien Didelot
2019-01-17 17:48 ` Florian Fainelli
2019-01-17 18:47 ` Vivien Didelot
2019-01-17 19:06 ` Florian Fainelli
2019-01-16 20:00 ` [PATCH net-next 04/14] net: systemport: Fix reception of BPDUs Florian Fainelli
2019-01-16 20:00 ` [PATCH net-next 05/14] net: dsa: b53: Define registers for IGMP snooping Florian Fainelli
2019-01-16 20:00 ` [PATCH net-next 06/14] net: dsa: b53: Add support for MDB Florian Fainelli
2019-01-16 20:00 ` Florian Fainelli [this message]
2019-01-16 20:00 ` [PATCH net-next 08/14] net: dsa: Add ndo_vlan_rx_{add,kill}_vid implementation Florian Fainelli
2019-01-16 20:00 ` [PATCH net-next 09/14] net: bridge: Propagate MC addresses with VID through switchdev Florian Fainelli
2019-01-17 14:05 ` Ido Schimmel
2019-01-17 19:17 ` Florian Fainelli
2019-01-18 10:43 ` Ido Schimmel
2019-01-18 11:41 ` Ido Schimmel
2019-01-18 21:48 ` Florian Fainelli
2019-01-19 13:55 ` Ido Schimmel
2019-01-20 3:22 ` Florian Fainelli
2019-01-21 8:41 ` Ido Schimmel
2019-01-21 8:46 ` Jiri Pirko
2019-01-16 20:00 ` [PATCH net-next 10/14] net: vlan: " Florian Fainelli
2019-01-17 14:49 ` Ido Schimmel
2019-01-17 19:12 ` Florian Fainelli
2019-01-21 9:13 ` Ido Schimmel
2019-01-21 9:17 ` Ilias Apalodimas
2019-01-22 11:30 ` Ivan Khoronzhuk
2019-01-22 11:39 ` Ivan Khoronzhuk
2019-01-16 20:00 ` [PATCH net-next 11/14] net: dsa: Make VLAN filtering use DSA notifiers Florian Fainelli
2019-01-16 20:01 ` [PATCH net-next 12/14] net: dsa: Wire up multicast IGMP snooping attribute notification Florian Fainelli
2019-01-17 18:36 ` Vivien Didelot
2019-01-17 19:07 ` Florian Fainelli
2019-01-16 20:01 ` [PATCH net-next 13/14] net: dsa: b53: Add support for toggling IGMP snooping Florian Fainelli
2019-01-16 20:01 ` [PATCH net-next 14/14] net: dsa: bcm_sf2: Enable management mode Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190116200102.2749-8-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=ilias.apalodimas@linaro.org \
--cc=ivan.khoronzhuk@linaro.org \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).