linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rdma: not display the rdma link in other net namespace
@ 2022-09-26  2:40 yanjun.zhu
  2022-09-25 10:22 ` Yanjun Zhu
  2022-09-27 10:34 ` Leon Romanovsky
  0 siblings, 2 replies; 18+ messages in thread
From: yanjun.zhu @ 2022-09-26  2:40 UTC (permalink / raw)
  To: leonro, linux-rdma, jgg, yanjun.zhu

From: Zhu Yanjun <yanjun.zhu@linux.dev>

When the net devices are moved to another net namespace, the command
"rdma link" should not dispaly the rdma link about this net device.

For example, when the net device eno12399 is moved to net namespace net0
from init_net, the rdma link of eno12399 should not display in init_net.

Before this change:

Init_net:

link roceo12399/1 state DOWN physical_state DISABLED  <---should not display
link roceo12409/1 state DOWN physical_state DISABLED netdev eno12409
link rocep202s0f0/1 state DOWN physical_state DISABLED netdev ens7f0
link rocep202s0f1/1 state ACTIVE physical_state LINK_UP netdev ens7f1

net0:

link roceo12399/1 state DOWN physical_state DISABLED netdev eno12399
link roceo12409/1 state DOWN physical_state DISABLED <---should not display
link rocep202s0f0/1 state DOWN physical_state DISABLED <---should not display
link rocep202s0f1/1 state ACTIVE physical_state LINK_UP <---should not display

After this change

Init_net:

link roceo12409/1 state DOWN physical_state DISABLED netdev eno12409
link rocep202s0f0/1 state DOWN physical_state DISABLED netdev ens7f0
link rocep202s0f1/1 state ACTIVE physical_state LINK_UP netdev ens7f1

net0:

link roceo12399/1 state DOWN physical_state DISABLED netdev eno12399

Fixes: da990ab40a92 ("rdma: Add link object")
Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
---
 rdma/link.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rdma/link.c b/rdma/link.c
index bf24b849..449a7636 100644
--- a/rdma/link.c
+++ b/rdma/link.c
@@ -238,6 +238,9 @@ static int link_parse_cb(const struct nlmsghdr *nlh, void *data)
 		return MNL_CB_ERROR;
 	}
 
+	if (!tb[RDMA_NLDEV_ATTR_NDEV_NAME] || !tb[RDMA_NLDEV_ATTR_NDEV_INDEX])
+		return MNL_CB_OK;
+
 	idx = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
 	port = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]);
 	name = mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_DEV_NAME]);
-- 
2.27.0


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

end of thread, other threads:[~2022-10-13  8:30 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-26  2:40 [PATCH] rdma: not display the rdma link in other net namespace yanjun.zhu
2022-09-25 10:22 ` Yanjun Zhu
2022-09-27 10:34 ` Leon Romanovsky
2022-09-27 10:58   ` Yanjun Zhu
2022-09-28  6:04     ` Leon Romanovsky
2022-09-30  7:25       ` Yanjun Zhu
2022-10-06 12:53         ` Leon Romanovsky
2022-10-06 14:26           ` Yanjun Zhu
2022-10-06 16:21             ` Leon Romanovsky
2022-10-06 16:23               ` Jason Gunthorpe
2022-10-07  6:21                 ` Leon Romanovsky
2022-10-07  6:56                   ` Yanjun Zhu
2022-10-11  0:25                   ` [RFC PATCH 1/1] RDMA/core: Fix a problem from rdma link in exclusive mode Zhu Yanjun
2022-10-11 10:12                     ` Leon Romanovsky
2022-10-11 15:08                       ` Yanjun Zhu
2022-10-13  8:30                       ` yanjun.zhu
2022-10-09 10:20     ` [PATCH] rdma: not display the rdma link in other net namespace yanjun.zhu
2022-10-11  9:49       ` 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).