[avahi] Per-interface fds

Lennart Poettering lennart at poettering.net
Mon Aug 27 04:45:44 PDT 2007


On Fri, 24.08.07 14:48, Zachary Loafman (zml+avahi at zml.net) wrote:

> Hey -
> 
> I just opened up ticket #163 (http://avahi.org/ticket/163). I have a
> simple patch for the issue (basically just reorder the
> #ifdef/#elif/#elif section in socket.c that deals with SENDSRCADDR,

Thanks for preparing this patch. I will definitely merge this one.

> etc). However, I'd like to propose a deeper change: per-interface file
> descriptors. The main advantage of this is that it *should* avoid the
> portability issues of the current attempt.
> 
>  I think the change would look something like this:
> 
> *) Move the fd_* and watch_* fields from AvahiServer to AvahiInterface.
> *) Encourage use of avahi_interface_send_packet and replumb a few interfaces
> *) Change the socket setup code to use setsockopt(...,IP_MULTICAST_IF...).
> 
> After that, Avahi shouldn't need to use IP_PKTINFO.

What's the advantage of that? I would say IP_PKTINFO is the only
reasonable API for all this stuff. It's a pity the BSDs don't support
it. But I'd say it would be a step in the wrong direction to not make
any use of it.

> Does this sound like a reasonable change?

Humm. I must say I am not really convinced. The IP multicasting socket
API was designed in a way that you can subscribe to multiple groups on
multiple interfaces with a single socket. That's the way we use it
right now, and it works fine on Linux, and is the cleneast way I would
say.

OTOH it is usually pretty easy to convince me with technical
arguments. Could you please explain in more detail what exactly would
be the benefit of using multiple seperate sockets instead of just one?
That it "should avoid issues" is not specific enough...

> PS Is the server.c reflector use of avahi_send_dns_packet_ipv4 (circa
> line 819) using the right fd? It looks like it's sending out a
> multicast packet over the unicast fd).

No. This specific reflecting is for "legacy unicast" packets. Those
are identified by a source port number != 5353. If we used the normal
mcast socket the source port of our forwarded packet would be 5353 as
well, so we use our unicast socket for this which is bound to
something that is not 5353.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4


More information about the avahi mailing list