mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
net: netdevsim: Support setting dev->perm_addr on port creation
Network management daemons that match on the device permanent address currently have no virtual interface types to test against. NetworkManager, in particular, has carried an out of tree patch to set the permanent address on netdevsim devices to use in its CI for this purpose. To support this use case, support setting netdev->perm_addr when creating a netdevsim port. Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Link: https://patch.msgid.link/20250710-netdevsim-perm_addr-v4-1-c9db2fecf3bf@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
650fe2a9dd
commit
54cb59cf81
@@ -589,7 +589,7 @@ static void nsim_dev_dummy_region_exit(struct nsim_dev *nsim_dev)
|
||||
|
||||
static int
|
||||
__nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
|
||||
unsigned int port_index);
|
||||
unsigned int port_index, u8 perm_addr[ETH_ALEN]);
|
||||
static void __nsim_dev_port_del(struct nsim_dev_port *nsim_dev_port);
|
||||
|
||||
static int nsim_esw_legacy_enable(struct nsim_dev *nsim_dev,
|
||||
@@ -613,7 +613,7 @@ static int nsim_esw_switchdev_enable(struct nsim_dev *nsim_dev,
|
||||
int i, err;
|
||||
|
||||
for (i = 0; i < nsim_dev_get_vfs(nsim_dev); i++) {
|
||||
err = __nsim_dev_port_add(nsim_dev, NSIM_DEV_PORT_TYPE_VF, i);
|
||||
err = __nsim_dev_port_add(nsim_dev, NSIM_DEV_PORT_TYPE_VF, i, NULL);
|
||||
if (err) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Failed to initialize VFs' netdevsim ports");
|
||||
pr_err("Failed to initialize VF id=%d. %d.\n", i, err);
|
||||
@@ -1396,7 +1396,7 @@ static const struct devlink_ops nsim_dev_devlink_ops = {
|
||||
#define NSIM_DEV_TEST1_DEFAULT true
|
||||
|
||||
static int __nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
|
||||
unsigned int port_index)
|
||||
unsigned int port_index, u8 perm_addr[ETH_ALEN])
|
||||
{
|
||||
struct devlink_port_attrs attrs = {};
|
||||
struct nsim_dev_port *nsim_dev_port;
|
||||
@@ -1433,7 +1433,7 @@ static int __nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_typ
|
||||
if (err)
|
||||
goto err_dl_port_unregister;
|
||||
|
||||
nsim_dev_port->ns = nsim_create(nsim_dev, nsim_dev_port);
|
||||
nsim_dev_port->ns = nsim_create(nsim_dev, nsim_dev_port, perm_addr);
|
||||
if (IS_ERR(nsim_dev_port->ns)) {
|
||||
err = PTR_ERR(nsim_dev_port->ns);
|
||||
goto err_port_debugfs_exit;
|
||||
@@ -1489,7 +1489,7 @@ static int nsim_dev_port_add_all(struct nsim_dev *nsim_dev,
|
||||
int i, err;
|
||||
|
||||
for (i = 0; i < port_count; i++) {
|
||||
err = __nsim_dev_port_add(nsim_dev, NSIM_DEV_PORT_TYPE_PF, i);
|
||||
err = __nsim_dev_port_add(nsim_dev, NSIM_DEV_PORT_TYPE_PF, i, NULL);
|
||||
if (err)
|
||||
goto err_port_del_all;
|
||||
}
|
||||
@@ -1745,7 +1745,7 @@ __nsim_dev_port_lookup(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type,
|
||||
}
|
||||
|
||||
int nsim_drv_port_add(struct nsim_bus_dev *nsim_bus_dev, enum nsim_dev_port_type type,
|
||||
unsigned int port_index)
|
||||
unsigned int port_index, u8 perm_addr[ETH_ALEN])
|
||||
{
|
||||
struct nsim_dev *nsim_dev = dev_get_drvdata(&nsim_bus_dev->dev);
|
||||
int err;
|
||||
@@ -1754,7 +1754,7 @@ int nsim_drv_port_add(struct nsim_bus_dev *nsim_bus_dev, enum nsim_dev_port_type
|
||||
if (__nsim_dev_port_lookup(nsim_dev, type, port_index))
|
||||
err = -EEXIST;
|
||||
else
|
||||
err = __nsim_dev_port_add(nsim_dev, type, port_index);
|
||||
err = __nsim_dev_port_add(nsim_dev, type, port_index, perm_addr);
|
||||
devl_unlock(priv_to_devlink(nsim_dev));
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user