Bug 1609

Summary: inetd should add IPV6_V6ONLY option to IPv6 socket
Product: Busybox Reporter: AFu Lai <lai.chunfu>
Component: NetworkingAssignee: unassigned
Status: RESOLVED WONTFIX    
Severity: minor CC: busybox-cvs
Priority: P5 Keywords: patch
Version: 1.16.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description AFu Lai 2010-04-22 03:22:54 UTC
I can't open IPv4 and IPv6 listens at the same time due to the fault of 'bind' function. Does anyone want to use IPv4 mapped address? Can we set IPV6_V6ONLY option to IPv6 socket with some conditions?
In my case, IPV6_V6ONLY is normally set.

----
#if ENABLE_FEATURE_IPV6
		if (sep->se_family == AF_INET6) {	// AFU patched
			int v6only = 1;
			setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only));
		}
#endif
		r = bind(fd, &sep->se_lsa->u.sa, sep->se_lsa->len);
Comment 1 Denys Vlasenko 2010-05-18 23:03:26 UTC
There is a workaround which might be enough. If you bind to a local address, then depending on address family you are getting bound to IPv6 only or IPv4 only:

# nc -vvv -l -s ::1 -p123
listening on [::1]:123 ...

Above: I created an IPv6 listening socket on loopback. Now, in another xterm:

# nc -vvv -l -s 127.0.0.1 -p123
listening on 127.0.0.1:123 ...

I can create an IPv4 listening socket on loopback on the same port, and they happily coexist.

If I omit "-s ::1", then second nc complains: "nc: bind: Address already in use"


The same idea works for inetd. You need to use address prefix syntax on conf file:

::1:123 stream tcp6 nowait root echo echo Hello IPv6 localhost
Comment 2 Denys Vlasenko 2010-08-30 23:07:35 UTC
Closing it as "wontfix" under assumption the described workaround works for you. If you still need this, please reopen.