From b6153d9e1e9324ad66a139dfcace38566c665ea9 Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Thu, 15 Aug 2013 11:49:26 +0200 Subject: [PATCH] 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 --- ...ont_use_SO_REUSEPORT_on_dhcp4_socket.patch | 17 ----- ...as-well-as-SOREUSEPORT-on-DHCP-socke.patch | 63 +++++++++++++++++++ dnsmasq.spec | 10 ++- 3 files changed, 70 insertions(+), 20 deletions(-) delete mode 100644 dnsmasq-2.66-Dont_use_SO_REUSEPORT_on_dhcp4_socket.patch create mode 100644 dnsmasq-2.66-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch diff --git a/dnsmasq-2.66-Dont_use_SO_REUSEPORT_on_dhcp4_socket.patch b/dnsmasq-2.66-Dont_use_SO_REUSEPORT_on_dhcp4_socket.patch deleted file mode 100644 index 6ad4dfc..0000000 --- a/dnsmasq-2.66-Dont_use_SO_REUSEPORT_on_dhcp4_socket.patch +++ /dev/null @@ -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)); diff --git a/dnsmasq-2.66-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch b/dnsmasq-2.66-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch new file mode 100644 index 0000000..3d05210 --- /dev/null +++ b/dnsmasq-2.66-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch @@ -0,0 +1,63 @@ +From ffbad34b310ab2db6a686c85f5c0a0e52c0680c8 Mon Sep 17 00:00:00 2001 +From: Simon Kelley +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 +--- + 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 + diff --git a/dnsmasq.spec b/dnsmasq.spec index ec7b0b2..a27fa2c 100644 --- a/dnsmasq.spec +++ b/dnsmasq.spec @@ -13,7 +13,7 @@ Name: dnsmasq Version: 2.67 -Release: 0.5.%{?extraversion}%{?dist} +Release: 0.6.%{?extraversion}%{?dist} Summary: A lightweight DHCP/caching DNS server 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 Source1: %{name}.service -# Don't use SO_REUSEPORT on DHCPv4 socket to prevent conflicts with ISC DHCP -Patch0: %{name}-2.66-Dont_use_SO_REUSEPORT_on_dhcp4_socket.patch +# commit ffbad34b310ab2db6a686c85f5c0a0e52c0680c8 +Patch0: %{name}-2.66-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -140,6 +141,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/dhcp_* %changelog +* Thu Aug 15 2013 Tomas Hozza - 2.67-0.6.test7 +- Use SO_REUSEPORT and SO_REUSEADDR if possible for DHCPv4/6 (#981973) + * Mon Aug 12 2013 Tomas Hozza - 2.67-0.5.test7 - Don't use SO_REUSEPORT on DHCPv4 socket to prevent conflicts with ISC DHCP (#981973)