Blame SOURCES/0053-rdma-Add-an-option-to-rename-IB-device-interface.patch

7e752c
From 452611d090e456cf7b49bfbb2522df2928452e10 Mon Sep 17 00:00:00 2001
7e752c
From: Andrea Claudi <aclaudi@redhat.com>
7e752c
Date: Mon, 10 Jun 2019 15:32:55 +0200
7e752c
Subject: [PATCH] rdma: Add an option to rename IB device interface
7e752c
7e752c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1663228
7e752c
Upstream Status: iproute2.git commit 4443c9c6a01ea
7e752c
7e752c
commit 4443c9c6a01eac8c8f2743d4d185ceb9be4d1207
7e752c
Author: Leon Romanovsky <leonro@mellanox.com>
7e752c
Date:   Wed Oct 31 09:17:57 2018 +0200
7e752c
7e752c
    rdma: Add an option to rename IB device interface
7e752c
7e752c
    Enrich rdmatool with an option to rename IB devices,
7e752c
    the command interface follows Iproute2 convention:
7e752c
    "rdma dev set [OLD-DEVNAME] name NEW-DEVNAME"
7e752c
7e752c
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
7e752c
    Reviewed-by: Steve Wise <swise@opengridcomputing.com>
7e752c
    Signed-off-by: David Ahern <dsahern@gmail.com>
7e752c
---
7e752c
 rdma/dev.c | 35 +++++++++++++++++++++++++++++++++++
7e752c
 1 file changed, 35 insertions(+)
7e752c
7e752c
diff --git a/rdma/dev.c b/rdma/dev.c
7e752c
index e2eafe47311b0..760b7fb3bb18f 100644
7e752c
--- a/rdma/dev.c
7e752c
+++ b/rdma/dev.c
7e752c
@@ -14,6 +14,7 @@
7e752c
 static int dev_help(struct rd *rd)
7e752c
 {
7e752c
 	pr_out("Usage: %s dev show [DEV]\n", rd->filename);
7e752c
+	pr_out("       %s dev set [DEV] name DEVNAME\n", rd->filename);
7e752c
 	return 0;
7e752c
 }
7e752c
 
7e752c
@@ -240,17 +241,51 @@ static int dev_one_show(struct rd *rd)
7e752c
 	return rd_exec_cmd(rd, cmds, "parameter");
7e752c
 }
7e752c
 
7e752c
+static int dev_set_name(struct rd *rd)
7e752c
+{
7e752c
+	uint32_t seq;
7e752c
+
7e752c
+	if (rd_no_arg(rd)) {
7e752c
+		pr_err("Please provide device new name.\n");
7e752c
+		return -EINVAL;
7e752c
+	}
7e752c
+
7e752c
+	rd_prepare_msg(rd, RDMA_NLDEV_CMD_SET,
7e752c
+		       &seq, (NLM_F_REQUEST | NLM_F_ACK));
7e752c
+	mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx);
7e752c
+	mnl_attr_put_strz(rd->nlh, RDMA_NLDEV_ATTR_DEV_NAME, rd_argv(rd));
7e752c
+
7e752c
+	return rd_send_msg(rd);
7e752c
+}
7e752c
+
7e752c
+static int dev_one_set(struct rd *rd)
7e752c
+{
7e752c
+	const struct rd_cmd cmds[] = {
7e752c
+		{ NULL,		dev_help},
7e752c
+		{ "name",	dev_set_name},
7e752c
+		{ 0 }
7e752c
+	};
7e752c
+
7e752c
+	return rd_exec_cmd(rd, cmds, "parameter");
7e752c
+}
7e752c
+
7e752c
 static int dev_show(struct rd *rd)
7e752c
 {
7e752c
 	return rd_exec_dev(rd, dev_one_show);
7e752c
 }
7e752c
 
7e752c
+static int dev_set(struct rd *rd)
7e752c
+{
7e752c
+	return rd_exec_require_dev(rd, dev_one_set);
7e752c
+}
7e752c
+
7e752c
 int cmd_dev(struct rd *rd)
7e752c
 {
7e752c
 	const struct rd_cmd cmds[] = {
7e752c
 		{ NULL,		dev_show },
7e752c
 		{ "show",	dev_show },
7e752c
 		{ "list",	dev_show },
7e752c
+		{ "set",	dev_set },
7e752c
 		{ "help",	dev_help },
7e752c
 		{ 0 }
7e752c
 	};
7e752c
-- 
7e752c
2.20.1
7e752c