blob: a5c0e69d6ca404847eec66723c1f8d23f9be7cd5 [file] [log] [blame]
--- dnsmasq-2.47.orig/src/dhcp.c 2009-08-21 14:21:56.000000000 -0700
+++ dnsmasq-2.47/src/dhcp.c 2014-10-17 15:51:30.675711301 -0700
@@ -53,14 +53,22 @@
/* When bind-interfaces is set, there might be more than one dnmsasq
instance binding port 67. That's OK if they serve different networks.
- Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD. */
+ Need to set REUSEADDR|REUSEPORT to make this posible.
+ Handle the case that REUSEPORT is defined, but the kernel doesn't
+ support it. This handles the introduction of REUSEPORT on Linux. */
if (daemon->options & OPT_NOWILD)
{
+ int rc = 0;
+
#ifdef SO_REUSEPORT
- int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt));
-#else
- int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
+ rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt));
+ if (rc == -1 && errno == ENOPROTOOPT)
+ rc = 0; /* Ignore if this is not supported by kernel */
#endif
+
+ if (rc != -1)
+ rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
+
if (rc == -1)
die(_("failed to set SO_REUSE{ADDR|PORT} on DHCP socket: %s"), NULL, EC_BADNET);
}