From: NeilBrown Date: Mon, 23 May 2011 12:23:51 +0000 (-0400) Subject: supress socket error when address family is not supported X-Git-Tag: nfs-utils-1-2-4-rc9~10 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=27dcd8a775024160e741cce53e4a402eaac3501d;p=nfs-utils.git supress socket error when address family is not supported From: Suresh Jayaraman It was observed that when ipv6 module was not loaded and cannot be auto-loaded, when starting NFS server, the following error occurs: "rpc.nfsd: unable to create inet6 TCP socket: errno 97 (Address family not supported by protocol)" This is obviously a true message, but does not represent an "error" when ipv6 is not enabled. Rather, it is an expected condition. As such, it can be confusing / misleading / distracting to display it in this scenario. This patch instead of throwing error when a socket call fails with EAFNOSUPPORT, makes it as a NOTICE. Signed-off-by: Suresh Jayaraman Signed-off-by: Neil Brown Signed-off-by: Steve Dickson --- diff --git a/utils/nfsd/nfssvc.c b/utils/nfsd/nfssvc.c index ea36399..f607214 100644 --- a/utils/nfsd/nfssvc.c +++ b/utils/nfsd/nfssvc.c @@ -174,8 +174,13 @@ nfssvc_setfds(const struct addrinfo *hints, const char *node, const char *port) sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); if (sockfd < 0) { - xlog(L_ERROR, "unable to create %s %s socket: " - "errno %d (%m)", family, proto, errno); + if (errno == EAFNOSUPPORT) + xlog(L_NOTICE, "address family %s not " + "supported by protocol %s", + family, proto); + else + xlog(L_ERROR, "unable to create %s %s socket: " + "errno %d (%m)", family, proto, errno); rc = errno; goto error; }