@@ -324,6 +324,13 @@ static int cma_set_qkey(struct rdma_id_private *id_priv)
return ret;
}
+static void cma_translate_ib(struct sockaddr_ib *addr, struct rdma_dev_addr *dev_addr)
+{
+ dev_addr->dev_type = ARPHRD_INFINIBAND;
+ rdma_addr_set_sgid(dev_addr, (union ib_gid *) &addr->sib_addr);
+ ib_addr_set_pkey(dev_addr, ntohs(addr->sib_pkey));
+}
+
static int cma_acquire_dev(struct rdma_id_private *id_priv)
{
struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
@@ -2148,7 +2155,8 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
struct rdma_id_private *id_priv;
int ret;
- if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6)
+ if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6 &&
+ addr->sa_family != AF_IB)
return -EAFNOSUPPORT;
id_priv = container_of(id, struct rdma_id_private, id);
@@ -2160,9 +2168,14 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
goto err1;
if (!cma_any_addr(addr)) {
- ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
- if (ret)
- goto err1;
+ if (addr->sa_family == AF_IB) {
+ cma_translate_ib((struct sockaddr_ib *) addr,
+ &id->route.addr.dev_addr);
+ } else {
+ ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
+ if (ret)
+ goto err1;
+ }
mutex_lock(&lock);
ret = cma_acquire_dev(id_priv);