Commit 08ad3040 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

sock: set IPv6_V6ONLY on IPv6 sockets



This allows listening on the same port on IPv4 and IPv6 simultaneously;
otherwise, the second listen call would fail with an "address in use"
error.

Change-Id: I75010a2d1ec6559653e0bda40517dc13d8f5b9a5
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/401718


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent ad14da9e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -227,6 +227,15 @@ retry:
			continue;
		}

		if (res->ai_family == AF_INET6) {
			rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof val);
			if (rc != 0) {
				close(fd);
				/* error */
				continue;
			}
		}

		if (type == SPDK_SOCK_CREATE_LISTEN) {
			rc = bind(fd, res->ai_addr, res->ai_addrlen);
			if (rc != 0) {