[OE-core] [PATCH v2] linux-libc-headers: fix duplicate IFF_LOWER_UP DORMANT ECHO on musl

André Draszik git at andred.net
Fri Jun 23 11:42:13 UTC 2017


From: André Draszik <adraszik at tycoint.com>

musl _does_ define IFF_LOWER_UP DORMANT ECHO so we should
prevent redefinition of these when on musl.

As per the included patch, this can be triggered by
(from connman 6to4.c):
    include <errno.h>
    include <stdio.h>
    include <stdlib.h>
    include <string.h>
    include <sys/socket.h>
    include <netinet/in.h>
    include <arpa/inet.h>
    include <net/if.h>
    include <linux/ip.h>
    include <linux/if_tunnel.h>
    include <linux/netlink.h>
    include <linux/rtnetlink.h>
    include <sys/ioctl.h>
    include <unistd.h>

In file included from ../git/src/6to4.c:34:0:
.../usr/include/linux/if.h:97:2: error: expected identifier before numeric constant
  IFF_LOWER_UP   = 1<<16, /* __volatile__ */
  ^

This is because at that time, IFF_LOWER_UP has been converted
to 0x10000 already:
enum net_device_flags {
 0x10000 = 1<<16,
 0x20000 = 1<<17,
 0x40000 = 1<<18,

};

Backport a patch that addresses this.

Signed-off-by: André Draszik <adraszik at tycoint.com>
---
 ....h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch | 46 ++++++++++++++++++++++
 .../linux-libc-headers/linux-libc-headers_4.10.bb  |  1 +
 2 files changed, 47 insertions(+)
 create mode 100644 meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch

diff --git a/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch b/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch
new file mode 100644
index 0000000000..bde2132ebf
--- /dev/null
+++ b/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch
@@ -0,0 +1,46 @@
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [v2,2/3] uapi glibc compat: fix build if libc defines IFF_ECHO
+From: Hauke Mehrtens <hauke at hauke-m.de>
+X-Patchwork-Id: 9686293
+Message-Id: <20170418210036.26039-3-hauke at hauke-m.de>
+To: davem at davemloft.net, netdev at vger.kernel.org
+Cc: linux-kernel at vger.kernel.org, jarod at redhat.com, jogo at openwrt.org,
+ david.heidelberger at ixit.cz, maillist-linux at barfooze.de,
+ mikko.rapeli at iki.fi, dwmw2 at infradead.org, Hauke Mehrtens <hauke at hauke-m.de>
+Date: Tue, 18 Apr 2017 23:00:35 +0200
+
+musl 1.1.15 defines IFF_ECHO and the other net_device_flags options.
+When a user application includes linux/if.h and net/if.h the compile
+will fail.
+
+Activate __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO only when
+it is needed. This should also make this work in case glibc will add
+these defines.
+
+Acked-by: Mikko Rapeli <mikko.rapeli at iki.fi>
+Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
+---
+Upstream-Status: Submitted [https://patchwork.kernel.org/patch/9686293/]
+Signed-off-by: André Draszik <adraszik at tycoint.com>
+Acked-by: Stephane Ayotte <sayotte at tycoint.com>
+ include/uapi/linux/libc-compat.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
+index 43a81136ea6e..ce2fa8a4ced6 100644
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -64,9 +64,11 @@
+ /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
+ /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
++#ifndef IFF_ECHO
+ #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+ #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
++#endif /* IFF_ECHO */
+ 
+ #else /* _NET_IF_H */
+ 
diff --git a/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.10.bb b/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.10.bb
index 108446aa34..29262789a8 100644
--- a/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.10.bb
+++ b/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.10.bb
@@ -4,6 +4,7 @@ SRC_URI_append_libc-musl = "\
     file://0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch \
     file://0002-libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch \
     file://0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch \
+    file://0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch \
    "
 
 SRC_URI[md5sum] = "b5e7f6b9b2fe1b6cc7bc56a3a0bfc090"
-- 
2.11.0




More information about the Openembedded-core mailing list