Subject: Re: bind(2) ordering constraint

From: Tim Hartrick <[email-masked]>
Date: Sat, 5 Aug 2000 17:12:49 -0700 (PDT)

Itojun,

	This is what our implementation does.  Not too surprisingly the
behavior below doesn't match what I said our implementation did.  It is
quite a bit more restrictive than I had remembered.

	Unlike Solaris and I guess Windows we don't have independent
port spaces for IPv6 and IPv4 although that seems to be the easiest way
to avoid messing up existing IPv4 binaries.

starting tests, socktype = SOCK_DGRAM
wild4 then wild4
	bind socket for 0.0.0.0/8888
	bind socket for 0.0.0.0/8888
	failed bind for 0.0.0.0/8888, Address already in use
wild4 then wild6
	bind socket for 0.0.0.0/8888
	bind socket for ::/8888
	failed bind for ::/8888, Address already in use
wild4 then loop4
	bind socket for 0.0.0.0/8888
	bind socket for 127.0.0.1/8888
	failed bind for 127.0.0.1/8888, Address already in use
wild4 then loop6
	bind socket for 0.0.0.0/8888
	bind socket for ::1/8888
	failed bind for ::1/8888, Address already in use
wild4 then one4
	bind socket for 0.0.0.0/8888
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Address already in use
wild4 then map4
	bind socket for 0.0.0.0/8888
	bind socket for ::ffff:127.0.0.1/8888
	failed bind for ::ffff:127.0.0.1/8888, Address already in use
wild6 then wild4
	bind socket for ::/8888
	bind socket for 0.0.0.0/8888
	failed bind for 0.0.0.0/8888, Address already in use
wild6 then wild6
	bind socket for ::/8888
	bind socket for ::/8888
	failed bind for ::/8888, Address already in use
wild6 then loop4
	bind socket for ::/8888
	bind socket for 127.0.0.1/8888
	failed bind for 127.0.0.1/8888, Address already in use
wild6 then loop6
	bind socket for ::/8888
	bind socket for ::1/8888
	failed bind for ::1/8888, Address already in use
wild6 then one4
	bind socket for ::/8888
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Address already in use
wild6 then map4
	bind socket for ::/8888
	bind socket for ::ffff:127.0.0.1/8888
	failed bind for ::ffff:127.0.0.1/8888, Address already in use
loop4 then wild4
	bind socket for 127.0.0.1/8888
	bind socket for 0.0.0.0/8888
	failed bind for 0.0.0.0/8888, Address already in use
loop4 then wild6
	bind socket for 127.0.0.1/8888
	bind socket for ::/8888
	failed bind for ::/8888, Address already in use
loop4 then loop4
	bind socket for 127.0.0.1/8888
	bind socket for 127.0.0.1/8888
	failed bind for 127.0.0.1/8888, Address already in use
loop4 then loop6
	bind socket for 127.0.0.1/8888
	bind socket for ::1/8888
loop4 then one4
	bind socket for 127.0.0.1/8888
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
loop4 then map4
	bind socket for 127.0.0.1/8888
	bind socket for ::ffff:127.0.0.1/8888
	failed bind for ::ffff:127.0.0.1/8888, Address already in use
loop6 then wild4
	bind socket for ::1/8888
	bind socket for 0.0.0.0/8888
	failed bind for 0.0.0.0/8888, Address already in use
loop6 then wild6
	bind socket for ::1/8888
	bind socket for ::/8888
	failed bind for ::/8888, Address already in use
loop6 then loop4
	bind socket for ::1/8888
	bind socket for 127.0.0.1/8888
loop6 then loop6
	bind socket for ::1/8888
	bind socket for ::1/8888
	failed bind for ::1/8888, Address already in use
loop6 then one4
	bind socket for ::1/8888
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
loop6 then map4
	bind socket for ::1/8888
	bind socket for ::ffff:127.0.0.1/8888
one4 then wild4
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
one4 then wild6
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
one4 then loop4
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
one4 then loop6
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
one4 then one4
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
one4 then map4
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
map4 then wild4
	bind socket for ::ffff:127.0.0.1/8888
	bind socket for 0.0.0.0/8888
	failed bind for 0.0.0.0/8888, Address already in use
map4 then wild6
	bind socket for ::ffff:127.0.0.1/8888
	bind socket for ::/8888
	failed bind for ::/8888, Address already in use
map4 then loop4
	bind socket for ::ffff:127.0.0.1/8888
	bind socket for 127.0.0.1/8888
	failed bind for 127.0.0.1/8888, Address already in use
map4 then loop6
	bind socket for ::ffff:127.0.0.1/8888
	bind socket for ::1/8888
map4 then one4
	bind socket for ::ffff:127.0.0.1/8888
	bind socket for 0.0.0.1/8888
	failed bind for 0.0.0.1/8888, Cannot assign requested address
map4 then map4
	bind socket for ::ffff:127.0.0.1/8888
	bind socket for ::ffff:127.0.0.1/8888
	failed bind for ::ffff:127.0.0.1/8888, Address already in use

--------------------------------------------------------------------
IETF IPng Working Group Mailing List
IPng Home Page:                      http://playground.sun.com/ipng
FTP archive:                      ftp://playground.sun.com/pub/ipng
Direct all administrative requests to [email-masked]
--------------------------------------------------------------------

---

From: Jun-ichiro itojun Hagino <[email-masked]>
Date: Sun, 06 Aug 2000 09:15:00 +0900

>	failed bind for 0.0.0.0/8888, Address already in use

	thanks, doesn't the "wild4 then wild6" entry cause some problem
	for you?

	actually, if we have bind(2) ordering constraint in the kernel,
	the order of return value from getaddrinfo(3) has to be carefully
	designed - in your case, I bet you need to return AF_INET6 first on
	AI_PASSIVE getaddrinfo lookup.

itojun

---

From: Hideaki YOSHIFUJI (吉藤英明) <[email-masked]>
Date: Sun, 06 Aug 2000 21:30:56 +0900

> 	AI_PASSIVE getaddrinfo lookup.

Yes, getaddrinfo() flagged AI_PASSIVE with PF_UNSPEC hints SHOULD return 
PF_INET6 before PF_INET.  glibc is ok at this point.

-- 
Hideaki YOSHIFUJI @ USAGI Project  <[email-masked]>
Web Page: http://www.ecei.tohoku.ac.jp/%7Eyoshfuji/
PGP5i FP: F731 6599 5EB2 BBA7 1515  1323 1806 A96F 5700 6B25 
--------------------------------------------------------------------
IETF IPng Working Group Mailing List
IPng Home Page:                      http://playground.sun.com/ipng
FTP archive:                      ftp://playground.sun.com/pub/ipng
Direct all administrative requests to [email-masked]
--------------------------------------------------------------------

---

From: Jun-ichiro itojun Hagino <[email-masked]>
Date: Mon, 07 Aug 2000 00:17:25 +0900

>PF_INET6 before PF_INET.  glibc is ok at this point.

	"getaddrinfo(3) should sort replies so that it respects bind(2)
	behavior".  for Tim's case and linux's case, due to bind(2) behavior,
	getaddrinfo(3) should return AF_INET6 entries first.

itojun