]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Set SOREUSEADDR as well as SOREUSEPORT on DHCP sockets when both available.
authorSimon Kelley <simon@thekelleys.org.uk>
Wed, 14 Aug 2013 14:53:57 +0000 (15:53 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Wed, 14 Aug 2013 14:53:57 +0000 (15:53 +0100)
src/dhcp.c
src/dhcp6.c

index 333a327bb6404964a03e6a85a59d99601367e84c..b95a4bab8760f97a163d7d67cffc4a1e7c657a83 100644 (file)
@@ -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)
index 17e03e515fcd2bbee83e0cc84ab1b7c2bf885474..89af7dd9bdaeaee23e2ee4b7dfa03cb7765c05b5 100644 (file)
@@ -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)