From owner-freebsd-bugs Sun Mar 28 13:17:19 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from mail.rdc1.bc.home.com (ha1.rdc1.bc.wave.home.com [24.2.10.66]) by hub.freebsd.org (Postfix) with ESMTP id 37BB615724 for ; Sun, 28 Mar 1999 13:17:15 -0800 (PST) (envelope-from pangolin@home.com) Received: from cr1003333-a.crdva1.bc.wave.home.com ([24.113.51.240]) by mail.rdc1.bc.home.com (InterMail v4.00.03 201-229-104) with ESMTP id <19990328211656.DXBI19860.mail.rdc1.bc.home.com@cr1003333-a.crdva1.bc.wave.home.com>; Sun, 28 Mar 1999 13:16:56 -0800 Content-Length: 2238 X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <199903280520.VAA37458@freefall.freebsd.org> Date: Sun, 28 Mar 1999 13:16:56 -0800 (PST) Reply-To: Jonathan Hanna Organization: Pangolin Systems From: Jonathan Hanna To: Per Kristian Hove Subject: Re: kern/10826: TCP connection looped back to itself Cc: freebsd-bugs@freebsd.org Message-Id: <19990328211656.DXBI19860.mail.rdc1.bc.home.com@cr1003333-a.crdva1.bc.wave.home.com> Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On 28-Mar-99 Per Kristian Hove wrote: > > On Sat, 27 Mar 1999, Chris Costello wrote: > > > How is this a bug? It behaves how it should, doesn't it? > > If it does, I'm sorry I've taken up your time on something that isn't a > bug. I'm not at all a networking guru, it just seemed strange to me to get > a connection when nothing should be listening to that port. > > But when setting net.inet.tcp.log_in_vin = 1 and try to connect to port > 3434, I see in my logs > Connection attempt to TCP 127.0.0.1:3434 from 127.0.0.1:3460 > and when I then try to connect to port 3461 (the "outgoing" port number > increases by 1 for every connection attempt), that succeeds. So what > seemed random, it's not random at all. > > I thought you had to explicitly listen() [and then accept()] in order to > accept connections. But connect()ing on a socket makes it accept incoming > connections? (And yes, I'm no programmer either). > > This is how I thought it worked: > When I connect to the port, a port is allocated locally in the local end > of the connection. Then a SYN is sent to the remote end, and if I get a > (SYN | ACK) in return, I will get connected to the destination end. If I > should get just a (SYN | ~ACK), I shouldn't get connected to the remote > end. I only send a SYN (to myself, by accident, cause the port > number is the same in both ends of the connection), and since I'm sending > it to myself, I also think that I'm receiving it. But since it's just a > SYN, and not a (SYN | ACK), I shouldn't accept that it's a valid response > to my original SYN. It seems like FreeBSD reads the SYN as 'okay, let him > have a connection'. At the risk of adding to the noise level... As far as the TCP protocol is defined the "three was handshake" for connection establishment is symmetric. listen() is really only a special case of connect() that does not time out (and allocates a new socket etc.). Doing reasonably simultaneous connects on both ends is supposed to work and there may even be programs that depend on it. This is like PPP, where the protocol is symmetric and the being a "client" or "server" just depends on a willingness to time out. Jonathan Hanna To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message