IPv6 sockets for knfsd can't be allowed to accept IPv4 packets. Set the correct option to prevent it. Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx> --- support/nfs/nfssvc.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/support/nfs/nfssvc.c b/support/nfs/nfssvc.c index c2c5480..b14d37d 100644 --- a/support/nfs/nfssvc.c +++ b/support/nfs/nfssvc.c @@ -60,18 +60,26 @@ nfssvc_setfds(unsigned int ctlbits, struct sockaddr *sa, socklen_t addrlen) int fd, on = 1; char buf[BUFSIZ]; int udpfd = -1, tcpfd = -1; + unsigned short family = sa->sa_family; fd = open(NFSD_PORTS_FILE, O_WRONLY); if (fd < 0) return; if (NFSCTL_UDPISSET(ctlbits)) { - udpfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + udpfd = socket(family, SOCK_DGRAM, IPPROTO_UDP); if (udpfd < 0) { syslog(LOG_ERR, "nfssvc: unable to create UDP socket: " "errno %d (%s)\n", errno, strerror(errno)); exit(1); } + if (family == AF_INET6 && setsockopt(udpfd, IPPROTO_IPV6, + IPV6_V6ONLY, &on, + sizeof(on))) { + syslog(LOG_ERR, "nfssvc: unable to set IPV6_V6ONLY: " + "errno %d (%s)\n", errno, strerror(errno)); + exit(1); + } if (bind(udpfd, sa, addrlen) < 0) { syslog(LOG_ERR, "nfssvc: unable to bind UDP socket: " "errno %d (%s)\n", errno, strerror(errno)); @@ -80,7 +88,7 @@ nfssvc_setfds(unsigned int ctlbits, struct sockaddr *sa, socklen_t addrlen) } if (NFSCTL_TCPISSET(ctlbits)) { - tcpfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + tcpfd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (tcpfd < 0) { syslog(LOG_ERR, "nfssvc: unable to create TCP socket: " "errno %d (%s)\n", errno, strerror(errno)); @@ -91,6 +99,14 @@ nfssvc_setfds(unsigned int ctlbits, struct sockaddr *sa, socklen_t addrlen) "errno %d (%s)\n", errno, strerror(errno)); exit(1); } + if (family == AF_INET6 && setsockopt(tcpfd, IPPROTO_IPV6, + IPV6_V6ONLY, &on, + sizeof(on))) { + syslog(LOG_ERR, "nfssvc: unable to set IPV6_V6ONLY: " + "errno %d (%s)\n", errno, strerror(errno)); + exit(1); + } + if (bind(tcpfd, sa, addrlen) < 0) { syslog(LOG_ERR, "nfssvc: unable to bind TCP socket: " "errno %d (%s)\n", errno, strerror(errno)); -- 1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html