From: Leon Romanovsky <leon@kernel.org>
To: David Ahern <dsahern@gmail.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
netdev <netdev@vger.kernel.org>,
RDMA mailing list <linux-rdma@vger.kernel.org>,
Stephen Hemminger <stephen@networkplumber.org>,
Steve Wise <swise@opengridcomputing.com>
Subject: [PATCH iproute2-next v1 3/4] rdma: Add an option to rename IB device interface
Date: Wed, 31 Oct 2018 09:17:57 +0200 [thread overview]
Message-ID: <20181031071758.6178-4-leon@kernel.org> (raw)
In-Reply-To: <20181031071758.6178-1-leon@kernel.org>
From: Leon Romanovsky <leonro@mellanox.com>
Enrich rdmatool with an option to rename IB devices,
the command interface follows Iproute2 convention:
"rdma dev set [OLD-DEVNAME] name NEW-DEVNAME"
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
---
rdma/dev.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/rdma/dev.c b/rdma/dev.c
index e2eafe47..760b7fb3 100644
--- a/rdma/dev.c
+++ b/rdma/dev.c
@@ -14,6 +14,7 @@
static int dev_help(struct rd *rd)
{
pr_out("Usage: %s dev show [DEV]\n", rd->filename);
+ pr_out(" %s dev set [DEV] name DEVNAME\n", rd->filename);
return 0;
}
@@ -240,17 +241,51 @@ static int dev_one_show(struct rd *rd)
return rd_exec_cmd(rd, cmds, "parameter");
}
+static int dev_set_name(struct rd *rd)
+{
+ uint32_t seq;
+
+ if (rd_no_arg(rd)) {
+ pr_err("Please provide device new name.\n");
+ return -EINVAL;
+ }
+
+ rd_prepare_msg(rd, RDMA_NLDEV_CMD_SET,
+ &seq, (NLM_F_REQUEST | NLM_F_ACK));
+ mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx);
+ mnl_attr_put_strz(rd->nlh, RDMA_NLDEV_ATTR_DEV_NAME, rd_argv(rd));
+
+ return rd_send_msg(rd);
+}
+
+static int dev_one_set(struct rd *rd)
+{
+ const struct rd_cmd cmds[] = {
+ { NULL, dev_help},
+ { "name", dev_set_name},
+ { 0 }
+ };
+
+ return rd_exec_cmd(rd, cmds, "parameter");
+}
+
static int dev_show(struct rd *rd)
{
return rd_exec_dev(rd, dev_one_show);
}
+static int dev_set(struct rd *rd)
+{
+ return rd_exec_require_dev(rd, dev_one_set);
+}
+
int cmd_dev(struct rd *rd)
{
const struct rd_cmd cmds[] = {
{ NULL, dev_show },
{ "show", dev_show },
{ "list", dev_show },
+ { "set", dev_set },
{ "help", dev_help },
{ 0 }
};
--
2.14.4
next prev parent reply other threads:[~2018-10-31 16:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-31 7:17 [PATCH iproute2-next v1 0/4] rdma: IB device rename Leon Romanovsky
2018-10-31 7:17 ` [PATCH iproute2-next v1 1/4] rdma: Update kernel include file to support IB device renaming Leon Romanovsky
2018-11-02 16:43 ` David Ahern
2018-10-31 7:17 ` [PATCH iproute2-next v1 2/4] rdma: Introduce command execution helper with required device name Leon Romanovsky
2018-11-02 16:43 ` David Ahern
2018-10-31 7:17 ` Leon Romanovsky [this message]
2018-11-02 16:43 ` [PATCH iproute2-next v1 3/4] rdma: Add an option to rename IB device interface David Ahern
2018-10-31 7:17 ` [PATCH iproute2-next v1 4/4] rdma: Document IB device renaming option Leon Romanovsky
2018-11-02 16:47 ` David Ahern
2018-11-04 11:12 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181031071758.6178-4-leon@kernel.org \
--to=leon@kernel.org \
--cc=dsahern@gmail.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
--cc=swise@opengridcomputing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).