[ofa-general] IPv6 RDMA CM PATCHv2 5/8

Hefty, Sean sean.hefty at intel.com
Mon Aug 11 12:27:17 PDT 2008


> drivers/infiniband/core/cma.c |   75 +++++++++++++++++++++++++++++------------
> 1 files changed, 53 insertions(+), 22 deletions(-)
>
>diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>index 4728265..ec0855f 100644
>--- a/drivers/infiniband/core/cma.c
>+++ b/drivers/infiniband/core/cma.c
>@@ -2113,32 +2113,63 @@ EXPORT_SYMBOL(rdma_bind_addr);
> static int cma_format_hdr(void *hdr, enum rdma_port_space ps,
>                          struct rdma_route *route)
> {
>-       struct sockaddr_in *src4, *dst4;
>        struct cma_hdr *cma_hdr;
>        struct sdp_hh *sdp_hdr;
>
>-       src4 = (struct sockaddr_in *) &route->addr.src_addr;
>-       dst4 = (struct sockaddr_in *) &route->addr.dst_addr;
>-
>-       switch (ps) {
>-       case RDMA_PS_SDP:
>-               sdp_hdr = hdr;
>-               if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION)
>-                       return -EINVAL;
>-               sdp_set_ip_ver(sdp_hdr, 4);
>-               sdp_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
>-               sdp_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
>-               sdp_hdr->port = src4->sin_port;
>-               break;
>-       default:
>-               cma_hdr = hdr;
>-               cma_hdr->cma_version = CMA_VERSION;
>-               cma_set_ip_ver(cma_hdr, 4);
>-               cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
>-               cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
>-               cma_hdr->port = src4->sin_port;
>-               break;
>+       if (route->addr.src_addr.ss_family == AF_INET) {
>+               struct sockaddr_in *src4, *dst4;
>+
>+               src4 = (struct sockaddr_in *) &route->addr.src_addr;
>+               dst4 = (struct sockaddr_in *) &route->addr.dst_addr;
>+
>+               switch (ps) {
>+               case RDMA_PS_SDP:
>+                       sdp_hdr = hdr;
>+                       if (sdp_get_majv(sdp_hdr->sdp_version) !=
>SDP_MAJ_VERSION)
>+                               return -EINVAL;
>+                       sdp_set_ip_ver(sdp_hdr, 4);
>+                       sdp_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
>+                       sdp_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
>+                       sdp_hdr->port = src4->sin_port;
>+                       break;
>+               default:
>+                       cma_hdr = hdr;
>+                       cma_hdr->cma_version = CMA_VERSION;
>+                       cma_set_ip_ver(cma_hdr, 4);
>+                       cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
>+                       cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
>+                       cma_hdr->port = src4->sin_port;
>+                       break;
>+               }
>+       } else if (route->addr.src_addr.ss_family == AF_INET6) {

I think this can just be 'else', since we've checked the address family elsewhere.

>+               struct sockaddr_in6 *src6, *dst6;
>+
>+               src6 = (struct sockaddr_in6 *) &route->addr.src_addr;
>+               dst6 = (struct sockaddr_in6 *) &route->addr.dst_addr;
>+
>+               switch (ps) {
>+               case RDMA_PS_SDP:
>+                       sdp_hdr = hdr;
>+                       if (sdp_get_majv(sdp_hdr->sdp_version) !=
>SDP_MAJ_VERSION)
>+                          return -EINVAL;
>+                       sdp_set_ip_ver(sdp_hdr, 6);
>+                       sdp_hdr->src_addr.ip6 = src6->sin6_addr;
>+                       sdp_hdr->dst_addr.ip6 = dst6->sin6_addr;
>+                       sdp_hdr->port = src6->sin6_port;
>+                       break;
>+               default:
>+                       cma_hdr = hdr;
>+                       cma_hdr->cma_version = CMA_VERSION;
>+                       cma_set_ip_ver(cma_hdr, 6);
>+                       cma_hdr->src_addr.ip6 = src6->sin6_addr;
>+                       cma_hdr->dst_addr.ip6 = dst6->sin6_addr;
>+                       cma_hdr->port = src6->sin6_port;
>+                       break;
>        }
>+               return 0;
>+       } else
>+               return -EAFNOSUPPORT;
>+
>        return 0;

Converting the first else will fix this, but the spacing is off here, and the first 'return 0' isn't needed.

- Sean



More information about the general mailing list