Skip to contentSkip to conversation

avahi: handle SO_REUSEPORT not being available

PATCH In review Ross Burton 2 participants 2 messages Feb 18, 2014 – Feb 19, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avahi: handle SO_REUSEPORT not being available

Linux < 3.9 doesn't have the SO_REUSEPORT option so instead of failing to start when built with >=3.9 kernel headers but booted on <3.9 kernels, continue as if SO_REUSEPORT wasn't available.

---
 meta/recipes-connectivity/avahi/avahi.inc          |    1 +
 .../avahi/files/reuseport-check.patch              |   30 ++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 meta/recipes-connectivity/avahi/files/reuseport-check.patch
meta/recipes-connectivity/avahi/avahi.inc +1 -0
index 3a95b7f..e4ff26a 100644
@@ -26,6 +26,7 @@ SRC_URI = "http://avahi.org/download/avahi-${PV}.tar.gz \
           file://fix_for_automake_1.12.x.patch \
           file://out-of-tree.patch \
           file://0001-avahi-fix-avahi-status-command-error-prompt.patch \
+          file://reuseport-check.patch \
           "
 
 USERADD_PACKAGES = "avahi-daemon avahi-autoipd"
meta/recipes-connectivity/avahi/files/reuseport-check.patch new file +30 -0
new file mode 100644
index 0000000..bb81c2c
@@ -0,0 +1,30 @@
+Fix avahi-daemon when running on kernel < 3.9 (patch taken from Ubuntu).
+
+Upstream-Status: Pending (unmaintained upstream)
+Signed-off-by: Ross Burton <[email protected]>
+
+Description: SO_REUSEPORT may not exist in running kernel
+ When userspace defines SO_REUSEPORT we will attempt to enable socket
+ port number reuse.  However if the running kernel does not support
+ this call it will fail preventing daemon startup.  If this call is
+ present but fails ENOPROTOOPT then we know that actually the kernel
+ does not support it and we should continue as if we did not have the
+ call at all.  (LP: #1228204)
+ .
+ This patch could be removed from the debian package after jessie release.
+Author: Andy Whitcroft <[email protected]>
+
+Index: avahi-0.6.31/avahi-core/socket.c
+===================================================================
+--- avahi-0.6.31.orig/avahi-core/socket.c	2013-09-20 16:36:50.000000000 +0100
++++ avahi-0.6.31/avahi-core/socket.c	2013-09-20 16:38:23.781863644 +0100
+@@ -177,7 +177,8 @@
+     yes = 1;
+     if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)) < 0) {
+         avahi_log_warn("SO_REUSEPORT failed: %s", strerror(errno));
+-        return -1;
++        if (errno != ENOPROTOOPT)
++            return -1;
+     }
+ #endif
+ 
Signature · 1 line
1.7.10.4
Tested-by on v1 1/1
#1 lore raw

Op 18 feb. 2014, om 13:13 heeft Ross Burton <[email protected]> het volgende geschreven:

Quoted 5 lines

Linux < 3.9 doesn't have the SO_REUSEPORT option so instead of failing to start when built with >=3.9 kernel headers but booted on <3.9 kernels, continue as if SO_REUSEPORT wasn't available.

Great timing! I ran into this last week.

Quoted 62 lines

---
meta/recipes-connectivity/avahi/avahi.inc | 1 +
.../avahi/files/reuseport-check.patch | 30 ++++++++++++++++++++

2 files changed, 31 insertions(+)

create mode 100644 meta/recipes-connectivity/avahi/files/reuseport-check.patch

meta/recipes-connectivity/avahi/avahi.inc +1 -0
index 3a95b7f..e4ff26a 100644
@@ -26,6 +26,7 @@ SRC_URI = "http://avahi.org/download/avahi-${PV}.tar.gz \
          file://fix_for_automake_1.12.x.patch \
          file://out-of-tree.patch \
          file://0001-avahi-fix-avahi-status-command-error-prompt.patch \
+          file://reuseport-check.patch \
          "
 

USERADD_PACKAGES = "avahi-daemon avahi-autoipd"

meta/recipes-connectivity/avahi/files/reuseport-check.patch new file +30 -0
new file mode 100644
index 0000000..bb81c2c
@@ -0,0 +1,30 @@
+Fix avahi-daemon when running on kernel < 3.9 (patch taken from Ubuntu).
+
+Upstream-Status: Pending (unmaintained upstream)
+Signed-off-by: Ross Burton <[email protected]>
+
+Description: SO_REUSEPORT may not exist in running kernel
+ When userspace defines SO_REUSEPORT we will attempt to enable socket
+ port number reuse.  However if the running kernel does not support
+ this call it will fail preventing daemon startup.  If this call is
+ present but fails ENOPROTOOPT then we know that actually the kernel
+ does not support it and we should continue as if we did not have the
+ call at all.  (LP: #1228204)
+ .
+ This patch could be removed from the debian package after jessie release.
+Author: Andy Whitcroft <[email protected]>
+
+Index: avahi-0.6.31/avahi-core/socket.c
+===================================================================
+--- avahi-0.6.31.orig/avahi-core/socket.c	2013-09-20 16:36:50.000000000 +0100
++++ avahi-0.6.31/avahi-core/socket.c	2013-09-20 16:38:23.781863644 +0100
+@@ -177,7 +177,8 @@
+     yes = 1;
+     if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)) < 0) {
+         avahi_log_warn("SO_REUSEPORT failed: %s", strerror(errno));
+-        return -1;
++        if (errno != ENOPROTOOPT)
++            return -1;
+     }
+ #endif
+ 
Signature · 6 lines
1.7.10.4

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core