Linux NFS & Heartbeat Failover (RH9.0)
Subsystems (3)
Hi,
I am having a problem with NFS server on a multi-homed system. The problem is that I want NFS to reply to client requests on eth0:0 and not eth0. The reason for that is that eth0:0 alias/virtual ip is managed by heartbeat for failover to the backup nfs server (with the /var/lib/nfs on it).
A link of someone who had the same problem (I think):
http://lists.linux-ha.org/pipermail/linux-ha/2003-March/007269.html
Summary:
NFS Client is unable to connect to nfs server started under heartbeat through virtual IP.
I have a very similar setup. 2 Redhat 9.0 (2.4.20-19.9smp kernel, glibc-2.3.2- 27, nfs-utils-1.0.1-3.9 from rpm) boxes running DRBD -
Network RAID 1 -
and NFS Server +statd+portmap+fam under heartbeat 1.0.3
I have edited the default /etc/init.d/nfslock script to start rpc.statd with the option -n vitualIP so that when NFS server crashes and falls over to the secondary, I shouldn't have problems from clients complaining that the statd host changed.
However, like him, I got the same error when trying to mount an exported directory from the NFS Server via the virtual IP of the 2-node heartbeat cluster.
The error is: NFSPROC_NULL: RPC: Timed out
Running tcpdump on the primary node like so:
tcpdump -np -s 1600 udp port 2049
gives some interesting info, especially when I retry mounting by the virtual ip from the nfs client. It looks like the server accepts the connection on the virtual ip (i.e. eth0:0) but nfsd on port 2049 replies using the primary interface ip (i.e. eth0). The client doesn't like the reply from different host I guess therefore timing out.
rpcinfo -e nfs.server.virtual.ip (from the client) works as expected. showmount -e nfs.server.virt.ip (from the client) works as expected also.
Searching everywhere found few hints. FreeBSD's nfsd has a -h option to specify host/ip to tie nfsd to, but Linux doesn't. This blows because AFAIK drbd is strictly linux 2.x based.
I tried modifying /etc/ha.d/resources.d/IPaddr so that the ip is assigned in add_address() to eth0 statically instead of the eth#:# and also in delete_address, and although I was able to mount now from the clients, heartbeat stop doesn't seem to stop the services anymore and I see errors reported in /var/log/ha-log about IPaddr error 1
Any help would be appreciated.
Please CC me if you reply as I am not subscribed to the list.
Best Regards,
Tim
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 8 lines · On Saturday August 16, [email protected] wrote:
Running tcpdump on the primary node like so:
tcpdump -np -s 1600 udp port 2049
gives some interesting info, especially when I retry mounting by the virtual ip from the nfs client. It looks like the server accepts the connection on the virtual ip (i.e. eth0:0) but nfsd on port 2049 replies using the primary interface ip (i.e. eth0). The client doesn't like the reply from different host I guess therefore timing out.
Could you try the following patch and let me know if it helps? Thanks.
NeilBrown
----------- Diffstat output ------------
./include/linux/sunrpc/svc.h | 2 ++ ./net/sunrpc/svcsock.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
include/linux/sunrpc/svc.h renamed from include/linux/sunrpc/svc.h~current~ +2 -0
@@ -112,6 +112,8 @@ struct svc_rqst { rq_secure :1 ,/* secure port */ rq_auth : 1; /* check client */ +__u32 rq_daddr;/* dest addr of request - reply from here */ +void * rq_argp;/* decoded arguments */ void * rq_resp;/* xdr'd results */
net/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c~current~ +16 -2
@@ -317,6 +317,9 @@ svc_sendto(struct svc_rqst *rqstp, strucstruct svc_sock *svsk = rqstp->rq_sock;struct socket *sock = svsk->sk_sock;struct msghdr msg; +struct {struct cmsghdr cmh; +struct in_pktinfo pki; + } cm;int i, buflen, len;for (i = buflen =0 ; i < nr; i++)
@@ -326,8 +329,18 @@ svc_sendto(struct svc_rqst *rqstp, struc msg.msg_namelen =sizeof (rqstp->rq_addr); msg.msg_iov = iov; msg.msg_iovlen = nr; - msg.msg_control =NULL ; - msg.msg_controllen =0 ; +if (rqstp->rq_prot ==IPPROTO_UDP ) { + msg.msg_control = &cm; + msg.msg_controllen =sizeof (cm); + cm.cmh.cmsg_len =sizeof (cm); + cm.cmh.cmsg_level =SOL_IP ; + cm.cmh.cmsg_type =IP_PKTINFO ; + cm.pki.ipi_ifindex =0 ; + cm.pki.ipi_spec_dst.s_addr = rqstp->rq_daddr; + }else { + msg.msg_control =NULL ; + msg.msg_controllen =0 ; + }/* This was MSG_DONTWAIT, but I now want it to wait. * The only thing that it would wait for is memory and
@@ -531,6 +544,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) rqstp->rq_addr.sin_family =AF_INET ; rqstp->rq_addr.sin_port = skb->h.uh->source; rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr; + rqstp->rq_daddr = skb->nh.iph->daddr;if (serv->sv_stats) serv->sv_stats->netudpcnt++;
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Hi Neil,
Thank you for taking the time to write this patch. As this requires a kernel recompile, I am going to put it off till later today/tomorrow, I am not sure. I probably have to recompile nfs-utils too (correct me if I am wrong). As a temporary workaround, I have changed the IPaddr script in heartbeat-1.0.3 which swaps eth0 and eth0:0 so that the virtual IP is set on eth0 and the real IP is moved to eth0:0, and resetup the routes as detected from route/ifconfig output. This is a temporary cheap hack, as I could've just installed a 3rd nic, but this is a 1u machine so it's not very feasible...
Regards,
Tim
Quoting Neil Brown <[email protected]>:
Quoted 29 lines · On Saturday August 16, [email protected] wrote:
Quoted 4 lines
Running tcpdump on the primary node like so:
tcpdump -np -s 1600 udp port 2049
gives some interesting info, especially when I retry mounting by thevirtual
Quoted 1 line
ip from the nfs client. It looks like the server accepts the connection on
the
Quoted 4 lines
virtual ip (i.e. eth0:0) but nfsd on port 2049 replies using the primary interface ip (i.e. eth0). The client doesn't like the reply from different
host I guess therefore timing out.
Could you try the following patch and let me know if it helps? Thanks.
NeilBrown
----------- Diffstat output ------------
./include/linux/sunrpc/svc.h | 2 ++ ./net/sunrpc/svcsock.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)diff
./include/linux/sunrpc/svc.h~current~./include/linux/sunrpc/svc.h
---./include/linux/sunrpc/svc.h~current~2003-08-17 20:25:23.000000000
+1000
+++./include/linux/sunrpc/svc.h2003-08-17 20:26:34.000000000 +1000
include/linux/sunrpc/svc.h struct svc_rqst { · line 115
Quoted 4 lines
include/linux/sunrpc/svc.h renamed from include/linux/sunrpc/svc.h~current~ +1
-0@@ -112,6 +112,8 @@ struct svc_rqst { rq_secure :1 ,/* secure port */ rq_auth : 1; /* check client */ +__u32 rq_daddr;/* dest addr of request -
reply from here */
Quoted 41 lines
include/linux/sunrpc/svc.h renamed from include/linux/sunrpc/svc.h~current~ +1
-0+void * rq_argp;/* decoded arguments */ void * rq_resp;/* xdr'd results */ diff
./net/sunrpc/svcsock.c~current~./net/sunrpc/svcsock.cnet/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c~current~ +15
-2@@ -317,6 +317,9 @@ svc_sendto(struct svc_rqst *rqstp, strucstruct svc_sock *svsk = rqstp->rq_sock;struct socket *sock = svsk->sk_sock;struct msghdr msg; +struct {struct cmsghdr cmh; +struct in_pktinfo pki; + } cm;int i, buflen, len;for (i = buflen =0 ; i < nr; i++)@@ -326,8 +329,18 @@ svc_sendto(struct svc_rqst *rqstp, struc msg.msg_namelen =sizeof (rqstp->rq_addr); msg.msg_iov = iov; msg.msg_iovlen = nr; - msg.msg_control =NULL ; - msg.msg_controllen =0 ; +if (rqstp->rq_prot ==IPPROTO_UDP ) { + msg.msg_control = &cm; + msg.msg_controllen =sizeof (cm); + cm.cmh.cmsg_len =sizeof (cm); + cm.cmh.cmsg_level =SOL_IP ; + cm.cmh.cmsg_type =IP_PKTINFO ; + cm.pki.ipi_ifindex =0 ; + cm.pki.ipi_spec_dst.s_addr = rqstp->rq_daddr; + }else { + msg.msg_control =NULL ; + msg.msg_controllen =0 ; + }/* This was MSG_DONTWAIT, but I now want it to wait. * The only thing that it would wait for is memory and
net/sunrpc/svcsock.c svc_udp_recvfrom(struct svc_rqst *rqstp) · line 550
Quoted 7 lines
net/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c~current~ +1
-0@@ -531,6 +544,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) rqstp->rq_addr.sin_family =AF_INET ; rqstp->rq_addr.sin_port = skb->h.uh->source; rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr; + rqstp->rq_daddr = skb->nh.iph->daddr;if (serv->sv_stats) serv->sv_stats->netudpcnt++;
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
Hi,
Neil, Thank you very much for your very useful patch. Unfortunately, I didnt realize this was against ~current (2.6.x ?) therefore it failed horribly :/ I modified it against 2.4.20-19 (redhat9's kernel-source updated), and it works as expected. The nfsd on port 2049 no longer responds on eth0 when it gets a request on eth0:0, but instead replies on the if/addr it received the connection from.
Keep up the good work!
Best Regards,
Tim Hasson
This is a unidiff against 2.4.20-19
include/linux/sunrpc/svc.h 2003-08-19 01:29:41.000000000 -0700 renamed from include/linux/sunrpc/svc.h.orig 2003-08-19 01:23:38.000000000 -0700 +1 -0
@@ -111,6 +111,7 @@ rq_userset : 1, /* auth->setuser OK */ rq_secure : 1, /* secure port */ rq_auth : 1; /* check client */ + u32 rq_daddr; /* dest addr of request - reply
from here */
void * rq_argp; /* decoded arguments */
void * rq_resp; /* xdr'd results */net/sunrpc/svcsock.c 2003-08-19 01:54:32.000000000 -0700 renamed from net/sunrpc/svcsock.c.orig 2003-08-19 01:28:27.000000000 -0700 +17 -2
@@ -316,6 +316,9 @@ struct socket *sock = svsk->sk_sock; struct msghdr msg; int i, buflen, len; + struct { struct cmsghdr cmh; + struct in_pktinfo pki; + } cm; for (i = buflen = 0; i < nr; i++) buflen += iov[i].iov_len;
@@ -324,8 +327,6 @@ msg.msg_namelen = sizeof(rqstp->rq_addr); msg.msg_iov = iov; msg.msg_iovlen = nr; - msg.msg_control = NULL; - msg.msg_controllen = 0; /* This was MSG_DONTWAIT, but I now want it to wait. * The only thing that it would wait for is memory and
@@ -335,6 +336,19 @@ */ msg.msg_flags = 0; + /* set the source */ + if (rqstp->rq_prot == IPPROTO_UDP) { + msg.msg_control = &cm; + msg.msg_controllen = sizeof(cm); + cm.cmh.cmsg_len = sizeof(cm); + cm.cmh.cmsg_level = SOL_IP; + cm.cmh.cmsg_type = IP_PKTINFO; + cm.pki.ipi_ifindex = 0; + cm.pki.ipi_spec_dst.s_addr = rqstp->rq_daddr; + } else { + msg.msg_control = NULL; + msg.msg_controllen = 0; + } oldfs = get_fs(); set_fs(KERNEL_DS); len = sock_sendmsg(sock, &msg, buflen); set_fs(oldfs);
@@ -529,6 +543,7 @@ rqstp->rq_addr.sin_family = AF_INET; rqstp->rq_addr.sin_port = skb->h.uh->source; rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr; + rqstp->rq_daddr = skb->nh.iph->daddr; if (serv->sv_stats) serv->sv_stats->netudpcnt++;
Quoting Neil Brown <[email protected]>:
Quoted 29 lines · On Saturday August 16, [email protected] wrote:
Quoted 4 lines
Running tcpdump on the primary node like so:
tcpdump -np -s 1600 udp port 2049
gives some interesting info, especially when I retry mounting by thevirtual
Quoted 1 line
ip from the nfs client. It looks like the server accepts the connection on
the
Quoted 4 lines
virtual ip (i.e. eth0:0) but nfsd on port 2049 replies using the primary interface ip (i.e. eth0). The client doesn't like the reply from different
host I guess therefore timing out.
Could you try the following patch and let me know if it helps? Thanks.
NeilBrown
----------- Diffstat output ------------
./include/linux/sunrpc/svc.h | 2 ++ ./net/sunrpc/svcsock.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)diff
./include/linux/sunrpc/svc.h~current~./include/linux/sunrpc/svc.h
---./include/linux/sunrpc/svc.h~current~2003-08-17 20:25:23.000000000
+1000
+++./include/linux/sunrpc/svc.h2003-08-17 20:26:34.000000000 +1000
Review struct svc_rqst { · line 115
Quoted 4 lines
(quoted diff) +1
-0@@ -112,6 +112,8 @@ struct svc_rqst { rq_secure : 1, /* secure port */ rq_auth : 1; /* check client */ + __u32 rq_daddr; /* dest addr of request -
reply from here */
Quoted 41 lines
(quoted diff) +1
-0+ void * rq_argp; /* decoded arguments */ void * rq_resp; /* xdr'd results */diff
./net/sunrpc/svcsock.c~current~./net/sunrpc/svcsock.cnet/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c~current~ +15
-2@@ -317,6 +317,9 @@ svc_sendto(struct svc_rqst *rqstp, strucstruct svc_sock *svsk = rqstp->rq_sock;struct socket *sock = svsk->sk_sock;struct msghdr msg; +struct {struct cmsghdr cmh; +struct in_pktinfo pki; + } cm;int i, buflen, len;for (i = buflen =0 ; i < nr; i++)@@ -326,8 +329,18 @@ svc_sendto(struct svc_rqst *rqstp, struc msg.msg_namelen =sizeof (rqstp->rq_addr); msg.msg_iov = iov; msg.msg_iovlen = nr; - msg.msg_control =NULL ; - msg.msg_controllen =0 ; +if (rqstp->rq_prot ==IPPROTO_UDP ) { + msg.msg_control = &cm; + msg.msg_controllen =sizeof (cm); + cm.cmh.cmsg_len =sizeof (cm); + cm.cmh.cmsg_level =SOL_IP ; + cm.cmh.cmsg_type =IP_PKTINFO ; + cm.pki.ipi_ifindex =0 ; + cm.pki.ipi_spec_dst.s_addr = rqstp->rq_daddr; + }else { + msg.msg_control =NULL ; + msg.msg_controllen =0 ; + }/* This was MSG_DONTWAIT, but I now want it to wait. * The only thing that it would wait for is memory and
net/sunrpc/svcsock.c svc_udp_recvfrom(struct svc_rqst *rqstp) · line 550
Quoted 7 lines
net/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c~current~ +1
-0@@ -531,6 +544,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) rqstp->rq_addr.sin_family =AF_INET ; rqstp->rq_addr.sin_port = skb->h.uh->source; rqstp->rq_addr.sin_addr.s_addr = skb->nh.iph->saddr; + rqstp->rq_daddr = skb->nh.iph->daddr;if (serv->sv_stats) serv->sv_stats->netudpcnt++;
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
Quoted 9 lines · On Tuesday August 19, [email protected] wrote:
Hi,
Neil, Thank you very much for your very useful patch. Unfortunately, I didnt realize this was against ~current (2.6.x ?) therefore it failed horribly :/ I modified it against 2.4.20-19 (redhat9's kernel-source updated), and it works as expected. The nfsd on port 2049 no longer responds on eth0 when it gets a request on eth0:0, but instead replies on the if/addr it received the connection from.
Keep up the good work!
That patch was against a 2.4 kernel, but it must have been different enough from yours that patch failed to apply it ('wiggle' would have worked).
The code in 2.6 is quite different due to the zero-copy stuff. Linus recently accepted the 2.6 equivalent patch so this will definately be fixed in 2.6.0, and probably in 2.4.23 as well.
NeilBrown
-------------------------------------------------------
This SF.net email is sponsored by Dice.com.
Did you know that Dice has over 25,000 tech jobs available today? From careers in IT to Engineering to Tech Sales, Dice has tech jobs from the best hiring companies. http://www.dice.com/index.epl?rel_code=104
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs