[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210224114350.2791260-5-olteanv@gmail.com>
Date: Wed, 24 Feb 2021 13:43:37 +0200
From: Vladimir Oltean <olteanv@...il.com>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Vivien Didelot <vivien.didelot@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
Ido Schimmel <idosch@...sch.org>,
DENG Qingfang <dqfext@...il.com>,
Tobias Waldekranz <tobias@...dekranz.com>,
George McCollister <george.mccollister@...il.com>,
Vlad Yasevich <vyasevich@...il.com>,
Roopa Prabhu <roopa@...dia.com>,
Nikolay Aleksandrov <nikolay@...dia.com>
Subject: [RFC PATCH v2 net-next 04/17] net: dsa: install the port MAC addresses as host fdb entries
From: Vladimir Oltean <vladimir.oltean@....com>
In preparation of support for IFF_UNICAST_FLT for DSA standalone ports,
the unicast address of the DSA interfaces should always be known to the
switch and installed as an FDB entry towards the CPU port associated
with that user port.
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
net/dsa/slave.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index b6ea7e21b3b6..6544a4ec69f4 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -223,11 +223,9 @@ static int dsa_slave_open(struct net_device *dev)
goto out;
}
- if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
- err = dev_uc_add(master, dev->dev_addr);
- if (err < 0)
- goto out;
- }
+ err = dsa_host_fdb_add(dp, dev->dev_addr, 0);
+ if (err && err != -EOPNOTSUPP)
+ goto out;
if (dev->flags & IFF_ALLMULTI) {
err = dev_set_allmulti(master, 1);
@@ -253,8 +251,7 @@ static int dsa_slave_open(struct net_device *dev)
if (dev->flags & IFF_ALLMULTI)
dev_set_allmulti(master, -1);
del_unicast:
- if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
- dev_uc_del(master, dev->dev_addr);
+ dsa_host_fdb_del(dp, dev->dev_addr, 0);
out:
return err;
}
@@ -273,8 +270,7 @@ static int dsa_slave_close(struct net_device *dev)
if (dev->flags & IFF_PROMISC)
dev_set_promiscuity(master, -1);
- if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
- dev_uc_del(master, dev->dev_addr);
+ dsa_host_fdb_del(dp, dev->dev_addr, 0);
return 0;
}
@@ -302,26 +298,18 @@ static void dsa_slave_set_rx_mode(struct net_device *dev)
static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
{
- struct net_device *master = dsa_slave_to_master(dev);
+ struct dsa_port *dp = dsa_slave_to_port(dev);
struct sockaddr *addr = a;
int err;
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
- if (!(dev->flags & IFF_UP))
- goto out;
-
- if (!ether_addr_equal(addr->sa_data, master->dev_addr)) {
- err = dev_uc_add(master, addr->sa_data);
- if (err < 0)
- return err;
- }
-
- if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
- dev_uc_del(master, dev->dev_addr);
+ err = dsa_host_fdb_add(dp, addr->sa_data, 0);
+ if (err && err != -EOPNOTSUPP)
+ return err;
-out:
+ dsa_host_fdb_del(dp, dev->dev_addr, 0);
ether_addr_copy(dev->dev_addr, addr->sa_data);
return 0;
--
2.25.1
Powered by blists - more mailing lists