summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2013-08-14 15:53:57 +0100
committerSimon Kelley <simon@thekelleys.org.uk>2013-08-14 15:53:57 +0100
commitffbad34b310ab2db6a686c85f5c0a0e52c0680c8 (patch)
treece94aedc9352e929a3d7da1d0425f873dbfd9be4
parentf086d3964151831051d02ac030eaa4c10329fa3f (diff)
downloaddnsmasq-ffbad34b310ab2db6a686c85f5c0a0e52c0680c8.tar.gz
Set SOREUSEADDR as well as SOREUSEPORT on DHCP sockets when both available.
-rw-r--r--src/dhcp.c8
-rw-r--r--src/dhcp6.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/dhcp.c b/src/dhcp.c
index 333a327..b95a4ba 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -70,15 +70,15 @@ static int make_fd(int port)
support it. This handles the introduction of REUSEPORT on Linux. */
if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
{
- int rc = -1, porterr = 0;
+ int rc = 0;
#ifdef SO_REUSEPORT
if ((rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt))) == -1 &&
- errno != ENOPROTOOPT)
- porterr = 1;
+ errno == ENOPROTOOPT)
+ rc = 0;
#endif
- if (rc == -1 && !porterr)
+ if (rc != -1)
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
if (rc == -1)
diff --git a/src/dhcp6.c b/src/dhcp6.c
index 17e03e5..89af7dd 100644
--- a/src/dhcp6.c
+++ b/src/dhcp6.c
@@ -55,15 +55,15 @@ void dhcp6_init(void)
support it. This handles the introduction of REUSEPORT on Linux. */
if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
{
- int rc = -1, porterr = 0;
+ int rc = 0;
#ifdef SO_REUSEPORT
if ((rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt))) == -1 &&
- errno != ENOPROTOOPT)
- porterr = 1;
+ errno == ENOPROTOOPT)
+ rc = 0;
#endif
- if (rc == -1 && !porterr)
+ if (rc != -1)
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
if (rc == -1)