netdevsim: register port netdevices into net of device
authorJiri Pirko <jiri@mellanox.com>
Thu, 3 Oct 2019 09:49:37 +0000 (11:49 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Oct 2019 18:10:56 +0000 (11:10 -0700)
Register newly created port netdevice into net namespace
that the parent device belongs to.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/netdev.c
drivers/net/netdevsim/netdevsim.h

index 0740940f41b12949558b6150edec27917d3cfe3c..2908e0a0d6e19aab337634e43b03f0296d0102aa 100644 (file)
@@ -290,6 +290,7 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
        if (!dev)
                return ERR_PTR(-ENOMEM);
 
+       dev_net_set(dev, nsim_dev_net(nsim_dev));
        ns = netdev_priv(dev);
        ns->netdev = dev;
        ns->nsim_dev = nsim_dev;
index 702d951fe16085325b54aead2c4ccbccd3f3e293..198ca31cec94c4f7fddab2df32dc4da924204b67 100644 (file)
@@ -164,6 +164,11 @@ struct nsim_dev {
        struct devlink_region *dummy_region;
 };
 
+static inline struct net *nsim_dev_net(struct nsim_dev *nsim_dev)
+{
+       return devlink_net(priv_to_devlink(nsim_dev));
+}
+
 int nsim_dev_init(void);
 void nsim_dev_exit(void);
 int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev);