Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jun 1996 16:17:15 +0100 (BST)
From:      Jonathan Laventhol <jcl@pavilion.co.uk>
To:        hackers@freebsd.org
Subject:   Multiple delivery of UDP and IP aliases
Message-ID:  <199606251517.QAA13345@deputy.pavilion.co.uk>

next in thread | raw e-mail | index | archive | help
Dear BSD Clever People --

(Please respond directly: I'm not on the mailing lists.  Thanks.)

Anybody understand the following:

I'm getting multiple delivery of UDP packets under particular
circumstances to do with SO_REUSEADDR and aliases on interfaces.
Briefly, a packet sent to an alias is getting delivered twice,
to different sockets, whereas the packet to the main address
only gets delivered once.  This is a real problem to do with
named serving on alias ip addresses, but I've got test code if
anyone wants to play with it.

Get an interface with two alias addresses:
	ifconfig de0 inet 192.9.200.1 netmask 255.255.255.0
	ifconfig de0 inet alias 192.9.200.2 netmask 255.255.255.255
	ifconfig de0 inet alias 192.9.200.3 netmask 255.255.255.255

Get two DGRAM sockets, both marked SO_REUSEADDR:
	bind socket1 to 192.9.200.2 port 2000
	bind socket0 to INADDR_ANY port 2000

Get another host, 192.9.200.9.

Transmit a UDP packet
from		to		arrives
192.9.200.9	192.9.100.1	socket0
192.9.200.9	192.9.200.2	*** socket1 and socket0 ***
192.9.200.9	192.9.200.3	socket0


But ...  get two DGRAM sockets, both marked SO_REUSEADDR:
	bind socket1 to 192.9.200.1 port 2000  (the 'real' address)
	bind socket0 to INADDR_ANY port 2000

Transmit a UDP packet
from		to		arrives
192.9.200.9	192.9.100.1	socket1
192.9.200.9	192.9.200.2	socket0
192.9.200.9	192.9.200.3	socket0



The duplication looks suspect to me.  I (briefly) tried to find it
in the kernel but didn't see it.  I did, however, find this
intriguing comment in udp_usrreq.c


 * udp_usrreq.c,v 1.12 1995/05/30 08:10:02 rgrimes Exp

/*
 * Deliver a multicast or broadcast datagram to *all* sockets
 * for which the local and remote addresses and ports match
 * those of the incoming datagram.  This allows more than
 * one process to receive multi/broadcasts on the same port.
 * (This really ought to be done for unicast datagrams as
 * well, but that would cause problems with existing
 * applications that open both address-specific sockets and
 * a wildcard socket listening to the same port -- they would
 * end up receiving duplicates of every unicast datagram.
 * Those applications open the multiple sockets to overcome an
 * inadequacy of the UDP socket interface, but for backwards
 * compatibility we avoid the problem here rather than
 * fixing the interface.  Maybe 4.5BSD will remedy this?)
 */



Anybody know a) where the duplication I'm reporting happens, and
b) what the 'inadequacy of the UDP socket interface' is?


All help gratefully received.

Jonathan.

        -------------------------------------------------
        J o n a t h a n                 L a v e n t h o l
        T e c h n i c a l                 D i r e c t o r
        P a v i l i o n       I n t e r n e t       p l c
        aqua house    24 old steine    brighton   bn1 1el
        01273 607072   phone     .     01273 607073   fax
        -------------------------------------------------



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