diff options
author | Sean Hefty <sean.hefty@intel.com> | 2013-05-29 13:09:15 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-06-20 16:08:04 -0400 |
commit | b0569e40753aa4f742cfd792447a093ab7937563 (patch) | |
tree | 2e7c67e3f6a10845646dd27af55f0bf7a58a2e8b /drivers/infiniband | |
parent | f4753834b5d06cae9a1d5453c96760571876a014 (diff) |
RDMA/cma: Restrict AF_IB loopback to binding to IB devices only
If a user specifies AF_IB as the source address for a loopback
connection, limit the resolution to IB devices only.
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/cma.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 90694530757a..524cf986d9fa 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -1981,26 +1981,38 @@ static void cma_set_loopback(struct sockaddr *addr) | |||
1981 | 1981 | ||
1982 | static int cma_bind_loopback(struct rdma_id_private *id_priv) | 1982 | static int cma_bind_loopback(struct rdma_id_private *id_priv) |
1983 | { | 1983 | { |
1984 | struct cma_device *cma_dev; | 1984 | struct cma_device *cma_dev, *cur_dev; |
1985 | struct ib_port_attr port_attr; | 1985 | struct ib_port_attr port_attr; |
1986 | union ib_gid gid; | 1986 | union ib_gid gid; |
1987 | u16 pkey; | 1987 | u16 pkey; |
1988 | int ret; | 1988 | int ret; |
1989 | u8 p; | 1989 | u8 p; |
1990 | 1990 | ||
1991 | cma_dev = NULL; | ||
1991 | mutex_lock(&lock); | 1992 | mutex_lock(&lock); |
1992 | if (list_empty(&dev_list)) { | 1993 | list_for_each_entry(cur_dev, &dev_list, list) { |
1994 | if (cma_family(id_priv) == AF_IB && | ||
1995 | rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB) | ||
1996 | continue; | ||
1997 | |||
1998 | if (!cma_dev) | ||
1999 | cma_dev = cur_dev; | ||
2000 | |||
2001 | for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { | ||
2002 | if (!ib_query_port(cur_dev->device, p, &port_attr) && | ||
2003 | port_attr.state == IB_PORT_ACTIVE) { | ||
2004 | cma_dev = cur_dev; | ||
2005 | goto port_found; | ||
2006 | } | ||
2007 | } | ||
2008 | } | ||
2009 | |||
2010 | if (!cma_dev) { | ||
1993 | ret = -ENODEV; | 2011 | ret = -ENODEV; |
1994 | goto out; | 2012 | goto out; |
1995 | } | 2013 | } |
1996 | list_for_each_entry(cma_dev, &dev_list, list) | ||
1997 | for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p) | ||
1998 | if (!ib_query_port(cma_dev->device, p, &port_attr) && | ||
1999 | port_attr.state == IB_PORT_ACTIVE) | ||
2000 | goto port_found; | ||
2001 | 2014 | ||
2002 | p = 1; | 2015 | p = 1; |
2003 | cma_dev = list_entry(dev_list.next, struct cma_device, list); | ||
2004 | 2016 | ||
2005 | port_found: | 2017 | port_found: |
2006 | ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid); | 2018 | ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid); |