From patchwork Tue Jun 7 08:48:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 631400 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rP4x34nwdz9sxS for ; Tue, 7 Jun 2016 18:48:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=cjjc4JUx; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=FTb yylouUjJhp5O1Iyup6jX3Mws39m5kw+t8LkRf3jjCpBsNnehqNfJ2DRJ7mbzVJ2u BRKLZbcTEipeciGJnYyLiFn8RH0B3+kOCD65zjj5wO/ZvoQfQeDb5tvMj6ombuYE fYjvcwZmb16ExFGxtn5Im4MTmonNcIaSueZtIuMU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; s=default; bh=A8w0KyC/N umOPTwxWYoP+/Il998=; b=cjjc4JUxzvcgaWo75P/qlZBHEyg2bBDtFPx+EVtvU LDwjPg5gMSR8WGsK5aTTy0H4JuKSOeOc1KAUbRJwmFOkO65fzut8tlJKCjunudmS QVJRz4NFzmEBpabrEGubvvDjdYnnMC41J3NCDyuSEwrsLvjg05k6z/77qNOR2/JJ Iw= Received: (qmail 104676 invoked by alias); 7 Jun 2016 08:48:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 104664 invoked by uid 89); 7 Jun 2016 08:48:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=coordination X-HELO: mail-qk0-f169.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:organization:message-id:date :user-agent:mime-version:content-transfer-encoding; bh=tTuFOzkB9BsCdnm9CcVTgqacdfcRgY5tcmHACUkE6pM=; b=FsM3/1Am95FXtUjWgeyuHYdKcHnZq6qnYfMfWQtFnKL7nx6XjOPve9OF5RmvoW9cRX pQHmu3mgmhqwc8hxAZYl6cGeEmeAGLtTaG8x9JNbe2whyBtSpNDA3PamfcjqLG5T3Yhk YTgwXs35bFxRJomJv74ZewVre8r0EHf7ER7hjXfZVMMgTzie023i23HeOwhM8GRz9jAU In9oTVzW7HXSX4kWdu8UdVNYyrj0VqK3e0Gh+kfSi7BjMzJrGWn69nBcXxAq94IKFM4y ISos+3Yx0EH/09Wr3R7CHc9WVpLOxSQ0kjfoWznJEIDpVju5PL8md50paF9YczT9+W0+ +wEA== X-Gm-Message-State: ALyK8tKte28+/U14HmPVnuS+m99FAhEi1gWuZZYLTge/XqWqfCxSejJshBIixfYq4qtPL/An X-Received: by 10.55.78.4 with SMTP id c4mr20361569qkb.71.1465289316185; Tue, 07 Jun 2016 01:48:36 -0700 (PDT) To: GNU C Library From: Carlos O'Donell Subject: [COMMITTED] Fix linux/in6.h and netinet/in.h coordination (Bug 20214) Message-ID: <57568A61.3070901@redhat.com> Date: Tue, 7 Jun 2016 04:48:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In: https://sourceware.org/glibc/wiki/Synchronizing_Headers we explain how we synchronize our headers with Linux kernel headers. In order to synchronize with the Linux linux/in6.h and linux/ipv6.h headers we checked for their guard macros and then defined __USE_KERNEL_IPV6_DEFS and conditionalized code on this macro. In upstream kernel 56c176c9 the _UAPI prefix was stripped and this broke our synchronized headers again. We now need to check for _LINUX_IN6_H and _IPV6_H, and keep checking the old versions of the header guard checks for maximum backwards compatibility with older Linux headers (the history is actually a bit muddled here and it appears upstream linus kernel broke this 10 months *before* our fix was ever applied to glibc, but without glibc testing we didn't notice and distro kernels have their own testing to fix this). The use cases fixed by this patch are: #include #include * Standard set of failures. ~~~ ../inet/netinet/in.h:101:5: error: expected identifier before numeric constant IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:102:0: error: "IPPROTO_HOPOPTS" redefined [-Werror] #define IPPROTO_HOPOPTS IPPROTO_HOPOPTS ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:131:0: note: this is the location of the previous definition #define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:104:0: error: "IPPROTO_ROUTING" redefined [-Werror] #define IPPROTO_ROUTING IPPROTO_ROUTING ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:132:0: note: this is the location of the previous definition #define IPPROTO_ROUTING 43 /* IPv6 routing header */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:106:0: error: "IPPROTO_FRAGMENT" redefined [-Werror] #define IPPROTO_FRAGMENT IPPROTO_FRAGMENT ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:133:0: note: this is the location of the previous definition #define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:108:0: error: "IPPROTO_ICMPV6" redefined [-Werror] #define IPPROTO_ICMPV6 IPPROTO_ICMPV6 ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:134:0: note: this is the location of the previous definition #define IPPROTO_ICMPV6 58 /* ICMPv6 */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:110:0: error: "IPPROTO_NONE" redefined [-Werror] #define IPPROTO_NONE IPPROTO_NONE ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:135:0: note: this is the location of the previous definition #define IPPROTO_NONE 59 /* IPv6 no next header */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:112:0: error: "IPPROTO_DSTOPTS" redefined [-Werror] #define IPPROTO_DSTOPTS IPPROTO_DSTOPTS ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:136:0: note: this is the location of the previous definition #define IPPROTO_DSTOPTS 60 /* IPv6 destination options */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:114:0: error: "IPPROTO_MH" redefined [-Werror] #define IPPROTO_MH IPPROTO_MH ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:137:0: note: this is the location of the previous definition #define IPPROTO_MH 135 /* IPv6 mobility header */ ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:211:8: error: redefinition of ‘struct in6_addr’ struct in6_addr ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:32:8: note: originally defined here struct in6_addr { ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:221:0: error: "s6_addr" redefined [-Werror] #define s6_addr __in6_u.__u6_addr8 ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:40:0: note: this is the location of the previous definition #define s6_addr in6_u.u6_addr8 ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:223:0: error: "s6_addr16" redefined [-Werror] # define s6_addr16 __in6_u.__u6_addr16 ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:42:0: note: this is the location of the previous definition #define s6_addr16 in6_u.u6_addr16 ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:224:0: error: "s6_addr32" redefined [-Werror] # define s6_addr32 __in6_u.__u6_addr32 ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:43:0: note: this is the location of the previous definition #define s6_addr32 in6_u.u6_addr32 ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:254:8: error: redefinition of ‘struct sockaddr_in6’ struct sockaddr_in6 ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:49:8: note: originally defined here struct sockaddr_in6 { ^ In file included from ../include/netinet/in.h:3:0, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../inet/netinet/in.h:290:8: error: redefinition of ‘struct ipv6_mreq’ struct ipv6_mreq ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:59:8: note: originally defined here struct ipv6_mreq { ^ cc1: all warnings being treated as errors ~~~ * New set of failures related to IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP: ~~~~ In file included from ../inet/netinet/in.h:37:0, from ../include/netinet/in.h:3, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../sysdeps/unix/sysv/linux/bits/in.h:218:0: error: "IPV6_ADD_MEMBERSHIP" redefined [-Werror] # define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:169:0: note: this is the location of the previous definition #define IPV6_ADD_MEMBERSHIP 20 ^ In file included from ../inet/netinet/in.h:37:0, from ../include/netinet/in.h:3, from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:2: ../sysdeps/unix/sysv/linux/bits/in.h:219:0: error: "IPV6_DROP_MEMBERSHIP" redefined [-Werror] # define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP ^ In file included from ../sysdeps/unix/sysv/linux//tst-ipv6-compat2.c:1:0: /home/carlos/build/glibc-headers/include/linux/in6.h:170:0: note: this is the location of the previous definition #define IPV6_DROP_MEMBERSHIP 21 ^ cc1: all warnings being treated as errors ~~~~ Notice that in the case of xattr.h the Linux kernel headers define the __USE_KERNEL_* macro themselves for glibc to use. This has the added benefit of not needing consistent guard macro names, just a consistent __USE_KERNEL_* macro name. Sadly it's just a simple define, and doesn't set the value of the macro to 0 or 1 (as it should to avoid typos). Even if we wanted to do this also for linux/in6.h and linux/ipv6.h, we would still need to support older headers and define the value ourselves. Therefore the point is moot but we should look to using a method like this for glibc and linux with each side defining a __USE_LIBC_* and a __USE_KERNEL_* feature macros respectively defined to 0 or 1 which avoids guard changes and complex conditionals duplicated. I will look at proposing something like this. Passes reg tests based on tests-compile support [1]. Committed. diff --git a/sysdeps/unix/sysv/linux/bits/in.h b/sysdeps/unix/sysv/linux/bits/in.h index 9bdadf3..4d70a6b 100644 --- a/sysdeps/unix/sysv/linux/bits/in.h +++ b/sysdeps/unix/sysv/linux/bits/in.h @@ -25,8 +25,14 @@ kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly. - Neither the linux kernel nor glibc should break this ABI without coordination. */ -#if defined _UAPI_LINUX_IN6_H || defined _UAPI_IPV6_H + Neither the linux kernel nor glibc should break this ABI without coordination. + In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check + for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for + maximum backwards compatibility. */ +#if defined _UAPI_LINUX_IN6_H \ + || defined _UAPI_IPV6_H \ + || defined _LINUX_IN6_H \ + || defined _IPV6_H /* This is not quite the same API since the kernel always defines s6_addr16 and s6_addr32. This is not a violation of POSIX since POSIX says "at least the following member" and that holds true. */ @@ -209,8 +215,10 @@ struct in_pktinfo #define IPV6_TCLASS 67 /* Obsolete synonyms for the above. */ -#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP -#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP +#if !__USE_KERNEL_IPV6_DEFS +# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP +# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP +#endif #define IPV6_RXHOPOPTS IPV6_HOPOPTS #define IPV6_RXDSTOPTS IPV6_DSTOPTS