]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
rdma: Relax requirement to have PID for HW objects
authorLeon Romanovsky <leonro@mellanox.com>
Wed, 2 Oct 2019 13:49:34 +0000 (16:49 +0300)
committerDavid Ahern <dsahern@kernel.org>
Mon, 7 Oct 2019 21:54:30 +0000 (21:54 +0000)
RDMA has weak connection between PIDs and HW objects, because
the latter tied to file descriptors for their lifetime management.

The outcome of such connection is that for the following scenario,
the returned PID will be 0 (not-valid):
 1. Create FD and context
 2. Share it with ephemeral child
 3. Create any object and exit that child

This flow was revealed in testing environment and of course real users
are not running such scenario, because it makes no sense at all in RDMA
world.

Let's do two changes in the code to support such workflow anyway:
 1. Remove need to provide PID/kernel name. Code already supports it,
    just need to remove extra validation.
 2. Ball-out in case PID is 0.

Link: https://lore.kernel.org/linux-rdma/20191002123245.18153-2-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
rdma/res-cmid.c
rdma/res-cq.c
rdma/res-mr.c
rdma/res-pd.c
rdma/res-qp.c
rdma/res.c

index 0b8300880a207d6d4a7a5a6dc2eb714fd7805f52..0ee9c3d4e5af75a8eb9549fce6049f2892f90c07 100644 (file)
@@ -120,11 +120,8 @@ static int res_cm_id_line(struct rd *rd, const char *name, int idx,
        char *comm = NULL;
 
        if (!nla_line[RDMA_NLDEV_ATTR_RES_STATE] ||
-           !nla_line[RDMA_NLDEV_ATTR_RES_PS] ||
-           (!nla_line[RDMA_NLDEV_ATTR_RES_PID] &&
-            !nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])) {
+           !nla_line[RDMA_NLDEV_ATTR_RES_PS])
                return MNL_CB_ERROR;
-       }
 
        if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX])
                port = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_PORT_INDEX]);
index d2591fbebfb5289d41c55196475ad8c4bc9d297e..6855e7981ffc17f345fc8fad297f3cf594d5637b 100644 (file)
@@ -56,11 +56,8 @@ static int res_cq_line(struct rd *rd, const char *name, int idx,
        uint32_t cqe;
 
        if (!nla_line[RDMA_NLDEV_ATTR_RES_CQE] ||
-           !nla_line[RDMA_NLDEV_ATTR_RES_USECNT] ||
-           (!nla_line[RDMA_NLDEV_ATTR_RES_PID] &&
-            !nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])) {
+           !nla_line[RDMA_NLDEV_ATTR_RES_USECNT])
                return MNL_CB_ERROR;
-       }
 
        cqe = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_CQE]);
 
index f4a24dc1e7cf4e794d28e1af8365859b4afcfb49..c1b8069abbfeaa72e4a5c52c0516e37133fce388 100644 (file)
@@ -17,11 +17,8 @@ static int res_mr_line(struct rd *rd, const char *name, int idx,
        uint32_t mrn = 0;
        uint32_t pid = 0;
 
-       if (!nla_line[RDMA_NLDEV_ATTR_RES_MRLEN] ||
-           (!nla_line[RDMA_NLDEV_ATTR_RES_PID] &&
-            !nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])) {
+       if (!nla_line[RDMA_NLDEV_ATTR_RES_MRLEN])
                return MNL_CB_ERROR;
-       }
 
        if (nla_line[RDMA_NLDEV_ATTR_RES_RKEY])
                rkey = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_RKEY]);
index 07c836e86d4ebac677b211460fe2e34f48c48bab..6e5e4e6b8fb87cc0a185ee9d33670d1cdb5ea3f6 100644 (file)
@@ -17,11 +17,8 @@ static int res_pd_line(struct rd *rd, const char *name, int idx,
        uint32_t pdn = 0;
        uint64_t users;
 
-       if (!nla_line[RDMA_NLDEV_ATTR_RES_USECNT] ||
-           (!nla_line[RDMA_NLDEV_ATTR_RES_PID] &&
-            !nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])) {
+       if (!nla_line[RDMA_NLDEV_ATTR_RES_USECNT])
                return MNL_CB_ERROR;
-       }
 
        if (nla_line[RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY])
                local_dma_lkey = mnl_attr_get_u32(
index 954e465de6fd6a5343c06698e093a38c51213e8d..e30d68edc7d8461e0ba853f2cc17d7c85b350189 100644 (file)
@@ -90,11 +90,8 @@ static int res_qp_line(struct rd *rd, const char *name, int idx,
        if (!nla_line[RDMA_NLDEV_ATTR_RES_LQPN] ||
            !nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN] ||
            !nla_line[RDMA_NLDEV_ATTR_RES_TYPE] ||
-           !nla_line[RDMA_NLDEV_ATTR_RES_STATE] ||
-           (!nla_line[RDMA_NLDEV_ATTR_RES_PID] &&
-            !nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])) {
+           !nla_line[RDMA_NLDEV_ATTR_RES_STATE])
                return MNL_CB_ERROR;
-       }
 
        if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX])
                port = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_PORT_INDEX]);
index 6003006e98aa43ca32a481240d541f84bbf9c809..e8607808155afe24e4c1a391aed6d7dd3be37668 100644 (file)
@@ -211,6 +211,9 @@ char *get_task_name(uint32_t pid)
        char *comm;
        FILE *f;
 
+       if (!pid)
+               return NULL;
+
        if (asprintf(&comm, "/proc/%d/comm", pid) < 0)
                return NULL;