diff options
author | Bart Van Assche <bvanassche@acm.org> | 2019-09-30 16:16:57 -0700 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-10-04 15:35:05 -0300 |
commit | 934f05b05d73d6c9ad68da66e2fd68abf72d1770 (patch) | |
tree | 0048419f1d98e8d1568da45c4c236ed4c3264faa /drivers/infiniband/sw | |
parent | 30e0f6cf5acb39cd04316d1eecbf4c6087c7ee02 (diff) | |
download | linux-934f05b05d73d6c9ad68da66e2fd68abf72d1770.tar.gz linux-934f05b05d73d6c9ad68da66e2fd68abf72d1770.tar.bz2 linux-934f05b05d73d6c9ad68da66e2fd68abf72d1770.zip |
RDMA/siw: Make node GUIDs valid EUI-64 identifiers
>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>
Diffstat (limited to 'drivers/infiniband/sw')
-rw-r--r-- | drivers/infiniband/sw/siw/siw_main.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c index 05a92f997f60..d1a1b7aa7d83 100644 --- a/drivers/infiniband/sw/siw/siw_main.c +++ b/drivers/infiniband/sw/siw/siw_main.c @@ -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) | |