Re: 2.4/2.6 local TCP connect oddity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 21 Oct 2007 19:29:02 +0200
Willy Tarreau <[email protected]> wrote:

> Hi,
> 
> On Sun, Oct 21, 2007 at 05:53:37PM +0200, Tal Kelrich wrote:
> > Hi,
> > 
> > I've run into a problem where a process trying to connect to a local
> > port within the local port range eventually ends up connected to
> > itself, with source port = dest port.
> > 
> > similar behavior can be gotten by running netcat as follows:
> > nc -p 1025 localhost 1025
> > 
> > I'm not really sure if that's a bug, but the original case was at
> > least unexpected.
> 
> It is not a bug, it is caused by the "simultaneous connect" feature of
> TCP. Although rarely used, in TCP you can connect two clients
> together. They just have to exchange their SYN, SYN/ACK then ACK and
> bingo, they're connected. In fact, you found the easiest way to
> achieve it, by using the same port. To demonstrate the feature, I'm
> used to either temporarily block SYNs with iptables, or by unplugging
> the cable between two machines.
> 

Hi,

It still seems confusing that a connect against localhost may
randomly succeed.

Here's a better example, if somewhat violent. eventually succeeds.
(p=$((`cat /proc/sys/net/ipv4/ip_local_port_range|cut -f1`+1)); while
true ; do nc -v -v 127.0.0.1 $p ; done)

Regards,
	Tal

-- 
Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F  CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
----
We are each entitled to our own opinion, but no one is entitled to his
own facts.
		-- Patrick Moynihan
----
-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux