From 11ea88298bb883432cd49b0111f8c2f6ff4a28a0 Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Oct 03 2013 10:24:30 +0000 Subject: Use SO_REUSEPORT and SO_REUSEADDR if possible for DHCPv4/6 (#981973) Signed-off-by: Tomas Hozza --- diff --git a/dnsmasq-2.65-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch b/dnsmasq-2.65-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch new file mode 100644 index 0000000..3d05210 --- /dev/null +++ b/dnsmasq-2.65-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 9fb40e3..9315acd 100644 --- a/dnsmasq.spec +++ b/dnsmasq.spec @@ -13,7 +13,7 @@ Name: dnsmasq Version: 2.65 -Release: 7%{?extraversion}%{?dist} +Release: 8%{?extraversion}%{?dist} Summary: A lightweight DHCP/caching DNS server Group: System Environment/Daemons @@ -31,6 +31,8 @@ Patch1: %{name}-2.65-Handle-wrong-interface-for-locally-routed-packets.p Patch2: %{name}-2.65-Allocate-dhcp_buff-ers-also-if-deamon-ra_contexts.patch # http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=patch;h=56a1142f033234e3ee3b6361e9a1bcdbe606f816;hp=5b37aa8c19a6ec3379518370661a659807758872 Patch3: %{name}-2.65-fix-so_reuseport-issue.patch +# commit ffbad34b310ab2db6a686c85f5c0a0e52c0680c8 +Patch4: %{name}-2.65-Set-SOREUSEADDR-as-well-as-SOREUSEPORT-on-DHCP-socke.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -69,6 +71,7 @@ query/remove a DHCP server's leases. %patch1 -p1 -b .local_queries %patch2 -p2 -b .SIGSEGV %patch3 -p1 -b .so_reuseport +%patch4 -p1 -b .reuseport # use /var/lib/dnsmasq instead of /var/lib/misc for file in dnsmasq.conf.example man/dnsmasq.8 man/es/dnsmasq.8 src/config.h; do @@ -146,6 +149,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/dhcp_* %changelog +* Thu Oct 03 2013 Tomas Hozza - 2.65-8 +- Use SO_REUSEPORT and SO_REUSEADDR if possible for DHCPv4/6 (#981973) + * Tue Jul 16 2013 Tomas Hozza - 2.65-7 - Don't use SO_REUSEPORT if it's not suported (#950755) @@ -181,7 +187,7 @@ rm -rf $RPM_BUILD_ROOT * Tue Oct 23 2012 Tomas Hozza - 2.63-2 - Introduce new systemd-rpm macros in dnsmasq spec file (#850096) -* Sat Aug 23 2012 Douglas Schilling Landgraf - 2.63-1 +* Thu Aug 23 2012 Douglas Schilling Landgraf - 2.63-1 - Use .tar.gz compression, in upstream site there is no .lzma anymore - New version 2.63 @@ -211,7 +217,7 @@ rm -rf $RPM_BUILD_ROOT * Mon Aug 08 2011 Patrick "Jima" Laughton - 2.52-3 - Applied Jóhann's patch, minor cleanup -* Thu Jul 26 2011 Jóhann B. Guðmundsson - 2.52-3 +* Tue Jul 26 2011 Jóhann B. Guðmundsson - 2.52-3 - Introduce systemd unit file, drop SysV support * Tue Feb 08 2011 Fedora Release Engineering - 2.52-2