]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
rdma: Introduce command execution helper with required device name
authorLeon Romanovsky <leonro@mellanox.com>
Wed, 31 Oct 2018 07:17:56 +0000 (09:17 +0200)
committerDavid Ahern <dsahern@gmail.com>
Fri, 2 Nov 2018 16:38:18 +0000 (09:38 -0700)
In contradiction to various show commands, the set command explicitly
requires to use device name as an argument. Provide new command
execution helper which enforces it.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
rdma/rdma.h
rdma/utils.c

index c3b7530b6cc7125a4764c65ff2968106210f595d..547bb5749a39f68e7237f976ee57518f3e7aa21d 100644 (file)
@@ -90,6 +90,7 @@ int cmd_link(struct rd *rd);
 int cmd_res(struct rd *rd);
 int rd_exec_cmd(struct rd *rd, const struct rd_cmd *c, const char *str);
 int rd_exec_dev(struct rd *rd, int (*cb)(struct rd *rd));
+int rd_exec_require_dev(struct rd *rd, int (*cb)(struct rd *rd));
 int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port);
 void rd_free(struct rd *rd);
 int rd_set_arg_to_devname(struct rd *rd);
index 4840bf226d54d01cadbc46e298a7bdb4686d6aa1..61f4aeb1bcf27ca5c345e152d1b8501c7c487310 100644 (file)
@@ -577,6 +577,16 @@ out:
        return ret;
 }
 
+int rd_exec_require_dev(struct rd *rd, int (*cb)(struct rd *rd))
+{
+       if (rd_no_arg(rd)) {
+               pr_err("Please provide device name.\n");
+               return -EINVAL;
+       }
+
+       return rd_exec_dev(rd, cb);
+}
+
 int rd_exec_cmd(struct rd *rd, const struct rd_cmd *cmds, const char *str)
 {
        const struct rd_cmd *c;