From: Nicholas Bellinger <n...@linux-iscsi.org>

This patch fixes the sport->port_guid formatting code in srpt_add_one() to
properly use sport->gid.global.interface_id instead of device->node_guid w/
a port offset.  This requires using ib_query_gid() from srpt_refresh_port(),
so the sport->port_guid assignment has been moved after srpt_refresh_port().

Reported-by: Bart Van Assche <bvanass...@acm.org>
Cc: Bart Van Assche <bvanass...@acm.org>
Cc: Roland Dreier <rol...@purestorage.com>
Signed-off-by: Nicholas A. Bellinger <n...@linux-iscsi.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c 
b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 6e19816..ae9fd0e 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -3325,17 +3325,14 @@ static void srpt_add_one(struct ib_device *device)
                INIT_LIST_HEAD(&sport->port_acl_list);
                spin_lock_init(&sport->port_acl_lock);
 
-               sprintf(sport->port_guid, "0x0000000000000000%04x%04x%04x%04x",
-                                be16_to_cpu(((__be16 *)&device->node_guid)[0]),
-                                be16_to_cpu(((__be16 *)&device->node_guid)[1]),
-                                be16_to_cpu(((__be16 *)&device->node_guid)[2]),
-                                be16_to_cpu(((__be16 *)&device->node_guid)[3]) 
+ i);
-
                if (srpt_refresh_port(sport)) {
                        printk(KERN_ERR "MAD registration failed for %s-%d.\n",
                               srpt_sdev_name(sdev), i);
                        goto err_ring;
                }
+               snprintf(sport->port_guid, sizeof(sport->port_guid),
+                               "0x0000000000000000%016llx",
+                               be64_to_cpu(sport->gid.global.interface_id));
        }
 
        spin_lock(&srpt_dev_lock);
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to