11ea882
From ffbad34b310ab2db6a686c85f5c0a0e52c0680c8 Mon Sep 17 00:00:00 2001
11ea882
From: Simon Kelley <simon@thekelleys.org.uk>
11ea882
Date: Wed, 14 Aug 2013 15:53:57 +0100
11ea882
Subject: [PATCH] Set SOREUSEADDR as well as SOREUSEPORT on DHCP sockets when
11ea882
 both available.
11ea882
11ea882
Signed-off-by: Tomas Hozza <thozza@redhat.com>
11ea882
---
11ea882
 src/dhcp.c  | 8 ++++----
11ea882
 src/dhcp6.c | 8 ++++----
11ea882
 2 files changed, 8 insertions(+), 8 deletions(-)
11ea882
11ea882
diff --git a/src/dhcp.c b/src/dhcp.c
11ea882
index 333a327..b95a4ba 100644
11ea882
--- a/src/dhcp.c
11ea882
+++ b/src/dhcp.c
11ea882
@@ -70,15 +70,15 @@ static int make_fd(int port)
11ea882
      support it. This handles the introduction of REUSEPORT on Linux. */
11ea882
   if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
11ea882
     {
11ea882
-      int rc = -1, porterr = 0;
11ea882
+      int rc = 0;
11ea882
 
11ea882
 #ifdef SO_REUSEPORT
11ea882
       if ((rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt))) == -1 && 
11ea882
-	  errno != ENOPROTOOPT)
11ea882
-	porterr = 1;
11ea882
+	  errno == ENOPROTOOPT)
11ea882
+	rc = 0;
11ea882
 #endif
11ea882
       
11ea882
-      if (rc == -1 && !porterr)
11ea882
+      if (rc != -1)
11ea882
 	rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
11ea882
       
11ea882
       if (rc == -1)
11ea882
diff --git a/src/dhcp6.c b/src/dhcp6.c
11ea882
index 17e03e5..89af7dd 100644
11ea882
--- a/src/dhcp6.c
11ea882
+++ b/src/dhcp6.c
11ea882
@@ -55,15 +55,15 @@ void dhcp6_init(void)
11ea882
      support it. This handles the introduction of REUSEPORT on Linux. */
11ea882
   if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
11ea882
     {
11ea882
-      int rc = -1, porterr = 0;
11ea882
+      int rc = 0;
11ea882
 
11ea882
 #ifdef SO_REUSEPORT
11ea882
       if ((rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt))) == -1 &&
11ea882
-	  errno != ENOPROTOOPT)
11ea882
-	porterr = 1;
11ea882
+	  errno == ENOPROTOOPT)
11ea882
+	rc = 0;
11ea882
 #endif
11ea882
       
11ea882
-      if (rc == -1 && !porterr)
11ea882
+      if (rc != -1)
11ea882
 	rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
11ea882
       
11ea882
       if (rc == -1)
11ea882
-- 
11ea882
1.8.3.1
11ea882