]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
rdma: Add support for the netlink extack
authorPatrisious Haddad <phaddad@nvidia.com>
Sun, 3 Jan 2021 06:17:06 +0000 (08:17 +0200)
committerDavid Ahern <dsahern@kernel.org>
Sun, 10 Jan 2021 17:18:42 +0000 (17:18 +0000)
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>
Signed-off-by: David Ahern <dsahern@kernel.org>
rdma/rdma.h
rdma/utils.c

index fc8bcf09274d09ce466d01027abc6b160fc2c2a1..470e11c8b1a1c84046d04d3a5718fc9683405dc6 100644 (file)
@@ -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)
index 2a201aa4aeb7fa86f78c368ab6ecc0e9a2f2be65..903a544c9b17a147fcda46220e2586976c6de021 100644 (file)
@@ -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;
 }