From: Steve Dickson <SteveD@redhat.com>
To: nfs@lists.sourceforge.net
Subject: [PATCH] STATD - SM_NOTIFY have wrong ID_NAME on multihost servers.
Date: Tue, 23 Nov 2004 15:28:07 -0500 [thread overview]
Message-ID: <41A39D57.8060902@RedHat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
Here is a patch that make sure the correct hostname is used
in the SM_NOTIFY message what is sent from a rebooted server
that has multiple network interfaces.
Using the network part of the destination address, the correct network
interface is found. Then a gethostbyaddr() on that interface is done,
which yields the correct hostname that should be sent in the notify
message....
Comments?
SteveD.
[-- Attachment #2: nfs-utils-1.0.6-statd-notify-hostname.patch --]
[-- Type: text/x-patch, Size: 2311 bytes --]
--- nfs-utils-1.0.6/utils/statd/rmtcall.c.orig 2004-11-08 11:03:49.352146000 -0500
+++ nfs-utils-1.0.6/utils/statd/rmtcall.c 2004-11-23 13:43:34.751897000 -0500
@@ -26,6 +26,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
+#include <net/if.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
@@ -34,6 +35,7 @@
#include <netdb.h>
#include <string.h>
#include <unistd.h>
+#include <ifaddrs.h>
#include "sm_inter.h"
#include "statd.h"
#include "notlist.h"
@@ -73,7 +75,44 @@
return sockfd;
}
-
+/*
+ * Using the NL_ADDR(lp), reset (if needed) the hostname
+ * that will be put in the SM_NOTIFY to the hostname
+ * that is associated with the network interface
+ * that was monitored
+ */
+static void
+reset_my_name(notify_list *lp)
+{
+ struct ifaddrs *ifa = NULL, *ifap;
+ struct in_addr netaddr, tmp;
+ struct sockaddr_in *sin, *nsin;
+ struct hostent *hp;
+
+ netaddr.s_addr = inet_netof(NL_ADDR(lp));
+ if (getifaddrs(&ifa) >= 0) {
+ for (ifap = ifa; ifap != NULL; ifap = ifap->ifa_next) {
+ if (ifap->ifa_addr->sa_family != AF_INET)
+ continue;
+ if (!(ifap->ifa_flags & IFF_UP))
+ continue;
+ sin = (struct sockaddr_in *)ifap->ifa_addr;
+ nsin = (struct sockaddr_in *)ifap->ifa_netmask;
+ tmp.s_addr = sin->sin_addr.s_addr & nsin->sin_addr.s_addr;
+ if (memcmp(&tmp.s_addr, &netaddr.s_addr, sizeof(netaddr.s_addr)))
+ continue;
+ hp = gethostbyaddr((char *)&sin->sin_addr,
+ sizeof(sin->sin_addr), AF_INET);
+ if (hp == NULL)
+ continue;
+ if (strcmp(NL_MY_NAME(lp), hp->h_name)) {
+ free(NL_MY_NAME(lp));
+ NL_MY_NAME(lp)= strdup(hp->h_name);
+ }
+ }
+ }
+ return;
+}
/*
* Try to resolve host name for notify/callback request
*
@@ -283,6 +322,7 @@
{
struct sockaddr_in sin;
struct status new_status;
+ stat_chge new_stat;
xdrproc_t func;
void *objp;
u_int32_t proc, vers, prog;
@@ -309,9 +349,14 @@
/* Use source address for notify replies */
sin.sin_addr = lp->addr;
+ /* Make sure the correct hostname is sent */
+ reset_my_name(lp);
func = (xdrproc_t) xdr_stat_chge;
- objp = &SM_stat_chge;
+ new_stat.state = MY_STATE;
+ new_stat.mon_name = NL_MY_NAME(lp);
+
+ objp = &new_stat;
break;
case NOTIFY_CALLBACK:
prog = NL_MY_PROG(lp);
next reply other threads:[~2004-11-23 20:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-23 20:28 Steve Dickson [this message]
2004-11-23 23:26 ` [PATCH] STATD - SM_NOTIFY have wrong ID_NAME on multihost servers Ragnar Kjørstad
2004-11-24 0:46 ` Steve Dickson
2004-11-24 2:00 ` Ragnar Kjørstad
2004-11-24 12:00 ` Steve Dickson
2004-11-24 17:35 ` Ragnar Kjørstad
2004-11-24 18:43 ` Marc Eshel
2004-11-24 20:35 ` Ragnar Kjørstad
2004-11-24 22:08 ` Steve Dickson
2004-11-24 23:25 ` Ragnar Kjørstad
2004-11-26 13:01 ` Steve Dickson
2004-11-24 4:42 ` Marc Eshel
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=41A39D57.8060902@RedHat.com \
--to=steved@redhat.com \
--cc=nfs@lists.sourceforge.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.