]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
rdma: Set pointer to device name position
authorLeon Romanovsky <leonro@mellanox.com>
Wed, 31 Jan 2018 08:11:50 +0000 (10:11 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 6 Feb 2018 01:23:52 +0000 (17:23 -0800)
The dev and link execution callbacks expects that next
command line argument is device or port name.

Set pointer to device or port name position prior calls to
rd_exec_dev()/rd_exec_link().

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
rdma/rdma.h
rdma/utils.c

index 8e60ce26fdbf16e450c56b627d44e7edd534160b..35506a962fd9151434949321ae951a877569033e 100644 (file)
@@ -87,6 +87,7 @@ 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_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);
 int rd_argc(struct rd *rd);
 
 /*
index 157699c078c8dd898a3401b1f021973c1f6da1ba..f93f05e15b0c44e4f81e64765ec0a5b1277f25d9 100644 (file)
@@ -412,6 +412,25 @@ void rd_free(struct rd *rd)
        filters_cleanup(rd);
 }
 
+int rd_set_arg_to_devname(struct rd *rd)
+{
+       int ret = 0;
+
+       while (!rd_no_arg(rd)) {
+               if (rd_argv_match(rd, "dev") || rd_argv_match(rd, "link")) {
+                       rd_arg_inc(rd);
+                       if (rd_no_arg(rd)) {
+                               pr_err("No device name was supplied\n");
+                               ret = -EINVAL;
+                       }
+                       goto out;
+               }
+               rd_arg_inc(rd);
+       }
+out:
+       return ret;
+}
+
 int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port)
 {
        struct dev_map *dev_map;