* [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers
@ 2007-02-26 11:18 Steve Dickson
2007-02-27 6:32 ` Neil Brown
0 siblings, 1 reply; 6+ messages in thread
From: Steve Dickson @ 2007-02-26 11:18 UTC (permalink / raw)
To: nfs
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: patch-09.dif --]
[-- Type: text/x-patch, Size: 814 bytes --]
commit 253c6b866a1ed4678c30131a41ef96821bae9d5f
Author: Steve Dickson <steved@redhat.com>
Date: Sat Feb 24 16:08:22 2007 -0500
Doing a connect on UDP sockets causes the Linux network
stack to reject UDP patches from multi-home server with
nic on the same subnet which caused mounts to hang.
Signed-off-by: Steve Dickson <steved@redhat.com>
diff --git a/support/nfs/conn.c b/support/nfs/conn.c
index 89f7676..06afcc4 100644
--- a/support/nfs/conn.c
+++ b/support/nfs/conn.c
@@ -98,7 +98,7 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp)
return RPC_ANYSOCK;
}
}
- if (type == SOCK_STREAM || type == SOCK_DGRAM) {
+ if (type == SOCK_STREAM) {
cc = connect(so, (struct sockaddr *)saddr, namelen);
if (cc < 0) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
[-- Attachment #3: Type: text/plain, Size: 345 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 140 bytes --]
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers 2007-02-26 11:18 [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers Steve Dickson @ 2007-02-27 6:32 ` Neil Brown 2007-02-27 18:12 ` Jeff Layton 0 siblings, 1 reply; 6+ messages in thread From: Neil Brown @ 2007-02-27 6:32 UTC (permalink / raw) To: Steve Dickson; +Cc: nfs On Monday February 26, SteveD@redhat.com wrote: > commit 253c6b866a1ed4678c30131a41ef96821bae9d5f > Author: Steve Dickson <steved@redhat.com> > Date: Sat Feb 24 16:08:22 2007 -0500 > > Doing a connect on UDP sockets causes the Linux network > stack to reject UDP patches from multi-home server with > nic on the same subnet which caused mounts to hang. > > Signed-off-by: Steve Dickson <steved@redhat.com> > > diff --git a/support/nfs/conn.c b/support/nfs/conn.c > index 89f7676..06afcc4 100644 > --- a/support/nfs/conn.c > +++ b/support/nfs/conn.c > @@ -98,7 +98,7 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) > return RPC_ANYSOCK; > } > } > - if (type == SOCK_STREAM || type == SOCK_DGRAM) { > + if (type == SOCK_STREAM) { You are reverting a change from commit c2db41e8abb6ddc9d03a0c91c6db043fa0f85a8f This was needed so we could find our local address to get the call-back address sent to the server right for NFSv4. I think the correct thing to do here is to fix mountd so that it replies from the correct address. Careful use of IP_PKTINFO makes this fairly easy to manage.... except that the recvfrom and sendto code is buried inside libc.... but if memory serves, that was fixed to get this right some time ago. What OS is running on this multi-homed server?? Maybe we have to do something ghastly like disconnect the socket after getting the local address... I hope not. NeilBrown ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers 2007-02-27 6:32 ` Neil Brown @ 2007-02-27 18:12 ` Jeff Layton 2007-03-01 1:48 ` Neil Brown 0 siblings, 1 reply; 6+ messages in thread From: Jeff Layton @ 2007-02-27 18:12 UTC (permalink / raw) To: Neil Brown; +Cc: nfs, Steve Dickson Neil Brown wrote: > On Monday February 26, SteveD@redhat.com wrote: >> commit 253c6b866a1ed4678c30131a41ef96821bae9d5f >> Author: Steve Dickson <steved@redhat.com> >> Date: Sat Feb 24 16:08:22 2007 -0500 >> >> Doing a connect on UDP sockets causes the Linux network >> stack to reject UDP patches from multi-home server with >> nic on the same subnet which caused mounts to hang. >> >> Signed-off-by: Steve Dickson <steved@redhat.com> >> >> diff --git a/support/nfs/conn.c b/support/nfs/conn.c >> index 89f7676..06afcc4 100644 >> --- a/support/nfs/conn.c >> +++ b/support/nfs/conn.c >> @@ -98,7 +98,7 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) >> return RPC_ANYSOCK; >> } >> } >> - if (type == SOCK_STREAM || type == SOCK_DGRAM) { >> + if (type == SOCK_STREAM) { > > You are reverting a change from commit > c2db41e8abb6ddc9d03a0c91c6db043fa0f85a8f > > This was needed so we could find our local address to get the > call-back address sent to the server right for NFSv4. > > I think the correct thing to do here is to fix mountd so that it > replies from the correct address. Careful use of IP_PKTINFO makes > this fairly easy to manage.... except that the recvfrom and sendto > code is buried inside libc.... but if memory serves, that was fixed to > get this right some time ago. > > What OS is running on this multi-homed server?? > > Maybe we have to do something ghastly like disconnect the socket after > getting the local address... I hope not. > > NeilBrown > I know we saw this with Solaris servers in particular (it's been a while, but I think I was testing against Solaris 8). The fedora BZ is here if you want to see all the gory details: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=212471 I'm thinking we will have to deal with this situation, unfortunately, so maybe disconnecting the socket after getting the address is the best thing? -- Jeff ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers 2007-02-27 18:12 ` Jeff Layton @ 2007-03-01 1:48 ` Neil Brown 2007-03-11 19:58 ` Jeff Layton 0 siblings, 1 reply; 6+ messages in thread From: Neil Brown @ 2007-03-01 1:48 UTC (permalink / raw) To: Jeff Layton; +Cc: nfs, Steve Dickson On Tuesday February 27, jlayton@poochiereds.net wrote: > > I know we saw this with Solaris servers in particular (it's been a > while, but I think I was testing against Solaris 8). The fedora BZ is > here if you want to see all the gory details: > > https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=212471 > > I'm thinking we will have to deal with this situation, unfortunately, so > maybe disconnecting the socket after getting the address is the best thing? > > -- Jeff Thanks for the link... Looks like we do need to be very careful about connecting UDP sockets. This patch maybe? NeilBrown diff --git a/support/include/conn.h b/support/include/conn.h index 1761dc4..11f16ab 100644 --- a/support/include/conn.h +++ b/support/include/conn.h @@ -35,7 +35,7 @@ int clnt_ping(struct sockaddr_in *, const u_long, const u_long, const u_int, struct sockaddr_in *); u_long nfsvers_to_mnt(const u_long); u_long mntvers_to_nfs(const u_long); -int get_socket(struct sockaddr_in *, u_int, int); +int get_socket(struct sockaddr_in *, u_int, int, int); CLIENT * mnt_openclnt(clnt_addr_t *, int *); void mnt_closeclnt(CLIENT *, int); diff --git a/support/nfs/conn.c b/support/nfs/conn.c index 89f7676..1020b47 100644 --- a/support/nfs/conn.c +++ b/support/nfs/conn.c @@ -49,7 +49,7 @@ u_long mntvers_to_nfs(const u_long vers) * RPC_ANYSOCK is returned which will cause * the RPC code to create the socket instead. */ -int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) +int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp, int conn) { int so, cc, type; struct sockaddr_in laddr; @@ -98,7 +98,7 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) return RPC_ANYSOCK; } } - if (type == SOCK_STREAM || type == SOCK_DGRAM) { + if (type == SOCK_STREAM || (conn && type == SOCK_DGRAM)) { cc = connect(so, (struct sockaddr *)saddr, namelen); if (cc < 0) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; @@ -129,9 +129,10 @@ clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, CLIENT *clnt=NULL; int sock, stat; static char clnt_res; + struct sockaddr dissolve; rpc_createerr.cf_stat = stat = errno = 0; - sock = get_socket(saddr, prot, FALSE); + sock = get_socket(saddr, prot, FALSE, TRUE); if (sock == RPC_ANYSOCK && errno == ETIMEDOUT) { /* * TCP timeout. Bubble up the error to see @@ -141,8 +142,22 @@ clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, goto out_bad; } + if (caddr) { + /* Get the address of our end of this connection */ + socklen_t len = sizeof(*caddr); + if (getsockname(sock, caddr, &len) != 0) + caddr->sin_family = 0; + } + switch(prot) { case IPPROTO_UDP: + /* The socket is connected (so we could getsockname successfully), + * but some servers on multi-homed hosts reply from + * the wrong address, so if we stay connected, we lose the reply. + */ + dissolve.sa_family = AF_UNSPEC; + connect(sock, &dissolve, sizeof(dissolve)); + clnt = clntudp_bufcreate(saddr, prog, vers, RETRY_TIMEOUT, &sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); @@ -166,15 +181,7 @@ clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, rpc_createerr.cf_stat = stat; } clnt_destroy(clnt); - if (sock != -1) { - if (caddr) { - /* Get the address of our end of this connection */ - socklen_t len = sizeof(*caddr); - if (getsockname(sock, caddr, &len) != 0) - caddr->sin_family = 0; - } - close(sock); - } + close(sock); if (stat == RPC_SUCCESS) return 1; @@ -191,7 +198,7 @@ CLIENT *mnt_openclnt(clnt_addr_t *mnt_server, int *msock) /* contact the mount daemon via TCP */ mnt_saddr->sin_port = htons((u_short)mnt_pmap->pm_port); - *msock = get_socket(mnt_saddr, mnt_pmap->pm_prot, TRUE); + *msock = get_socket(mnt_saddr, mnt_pmap->pm_prot, TRUE, FALSE); switch (mnt_pmap->pm_prot) { case IPPROTO_UDP: diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c index 507ccdb..0f66bdf 100644 --- a/utils/mount/nfsmount.c +++ b/utils/mount/nfsmount.c @@ -306,7 +306,7 @@ getport( enum clnt_stat stat; saddr->sin_port = htons (PMAPPORT); - socket = get_socket(saddr, prot, FALSE); + socket = get_socket(saddr, prot, FALSE, FALSE); switch (prot) { case IPPROTO_UDP: ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers 2007-03-01 1:48 ` Neil Brown @ 2007-03-11 19:58 ` Jeff Layton 2007-03-11 22:38 ` Neil Brown 0 siblings, 1 reply; 6+ messages in thread From: Jeff Layton @ 2007-03-11 19:58 UTC (permalink / raw) To: Neil Brown; +Cc: nfs, Steve Dickson Neil Brown wrote: > On Tuesday February 27, jlayton@poochiereds.net wrote: >> I know we saw this with Solaris servers in particular (it's been a >> while, but I think I was testing against Solaris 8). The fedora BZ is >> here if you want to see all the gory details: >> >> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=212471 >> >> I'm thinking we will have to deal with this situation, unfortunately, so >> maybe disconnecting the socket after getting the address is the best thing? >> >> -- Jeff > > Thanks for the link... Looks like we do need to be very careful about > connecting UDP sockets. > > This patch maybe? > > NeilBrown > > > diff --git a/support/include/conn.h b/support/include/conn.h > index 1761dc4..11f16ab 100644 > --- a/support/include/conn.h > +++ b/support/include/conn.h > @@ -35,7 +35,7 @@ int clnt_ping(struct sockaddr_in *, const u_long, const u_long, const u_int, > struct sockaddr_in *); > u_long nfsvers_to_mnt(const u_long); > u_long mntvers_to_nfs(const u_long); > -int get_socket(struct sockaddr_in *, u_int, int); > +int get_socket(struct sockaddr_in *, u_int, int, int); > CLIENT * mnt_openclnt(clnt_addr_t *, int *); > void mnt_closeclnt(CLIENT *, int); > > diff --git a/support/nfs/conn.c b/support/nfs/conn.c > index 89f7676..1020b47 100644 > --- a/support/nfs/conn.c > +++ b/support/nfs/conn.c > @@ -49,7 +49,7 @@ u_long mntvers_to_nfs(const u_long vers) > * RPC_ANYSOCK is returned which will cause > * the RPC code to create the socket instead. > */ > -int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) > +int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp, int conn) > { > int so, cc, type; > struct sockaddr_in laddr; > @@ -98,7 +98,7 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) > return RPC_ANYSOCK; > } > } > - if (type == SOCK_STREAM || type == SOCK_DGRAM) { > + if (type == SOCK_STREAM || (conn && type == SOCK_DGRAM)) { > cc = connect(so, (struct sockaddr *)saddr, namelen); > if (cc < 0) { > rpc_createerr.cf_stat = RPC_SYSTEMERROR; > @@ -129,9 +129,10 @@ clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, > CLIENT *clnt=NULL; > int sock, stat; > static char clnt_res; > + struct sockaddr dissolve; > > rpc_createerr.cf_stat = stat = errno = 0; > - sock = get_socket(saddr, prot, FALSE); > + sock = get_socket(saddr, prot, FALSE, TRUE); > if (sock == RPC_ANYSOCK && errno == ETIMEDOUT) { > /* > * TCP timeout. Bubble up the error to see > @@ -141,8 +142,22 @@ clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, > goto out_bad; > } > > + if (caddr) { > + /* Get the address of our end of this connection */ > + socklen_t len = sizeof(*caddr); > + if (getsockname(sock, caddr, &len) != 0) > + caddr->sin_family = 0; > + } > + > switch(prot) { > case IPPROTO_UDP: > + /* The socket is connected (so we could getsockname successfully), > + * but some servers on multi-homed hosts reply from > + * the wrong address, so if we stay connected, we lose the reply. > + */ > + dissolve.sa_family = AF_UNSPEC; > + connect(sock, &dissolve, sizeof(dissolve)); > + > clnt = clntudp_bufcreate(saddr, prog, vers, > RETRY_TIMEOUT, &sock, > RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); > @@ -166,15 +181,7 @@ clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, > rpc_createerr.cf_stat = stat; > } > clnt_destroy(clnt); > - if (sock != -1) { > - if (caddr) { > - /* Get the address of our end of this connection */ > - socklen_t len = sizeof(*caddr); > - if (getsockname(sock, caddr, &len) != 0) > - caddr->sin_family = 0; > - } > - close(sock); > - } > + close(sock); > > if (stat == RPC_SUCCESS) > return 1; > @@ -191,7 +198,7 @@ CLIENT *mnt_openclnt(clnt_addr_t *mnt_server, int *msock) > > /* contact the mount daemon via TCP */ > mnt_saddr->sin_port = htons((u_short)mnt_pmap->pm_port); > - *msock = get_socket(mnt_saddr, mnt_pmap->pm_prot, TRUE); > + *msock = get_socket(mnt_saddr, mnt_pmap->pm_prot, TRUE, FALSE); > > switch (mnt_pmap->pm_prot) { > case IPPROTO_UDP: > diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c > index 507ccdb..0f66bdf 100644 > --- a/utils/mount/nfsmount.c > +++ b/utils/mount/nfsmount.c > @@ -306,7 +306,7 @@ getport( > enum clnt_stat stat; > > saddr->sin_port = htons (PMAPPORT); > - socket = get_socket(saddr, prot, FALSE); > + socket = get_socket(saddr, prot, FALSE, FALSE); > > switch (prot) { > case IPPROTO_UDP: > Hi Neil, Apologies for the long delay, took me a bit to get my test rig back together. This patch does indeed seem to fix the problem. Thanks, Jeff ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers 2007-03-11 19:58 ` Jeff Layton @ 2007-03-11 22:38 ` Neil Brown 0 siblings, 0 replies; 6+ messages in thread From: Neil Brown @ 2007-03-11 22:38 UTC (permalink / raw) To: Jeff Layton; +Cc: nfs, Steve Dickson On Sunday March 11, jlayton@poochiereds.net wrote: > > > Hi Neil, > Apologies for the long delay, took me a bit to get my test rig back > together. This patch does indeed seem to fix the problem. > Thanks for testing! I'll push it into the nfs-utils .git shortly. Thanks, NeilBrown ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-11 22:38 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-02-26 11:18 [PATCH 09/11] nfs-utils: mount: Fixed mounts to multi-home servers Steve Dickson 2007-02-27 6:32 ` Neil Brown 2007-02-27 18:12 ` Jeff Layton 2007-03-01 1:48 ` Neil Brown 2007-03-11 19:58 ` Jeff Layton 2007-03-11 22:38 ` Neil Brown
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.