diff options
author | Sean Hefty <sean.hefty@intel.com> | 2009-11-19 15:55:22 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2009-11-19 15:55:22 -0500 |
commit | 6266ed6e4164466177238b11ecb825a3a108a3e4 (patch) | |
tree | 6960dcaeb66aa368b8e856022b8aafb81b255428 /drivers/infiniband | |
parent | e2e626972e652d18520f84d69fc06cfa307d11ff (diff) |
RDMA/cma: Replace net_device pointer with index
Provide the device interface when resolving route information to
ensure that the correct outbound device is used. This will also
simplify processing of sin6_scope_id for IPv6 support.
Based on work from:
David Wilder <dwilder@us.ibm.com>
Jason Gunthorpe <jgunthrope@obsidianresearch.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/addr.c | 14 | ||||
-rw-r--r-- | drivers/infiniband/core/cma.c | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index 373f1118d57b..788a02ef01dd 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c | |||
@@ -107,7 +107,7 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev, | |||
107 | memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN); | 107 | memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN); |
108 | if (dst_dev_addr) | 108 | if (dst_dev_addr) |
109 | memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN); | 109 | memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN); |
110 | dev_addr->src_dev = dev; | 110 | dev_addr->bound_dev_if = dev->ifindex; |
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
113 | EXPORT_SYMBOL(rdma_copy_addr); | 113 | EXPORT_SYMBOL(rdma_copy_addr); |
@@ -117,6 +117,15 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr) | |||
117 | struct net_device *dev; | 117 | struct net_device *dev; |
118 | int ret = -EADDRNOTAVAIL; | 118 | int ret = -EADDRNOTAVAIL; |
119 | 119 | ||
120 | if (dev_addr->bound_dev_if) { | ||
121 | dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if); | ||
122 | if (!dev) | ||
123 | return -ENODEV; | ||
124 | ret = rdma_copy_addr(dev_addr, dev, NULL); | ||
125 | dev_put(dev); | ||
126 | return ret; | ||
127 | } | ||
128 | |||
120 | switch (addr->sa_family) { | 129 | switch (addr->sa_family) { |
121 | case AF_INET: | 130 | case AF_INET: |
122 | dev = ip_dev_find(&init_net, | 131 | dev = ip_dev_find(&init_net, |
@@ -231,6 +240,8 @@ static int addr4_resolve_remote(struct sockaddr_in *src_in, | |||
231 | memset(&fl, 0, sizeof fl); | 240 | memset(&fl, 0, sizeof fl); |
232 | fl.nl_u.ip4_u.daddr = dst_ip; | 241 | fl.nl_u.ip4_u.daddr = dst_ip; |
233 | fl.nl_u.ip4_u.saddr = src_ip; | 242 | fl.nl_u.ip4_u.saddr = src_ip; |
243 | fl.oif = addr->bound_dev_if; | ||
244 | |||
234 | ret = ip_route_output_key(&init_net, &rt, &fl); | 245 | ret = ip_route_output_key(&init_net, &rt, &fl); |
235 | if (ret) | 246 | if (ret) |
236 | goto out; | 247 | goto out; |
@@ -279,6 +290,7 @@ static int addr6_resolve_remote(struct sockaddr_in6 *src_in, | |||
279 | memset(&fl, 0, sizeof fl); | 290 | memset(&fl, 0, sizeof fl); |
280 | fl.nl_u.ip6_u.daddr = dst_in->sin6_addr; | 291 | fl.nl_u.ip6_u.daddr = dst_in->sin6_addr; |
281 | fl.nl_u.ip6_u.saddr = src_in->sin6_addr; | 292 | fl.nl_u.ip6_u.saddr = src_in->sin6_addr; |
293 | fl.oif = addr->bound_dev_if; | ||
282 | 294 | ||
283 | dst = ip6_route_output(&init_net, NULL, &fl); | 295 | dst = ip6_route_output(&init_net, NULL, &fl); |
284 | if (!dst) | 296 | if (!dst) |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 052b4c01745d..699ad12b3a2f 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -2820,7 +2820,7 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id | |||
2820 | 2820 | ||
2821 | dev_addr = &id_priv->id.route.addr.dev_addr; | 2821 | dev_addr = &id_priv->id.route.addr.dev_addr; |
2822 | 2822 | ||
2823 | if ((dev_addr->src_dev == ndev) && | 2823 | if ((dev_addr->bound_dev_if == ndev->ifindex) && |
2824 | memcmp(dev_addr->src_dev_addr, ndev->dev_addr, ndev->addr_len)) { | 2824 | memcmp(dev_addr->src_dev_addr, ndev->dev_addr, ndev->addr_len)) { |
2825 | printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n", | 2825 | printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n", |
2826 | ndev->name, &id_priv->id); | 2826 | ndev->name, &id_priv->id); |