Merge branch 'fix-changing-dsa-conduit'
Marek Behún says: ==================== Fix changing DSA conduit This series fixes an issue in the DSA code related to host interface UC address installed into port FDB and port conduit address database when live-changing port conduit. The first patch refactores/deduplicates the installation/uninstallation of the interface's MAC address and the second patch fixes the issue. Cover letter for v1 and v2: https://patchwork.kernel.org/project/netdevbpf/cover/20240429163627.16031-1-kabel@kernel.org/ https://patchwork.kernel.org/project/netdevbpf/cover/20240502122922.28139-1-kabel@kernel.org/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
2ba6d15786
@ -1467,10 +1467,34 @@ int dsa_port_change_conduit(struct dsa_port *dp, struct net_device *conduit,
|
||||
*/
|
||||
dsa_user_unsync_ha(dev);
|
||||
|
||||
/* If live-changing, we also need to uninstall the user device address
|
||||
* from the port FDB and the conduit interface.
|
||||
*/
|
||||
if (dev->flags & IFF_UP)
|
||||
dsa_user_host_uc_uninstall(dev);
|
||||
|
||||
err = dsa_port_assign_conduit(dp, conduit, extack, true);
|
||||
if (err)
|
||||
goto rewind_old_addrs;
|
||||
|
||||
/* If the port doesn't have its own MAC address and relies on the DSA
|
||||
* conduit's one, inherit it again from the new DSA conduit.
|
||||
*/
|
||||
if (is_zero_ether_addr(dp->mac))
|
||||
eth_hw_addr_inherit(dev, conduit);
|
||||
|
||||
/* If live-changing, we need to install the user device address to the
|
||||
* port FDB and the conduit interface.
|
||||
*/
|
||||
if (dev->flags & IFF_UP) {
|
||||
err = dsa_user_host_uc_install(dev, dev->dev_addr);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Failed to install host UC address");
|
||||
goto rewind_addr_inherit;
|
||||
}
|
||||
}
|
||||
|
||||
dsa_user_sync_ha(dev);
|
||||
|
||||
if (vlan_filtering) {
|
||||
@ -1500,10 +1524,26 @@ rewind_new_vlan:
|
||||
rewind_new_addrs:
|
||||
dsa_user_unsync_ha(dev);
|
||||
|
||||
if (dev->flags & IFF_UP)
|
||||
dsa_user_host_uc_uninstall(dev);
|
||||
|
||||
rewind_addr_inherit:
|
||||
if (is_zero_ether_addr(dp->mac))
|
||||
eth_hw_addr_inherit(dev, old_conduit);
|
||||
|
||||
dsa_port_assign_conduit(dp, old_conduit, NULL, false);
|
||||
|
||||
/* Restore the objects on the old CPU port */
|
||||
rewind_old_addrs:
|
||||
if (dev->flags & IFF_UP) {
|
||||
tmp = dsa_user_host_uc_install(dev, dev->dev_addr);
|
||||
if (tmp) {
|
||||
dev_err(ds->dev,
|
||||
"port %d failed to restore host UC address: %pe\n",
|
||||
dp->index, ERR_PTR(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
dsa_user_sync_ha(dev);
|
||||
|
||||
if (vlan_filtering) {
|
||||
|
107
net/dsa/user.c
107
net/dsa/user.c
@ -355,60 +355,82 @@ static int dsa_user_get_iflink(const struct net_device *dev)
|
||||
return READ_ONCE(dsa_user_to_conduit(dev)->ifindex);
|
||||
}
|
||||
|
||||
static int dsa_user_open(struct net_device *dev)
|
||||
int dsa_user_host_uc_install(struct net_device *dev, const u8 *addr)
|
||||
{
|
||||
struct net_device *conduit = dsa_user_to_conduit(dev);
|
||||
struct dsa_port *dp = dsa_user_to_port(dev);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
int err;
|
||||
|
||||
if (dsa_switch_supports_uc_filtering(ds)) {
|
||||
err = dsa_port_standalone_host_fdb_add(dp, addr, 0);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ether_addr_equal(addr, conduit->dev_addr)) {
|
||||
err = dev_uc_add(conduit, addr);
|
||||
if (err < 0)
|
||||
goto del_host_addr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
del_host_addr:
|
||||
if (dsa_switch_supports_uc_filtering(ds))
|
||||
dsa_port_standalone_host_fdb_del(dp, addr, 0);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
void dsa_user_host_uc_uninstall(struct net_device *dev)
|
||||
{
|
||||
struct net_device *conduit = dsa_user_to_conduit(dev);
|
||||
struct dsa_port *dp = dsa_user_to_port(dev);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
if (!ether_addr_equal(dev->dev_addr, conduit->dev_addr))
|
||||
dev_uc_del(conduit, dev->dev_addr);
|
||||
|
||||
if (dsa_switch_supports_uc_filtering(ds))
|
||||
dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0);
|
||||
}
|
||||
|
||||
static int dsa_user_open(struct net_device *dev)
|
||||
{
|
||||
struct net_device *conduit = dsa_user_to_conduit(dev);
|
||||
struct dsa_port *dp = dsa_user_to_port(dev);
|
||||
int err;
|
||||
|
||||
err = dev_open(conduit, NULL);
|
||||
if (err < 0) {
|
||||
netdev_err(dev, "failed to open conduit %s\n", conduit->name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dsa_switch_supports_uc_filtering(ds)) {
|
||||
err = dsa_port_standalone_host_fdb_add(dp, dev->dev_addr, 0);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!ether_addr_equal(dev->dev_addr, conduit->dev_addr)) {
|
||||
err = dev_uc_add(conduit, dev->dev_addr);
|
||||
if (err < 0)
|
||||
goto del_host_addr;
|
||||
}
|
||||
err = dsa_user_host_uc_install(dev, dev->dev_addr);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = dsa_port_enable_rt(dp, dev->phydev);
|
||||
if (err)
|
||||
goto del_unicast;
|
||||
goto out_del_host_uc;
|
||||
|
||||
return 0;
|
||||
|
||||
del_unicast:
|
||||
if (!ether_addr_equal(dev->dev_addr, conduit->dev_addr))
|
||||
dev_uc_del(conduit, dev->dev_addr);
|
||||
del_host_addr:
|
||||
if (dsa_switch_supports_uc_filtering(ds))
|
||||
dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0);
|
||||
out_del_host_uc:
|
||||
dsa_user_host_uc_uninstall(dev);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int dsa_user_close(struct net_device *dev)
|
||||
{
|
||||
struct net_device *conduit = dsa_user_to_conduit(dev);
|
||||
struct dsa_port *dp = dsa_user_to_port(dev);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
dsa_port_disable_rt(dp);
|
||||
|
||||
if (!ether_addr_equal(dev->dev_addr, conduit->dev_addr))
|
||||
dev_uc_del(conduit, dev->dev_addr);
|
||||
|
||||
if (dsa_switch_supports_uc_filtering(ds))
|
||||
dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0);
|
||||
dsa_user_host_uc_uninstall(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -448,7 +470,6 @@ static void dsa_user_set_rx_mode(struct net_device *dev)
|
||||
|
||||
static int dsa_user_set_mac_address(struct net_device *dev, void *a)
|
||||
{
|
||||
struct net_device *conduit = dsa_user_to_conduit(dev);
|
||||
struct dsa_port *dp = dsa_user_to_port(dev);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
struct sockaddr *addr = a;
|
||||
@ -470,34 +491,16 @@ static int dsa_user_set_mac_address(struct net_device *dev, void *a)
|
||||
if (!(dev->flags & IFF_UP))
|
||||
goto out_change_dev_addr;
|
||||
|
||||
if (dsa_switch_supports_uc_filtering(ds)) {
|
||||
err = dsa_port_standalone_host_fdb_add(dp, addr->sa_data, 0);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
err = dsa_user_host_uc_install(dev, addr->sa_data);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!ether_addr_equal(addr->sa_data, conduit->dev_addr)) {
|
||||
err = dev_uc_add(conduit, addr->sa_data);
|
||||
if (err < 0)
|
||||
goto del_unicast;
|
||||
}
|
||||
|
||||
if (!ether_addr_equal(dev->dev_addr, conduit->dev_addr))
|
||||
dev_uc_del(conduit, dev->dev_addr);
|
||||
|
||||
if (dsa_switch_supports_uc_filtering(ds))
|
||||
dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0);
|
||||
dsa_user_host_uc_uninstall(dev);
|
||||
|
||||
out_change_dev_addr:
|
||||
eth_hw_addr_set(dev, addr->sa_data);
|
||||
|
||||
return 0;
|
||||
|
||||
del_unicast:
|
||||
if (dsa_switch_supports_uc_filtering(ds))
|
||||
dsa_port_standalone_host_fdb_del(dp, addr->sa_data, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
struct dsa_user_dump_ctx {
|
||||
@ -2879,12 +2882,6 @@ int dsa_user_change_conduit(struct net_device *dev, struct net_device *conduit,
|
||||
ERR_PTR(err));
|
||||
}
|
||||
|
||||
/* If the port doesn't have its own MAC address and relies on the DSA
|
||||
* conduit's one, inherit it again from the new DSA conduit.
|
||||
*/
|
||||
if (is_zero_ether_addr(dp->mac))
|
||||
eth_hw_addr_inherit(dev, conduit);
|
||||
|
||||
return 0;
|
||||
|
||||
out_revert_conduit_link:
|
||||
|
@ -42,6 +42,8 @@ int dsa_user_suspend(struct net_device *user_dev);
|
||||
int dsa_user_resume(struct net_device *user_dev);
|
||||
int dsa_user_register_notifier(void);
|
||||
void dsa_user_unregister_notifier(void);
|
||||
int dsa_user_host_uc_install(struct net_device *dev, const u8 *addr);
|
||||
void dsa_user_host_uc_uninstall(struct net_device *dev);
|
||||
void dsa_user_sync_ha(struct net_device *dev);
|
||||
void dsa_user_unsync_ha(struct net_device *dev);
|
||||
void dsa_user_setup_tagger(struct net_device *user);
|
||||
|
Loading…
x
Reference in New Issue
Block a user