Re: getpeername broken? ( was Re: probably problem with "lo" interface (Re: Strange problem with 2.3.42) )

From: Craig Schlenter (craig@qualica.com)
Date: Fri Feb 04 2000 - 10:11:00 EST


On Fri, Feb 04, 2000 at 08:34:55AM +0200, I wrote:
> On Thu, Feb 03, 2000 at 05:58:37PM -0800, David S. Miller wrote:
> >
> > Can people try this patch? Thanks.
> [snip]
> > - if (!sk->dport)
> > + if (!sk->dport || sk->state == TCP_SYN_SENT)
>
> getpeername still seems to report success :(
[snip, strace of strobe deleted]
> I'll stick some prink's in sometime tonight to see what state the socket is
> in. Perhaps it is already in TCP_CLOSE or something by the time getpeername
> is called?

Me again ...

The socket seems to have been in TCP_CLOSE. The following patch works for
me with no immediately obvious bad side effects:

--- /usr/src/linux/net/ipv4/af_inet.c 2000/02/03 17:33:26 1.1
+++ /usr/src/linux/net/ipv4/af_inet.c 2000/02/04 14:58:44
@@ -675,7 +675,7 @@
   
         sin->sin_family = AF_INET;
         if (peer) {
- if (!sk->dport)
+ if (!sk->dport || sk->state == TCP_SYN_SENT || sk->state == TCP_CLOSE)
                         return -ENOTCONN;
                 sin->sin_port = sk->dport;
                 sin->sin_addr.s_addr = sk->daddr;

Cheers,

--Craig

-
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 : Mon Feb 07 2000 - 21:00:11 EST