]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/statd/rmtcall.c
2001-03-11 H.J. Lu <hjl@lucon.org>
[nfs-utils.git] / utils / statd / rmtcall.c
index a08c4b1b04e064bbb632a0a4f2fb6de747e9283b..b70e5bb701e829a391ff6fda47abd10239fab4cb 100644 (file)
@@ -2,6 +2,9 @@
  * Copyright (C) 1996, 1999 Olaf Kirch
  * Modified by Jeffrey A. Uphoff, 1997-1999.
  * Modified by H.J. Lu, 1998.
+ * Modified by Lon Hohberger, Oct. 2000
+ *   - Bugfix handling client responses.
+ *   - Paranoia on NOTIFY_CALLBACK case
  *
  * NSM for Linux.
  */
@@ -27,6 +30,7 @@
 #include <rpc/rpc.h>
 #include <rpc/pmap_prot.h>
 #include <rpc/pmap_rmt.h>
+#include <time.h>
 #include <netdb.h>
 #include <string.h>
 #include <unistd.h>
@@ -238,7 +242,10 @@ recv_rply(int sockfd, struct sockaddr_in *sin, u_long *portp)
        }
 
        for (lp = notify; lp != NULL; lp = lp->next) {
-               if (lp->xid != xid)
+               /* LH - this was a bug... it should have been checking
+                * the xid from the response message from the client,
+                * not the static, internal xid */
+               if (lp->xid != mesg.rm_xid)
                        continue;
                if (lp->addr.s_addr != sin->sin_addr.s_addr) {
                        char addr [18];
@@ -290,13 +297,17 @@ process_entry(int sockfd, notify_list *lp)
        memset(&sin, 0, sizeof(sin));
        sin.sin_family = AF_INET;
        sin.sin_port   = lp->port;
-       sin.sin_addr   = lp->addr;
+       /* LH - moved address into switch */
 
        switch (NL_TYPE(lp)) {
        case NOTIFY_REBOOT:
                prog = SM_PROG;
                vers = SM_VERS;
                proc = SM_NOTIFY;
+
+               /* Use source address for notify replies */
+               sin.sin_addr   = lp->addr;
+
                func = (xdrproc_t) xdr_stat_chge;
                objp = &SM_stat_chge;
                break;
@@ -304,6 +315,11 @@ process_entry(int sockfd, notify_list *lp)
                prog = NL_MY_PROG(lp);
                vers = NL_MY_VERS(lp);
                proc = NL_MY_PROC(lp);
+
+               /* __FORCE__ loopback for callbacks to lockd ... */
+               /* Just in case we somehow ignored it thus far */
+               sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
                func = (xdrproc_t) xdr_status;
                objp = &new_status;
                new_status.mon_name = NL_MON_NAME(lp);