]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
netdevsim: add couple of debugfs bools to debug devlink reload
authorJiri Pirko <jiri@mellanox.com>
Sun, 6 Oct 2019 06:30:01 +0000 (08:30 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 6 Oct 2019 16:28:42 +0000 (18:28 +0200)
Add flag to disallow reload and another one that causes reload to
always fail.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/dev.c
drivers/net/netdevsim/netdevsim.h

index fbc4cdcfe551adf4c5976140d7ece7938c41fe81..31d1752c703aa56a050b78d8ca3a3e6c5074599d 100644 (file)
@@ -90,6 +90,10 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
                            &nsim_dev->test1);
        debugfs_create_file("take_snapshot", 0200, nsim_dev->ddir, nsim_dev,
                            &nsim_dev_take_snapshot_fops);
+       debugfs_create_bool("dont_allow_reload", 0600, nsim_dev->ddir,
+                           &nsim_dev->dont_allow_reload);
+       debugfs_create_bool("fail_reload", 0600, nsim_dev->ddir,
+                           &nsim_dev->fail_reload);
        return 0;
 }
 
@@ -478,6 +482,14 @@ static int nsim_dev_reload_down(struct devlink *devlink, bool netns_change,
 {
        struct nsim_dev *nsim_dev = devlink_priv(devlink);
 
+       if (nsim_dev->dont_allow_reload) {
+               /* For testing purposes, user set debugfs dont_allow_reload
+                * value to true. So forbid it.
+                */
+               NL_SET_ERR_MSG_MOD(extack, "User forbidded reload for testing purposes");
+               return -EOPNOTSUPP;
+       }
+
        nsim_dev_reload_destroy(nsim_dev);
        return 0;
 }
@@ -487,6 +499,14 @@ static int nsim_dev_reload_up(struct devlink *devlink,
 {
        struct nsim_dev *nsim_dev = devlink_priv(devlink);
 
+       if (nsim_dev->fail_reload) {
+               /* For testing purposes, user set debugfs fail_reload
+                * value to true. Fail right away.
+                */
+               NL_SET_ERR_MSG_MOD(extack, "User setup the reload to fail for testing purposes");
+               return -EINVAL;
+       }
+
        return nsim_dev_reload_create(nsim_dev, extack);
 }
 
index 8168a5475fe71466b5e94953be013b8c775e8499..24358385d869a33f97f4b2503f15c362847fa816 100644 (file)
@@ -161,6 +161,8 @@ struct nsim_dev {
        bool fw_update_status;
        u32 max_macs;
        bool test1;
+       bool dont_allow_reload;
+       bool fail_reload;
        struct devlink_region *dummy_region;
 };