netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2-next] rdma: Add support for the netlink extack
@ 2020-12-31  5:42 Leon Romanovsky
  2020-12-31 16:18 ` David Ahern
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2020-12-31  5:42 UTC (permalink / raw)
  To: David Ahern
  Cc: Patrisious Haddad, Doug Ledford, Jason Gunthorpe, linux-netdev,
	RDMA mailing list

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>
---
Kernel part:
https://lore.kernel.org/linux-rdma/20201230130240.180737-1-leon@kernel.org
---
 rdma/rdma.h  |  1 +
 rdma/utils.c | 24 ++++++++++--------------
 2 files changed, 11 insertions(+), 14 deletions(-)

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..927e2107 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -664,7 +664,7 @@ void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags)

 int rd_send_msg(struct rd *rd)
 {
-	int ret;
+	int ret, one;

 	rd->nl = mnl_socket_open(NETLINK_RDMA);
 	if (!rd->nl) {
@@ -672,6 +672,12 @@ int rd_send_msg(struct rd *rd)
 		return -ENODEV;
 	}

+	ret = mnl_socket_setsockopt(rd->nl, NETLINK_EXT_ACK, &one, sizeof(one));
+	if (ret < 0) {
+		pr_err("Failed to set socket option with err %d\n", ret);
+		goto err;
+	}
+
 	ret = mnl_socket_bind(rd->nl, 0, MNL_SOCKET_AUTOPID);
 	if (ret < 0) {
 		pr_err("Failed to bind socket with err %d\n", ret);
@@ -692,23 +698,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;
 }

--
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2-next] rdma: Add support for the netlink extack
  2020-12-31  5:42 [PATCH iproute2-next] rdma: Add support for the netlink extack Leon Romanovsky
@ 2020-12-31 16:18 ` David Ahern
  2021-01-03  5:56   ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2020-12-31 16:18 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Patrisious Haddad, Doug Ledford, Jason Gunthorpe, linux-netdev,
	RDMA mailing list

On 12/30/20 10:42 PM, Leon Romanovsky wrote:
> diff --git a/rdma/utils.c b/rdma/utils.c
> index 2a201aa4..927e2107 100644
> --- a/rdma/utils.c
> +++ b/rdma/utils.c
> @@ -664,7 +664,7 @@ void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags)
> 
>  int rd_send_msg(struct rd *rd)
>  {
> -	int ret;
> +	int ret, one;
> 
>  	rd->nl = mnl_socket_open(NETLINK_RDMA);
>  	if (!rd->nl) {
> @@ -672,6 +672,12 @@ int rd_send_msg(struct rd *rd)
>  		return -ENODEV;
>  	}
> 
> +	ret = mnl_socket_setsockopt(rd->nl, NETLINK_EXT_ACK, &one, sizeof(one));
> +	if (ret < 0) {
> +		pr_err("Failed to set socket option with err %d\n", ret);
> +		goto err;
> +	}
> +
>  	ret = mnl_socket_bind(rd->nl, 0, MNL_SOCKET_AUTOPID);
>  	if (ret < 0) {
>  		pr_err("Failed to bind socket with err %d\n", ret);

you should be able to use mnlu_socket_open in ./lib/mnl_utils.c


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2-next] rdma: Add support for the netlink extack
  2020-12-31 16:18 ` David Ahern
@ 2021-01-03  5:56   ` Leon Romanovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2021-01-03  5:56 UTC (permalink / raw)
  To: David Ahern
  Cc: Patrisious Haddad, Doug Ledford, Jason Gunthorpe, linux-netdev,
	RDMA mailing list

On Thu, Dec 31, 2020 at 09:18:52AM -0700, David Ahern wrote:
> On 12/30/20 10:42 PM, Leon Romanovsky wrote:
> > diff --git a/rdma/utils.c b/rdma/utils.c
> > index 2a201aa4..927e2107 100644
> > --- a/rdma/utils.c
> > +++ b/rdma/utils.c
> > @@ -664,7 +664,7 @@ void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags)
> >
> >  int rd_send_msg(struct rd *rd)
> >  {
> > -	int ret;
> > +	int ret, one;
> >
> >  	rd->nl = mnl_socket_open(NETLINK_RDMA);
> >  	if (!rd->nl) {
> > @@ -672,6 +672,12 @@ int rd_send_msg(struct rd *rd)
> >  		return -ENODEV;
> >  	}
> >
> > +	ret = mnl_socket_setsockopt(rd->nl, NETLINK_EXT_ACK, &one, sizeof(one));
> > +	if (ret < 0) {
> > +		pr_err("Failed to set socket option with err %d\n", ret);
> > +		goto err;
> > +	}
> > +
> >  	ret = mnl_socket_bind(rd->nl, 0, MNL_SOCKET_AUTOPID);
> >  	if (ret < 0) {
> >  		pr_err("Failed to bind socket with err %d\n", ret);
>
> you should be able to use mnlu_socket_open in ./lib/mnl_utils.c

Thanks, I'll change.

>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-03  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31  5:42 [PATCH iproute2-next] rdma: Add support for the netlink extack Leon Romanovsky
2020-12-31 16:18 ` David Ahern
2021-01-03  5:56   ` Leon Romanovsky

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).