During any file locking interaction between an NFS client and server, the client tells the server what hostname to use as the mon_name argument of an SM_NOTIFY request. The server, however, never tells the client what mon_name argument it will use when sending an SM_NOTIFY request. In order to recognize the server, clients usually guess what mon_name the server might send by using the server hostname provided by the user on the mount command line. Sometimes, however, the user provides an unqualified server name. The server might then call the client back with a fully qualified domain name, which might not match. Solaris, and perhaps other implementations, attempt to mitigate this problem by sending two SM_NOTIFY requests: one with an unqualified mon_name argument, and one with a fully qualified mon_name. Implement such a scheme for sm-notify. Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx> --- utils/statd/sm-notify.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c index e883ae9..5c4d38f 100644 --- a/utils/statd/sm-notify.c +++ b/utils/statd/sm-notify.c @@ -149,13 +149,13 @@ smn_get_host(const char *hostname, __attribute__((unused)) const struct sockaddr *sap, const struct mon *mon, const time_t timestamp) { + char *c, my_name[SM_MAXSTRLEN + 1]; struct nsm_host *host; - char *my_name; if (opt_srcaddr) - my_name = nsm_hostname; + strncpy(my_name, nsm_hostname, sizeof(my_name) - 1); else - my_name = mon->mon_id.my_id.my_name; + strncpy(my_name, mon->mon_id.my_id.my_name, sizeof(my_name) - 1); host = smn_alloc_host(hostname, my_name, timestamp); if (host == NULL) @@ -163,6 +163,19 @@ smn_get_host(const char *hostname, insert_host(host); xlog(D_GENERAL, "Added host %s to notify list", hostname); + + /* See if we should send an unqualified copy of my_name as well */ + c = strchr(my_name, '.'); + if (c) { + *c = '\0'; + host = smn_alloc_host(hostname, my_name, timestamp); + if (host != NULL) { + insert_host(host); + xlog(D_GENERAL, "Added unqualified copy of %s " + "to notify list", hostname); + } + } + return 1; } -- 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