From: shefty Date: Wed, 11 Mar 2009 21:37:05 +0000 (+0000) Subject: libibverbs/examples: fix IPv6 support X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=8f4ab838fe32dd9903ba4a6f39f4dea9b5c38ae2;p=~shefty%2Frdma-win.git libibverbs/examples: fix IPv6 support Allow servers to accept connections from IPv4 and IPv6 clients. Fix based on patch provided by Leonid. Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@2023 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/ulp/libibverbs/examples/rc_pingpong/rc_pingpong.c b/trunk/ulp/libibverbs/examples/rc_pingpong/rc_pingpong.c index 7281e8a8..5f9511aa 100644 --- a/trunk/ulp/libibverbs/examples/rc_pingpong/rc_pingpong.c +++ b/trunk/ulp/libibverbs/examples/rc_pingpong/rc_pingpong.c @@ -207,8 +207,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, for (t = res; t; t = t->ai_next) { sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); if (sockfd != INVALID_SOCKET) { + n = 0; + setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &n, sizeof n); n = 1; - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof n); if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) diff --git a/trunk/ulp/libibverbs/examples/srq_pingpong/srq_pingpong.c b/trunk/ulp/libibverbs/examples/srq_pingpong/srq_pingpong.c index a789275d..36446aa8 100644 --- a/trunk/ulp/libibverbs/examples/srq_pingpong/srq_pingpong.c +++ b/trunk/ulp/libibverbs/examples/srq_pingpong/srq_pingpong.c @@ -248,9 +248,10 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, for (t = res; t; t = t->ai_next) { sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); if (sockfd >= 0) { + n = 0; + setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &n, sizeof n); n = 1; - - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n); + setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof n); if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) break; diff --git a/trunk/ulp/libibverbs/examples/uc_pingpong/uc_pingpong.c b/trunk/ulp/libibverbs/examples/uc_pingpong/uc_pingpong.c index b292c5fc..d17559c1 100644 --- a/trunk/ulp/libibverbs/examples/uc_pingpong/uc_pingpong.c +++ b/trunk/ulp/libibverbs/examples/uc_pingpong/uc_pingpong.c @@ -194,8 +194,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, for (t = res; t; t = t->ai_next) { sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); if (sockfd != INVALID_SOCKET) { + n = 0; + setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &n, sizeof n); n = 1; - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof n); if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) diff --git a/trunk/ulp/libibverbs/examples/ud_pingpong/ud_pingpong.c b/trunk/ulp/libibverbs/examples/ud_pingpong/ud_pingpong.c index 831f7d0b..f3e73f7e 100644 --- a/trunk/ulp/libibverbs/examples/ud_pingpong/ud_pingpong.c +++ b/trunk/ulp/libibverbs/examples/ud_pingpong/ud_pingpong.c @@ -195,8 +195,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx, for (t = res; t; t = t->ai_next) { sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol); if (sockfd != INVALID_SOCKET) { + n = 0; + setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &n, sizeof n); n = 1; - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof n); if (!bind(sockfd, t->ai_addr, t->ai_addrlen))