Skip to contentSkip to conversation

sunrpc: fix peername failed on closed listener

PATCH In review Xiaotian Feng 3 participants 4 messages Dec 31, 2009 – Jan 6, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sunrpc: fix peername failed on closed listener

There're some warnings of "nfsd: peername failed (err 107)!" socket error -107 means Transport endpoint is not connected.
This warning message was outputed by svc_tcp_accept() [net/sunrpc/svcsock.c], when kernel_getpeername returns -107. This means socket might be CLOSED.

And svc_tcp_accept was called by svc_recv() [net/sunrpc/svc_xprt.c]

        if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
        <snip>
                newxpt = xprt->xpt_ops->xpo_accept(xprt);
        <snip>

So this might happen when xprt->xpt_flags has both XPT_LISTENER and XPT_CLOSE.

Let's take a look at commit b0401d72, this commit has moved the close processing after do recvfrom method, but this commit also introduces this warnings, if the xpt_flags has both XPT_LISTENER and XPT_CLOSED, we should close it, not accpet then close.

Cc J. Bruce Fields <[email protected]>
Cc Neil Brown <[email protected]>
Cc Trond Myklebust <[email protected]>
Cc David S. Miller <davem-fT/PcQaiUtIeIZ0/[email protected]>

---

net/sunrpc/svc_xprt.c +2 -1
index 1c924ee..187f0f4 100644
@@ -699,7 +699,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
 	spin_unlock_bh(&pool->sp_lock);
 
 	len = 0;
