From: Chuck Lever <chuck.lever@oracle.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org, Chris.Mason@oracle.com
Subject: [PATCH 20/29] statd: add IPv6 support in sm_notify_1_svc()
Date: Tue, 10 Nov 2009 16:59:29 -0500 [thread overview]
Message-ID: <20091110215929.23822.84374.stgit@matisse.1015granger.net> (raw)
In-Reply-To: <20091110215447.23822.15275.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
We have all the pieces in place, so update sm_notify_1_svc() to handle
SM_NOTIFY requests sent from IPv6 remotes.
This also eliminates a memory leak: the strdup'd memory containing the
callers' presentation address was never freed.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/statd/callback.c | 67 ++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 61 insertions(+), 6 deletions(-)
diff --git a/utils/statd/callback.c b/utils/statd/callback.c
index 56163d5..1a4b800 100644
--- a/utils/statd/callback.c
+++ b/utils/statd/callback.c
@@ -10,7 +10,7 @@
#include <config.h>
#endif
-#include <arpa/inet.h>
+#include <netdb.h>
#include "rpcmisc.h"
#include "statd.h"
@@ -22,17 +22,67 @@
/*
* Services SM_NOTIFY requests.
- * Any clients that have asked us to monitor that host are put on
- * the global callback list, which is processed as soon as statd
- * returns to svc_run.
+ *
+ * When NLM uses an SM_MON request to tell statd to monitor a remote,
+ * the request contains a "mon_name" argument. This is usually the
+ * "caller_name" argument of an NLMPROC_LOCK request. On Linux, the
+ * NLM can send statd the remote's IP address instead of its
+ * caller_name. The NSM protocol does not allow both the remote's
+ * caller_name and it's IP address to be sent in the same SM_MON
+ * request.
+ *
+ * The remote's caller_name is useful because it makes it simple
+ * to identify rebooting remotes by matching the "mon_name" argument
+ * they sent via an SM_NOTIFY request.
+ *
+ * The caller_name string may not be a fully qualified domain name,
+ * or even registered in the DNS database, however. Having the
+ * remote's IP address is useful because then there is no ambiguity
+ * about where to send an SM_NOTIFY after the local system reboots.
+ *
+ * Without the actual caller_name, however, statd must use an
+ * heuristic to match an incoming SM_NOTIFY request to one of the
+ * hosts it is currently monitoring. The incoming mon_name in an
+ * SM_NOTIFY address is converted to a list of IP addresses using
+ * DNS. Each mon_name on statd's monitor list is also converted to
+ * an address list, and the two lists are checked to see if there is
+ * a matching address.
+ *
+ * There are some risks to this strategy:
+ *
+ * 1. The external DNS database is not reliable. It can change
+ * over time, or the forward and reverse mappings could be
+ * inconsistent.
+ *
+ * 2. Local DNS resolution can produce different results for the
+ * mon_name than the results the remote might see for the same
+ * query, especially if the remote did not send a caller_name
+ * or mon_name that is a fully qualified domain name.
+ *
+ * 3. If the remote does not have a DNS entry at all (or if the
+ * remote can resolve itself, but the local host can't resolve
+ * the remote's hostname), the remote cannot be monitored, and
+ * therefore NLM locking cannot be provided for that host.
+ *
+ * 4. If statd's monitor list becomes substantial, finding a match
+ * generates a not inconsequential amount of DNS traffic.
+ *
+ * 5. statd is a single-threaded service. When DNS becomes slow or
+ * unresponsive, statd also becomes slow or unresponsive.
+ *
+ * Note that the caller_name is passed from NFS client to server, but the
+ * client never knows what mon_name the server might use to notify it of
+ * a reboot. On Linux, the client extracts the server's name from the
+ * devname it was passed by the mount command. This is often not a
+ * fully-qualified domain name.
*/
void *
sm_notify_1_svc(struct stat_chge *argp, struct svc_req *rqstp)
{
notify_list *lp, *call;
static char *result = NULL;
- struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
- char *ip_addr = xstrdup(inet_ntoa(sin->sin_addr));
+ struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt);
+ static char ip_addr[NI_MAXHOST];
xlog(D_CALL, "Received SM_NOTIFY from %s, state: %d",
argp->mon_name, argp->state);
@@ -44,6 +94,11 @@ sm_notify_1_svc(struct stat_chge *argp, struct svc_req *rqstp)
return ((void *) &result);
}
+ if (!nsm_present_address(sap, 0, ip_addr, sizeof(ip_addr))) {
+ xlog_warn("Unrecognized sender address");
+ return (void *)&result;
+ }
+
/* okir change: statd doesn't remove the remote host from its
* internal monitor list when receiving an SM_NOTIFY call from
* it. Lockd will want to continue monitoring the remote host
next prev parent reply other threads:[~2009-11-10 22:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-10 21:56 [PATCH 00/29] IPv6 support for statd Chuck Lever
[not found] ` <20091110215447.23822.15275.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2009-11-10 21:56 ` [PATCH 01/29] statd: Replace note() with xlog() in rpc.statd Chuck Lever
2009-11-10 21:56 ` [PATCH 02/29] statd: Replace nsm_log() with xlog() in sm-notify command Chuck Lever
2009-11-10 21:56 ` [PATCH 03/29] statd: replace smn_{get, set}_port() with the shared equivalents Chuck Lever
2009-11-10 21:56 ` [PATCH 04/29] statd: fix address copy in sm-notify.c Chuck Lever
2009-11-10 21:56 ` [PATCH 05/29] libnsm.a: Move the sm_inter XDR pieces to libnsm.a Chuck Lever
2009-11-10 21:57 ` [PATCH 06/29] libnsm.a: Introduce common routines to handle persistent storage Chuck Lever
2009-11-10 21:57 ` [PATCH 07/29] statd: Use the new nsm_ file.c calls in sm_notify Chuck Lever
2009-11-10 21:57 ` [PATCH 08/29] statd: Use the new nsm_ file.c calls in rpc.statd Chuck Lever
2009-11-10 21:57 ` [PATCH 09/29] libnsm.a: Add RPC construction helper functions Chuck Lever
2009-11-10 21:57 ` [PATCH 10/29] statd: Support sending SM_NOTIFY requests to IPv6 remotes Chuck Lever
2009-11-10 21:58 ` [PATCH 11/29] statd: Update rmtcall.c Chuck Lever
2009-11-10 21:58 ` [PATCH 12/29] statd: factor socket creation out of notify() Chuck Lever
2009-11-10 21:58 ` [PATCH 13/29] statd: Support creating a PF_INET6 socket in smn_create_socket() Chuck Lever
2009-11-10 21:58 ` [PATCH 14/29] statd: IPv6 support in reserved port binding " Chuck Lever
2009-11-10 21:58 ` [PATCH 15/29] statd: Use getaddrinfo(3) to generate bind address " Chuck Lever
2009-11-10 21:58 ` [PATCH 16/29] statd: Support IPv6 DNS lookups in smn_lookup Chuck Lever
2009-11-10 21:59 ` [PATCH 17/29] statd: squelch compiler warning in sm-notify.c Chuck Lever
2009-11-10 21:59 ` [PATCH 19/29] statd: add nsm_present_address() API Chuck Lever
2009-11-10 21:59 ` Chuck Lever [this message]
2009-11-10 21:59 ` [PATCH 21/29] statd: Support IPv6 is caller_is_localhost() Chuck Lever
2009-11-10 21:59 ` [PATCH 22/29] statd: Support IPv6 in sm_simu_crash_1_svc Chuck Lever
2009-11-10 21:59 ` [PATCH 23/29] statd: Support IPv6 in sm_mon_1_svc() Chuck Lever
2009-11-10 22:00 ` [PATCH 24/29] statd: Support IPv6 in sm_stat_1_svc() Chuck Lever
2009-11-10 22:00 ` [PATCH 25/29] libnsm.a: retain CAP_NET_BIND when dropping privileges Chuck Lever
2009-11-10 22:00 ` [PATCH 26/29] statd: Support TI-RPC statd listener Chuck Lever
2009-11-10 22:00 ` [PATCH 27/29] statd: update rpc.statd(8) and sm-notify(8) to reflect IPv6 support Chuck Lever
2009-11-10 22:01 ` [PATCH 28/29] statd: Use my_name when sending SM_NOTIFY requests Chuck Lever
2009-11-10 22:01 ` [PATCH 29/29] statd: Send unqualified and fully qualified mon_name in SM_NOTIFY Chuck Lever
2009-11-12 16:04 ` [PATCH 00/29] IPv6 support for statd Chuck Lever
2009-11-12 16:33 ` Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091110215929.23822.84374.stgit@matisse.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=Chris.Mason@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox