Subject: Re: Bind to local iface: bug or feautre.
To: Assar Westerlund <>
From: Jesus M. Gonzalez <>
List: tech-net
Date: 11/26/1996 12:31:16
Assar Westerlund writes:
 > "Jesus M. Gonzalez" <> writes:

 > > 	NetBSD returns an error when binding an UDP address where
 > > the host address matchs a local iface (instead of the more used
 > > INADDR_ANY). I'm not familar with the networking code,
 > > and I'm not sure if this is a bug or a feature... Could somebody
 > > tell me, so that I send-pr it if it is a bug?
 > It's not a bug, or perhaps it is.  The sockaddr_in needs to zeroed out
 > because a bit-by-bit comparison is done in `in_pcbbind' with
 > `ifa_ifwithaddr'

	Thanks, Assar. I went to the sources, and yeah, there is it.
I has a look at Stevens' book, and I saw the comment regarding the
zeroing of the sockaddr_in. But I wonder if this shouln't be changed
(fixed). Since all teh code is in a INET-dependent section, shouldn't
the comparasion be made just between the host_addr parts of the
involved sockaddr_ins? This is what seems to be done in Linux (though
the code is quite different). And anyway, it's rather surprising
that you don't need to zero the sockaddr_in if you use INADDR_ANY,
but you *need* to if you use any other address...

	Any more opoinions about this being a bug? (Just to be
sure of your opinion before filing a PR).

Jesus M. Gonzalez Barahona         | addr.:  c/ Butarque, 15
Grupo de Sistemas y Comunicaciones |         28911 Leganes, Spain
Departamento de Informatica        | tel: +34 1 624 94 58
Universidad Carlos III de Madrid   | fax: +34 1 624 94 30
e-mail:       | www: