diff mbox series

[iproute2-next,v2] rdma: Add support for the netlink extack

Message ID 20210103061706.18313-1-leon@kernel.org (mailing list archive)
State Accepted
Delegated to: David Ahern
Headers show
Series [iproute2-next,v2] rdma: Add support for the netlink extack | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Leon Romanovsky Jan. 3, 2021, 6:17 a.m. UTC
From: Patrisious Haddad <phaddad@nvidia.com>

Add support in rdma for extack errors to be received
in userspace when sent from kernel, so now netlink extack
error messages sent from kernel would be printed for the
user.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
David,

Just as a note, rdmatool is heavily influenced by the devlink and
general code should probably be applicable for both tools. Most likely
that any core refactoring/fix in the devlink is needed for rdmatool too.

Thanks
----
Changelog:
v2: Reused already existing function to set extack.
v1: https://lore.kernel.org/linux-rdma/20201231054217.372274-1-leon@kernel.org
---
 rdma/rdma.h  |  1 +
 rdma/utils.c | 24 ++++--------------------
 2 files changed, 5 insertions(+), 20 deletions(-)

--
2.29.2

Comments

David Ahern Jan. 10, 2021, 5:23 p.m. UTC | #1
On 1/2/21 11:17 PM, Leon Romanovsky wrote:
> From: Patrisious Haddad <phaddad@nvidia.com>
> 
> Add support in rdma for extack errors to be received
> in userspace when sent from kernel, so now netlink extack
> error messages sent from kernel would be printed for the
> user.
> 
> Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> David,
> 
> Just as a note, rdmatool is heavily influenced by the devlink and
> general code should probably be applicable for both tools. Most likely
> that any core refactoring/fix in the devlink is needed for rdmatool too.
> 

understood and it was not the best model to start with but here we are.

Petr did a good job of refactoring when he added dcb, but rdma was
slightly different so the refactoring did not update it.
Leon Romanovsky Jan. 11, 2021, 5:30 a.m. UTC | #2
On Sun, Jan 10, 2021 at 10:23:06AM -0700, David Ahern wrote:
> On 1/2/21 11:17 PM, Leon Romanovsky wrote:
> > From: Patrisious Haddad <phaddad@nvidia.com>
> >
> > Add support in rdma for extack errors to be received
> > in userspace when sent from kernel, so now netlink extack
> > error messages sent from kernel would be printed for the
> > user.
> >
> > Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > ---
> > David,
> >
> > Just as a note, rdmatool is heavily influenced by the devlink and
> > general code should probably be applicable for both tools. Most likely
> > that any core refactoring/fix in the devlink is needed for rdmatool too.
> >
>
> understood and it was not the best model to start with but here we are.
>
> Petr did a good job of refactoring when he added dcb, but rdma was
> slightly different so the refactoring did not update it.

I can work to reduce the gaps, just need to know them.

Thanks
diff mbox series

Patch

diff --git a/rdma/rdma.h b/rdma/rdma.h
index fc8bcf09..470e11c8 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -19,6 +19,7 @@ 

 #include "list.h"
 #include "utils.h"
+#include "mnl_utils.h"
 #include "json_print.h"

 #define pr_err(args...) fprintf(stderr, ##args)
diff --git a/rdma/utils.c b/rdma/utils.c
index 2a201aa4..903a544c 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -666,18 +666,12 @@  int rd_send_msg(struct rd *rd)
 {
 	int ret;

-	rd->nl = mnl_socket_open(NETLINK_RDMA);
+	rd->nl = mnlu_socket_open(NETLINK_RDMA);
 	if (!rd->nl) {
 		pr_err("Failed to open NETLINK_RDMA socket\n");
 		return -ENODEV;
 	}

-	ret = mnl_socket_bind(rd->nl, 0, MNL_SOCKET_AUTOPID);
-	if (ret < 0) {
-		pr_err("Failed to bind socket with err %d\n", ret);
-		goto err;
-	}
-
 	ret = mnl_socket_sendto(rd->nl, rd->nlh, rd->nlh->nlmsg_len);
 	if (ret < 0) {
 		pr_err("Failed to send to socket with err %d\n", ret);
@@ -692,23 +686,13 @@  err:

 int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, unsigned int seq)
 {
-	int ret;
-	unsigned int portid;
 	char buf[MNL_SOCKET_BUFFER_SIZE];
+	int ret;

-	portid = mnl_socket_get_portid(rd->nl);
-	do {
-		ret = mnl_socket_recvfrom(rd->nl, buf, sizeof(buf));
-		if (ret <= 0)
-			break;
-
-		ret = mnl_cb_run(buf, ret, seq, portid, callback, data);
-	} while (ret > 0);
-
+	ret = mnlu_socket_recv_run(rd->nl, seq, buf, MNL_SOCKET_BUFFER_SIZE,
+				   callback, data);
 	if (ret < 0 && !rd->suppress_errors)
 		perror("error");
-
-	mnl_socket_close(rd->nl);
 	return ret;
 }