Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 May 2001 23:43:00 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        freebsd-net@FreeBSD.ORG
Cc:        arch@FreeBSD.ORG
Subject:   FreeBSD breaks sockets two ways...
Message-ID:  <200105112343.QAA04578@usr08.primenet.com>

next in thread | raw e-mail | index | archive | help
I have run into two issues, that I find really, really annoying.  This
is in FreeBSD 4.3 and 5.x.  Bot machines are on a local (non-switched)
segment (it works the same with a switch, but taking that out proves
it is not the switch causing the problem).


Primus
------

The first is that when you create a socket, and bind it to a
specific local IP address, and then connect, it fails to
allocate an automatic port private to the socket; specifically:

	int	s;
	struct sockaddr_in sockaddr;

	s = socket(AF_INET, SOCK_STREAM, 0);
	bzero(&sockaddr,sizeof(sockaddr));
	sockaddr.sin_family = AF_INET;
	sockaddr.sin_addr.s_addr = s_addr2;
	sockaddr.sin_port = 0;
	if (bind(s, (struct sockaddr *) &sockaddr, sizeof(sockaddr)) == -1) {
		perror("bind");
		errx(1, "bind failed");
	}

...in other words, the sockets are all hashed into the same
(global) collsion domain, even though they are _not_ global,
they are specific to a particular IP address.


Secondus
--------

On an OS where the above actually works (e.g. _not_ FreeBSD), when
I make connections from two ports which are the same, but with
different IP addresses, it seems that the MAC address is used by
FreeBSD to differentiate connections, and _not_ the IP/port pair.

This means that on FreeBSD, the incoming connection on two different
source IPs from the same MAC address end up resetting the first
connection, when the second one comes in; instead of getting two
total connections, I end up getting only a single connection.



Both of these seem to be serious screwups in the routing code hash
lookup algorithm, acting as if everything is in the INADDR_ANY
domain, and as if it were keying off the MAC address, and not the
IP address... as it should be.


Has anyone else seen this?  Obviously, it's hard to reproduce
FreeBSD-to-FreeBSD (at least without a BPF program on the client
side to cause the problem)...


I'm primarily interested in a fix for 4.3.


					Thanks,
					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105112343.QAA04578>