RDMA/siw: Make node GUIDs valid EUI-64 identifiers
authorBart Van Assche <bvanassche@acm.org>
Mon, 30 Sep 2019 23:16:57 +0000 (16:16 -0700)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 4 Oct 2019 18:35:05 +0000 (15:35 -0300)
>From the IBTA: "GUID (Global Unique Identifier): A globally unique EUI-64
compliant identifier." Make sure that siw GUIDs are valid EUI-64 identifiers.

Link: https://lore.kernel.org/r/20190930231707.48259-6-bvanassche@acm.org
Cc: Bernard Metzler <bmt@zurich.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/sw/siw/siw_main.c

index 05a92f997f603bfbc64138ae2bdda31486baa36c..d1a1b7aa7d83af726c57d4c730c9086f9e3dcd9b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
 
+#include <net/addrconf.h>
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_user_verbs.h>
 #include <rdma/rdma_netlink.h>
@@ -350,15 +351,19 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
        sdev->netdev = netdev;
 
        if (netdev->type != ARPHRD_LOOPBACK) {
-               memcpy(&base_dev->node_guid, netdev->dev_addr, 6);
+               addrconf_addr_eui48((unsigned char *)&base_dev->node_guid,
+                                   netdev->dev_addr);
        } else {
                /*
                 * The loopback device does not have a HW address,
                 * but connection mangagement lib expects gid != 0
                 */
-               size_t gidlen = min_t(size_t, strlen(base_dev->name), 6);
+               size_t len = min_t(size_t, strlen(base_dev->name), 6);
+               char addr[6] = { };
 
-               memcpy(&base_dev->node_guid, base_dev->name, gidlen);
+               memcpy(addr, base_dev->name, len);
+               addrconf_addr_eui48((unsigned char *)&base_dev->node_guid,
+                                   addr);
        }
        base_dev->uverbs_cmd_mask =
                (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |