naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0052-rdma-Introduce-command-execution-helper-with-require.patch

7e752c
From 349c43f99f876e0663fb0b00396ac3d387bc32e9 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: Introduce command execution helper with required device
7e752c
 name
7e752c
7e752c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1663228
7e752c
Upstream Status: iproute2.git commit a14ceed32524c
7e752c
7e752c
commit a14ceed32524c7f9c05572886cd63e921e4c0faf
7e752c
Author: Leon Romanovsky <leonro@mellanox.com>
7e752c
Date:   Wed Oct 31 09:17:56 2018 +0200
7e752c
7e752c
    rdma: Introduce command execution helper with required device name
7e752c
7e752c
    In contradiction to various show commands, the set command explicitly
7e752c
    requires to use device name as an argument. Provide new command
7e752c
    execution helper which enforces it.
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/rdma.h  |  1 +
7e752c
 rdma/utils.c | 10 ++++++++++
7e752c
 2 files changed, 11 insertions(+)
7e752c
7e752c
diff --git a/rdma/rdma.h b/rdma/rdma.h
7e752c
index c3b7530b6cc71..547bb5749a39f 100644
7e752c
--- a/rdma/rdma.h
7e752c
+++ b/rdma/rdma.h
7e752c
@@ -90,6 +90,7 @@ int cmd_link(struct rd *rd);
7e752c
 int cmd_res(struct rd *rd);
7e752c
 int rd_exec_cmd(struct rd *rd, const struct rd_cmd *c, const char *str);
7e752c
 int rd_exec_dev(struct rd *rd, int (*cb)(struct rd *rd));
7e752c
+int rd_exec_require_dev(struct rd *rd, int (*cb)(struct rd *rd));
7e752c
 int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port);
7e752c
 void rd_free(struct rd *rd);
7e752c
 int rd_set_arg_to_devname(struct rd *rd);
7e752c
diff --git a/rdma/utils.c b/rdma/utils.c
7e752c
index 4840bf226d54d..61f4aeb1bcf27 100644
7e752c
--- a/rdma/utils.c
7e752c
+++ b/rdma/utils.c
7e752c
@@ -577,6 +577,16 @@ out:
7e752c
 	return ret;
7e752c
 }
7e752c
 
7e752c
+int rd_exec_require_dev(struct rd *rd, int (*cb)(struct rd *rd))
7e752c
+{
7e752c
+	if (rd_no_arg(rd)) {
7e752c
+		pr_err("Please provide device name.\n");
7e752c
+		return -EINVAL;
7e752c
+	}
7e752c
+
7e752c
+	return rd_exec_dev(rd, cb);
7e752c
+}
7e752c
+
7e752c
 int rd_exec_cmd(struct rd *rd, const struct rd_cmd *cmds, const char *str)
7e752c
 {
7e752c
 	const struct rd_cmd *c;
7e752c
-- 
7e752c
2.20.1
7e752c