From patchwork Mon Dec 7 16:42:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 7788401 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7E3E6BEEE1 for ; Mon, 7 Dec 2015 16:42:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A94C5204B0 for ; Mon, 7 Dec 2015 16:42:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A214D204A7 for ; Mon, 7 Dec 2015 16:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932275AbbLGQmG (ORCPT ); Mon, 7 Dec 2015 11:42:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60485 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932184AbbLGQmF (ORCPT ); Mon, 7 Dec 2015 11:42:05 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 40D8767C20 for ; Mon, 7 Dec 2015 16:42:05 +0000 (UTC) Received: from tonberry.usersys.redhat.com (dhcp145-110.rdu.redhat.com [10.13.145.110]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB7Gg48S008465 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 7 Dec 2015 11:42:04 -0500 Received: from tonberry.usersys.redhat.com (localhost [127.0.0.1]) by tonberry.usersys.redhat.com (8.15.2/8.14.5) with ESMTP id tB7Gg3tP021953; Mon, 7 Dec 2015 11:42:03 -0500 Received: (from smayhew@localhost) by tonberry.usersys.redhat.com (8.15.2/8.15.2/Submit) id tB7Gg3Et021952; Mon, 7 Dec 2015 11:42:03 -0500 From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH] statd: make statd_canonical_name emit a warning if the presentation address maps to an empty hostname Date: Mon, 7 Dec 2015 11:42:03 -0500 Message-Id: <1449506523-21897-1-git-send-email-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Certain name resolution misconfigurations (for example, a hosts file entry with an ip address but no hostnames) can cause get_nameinfo() to return an empty string in buf, which will lead to this cryptic failure: Dec 7 09:37:44 hostname rpc.statd[8024]: Failed to insert: creating /var/lib/nfs/statd/sm/: Is a directory Dec 7 09:37:44 hostname rpc.statd[8024]: STAT_FAIL to hostname.example.com for SM_MON of 192.168.1.2 Dec 7 09:37:44 hostname kernel: lockd: cannot monitor 192.168.1.2 It's better in that case to just go ahead and use the presentation address and log a more helpful warning: Dec 7 10:24:52 hostname rpc.statd[14224]: get_nameinfo returned empty hostname for 10.10.183.219. Fix your name resolution! Signed-off-by: Scott Mayhew Reviewed-by: Chuck Lever --- utils/statd/hostname.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/statd/hostname.c b/utils/statd/hostname.c index c61087c..86d11ca 100644 --- a/utils/statd/hostname.c +++ b/utils/statd/hostname.c @@ -211,6 +211,12 @@ statd_canonical_name(const char *hostname) /* OK to use presentation address, * if no reverse map exists */ return strdup(hostname); + else if (buf[0] == '\0') { + xlog_warn("get_nameinfo returned empty hostname for " + "%s. Fix your name resolution!", + hostname); + return strdup(hostname); + } return strdup(buf); }