-	if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
+	if (test_bit(XPT_LISTENER, &xprt->xpt_flags) &&
+	    !test_bit(XPT_CLOSE, &xprt->xpt_flags)) {
 		struct svc_xprt *newxpt;
 		newxpt = xprt->xpt_ops->xpo_accept(xprt);
 		if (newxpt) {

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

(CCing [email protected]) Greg, once this patch is ACKed, can You also queue it for 2.6.32.x please?
thanks!
nik

Quoted 45 lines · Xiaotian Feng

There're some warnings of "nfsd: peername failed (err 107)!" socket error -107 means Transport endpoint is not connected.
This warning message was outputed by svc_tcp_accept() [net/sunrpc/svcsock.c], when kernel_getpeername returns -107. This means socket might be CLOSED.

And svc_tcp_accept was called by svc_recv() [net/sunrpc/svc_xprt.c]

        if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
        <snip>
                newxpt = xprt->xpt_ops->xpo_accept(xprt);
        <snip>

So this might happen when xprt->xpt_flags has both XPT_LISTENER and XPT_CLOSE.

Let's take a look at commit b0401d72, this commit has moved the close processing after do recvfrom method, but this commit also introduces this warnings, if the xpt_flags has both XPT_LISTENER and XPT_CLOSED, we should close it, not accpet then close.

Cc J. Bruce Fields <[email protected]>
Cc Neil Brown <[email protected]>
Cc Trond Myklebust <[email protected]>
Cc David S. Miller <davem-fT/PcQaiUtIeIZ0/[email protected]>

---

net/sunrpc/svc_xprt.c +2 -2
index 1c924ee..187f0f4 100644
@@ -699,7 +699,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
 	spin_unlock_bh(&pool->sp_lock);
 
 	len = 0;
-	if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
+	if (test_bit(XPT_LISTENER, &xprt->xpt_flags) &&
+	    !test_bit(XPT_CLOSE, &xprt->xpt_flags)) {
 		struct svc_xprt *newxpt;
 		newxpt = xprt->xpt_ops->xpo_accept(xprt);
 		if (newxpt) {
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 17 lines
-------------------------------------
Ing. Nikola CIPRICH
LinuxBox.cz, s.r.o.
28. rijna 168, 709 01 Ostrava

tel.:   +420 596 603 142
fax:    +420 596 621 273
mobil:  +420 777 093 799
www.linuxbox.cz

mobil servis: +420 737 238 656
email servis: servis-Jp3n8lUXroTtwjQa/[email protected]
-------------------------------------
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to Xiaotian Feng
Quoted 12 lines · Xiaotian Feng

There're some warnings of "nfsd: peername failed (err 107)!" socket error -107 means Transport endpoint is not connected.
This warning message was outputed by svc_tcp_accept() [net/sunrpc/svcsock.c], when kernel_getpeername returns -107. This means socket might be CLOSED.

And svc_tcp_accept was called by svc_recv() [net/sunrpc/svc_xprt.c]

        if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
        <snip>
                newxpt = xprt->xpt_ops->xpo_accept(xprt);
        <snip>
Quoted 6 lines

So this might happen when xprt->xpt_flags has both XPT_LISTENER and XPT_CLOSE.

Let's take a look at commit b0401d72, this commit has moved the close processing after do recvfrom method, but this commit also introduces this warnings, if the xpt_flags has both XPT_LISTENER and XPT_CLOSED, we should close it, not accpet then close.

The logic here seems unnecessarily complicated now, but as a minimal fix, this seems fine.

Is the *only* justification for this to silence this warning, or is there some more serious problem I'm missing?

--b.

Quoted 21 lines
Cc J. Bruce Fields <[email protected]>
Cc Neil Brown <[email protected]>
Cc Trond Myklebust <[email protected]>
Cc David S. Miller <[email protected]>

---

net/sunrpc/svc_xprt.c +2 -1
index 1c924ee..187f0f4 100644
@@ -699,7 +699,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
 	spin_unlock_bh(&pool->sp_lock);
 
 	len = 0;
-	if (test_bit(XPT_LISTENER, &xprt->xpt_flags)) {
+	if (test_bit(XPT_LISTENER, &xprt->xpt_flags) &&
+	    !test_bit(XPT_CLOSE, &xprt->xpt_flags)) {
 		struct svc_xprt *newxpt;
 		newxpt = xprt->xpt_ops->xpo_accept(xprt);
 		if (newxpt) {
#3 lore raw
Quoted 20 lines · J. Bruce Fields
Quoted 12 lines · Xiaotian Feng

There're some warnings of "nfsd: peername failed (err 107)!" socket error -107 means Transport endpoint is not connected.
This warning message was outputed by svc_tcp_accept() [net/sunrpc/svcsock.c], when kernel_getpeername returns -107. This means socket might be CLOSED.

And svc_tcp_accept was called by svc_recv() [net/sunrpc/svc_xprt.c]

         if (test_bit(XPT_LISTENER,&xprt->xpt_flags)) {
         <snip>
                 newxpt = xprt->xpt_ops->xpo_accept(xprt);
         <snip>
Quoted 6 lines

So this might happen when xprt->xpt_flags has both XPT_LISTENER and XPT_CLOSE.

Let's take a look at commit b0401d72, this commit has moved the close processing after do recvfrom method, but this commit also introduces this warnings, if the xpt_flags has both XPT_LISTENER and XPT_CLOSED, we should close it, not accpet then close.

Quoted 5 lines

The logic here seems unnecessarily complicated now, but as a minimal fix, this seems fine.

Is the *only* justification for this to silence this warning, or is there some more serious problem I'm missing?

If a xprt->xpt_flags has XPT_CLOSE & XPT_LISTENER, kernel will accept it first, and svc_xprt_received(xptr) no mater xpo_accept is suceed or failed, then svc_delete_xprt(xprt).

I'm not sure what will happened between the svc_xprt_received and svc_delete_xprt, there isn't any lock to protect it.

Quoted 17 lines

--b.

Quoted 14 lines
Cc J. Bruce Fields<[email protected]>
Cc Neil Brown<[email protected]>
Cc Trond Myklebust<[email protected]>
Cc David S. Miller<davem-fT/PcQaiUtIeIZ0/[email protected]>

---

net/sunrpc/svc_xprt.c +0 -0
index 1c924ee..187f0f4 100644
@@ -699,7 +699,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
  	spin_unlock_bh(&pool->sp_lock);
 
Quoted 8 lines

net/sunrpc/svc_xprt.c int svc_recv(struct svc_rqst *rqstp, long timeout) · line 706

Quoted 7 lines
net/sunrpc/svc_xprt.c +2 -1
  	len = 0;
-	if (test_bit(XPT_LISTENER,&xprt->xpt_flags)) {
+	if (test_bit(XPT_LISTENER,&xprt->xpt_flags)&&
+	    !test_bit(XPT_CLOSE,&xprt->xpt_flags)) {
  		struct svc_xprt *newxpt;
  		newxpt = xprt->xpt_ops->xpo_accept(xprt);
  		if (newxpt) {

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html