[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: defaulting to net.ipv6.bindv6only=1 for squeeze



Na grupie linux.debian.devel napisałe(a)ś:
>
> I have failures now with a client that cannot connect() to the IPv4 address 
> but get an ENETUNREACH instead.
> The application DOES set this socket option:
> socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
                                ^-- You meant IPPROTO_TCP?
> setsockopt(3, SOL_IPV6, IPV6_V6ONLY, [0], 4) = 0
> bind(3, {sa_family=AF_INET6,....) = 0
> listen(3, ....) = 0
>
> Did you ever test that "setting this option back to 0 by a program before 
> bind() and listen()" actually works?

Yes. Following code actually works (runs with bindv6only enabled,
listens on [::]:1234 and accepts connection made to localhost:1234):
#v+
#include <sys/socket.h>
#include <netinet/in.h>

int main ()
{
	int no = 0;
	int listenfd = socket (AF_INET6, SOCK_STREAM, IPPROTO_TCP);
	int clientfd;
	char buf[1024];
	ssize_t rv;
	struct sockaddr_in6 addr = { AF_INET6, htons(1234), 0, IN6ADDR_ANY_INIT };
	setsockopt (listenfd, SOL_IPV6, IPV6_V6ONLY, &no, sizeof(no));
	bind (listenfd, (void*)&addr, sizeof(addr));
	listen (listenfd, 1);
	clientfd = accept (listenfd, 0, 0);
	while ((rv = read (clientfd, buf, sizeof(buf))) > 0)
		write (1, buf, rv);
	return 0;
}
#v-

> Reverting your change fixes this.

If something doesn't work with bindv6only enabled, it's broken.

Jarek.


Reply to: