Skip to content

Commit

Permalink
netdevsim: create devlink and netdev instances in namespace
Browse files Browse the repository at this point in the history
When user does create new netdevsim instance using sysfs bus file,
create the devlink instance and related netdev instance in the namespace
of the caller.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Oct 5, 2019
1 parent 8273fd8 commit 7b60027
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/netdevsim/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ nsim_bus_dev_new(unsigned int id, unsigned int port_count)
nsim_bus_dev->dev.bus = &nsim_bus;
nsim_bus_dev->dev.type = &nsim_bus_dev_type;
nsim_bus_dev->port_count = port_count;
nsim_bus_dev->initial_net = current->nsproxy->net_ns;

err = device_register(&nsim_bus_dev->dev);
if (err)
Expand Down
1 change: 1 addition & 0 deletions drivers/net/netdevsim/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ static struct nsim_dev *nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev)
devlink = devlink_alloc(&nsim_dev_devlink_ops, sizeof(*nsim_dev));
if (!devlink)
return ERR_PTR(-ENOMEM);
devlink_net_set(devlink, nsim_bus_dev->initial_net);
nsim_dev = devlink_priv(devlink);
nsim_dev->nsim_bus_dev = nsim_bus_dev;
nsim_dev->switch_id.id_len = sizeof(nsim_dev->switch_id.id);
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/netdevsim/netdevsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ struct nsim_bus_dev {
struct device dev;
struct list_head list;
unsigned int port_count;
struct net *initial_net; /* Purpose of this is to carry net pointer
* during the probe time only.
*/
unsigned int num_vfs;
struct nsim_vf_config *vfconfigs;
};
Expand Down

0 comments on commit 7b60027

Please sign in to comment.