Use SO_REUSEPORT and SO_REUSEADDR if possible for DHCPv4/6 (#981973)
Change fix for the Bug #981973 after discussion with the upstream. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
ea5468d6a1
commit
b6153d9e1e
@ -1,17 +0,0 @@
|
|||||||
diff -up dnsmasq-2.66/src/dhcp.c.reuseport dnsmasq-2.66/src/dhcp.c
|
|
||||||
--- dnsmasq-2.66/src/dhcp.c.reuseport 2013-08-12 14:35:07.575237403 +0200
|
|
||||||
+++ dnsmasq-2.66/src/dhcp.c 2013-08-12 14:35:48.220273629 +0200
|
|
||||||
@@ -72,11 +72,13 @@ static int make_fd(int port)
|
|
||||||
{
|
|
||||||
int rc = -1, porterr = 0;
|
|
||||||
|
|
||||||
+/*
|
|
||||||
#ifdef SO_REUSEPORT
|
|
||||||
if ((rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt))) == -1 &&
|
|
||||||
errno != ENOPROTOOPT)
|
|
||||||
porterr = 1;
|
|
||||||
#endif
|
|
||||||
+*/
|
|
||||||
|
|
||||||
if (rc == -1 && !porterr)
|
|
||||||
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt));
|
|
@ -0,0 +1,63 @@
|
|||||||
|
From ffbad34b310ab2db6a686c85f5c0a0e52c0680c8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||||
|
Date: Wed, 14 Aug 2013 15:53:57 +0100
|
||||||
|
Subject: [PATCH] Set SOREUSEADDR as well as SOREUSEPORT on DHCP sockets when
|
||||||
|
both available.
|
||||||
|
|
||||||
|
Signed-off-by: Tomas Hozza <thozza@redhat.com>
|
||||||
|
---
|
||||||
|
src/dhcp.c | 8 ++++----
|
||||||
|
src/dhcp6.c | 8 ++++----
|
||||||
|
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)
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
10
dnsmasq.spec
10
dnsmasq.spec
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
Name: dnsmasq
|
Name: dnsmasq
|
||||||
Version: 2.67
|
Version: 2.67
|
||||||
Release: 0.5.%{?extraversion}%{?dist}
|
Release: 0.6.%{?extraversion}%{?dist}
|
||||||
Summary: A lightweight DHCP/caching DNS server
|
Summary: A lightweight DHCP/caching DNS server
|
||||||
|
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
@ -22,8 +22,9 @@ URL: http://www.thekelleys.org.uk/dnsmasq/
|
|||||||
Source0: http://www.thekelleys.org.uk/dnsmasq/%{?extrapath}%{name}-%{version}%{?extraversion}.tar.gz
|
Source0: http://www.thekelleys.org.uk/dnsmasq/%{?extrapath}%{name}-%{version}%{?extraversion}.tar.gz
|
||||||
Source1: %{name}.service
|
Source1: %{name}.service
|
||||||
|
|
||||||
# Don't use SO_REUSEPORT on DHCPv4 socket to prevent conflicts with ISC DHCP
|
# commit ffbad34b310ab2db6a686c85f5c0a0e52c0680c8
|
||||||
Patch0: %{name}-2.66-Dont_use_SO_REUSEPORT_on_dhcp4_socket.patch
|
Patch0: %{name}-2.66-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch
|
||||||
|
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
|
||||||
@ -140,6 +141,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%{_mandir}/man1/dhcp_*
|
%{_mandir}/man1/dhcp_*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 15 2013 Tomas Hozza <thozza@redhat.com> - 2.67-0.6.test7
|
||||||
|
- Use SO_REUSEPORT and SO_REUSEADDR if possible for DHCPv4/6 (#981973)
|
||||||
|
|
||||||
* Mon Aug 12 2013 Tomas Hozza <thozza@redhat.com> - 2.67-0.5.test7
|
* Mon Aug 12 2013 Tomas Hozza <thozza@redhat.com> - 2.67-0.5.test7
|
||||||
- Don't use SO_REUSEPORT on DHCPv4 socket to prevent conflicts with ISC DHCP (#981973)
|
- Don't use SO_REUSEPORT on DHCPv4 socket to prevent conflicts with ISC DHCP (#981973)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user