2.2.15pre7 spurious error returns from shutdown()

From: Zack Weinberg (zack@wolery.cumb.org)
Date: Tue Feb 15 2000 - 16:52:26 EST


If you have a TCP socket and you call shutdown(socket, SHUT_WR) and
then later you call shutdown(socket, SHUT_RD) the second call will
return -ENOTCONN. This is not what userland expects. I see this
pattern in openssh 1.2.2 used to tunnel HTTP requests through a
firewall; you get a spurious error message for every HTTP connection.

The error comes from af_inet.c where we check for a connected socket
before calling the protocol shutdown method. TCP read shutdown
doesn't actually do anything, so we should just suppress the error in
this case. Patch:

--- net/ipv4/af_inet.c.old Sat Feb 12 14:38:29 2000
+++ net/ipv4/af_inet.c Tue Feb 15 13:33:49 2000
@@ -825,7 +825,7 @@ int inet_shutdown(struct socket *sock, i
                 return(-ENOTCONN);
         if (sock->state == SS_CONNECTING && sk->state == TCP_ESTABLISHED)
                 sock->state = SS_CONNECTED;
- if (!tcp_connected(sk->state))
+ if ((how & SEND_SHUTDOWN) && !tcp_connected(sk->state))
                 return(-ENOTCONN);
         sk->shutdown |= how;
         if (sk->prot->shutdown)

A lot of the logic in inet_shutdown looks like it belongs in
tcp_shutdown instead, but tcp_shutdown can't return an error so we're
stuck with it.

zw

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:30 EST