Subject: kern/7065: can not bind with SO_REUSEADDR - xntpd fails
To: None <gnats-bugs@gnats.netbsd.org>
From: Martin Husemann <martin@rumolt.teuto.de>
List: netbsd-bugs
Date: 02/28/1999 21:37:18
>Number:         7065
>Category:       kern
>Synopsis:       can not bind with SO_REUSEADDR - xntpd fails
>Confidential:   yes
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 28 12:50:01 1999
>Last-Modified:
>Originator:     Martin Husemann
>Organization:
	
>Release:        current as of today
>Environment:
	
System: NetBSD rumolt.teuto.de 1.3J NetBSD 1.3J (RUMOLT) #0: Sun Feb 28 19:45:06 MET 1999 martin@asprian.teuto.de:/usr/src/sys-i4b/arch/i386/compile/RUMOLT i386


>Description:

xntpd fails for me in a configuration that always used to work (first failure
was after upgrading from an early 1.3I to one of the latest 1.3I about a
week ago).

The problem is this:

Feb 28 21:28:19 rumolt xntpd[2780]: bind() fd 7, family 2, port 123, addr d408cb51, in_classd=0 flags=0 fails: Address already in use

This address is used by one ethernet and two point-to-point interfaces on
this machine:

ep0: flags=8822<BROADCAST,NOTRAILERS,SIMPLEX,MULTICAST> mtu 1500
	address: 00:10:4b:24:be:a8
	media: Ethernet 10baseT
	status: active
ipr0: flags=2811<UP,POINTOPOINT,SIMPLEX,LINK1> mtu 1500
	inet 212.8.203.81 --> 192.168.110.42 netmask 0xffffffff 
isp0: flags=2810<POINTOPOINT,SIMPLEX,LINK1> mtu 1500
	inet 212.8.203.81 --> 212.8.192.1 netmask 0xffffffff 

Although xntpd uses SO_REUSADDR the bind for the later two addreses fails
with above error message.

I think the code in xntpd should do thinks differently (what use are multiple
sockets bound to the same address in this case?), but as far as I always
understood this, the things it does are formaly correct, so we should not
fail here.

I can create an easy workaround in my local situation by skipping all
interfaces with IFF_POINTTOPOINT, but that is not the right thing to
do in general.

>How-To-Repeat:

ifconfig one ethernet and one ppp interface to the same local address.
Try to start xntpd.

>Fix:

I could create a patch to skip point to point interfaces in xntpd, but
the real solution (as far as I can see) should be inside the kernel, in
an area a lot people here know much more about than I do...
>Audit-Trail:
>Unformatted: