[openib-general] [PATCH] cma: fix bind to ip
Michael S. Tsirkin
mst at mellanox.co.il
Thu May 18 06:36:27 PDT 2006
Fix private data format for bind to specific IP for SDP.
Further, CMA format mask for IPv6 was set incorrectly (hint -
memset(foo, 1, bar) does not set memory to all-ones) so fix that.
Signed-off-by: Ali Ayoub <ali at mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>
Index: linux-2.6.16/drivers/infiniband/core/cma.c
===================================================================
--- linux-2.6.16.orig/drivers/infiniband/core/cma.c 2006-05-18 13:36:23.000000000 +0300
+++ linux-2.6.16/drivers/infiniband/core/cma.c 2006-05-18 13:47:59.000000000 +0300
@@ -930,29 +930,50 @@ static __be64 cma_get_service_id(enum rd
be16_to_cpu(((struct sockaddr_in *) addr)->sin_port));
}
-static void cma_set_compare_data(struct sockaddr *addr,
+static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
struct ib_cm_compare_data *compare)
{
- struct cma_hdr *data, *mask;
+ struct cma_hdr *cma_data, *cma_mask;
+ struct sdp_hh *sdp_data, *sdp_mask;
+ __u32 ip4_addr;
+ struct in6_addr ip6_addr;
memset(compare, 0, sizeof *compare);
- data = (void *) compare->data;
- mask = (void *) compare->mask;
+ cma_data = (void *)compare->data;
+ cma_mask = (void *)compare->mask;
+ sdp_data = (void *)compare->data;
+ sdp_mask = (void *)compare->mask;
switch (addr->sa_family) {
case AF_INET:
- cma_set_ip_ver(data, 4);
- cma_set_ip_ver(mask, 0xF);
- data->dst_addr.ip4.addr = ((struct sockaddr_in *) addr)->
- sin_addr.s_addr;
- mask->dst_addr.ip4.addr = ~0;
+ ip4_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
+ if (ps == RDMA_PS_SDP) {
+ sdp_set_ip_ver(sdp_data, 4);
+ sdp_set_ip_ver(sdp_mask, 0xF);
+ sdp_data->dst_addr.ip4.addr = ip4_addr;
+ sdp_mask->dst_addr.ip4.addr = ~0;
+ } else {
+ cma_set_ip_ver(cma_data, 4);
+ cma_set_ip_ver(cma_mask, 0xF);
+ cma_data->dst_addr.ip4.addr = ip4_addr;
+ cma_mask->dst_addr.ip4.addr = ~0;
+ }
break;
case AF_INET6:
- cma_set_ip_ver(data, 6);
- cma_set_ip_ver(mask, 0xF);
- data->dst_addr.ip6 = ((struct sockaddr_in6 *) addr)->
- sin6_addr;
- memset(&mask->dst_addr.ip6, 1, sizeof mask->dst_addr.ip6);
+ ip6_addr = ((struct sockaddr_in6 *)addr)->sin6_addr;
+ if (ps == RDMA_PS_SDP) {
+ sdp_set_ip_ver(sdp_data, 6);
+ sdp_set_ip_ver(sdp_mask, 0xF);
+ sdp_data->dst_addr.ip6 = ip6_addr;
+ memset(&sdp_mask->dst_addr.ip6, 0xFF,
+ sizeof sdp_mask->dst_addr.ip6);
+ } else {
+ cma_set_ip_ver(cma_data, 6);
+ cma_set_ip_ver(cma_mask, 0xF);
+ cma_data->dst_addr.ip6 = ip6_addr;
+ memset(&cma_mask->dst_addr.ip6, 0xFF,
+ sizeof cma_mask->dst_addr.ip6);
+ }
break;
default:
break;
@@ -976,7 +997,7 @@ static int cma_ib_listen(struct rdma_id_
if (cma_any_addr(addr))
ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, NULL);
else {
- cma_set_compare_data(addr, &compare_data);
+ cma_set_compare_data(id_priv->id.ps, addr, &compare_data);
ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, &compare_data);
}
--
MST
More information about the general
mailing list