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 | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/support/nfs/nfssvc.c b/support/nfs/nfssvc.c index 7634562..2aa5281 100644 --- a/support/nfs/nfssvc.c +++ b/support/nfs/nfssvc.c @@ -60,6 +60,7 @@ nfssvc_setfds(unsigned int ctlbits, struct sockaddr *sa, socklen_t addrlen) int fd, on = 1; char buf[BUFSIZ]; int udpfd = -1, tcpfd = -1, rc = 0; + unsigned short family = sa->sa_family; /* * if file can't be opened, then assume that it's not available and @@ -70,9 +71,19 @@ nfssvc_setfds(unsigned int ctlbits, struct sockaddr *sa, socklen_t addrlen) return 0; 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: " + syslog(LOG_ERR, "nfssvc: unable to create %s UDP " + "socket: errno %d (%s)\n", + family == AF_INET6 ? "ipv6" : "ipv4", errno, + strerror(errno)); + rc = -errno; + goto error; + } + 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)); rc = -errno; goto error; @@ -86,10 +97,12 @@ 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)); + syslog(LOG_ERR, "nfssvc: unable to create %s TCP " + "socket: errno %d (%s)\n", + family == AF_INET6 ? "ipv6" : "ipv4", errno, + strerror(errno)); rc = -errno; goto error; } @@ -99,6 +112,14 @@ nfssvc_setfds(unsigned int ctlbits, struct sockaddr *sa, socklen_t addrlen) rc = -errno; goto error; } + 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