2 * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff
3 * Modified by Olaf Kirch, Oct. 1996.
4 * Modified by Lon Hohberger, Oct. 2000.
19 /* Callback notify list. */
20 /* notify_list *cbnl = NULL; ... never used */
24 * Services SM_NOTIFY requests.
26 * When NLM uses an SM_MON request to tell statd to monitor a remote,
27 * the request contains a "mon_name" argument. This is usually the
28 * "caller_name" argument of an NLMPROC_LOCK request. On Linux, the
29 * NLM can send statd the remote's IP address instead of its
30 * caller_name. The NSM protocol does not allow both the remote's
31 * caller_name and it's IP address to be sent in the same SM_MON
34 * The remote's caller_name is useful because it makes it simple
35 * to identify rebooting remotes by matching the "mon_name" argument
36 * they sent via an SM_NOTIFY request.
38 * The caller_name string may not be a fully qualified domain name,
39 * or even registered in the DNS database, however. Having the
40 * remote's IP address is useful because then there is no ambiguity
41 * about where to send an SM_NOTIFY after the local system reboots.
43 * Without the actual caller_name, however, statd must use an
44 * heuristic to match an incoming SM_NOTIFY request to one of the
45 * hosts it is currently monitoring. The incoming mon_name in an
46 * SM_NOTIFY address is converted to a list of IP addresses using
47 * DNS. Each mon_name on statd's monitor list is also converted to
48 * an address list, and the two lists are checked to see if there is
51 * There are some risks to this strategy:
53 * 1. The external DNS database is not reliable. It can change
54 * over time, or the forward and reverse mappings could be
57 * 2. If statd's monitor list becomes substantial, finding a match
58 * can generate a not inconsequential amount of DNS traffic.
60 * 3. statd is a single-threaded service. When DNS becomes slow or
61 * unresponsive, statd also becomes slow or unresponsive.
63 * 4. If the remote does not have a DNS entry at all (or if the
64 * remote can resolve itself, but the local host can't resolve
65 * the remote's hostname), the remote cannot be monitored, and
66 * therefore NLM locking cannot be provided for that host.
68 * 5. Local DNS resolution can produce different results for the
69 * mon_name than the results the remote might see for the same
70 * query, especially if the remote did not send a caller_name
71 * or mon_name that is a fully qualified domain name.
73 * Note that a caller_name is passed from NFS client to server,
74 * but the client never knows what mon_name the server might use
75 * to notify it of a reboot. On Linux, the client extracts the
76 * server's name from the devname it was passed by the mount
77 * command. This is often not a fully-qualified domain name.
80 sm_notify_1_svc(struct stat_chge *argp, struct svc_req *rqstp)
82 notify_list *lp, *call;
83 static char *result = NULL;
84 struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt);
85 char ip_addr[INET6_ADDRSTRLEN];
87 xlog(D_CALL, "Received SM_NOTIFY from %s, state: %d",
88 argp->mon_name, argp->state);
90 /* quick check - don't bother if we're not monitoring anyone */
92 xlog_warn("SM_NOTIFY from %s while not monitoring any hosts",
94 return ((void *) &result);
97 if (!statd_present_address(sap, ip_addr, sizeof(ip_addr))) {
98 xlog_warn("Unrecognized sender address");
99 return ((void *) &result);
102 /* okir change: statd doesn't remove the remote host from its
103 * internal monitor list when receiving an SM_NOTIFY call from
104 * it. Lockd will want to continue monitoring the remote host
105 * until it issues an SM_UNMON call.
107 for (lp = rtnl ; lp ; lp = lp->next)
108 if (NL_STATE(lp) != argp->state &&
109 (statd_matchhostname(argp->mon_name, lp->dns_name) ||
110 statd_matchhostname(ip_addr, lp->dns_name))) {
111 NL_STATE(lp) = argp->state;
112 call = nlist_clone(lp);
113 nlist_insert(¬ify, call);
117 return ((void *) &result);