Commit e83915d1 authored by Simon Kelley's avatar Simon Kelley

Set V6ONLY on DNS upstream socket.

If query-port is set, we create sockets bound to the wildcard address and the query port for
IPv4 and IPv6, but the IPv6 one fails, because is covers IPv4 as well, and an IPv4 socket
already exists (it gets created first). Set V6ONLY to avoid this.
parent 6d37924b
...@@ -1234,7 +1234,8 @@ static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname) ...@@ -1234,7 +1234,8 @@ static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname)
struct serverfd *sfd; struct serverfd *sfd;
unsigned int ifindex = 0; unsigned int ifindex = 0;
int errsave; int errsave;
int opt = 1;
/* when using random ports, servers which would otherwise use /* when using random ports, servers which would otherwise use
the INADDR_ANY/port0 socket have sfd set to NULL */ the INADDR_ANY/port0 socket have sfd set to NULL */
if (!daemon->osport && intname[0] == 0) if (!daemon->osport && intname[0] == 0)
...@@ -1274,10 +1275,11 @@ static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname) ...@@ -1274,10 +1275,11 @@ static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname)
free(sfd); free(sfd);
return NULL; return NULL;
} }
if (!local_bind(sfd->fd, addr, intname, ifindex, 0) || !fix_fd(sfd->fd)) if ((addr->sa.sa_family == AF_INET6 && setsockopt(sfd->fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)) == -1) ||
!local_bind(sfd->fd, addr, intname, ifindex, 0) || !fix_fd(sfd->fd))
{ {
errsave = errno; /* save error from bind. */ errsave = errno; /* save error from bind/setsockopt. */
close(sfd->fd); close(sfd->fd);
free(sfd); free(sfd);
errno = errsave; errno = errsave;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment