[<prev] [next>] [day] [month] [year] [list]
Message-ID: <46C0CDFF.6080409@free.fr>
Date: Mon, 13 Aug 2007 23:32:47 +0200
From: Benoit PAPILLAULT <benoit.papillault@...e.fr>
To: linux-kernel@...r.kernel.org
Subject: UDP broadcast packets not looped back
Hi there,
I wrote a small C program using the BSD socket API to send a UDP
broadcast packet to all interfaces of my machine. To do so, i sendto()
it to 255.255.255.255 after using setsockopt(SO_BINDTODEVICE) on the
correct interface. It works perfectly.
However, in the same program, either using the same socket or another on
the same UDP, I found out that I just received the packet i'm sending as
well. And do not want it. I perfectly understand that some program might
be interested in broadcast packets they sent, but i don't.
I have seen that in the multicast world, every program can choose this
behaviour throught the setsockopt IP_MULTICAST_LOOP. I do not want to
use multicast since I don't want my packets to be routed (if there was
ever a multicast router on the link). But I admit I could use a TTL=1
packet in this case.
Anyway, I dig five minutes into the kernel source code I have at hand
and wrote a small patch to add IP_MULTICAST_LOOP to broadcast packets.
Since it might be interesting to other people, I just submit it here. It
has been testing on Ubuntu and kernel 2.6.23-rc1 from the wireless.git
repository. It should be very easy to adapt to other kernel version.
I have not seen this feature as being standard throught the OpenGroup
specification
(http://www.opengroup.org/onlinepubs/009695399/functions/setsockopt.html),
but it might be usefull anyway.
Comments welcome,
Benoit
View attachment "wireless-dev-udp-broadcast.diff" of type "text/x-patch" (805 bytes)
Powered by blists - more mailing lists