Discussion:
[avahi] Re: [avahi-commits] r646 - in /trunk: avahi-core/core.h avahi-core/server.c avahi-core/socket.c avahi-core/socket.h avahi-daemon/avahi-daemon.conf avahi-daemon/main.c docs/TODO
Marc Krochmal
2005-09-29 15:26:48 UTC
Permalink
Hey Lennart,

I can't say that this check-in makes me happy. :-(

You should always be setting SO_REUSEADDR. In fact, this is a MUST
in the spec.

Continuing the previous point, since using an unprivileged port
allows normal user-level code to bind, a given machine may have more
than one such user-level application running at a time. Because of
this, any code binding to UDP port 5353 MUST use the SO_REUSEPORT
option, so as to be a good citizen and not block other clients on
the
machine from also binding to that port.

I even responded to someone on the Bonjour list who was asking
questions about the comments on the Avahi web site, where it says you
must not run multiple responders on the same machine. I told him
that running Avahi, Howl, and Bonjour on the same machine will work
fine in reality, which is true.

Could you at least set SO_REUSEADDR by default?

-Marc
Author: lennart
Date: Thu Sep 29 01:49:09 2005
New Revision: 646
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?
rev=646&root=avahi&view=rev
* add option to not enable SO_REUSEADDR for multicast sockets,
effectively disallow multiple mDNS stacks running simultaneously
* add a config file option for this and enable it by default
* remove some bad \n in log messages
trunk/avahi-core/core.h
trunk/avahi-core/server.c
trunk/avahi-core/socket.c
trunk/avahi-core/socket.h
trunk/avahi-daemon/avahi-daemon.conf
trunk/avahi-daemon/main.c
trunk/docs/TODO
Modified: trunk/avahi-core/core.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/avahi-core/core.h?
rev=646&root=avahi&r1=645&r2=646&view=diff
======================================================================
========
--- trunk/avahi-core/core.h (original)
+++ trunk/avahi-core/core.h Thu Sep 29 01:49:09 2005
@@ -80,6 +80,7 @@
int enable_wide_area; /**< Enable wide area
support */
AvahiAddress wide_area_servers[AVAHI_MAX_WIDE_AREA_SERVERS]; /
** Unicast DNS server to use for wide area lookup */
unsigned n_wide_area_servers; /**< Number of servers in
wide_area_servers[] */
+ int disallow_other_stacks; /**< Make sure that only one
mDNS responder is run at the same time on the local machine. If
this is enable Avahi will not set SO_REUSADDR on its sockets,
effectively preventing other stacks from running on the local
machine */
} AvahiServerConfig;
/** Allocate a new mDNS responder object. */
Modified: trunk/avahi-core/server.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/avahi-core/
server.c?rev=646&root=avahi&r1=645&r2=646&view=diff
======================================================================
========
--- trunk/avahi-core/server.c (original)
+++ trunk/avahi-core/server.c Thu Sep 29 01:49:09 2005
@@ -1324,8 +1324,8 @@
static int setup_sockets(AvahiServer *s) {
assert(s);
- s->fd_ipv4 = s->config.use_ipv4 ? avahi_open_socket_ipv4() : -1;
- s->fd_ipv6 = s->config.use_ipv6 ? avahi_open_socket_ipv6() : -1;
+ s->fd_ipv4 = s->config.use_ipv4 ? avahi_open_socket_ipv4(s-
config.disallow_other_stacks) : -1;
+ s->fd_ipv6 = s->config.use_ipv6 ? avahi_open_socket_ipv6(s-
config.disallow_other_stacks) : -1;
if (s->fd_ipv6 < 0 && s->fd_ipv4 < 0)
return AVAHI_ERR_NO_NETWORK;
@@ -2446,6 +2446,7 @@
c->add_service_cookie = 1;
c->enable_wide_area = 0;
c->n_wide_area_servers = 0;
+ c->disallow_other_stacks = 0;
return c;
}
Modified: trunk/avahi-core/socket.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/avahi-core/
socket.c?rev=646&root=avahi&r1=645&r2=646&view=diff
======================================================================
========
--- trunk/avahi-core/socket.c (original)
+++ trunk/avahi-core/socket.c Thu Sep 29 01:49:09 2005
@@ -93,7 +93,7 @@
mreq.imr_ifindex = idx;
if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof
(mreq)) < 0) {
- avahi_log_warn("IP_ADD_MEMBERSHIP failed: %s\n", strerror
(errno));
+ avahi_log_warn("IP_ADD_MEMBERSHIP failed: %s", strerror
(errno));
return -1;
}
@@ -111,7 +111,7 @@
mreq6.ipv6mr_interface = idx;
if (setsockopt(fd, SOL_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6,
sizeof(mreq6)) < 0) {
- avahi_log_warn("IPV6_ADD_MEMBERSHIP failed: %s\n", strerror
(errno));
+ avahi_log_warn("IPV6_ADD_MEMBERSHIP failed: %s", strerror
(errno));
return -1;
}
@@ -129,7 +129,7 @@
mreq.imr_ifindex = idx;
if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof
(mreq)) < 0) {
- avahi_log_warn("IP_DROP_MEMBERSHIP failed: %s\n", strerror
(errno));
+ avahi_log_warn("IP_DROP_MEMBERSHIP failed: %s", strerror
(errno));
return -1;
}
@@ -147,7 +147,7 @@
mreq6.ipv6mr_interface = idx;
if (setsockopt(fd, SOL_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6,
sizeof(mreq6)) < 0) {
- avahi_log_warn("IPV6_DROP_MEMBERSHIP failed: %s\n",
strerror(errno));
+ avahi_log_warn("IPV6_DROP_MEMBERSHIP failed: %s", strerror
(errno));
return -1;
}
@@ -164,7 +164,7 @@
if (bind(fd, sa, l) < 0) {
if (errno != EADDRINUSE) {
- avahi_log_warn("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s", strerror(errno));
return -1;
}
@@ -174,12 +174,12 @@
/* Try again, this time with SO_REUSEADDR set */
yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof
(yes)) < 0) {
- avahi_log_warn("SO_REUSEADDR failed: %s\n", strerror
(errno));
+ avahi_log_warn("SO_REUSEADDR failed: %s", strerror
(errno));
return -1;
}
if (bind(fd, sa, l) < 0) {
- avahi_log_warn("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s", strerror(errno));
return -1;
}
} else {
@@ -190,7 +190,7 @@
yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof
(yes)) < 0) {
- avahi_log_warn("SO_REUSEADDR failed: %s\n", strerror
(errno));
+ avahi_log_warn("SO_REUSEADDR failed: %s", strerror
(errno));
return -1;
}
}
@@ -198,30 +198,30 @@
return 0;
}
-int avahi_open_socket_ipv4(void) {
+int avahi_open_socket_ipv4(int no_reuse) {
struct sockaddr_in local;
- int fd = -1, ttl, yes;
+ int fd = -1, ttl, yes, r;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- avahi_log_warn("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s", strerror(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &ttl, sizeof
(ttl)) < 0) {
- avahi_log_warn("IP_MULTICAST_TTL failed: %s\n", strerror
(errno));
+ avahi_log_warn("IP_MULTICAST_TTL failed: %s", strerror
(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IP, IP_TTL, &ttl, sizeof(ttl)) < 0) {
- avahi_log_warn("IP_TTL failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_TTL failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof
(yes)) < 0) {
- avahi_log_warn("IP_MULTICAST_LOOP failed: %s\n", strerror
(errno));
+ avahi_log_warn("IP_MULTICAST_LOOP failed: %s", strerror
(errno));
goto fail;
}
@@ -229,28 +229,33 @@
local.sin_family = AF_INET;
local.sin_port = htons(AVAHI_MDNS_PORT);
- if (bind_with_warn(fd, (struct sockaddr*) &local, sizeof
(local)) < 0)
+ if (no_reuse)
+ r = bind(fd, (struct sockaddr*) &local, sizeof(local));
+ else
+ r = bind_with_warn(fd, (struct sockaddr*) &local, sizeof
(local));
+
+ if (r < 0)
goto fail;
yes = 1;
if (setsockopt(fd, SOL_IP, IP_RECVTTL, &yes, sizeof(yes)) < 0) {
- avahi_log_warn("IP_RECVTTL failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_RECVTTL failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0) {
- avahi_log_warn("IP_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_PKTINFO failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
goto fail;
}
@@ -263,38 +268,38 @@
return -1;
}
-int avahi_open_socket_ipv6(void) {
+int avahi_open_socket_ipv6(int no_reuse) {
struct sockaddr_in6 sa, local;
- int fd = -1, ttl, yes;
+ int fd = -1, ttl, yes, r;
mdns_mcast_group_ipv6(&sa);
if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- avahi_log_warn("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s", strerror(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_HOPS, &ttl, sizeof
(ttl)) < 0) {
- avahi_log_warn("IPV6_MULTICAST_HOPS failed: %s\n", strerror
(errno));
+ avahi_log_warn("IPV6_MULTICAST_HOPS failed: %s", strerror
(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof
(ttl)) < 0) {
- avahi_log_warn("IPV6_UNICAST_HOPS failed: %s\n", strerror
(errno));
+ avahi_log_warn("IPV6_UNICAST_HOPS failed: %s", strerror
(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, &yes, sizeof(yes)) <
0) {
- avahi_log_warn("IPV6_V6ONLY failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_V6ONLY failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_LOOP, &yes, sizeof
(yes)) < 0) {
- avahi_log_warn("IPV6_MULTICAST_LOOP failed: %s\n", strerror
(errno));
+ avahi_log_warn("IPV6_MULTICAST_LOOP failed: %s", strerror
(errno));
goto fail;
}
@@ -302,28 +307,33 @@
local.sin6_family = AF_INET6;
local.sin6_port = htons(AVAHI_MDNS_PORT);
- if (bind_with_warn(fd, (struct sockaddr*) &local, sizeof
(local)) < 0)
+ if (no_reuse)
+ r = bind(fd, (struct sockaddr*) &local, sizeof(local));
+ else
+ r = bind_with_warn(fd, (struct sockaddr*) &local, sizeof
(local));
+
+ if (r < 0)
goto fail;
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &yes, sizeof(yes))
< 0) {
- avahi_log_warn("IPV6_HOPLIMIT failed: %s\n", strerror
(errno));
+ avahi_log_warn("IPV6_HOPLIMIT failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_PKTINFO, &yes, sizeof(yes))
< 0) {
- avahi_log_warn("IPV6_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_PKTINFO failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
goto fail;
}
@@ -346,7 +356,7 @@
break;
if (errno != EAGAIN) {
- avahi_log_debug("sendmsg() failed: %s\n", strerror
(errno));
+ avahi_log_debug("sendmsg() failed: %s", strerror(errno));
return -1;
}
@@ -631,7 +641,7 @@
int fd = -1, yes;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- avahi_log_warn("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s", strerror(errno));
goto fail;
}
@@ -639,29 +649,29 @@
local.sin_family = AF_INET;
if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
- avahi_log_warn("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_RECVTTL, &yes, sizeof(yes)) < 0) {
- avahi_log_warn("IP_RECVTTL failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_RECVTTL failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0) {
- avahi_log_warn("IP_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_PKTINFO failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
goto fail;
}
@@ -679,7 +689,7 @@
int fd = -1, yes;
if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- avahi_log_warn("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s", strerror(errno));
goto fail;
}
@@ -687,29 +697,29 @@
local.sin6_family = AF_INET6;
if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
- avahi_log_warn("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &yes, sizeof(yes))
< 0) {
- avahi_log_warn("IPV6_HOPLIMIT failed: %s\n", strerror
(errno));
+ avahi_log_warn("IPV6_HOPLIMIT failed: %s", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_PKTINFO, &yes, sizeof(yes))
< 0) {
- avahi_log_warn("IPV6_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_PKTINFO failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s", strerror(errno));
goto fail;
}
Modified: trunk/avahi-core/socket.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/avahi-core/
socket.h?rev=646&root=avahi&r1=645&r2=646&view=diff
======================================================================
========
--- trunk/avahi-core/socket.h (original)
+++ trunk/avahi-core/socket.h Thu Sep 29 01:49:09 2005
@@ -32,8 +32,8 @@
#define AVAHI_IPV4_MCAST_GROUP "224.0.0.251"
#define AVAHI_IPV6_MCAST_GROUP "ff02::fb"
-int avahi_open_socket_ipv4(void);
-int avahi_open_socket_ipv6(void);
+int avahi_open_socket_ipv4(int no_reuse);
+int avahi_open_socket_ipv6(int no_reuse);
int avahi_open_unicast_socket_ipv4(void);
int avahi_open_unicast_socket_ipv6(void);
Modified: trunk/avahi-daemon/avahi-daemon.conf
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/avahi-daemon/
avahi-daemon.conf?rev=646&root=avahi&r1=645&r2=646&view=diff
======================================================================
========
--- trunk/avahi-daemon/avahi-daemon.conf (original)
+++ trunk/avahi-daemon/avahi-daemon.conf Thu Sep 29 01:49:09 2005
@@ -7,6 +7,7 @@
use-iff-running=no
enable-dbus=yes
add-service-cookie=yes
+disallow-other-stacks=yes
[wide-area]
enable-wide-area=yes
Modified: trunk/avahi-daemon/main.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/avahi-daemon/
main.c?rev=646&root=avahi&r1=645&r2=646&view=diff
======================================================================
========
--- trunk/avahi-daemon/main.c (original)
+++ trunk/avahi-daemon/main.c Thu Sep 29 01:49:09 2005
@@ -393,6 +393,8 @@
c->server_config.check_response_ttl = is_yes(p-
value);
else if (strcasecmp(p->key, "use-iff-running") == 0)
c->server_config.use_iff_running = is_yes(p-
value);
+ else if (strcasecmp(p->key, "disallow-other-
stacks") == 0)
+ c->server_config.disallow_other_stacks = is_yes
(p->value);
else if (strcasecmp(p->key, "enable-dbus") == 0) {
if (*(p->value) == 'w' || *(p->value) == 'W') {
@@ -871,6 +873,7 @@
init_rand_seed();
avahi_server_config_init(&config.server_config);
+ config.server_config.disallow_other_stacks = 1;
config.command = DAEMON_RUN;
config.daemonize = 0;
config.config_file = NULL;
Modified: trunk/docs/TODO
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/docs/TODO?
rev=646&root=avahi&r1=645&r2=646&view=diff
======================================================================
========
--- trunk/docs/TODO (original)
+++ trunk/docs/TODO Thu Sep 29 01:49:09 2005
@@ -10,8 +10,6 @@
* Add static host configuration like static services [lathiat]
* wrap avahi_server_add_record() via DBUS and in avahi-client
[lathiat]
-
-* add option to disable SO_REUSEADDR to disallow binding of
multiple processes to port 5353
* add flags argument to disable cookies-setting for local services
@@ -87,3 +85,4 @@
* allow resolving of services without name
* add sever version check to avahi-client
* Passive observation of failures
+* add option to disable SO_REUSEADDR to disallow binding of
multiple processes to port 5353
_______________________________________________
avahi-commits mailing list
https://tango.0pointer.de/mailman/listinfo/avahi-commits
Marc Krochmal
2005-09-29 15:26:59 UTC
Permalink
Nice to know that someone from Apple takes so much interest in Avahi
that he takes notice of every commit. ;-)
Avahi is an exciting development for mDNS-SD so I'm interested.
I wonder if it is a good idea to put such a requirement in an RFC (or
spec). This is clearly an implementation issue and not a specification
issue. Whether REUSEADDR/REUSEPORT is set or not, doesn't change the
protocol behaviour at all, so I guess a SHOULD is what should be put
here, if at all.
Linux doesn't implement REUSEPORT, and I guess some embedded TCP/IP
stacks don't implement either REUSEPORT or REUSEADDR, so I think it is
very odd to require this feature in the spec. In addition the exact
behaviour of REUSEADDR/REUSEPORT is not well the defined. (we already
had a discussion about that)
In short: please change this MUST to a SHOULD and please refer to
REUSEADDR in addition to REUSEPORT.
OK, I agree that it should be a SHOULD. I'll make a note to change it.
Hrm. You know that I don't think that mDNS is reliable when multiple
stacks run on the same host. I hope I already made my reasoning for
that clear.
Well I didn't spell out *all* the details, but this is what I said...

"Regarding the statement on Avahi's web site, I've spoken to Lennart
who works on Avahi about it since I think he's overstating the
fallout. While Lennart is correct that two responders on the same
machine could conflict, since they might have different known answer
lists and one responder could steal the unicast responses of the
other responder, these issues won't actually result in the protocols
failing, since mDNS is resilient to packet loss, so it can cope with
these conflicts. While it's suboptimal to have multiple responders
on the same machine, you should be able to run Avahi, Howl, and
Bonjour on the same Linux machine without any problems."
The reason why I added this disallow-other-stacks option was primarily
security. Some guy came up on IRC and needed a way to make sure that
all mDNS traffic sent out from or recieved by the local machine was
done through Avahi and *only* through Avahi. Blocking port 5353 for
other apps by not setting REUSEADDR is an efficient way to do this.
Interesting. OK that makes sense, but I just fear that setting this
by default would break some applications that have embedded versions
of mDNS. I've talked to many developers over the years and have
tried to convince them that using a single mDNSResponder was a good
idea, but they still insisted on embedding the code into their
application, so it would be unfortunate if those applications now
stopped working because Avahi was installed. It would also be nice
to have Avahi and Darwin mdnsd running on the same machine without
any *major* conflicts.
Post by Marc Krochmal
Could you at least set SO_REUSEADDR by default?
Ok, I did so in r652.
BTW, could you please reply to commits directly to the main mailing
list instead of just me?
Sure, no problem. Obviously some e-mails are only meant for you
alone, but for the rest I can respond to the list.
I modified the configuration of avahi-commits now in away that it sets
a Reply-To: header pointing to the main mailing list. If you don't
object I will forward all older mails to the main mailing list now?
Sure, go ahead.

-Marc
Lennart Poettering
2005-09-29 15:28:16 UTC
Permalink
Post by Marc Krochmal
Hey Lennart,
Hey!
Post by Marc Krochmal
I can't say that this check-in makes me happy. :-(
Nice to know that someone from Apple takes so much interest in Avahi
that he takes notice of every commit. ;-)
Post by Marc Krochmal
You should always be setting SO_REUSEADDR. In fact, this is a MUST
in the spec.
Continuing the previous point, since using an unprivileged port
allows normal user-level code to bind, a given machine may have more
than one such user-level application running at a time. Because of
this, any code binding to UDP port 5353 MUST use the SO_REUSEPORT
option, so as to be a good citizen and not block other clients on the
machine from also binding to that port.
I wonder if it is a good idea to put such a requirement in an RFC (or
spec). This is clearly an implementation issue and not a specification
issue. Whether REUSEADDR/REUSEPORT is set or not, doesn't change the
protocol behaviour at all, so I guess a SHOULD is what should be put
here, if at all.

Linux doesn't implement REUSEPORT, and I guess some embedded TCP/IP
stacks don't implement either REUSEPORT or REUSEADDR, so I think it is
very odd to require this feature in the spec. In addition the exact
behaviour of REUSEADDR/REUSEPORT is not well the defined. (we already
had a discussion about that)

In short: please change this MUST to a SHOULD and please refer to
REUSEADDR in addition to REUSEPORT.
Post by Marc Krochmal
I even responded to someone on the Bonjour list who was asking
questions about the comments on the Avahi web site, where it says you
must not run multiple responders on the same machine. I told him
that running Avahi, Howl, and Bonjour on the same machine will work
fine in reality, which is true.
Hrm. You know that I don't think that mDNS is reliable when multiple
stacks run on the same host. I hope I already made my reasoning for
that clear.

The reason why I added this disallow-other-stacks option was primarily
security. Some guy came up on IRC and needed a way to make sure that
all mDNS traffic sent out from or recieved by the local machine was
done through Avahi and *only* through Avahi. Blocking port 5353 for
other apps by not setting REUSEADDR is an efficient way to do this.
Post by Marc Krochmal
Could you at least set SO_REUSEADDR by default?
Ok, I did so in r652.

BTW, could you please reply to commits directly to the main mailing
list instead of just me?

I modified the configuration of avahi-commits now in away that it sets
a Reply-To: header pointing to the main mailing list. If you don't
object I will forward all older mails to the main mailing list now?

Lennart
--
Lennart Poettering; lennart [at] poettering [dot] de
ICQ# 11060553; GPG 0x1A015CC4; http://0pointer.de/lennart/
Loading...