[rdma-core patch] ibacm: only open InfiniBand port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The low 64 bits of cxgb3 and cxgb4 devices' GID are zeros. If the
"provider" was set in the option file, ibacm will failed with
segment fault.

$ sed -i -e 's/# provider ibacmp 0xFE80000000000000/provider ibacmp 0xFE80000000000000/g' /etc/rdma/ibacm_opts.cfg
$ /usr/sbin/ibacm --systemd
Segmentation fault (core dumped)

acm_open_dev function should not open port for IWARP or ROCE devices.

Signed-off-by: Honggang Li <honli@xxxxxxxxxx>
---
 ibacm/src/acm.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index a21069d4..944cb820 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -2587,7 +2587,7 @@ acm_open_port(struct acmc_port *port, struct acmc_device *dev, uint8_t port_num)
 
 	port->mad_agentid = umad_register(port->mad_portid,
 					  IB_MGMT_CLASS_SA, 1, 1, NULL);
-	if (port->mad_agentid < 0) {
+	if (port->mad_agentid < 0 && port->mad_portid > 0) {
 		umad_close_port(port->mad_portid);
 		acm_log(0, "ERROR - unable to register MAD client\n");
 	}
@@ -2600,6 +2600,7 @@ static void acm_open_dev(struct ibv_device *ibdev)
 {
 	struct acmc_device *dev;
 	struct ibv_device_attr attr;
+	struct ibv_port_attr port_attr;
 	struct ibv_context *verbs;
 	size_t size;
 	int i, ret;
@@ -2628,6 +2629,17 @@ static void acm_open_dev(struct ibv_device *ibdev)
 	list_head_init(&dev->prov_dev_context_list);
 
 	for (i = 0; i < dev->port_cnt; i++) {
+		acm_log(1, "%s %d\n", dev->device.verbs->device->name, i);
+		ret = ibv_query_port(dev->device.verbs, i+1, &port_attr);
+		if (ret) {
+			acm_log(0, "ERROR - unable to query an RDMA port's attributes\n");
+			return;
+		}
+		if (port_attr.link_layer != IBV_LINK_LAYER_INFINIBAND) {
+			acm_log(1, "not an InfiniBand port\n");
+			return;
+		}
+
 		acm_open_port(&dev->port[i], dev, i + 1);
 	}
 
-- 
2.20.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux