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

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