mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 06:04:23 +08:00
eef8e906ae
When changing DSA user interface conduit while the user interface is up, DSA exhibits different behavior in comparison to when the interface is down. This different behavior concerns the primary unicast MAC address stored in the port standalone FDB and in the conduit device UC database. If we put a switch port down while changing the conduit with ip link set sw0p0 down ip link set sw0p0 type dsa conduit conduit1 ip link set sw0p0 up we delete the address in dsa_user_close() and install the (possibly different) address in dsa_user_open(). But when changing the conduit on the fly, the old address is not deleted and the new one is not installed. Since we explicitly want to support live-changing the conduit, uninstall the old address before calling dsa_port_assign_conduit() and install the (possibly different) new address after the call. Because conduit change might also trigger address change (the user interface is supposed to inherit the conduit interface MAC address if no address is defined in hardware (dp->mac is a zero address)), move the eth_hw_addr_inherit() call from dsa_user_change_conduit() to dsa_port_change_conduit(), just before installing the new address. Although this is in theory a flaw in DSA core, it needs not be backported, since there is currently no DSA driver that can be affected by this. The only DSA driver that supports changing conduit is felix, and, as explained by Vladimir Oltean [1]: There are 2 reasons why with felix the bug does not manifest itself. First is because both the 'ocelot' and the alternate 'ocelot-8021q' tagging protocols have the 'promisc_on_conduit = true' flag. So the unicast address doesn't have to be in the conduit's RX filter - neither the old or the new conduit. Second, dsa_user_host_uc_install() theoretically leaves behind host FDB entries installed towards the wrong (old) CPU port. But in felix_fdb_add(), we treat any FDB entry requested towards any CPU port as if it was a multicast FDB entry programmed towards _all_ CPU ports. For that reason, it is installed towards the port mask of the PGID_CPU port group ID: if (dsa_port_is_cpu(dp)) port = PGID_CPU; Therefore no Fixes tag for this change. [1] https://lore.kernel.org/netdev/20240507201827.47suw4fwcjrbungy@skbuf/ Signed-off-by: Marek Behún <kabel@kernel.org> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Tested-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
72 lines
2.0 KiB
C
72 lines
2.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#ifndef __DSA_USER_H
|
|
#define __DSA_USER_H
|
|
|
|
#include <linux/if_bridge.h>
|
|
#include <linux/if_vlan.h>
|
|
#include <linux/list.h>
|
|
#include <linux/netpoll.h>
|
|
#include <linux/types.h>
|
|
#include <net/dsa.h>
|
|
#include <net/gro_cells.h>
|
|
|
|
struct net_device;
|
|
struct netlink_ext_ack;
|
|
|
|
extern struct notifier_block dsa_user_switchdev_notifier;
|
|
extern struct notifier_block dsa_user_switchdev_blocking_notifier;
|
|
|
|
struct dsa_user_priv {
|
|
/* Copy of CPU port xmit for faster access in user transmit hot path */
|
|
struct sk_buff * (*xmit)(struct sk_buff *skb,
|
|
struct net_device *dev);
|
|
|
|
struct gro_cells gcells;
|
|
|
|
/* DSA port data, such as switch, port index, etc. */
|
|
struct dsa_port *dp;
|
|
|
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
|
struct netpoll *netpoll;
|
|
#endif
|
|
|
|
/* TC context */
|
|
struct list_head mall_tc_list;
|
|
};
|
|
|
|
void dsa_user_mii_bus_init(struct dsa_switch *ds);
|
|
int dsa_user_create(struct dsa_port *dp);
|
|
void dsa_user_destroy(struct net_device *user_dev);
|
|
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);
|
|
int dsa_user_change_mtu(struct net_device *dev, int new_mtu);
|
|
int dsa_user_change_conduit(struct net_device *dev, struct net_device *conduit,
|
|
struct netlink_ext_ack *extack);
|
|
int dsa_user_manage_vlan_filtering(struct net_device *dev,
|
|
bool vlan_filtering);
|
|
|
|
static inline struct dsa_port *dsa_user_to_port(const struct net_device *dev)
|
|
{
|
|
struct dsa_user_priv *p = netdev_priv(dev);
|
|
|
|
return p->dp;
|
|
}
|
|
|
|
static inline struct net_device *
|
|
dsa_user_to_conduit(const struct net_device *dev)
|
|
{
|
|
struct dsa_port *dp = dsa_user_to_port(dev);
|
|
|
|
return dsa_port_to_conduit(dp);
|
|
}
|
|
|
|
#endif
|