netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv6: sr: fix user space compilation error with old glibc
@ 2017-05-15  9:18 David Lebrun
  2017-05-15 10:05 ` Daniel Borkmann
  0 siblings, 1 reply; 6+ messages in thread
From: David Lebrun @ 2017-05-15  9:18 UTC (permalink / raw)
  To: netdev; +Cc: daniel, David Lebrun

When seg6.h is included in a user space program that also includes
netinet/in.h, it results in multiple definitions of structures such as
struct in6_addr. Recent glibc versions have a workaround that consists in
defining __USE_KERNEL_IPV6_DEFS to prevent duplicates. However, such a
program will fail to compile with older glibc versions.

This patch ensures that including seg6.h will work in any case.

Fixes: ea3ebc73b46fbdb049dafd47543bb22efaa09c8e ("uapi: fix linux/seg6.h and linux/seg6_iptunnel.h userspace compilation errors")
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David Lebrun <david.lebrun@uclouvain.be>
---
 include/uapi/linux/seg6.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h
index 7278511..52b8f46 100644
--- a/include/uapi/linux/seg6.h
+++ b/include/uapi/linux/seg6.h
@@ -15,7 +15,16 @@
 #define _UAPI_LINUX_SEG6_H
 
 #include <linux/types.h>
+
+#ifdef __KERNEL__
 #include <linux/in6.h>		/* For struct in6_addr. */
+#else
+#ifdef __USE_KERNEL_IPV6_DEFS
+#include <linux/in6.h>
+#else
+#include <netinet/in.h>
+#endif
+#endif
 
 /*
  * SRH
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net] ipv6: sr: fix user space compilation error with old glibc
  2017-05-15  9:18 [PATCH net] ipv6: sr: fix user space compilation error with old glibc David Lebrun
@ 2017-05-15 10:05 ` Daniel Borkmann
  2017-05-15 10:37   ` David Lebrun
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Borkmann @ 2017-05-15 10:05 UTC (permalink / raw)
  To: David Lebrun; +Cc: netdev

On 05/15/2017 11:18 AM, David Lebrun wrote:
> When seg6.h is included in a user space program that also includes
> netinet/in.h, it results in multiple definitions of structures such as
> struct in6_addr. Recent glibc versions have a workaround that consists in
> defining __USE_KERNEL_IPV6_DEFS to prevent duplicates. However, such a
> program will fail to compile with older glibc versions.
>
> This patch ensures that including seg6.h will work in any case.
>
> Fixes: ea3ebc73b46fbdb049dafd47543bb22efaa09c8e ("uapi: fix linux/seg6.h and linux/seg6_iptunnel.h userspace compilation errors")
> Reported-by: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: David Lebrun <david.lebrun@uclouvain.be>
> ---
>   include/uapi/linux/seg6.h | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h
> index 7278511..52b8f46 100644
> --- a/include/uapi/linux/seg6.h
> +++ b/include/uapi/linux/seg6.h
> @@ -15,7 +15,16 @@
>   #define _UAPI_LINUX_SEG6_H
>
>   #include <linux/types.h>
> +
> +#ifdef __KERNEL__
>   #include <linux/in6.h>		/* For struct in6_addr. */
> +#else
> +#ifdef __USE_KERNEL_IPV6_DEFS
> +#include <linux/in6.h>
> +#else
> +#include <netinet/in.h>
> +#endif
> +#endif
>
>   /*
>    * SRH
>

When this gets pulled into iproute2's include/linux/seg6.h due to
header rebase, we still have the same effect.

__USE_KERNEL_IPV6_DEFS gets defined by ip/iproute_lwtunnel.c, and
when we then include above header, we end up including linux/in6.h
just like before, same compile error in iproute2.

Or, is there still another fix for iproute2 coming after this has
landed?

Thanks,
Daniel

ip
     CC       iproute_lwtunnel.o
In file included from ../include/linux/seg6.h:23:0,
                  from iproute_lwtunnel.c:26:
../include/linux/in6.h:131:26: error: expected identifier before numeric constant
  #define IPPROTO_HOPOPTS  0 /* IPv6 hop-by-hop options */
                           ^
In file included from /usr/include/resolv.h:57:0,
                  from ../include/utils.h:6,
                  from iproute_lwtunnel.c:32:
/usr/include/netinet/in.h:196:8: error: redefinition of ‘struct in6_addr’
  struct in6_addr
         ^
In file included from ../include/linux/seg6.h:23:0,
                  from iproute_lwtunnel.c:26:
../include/linux/in6.h:32:8: note: originally defined here
  struct in6_addr {
         ^
In file included from /usr/include/resolv.h:57:0,
                  from ../include/utils.h:6,
                  from iproute_lwtunnel.c:32:
/usr/include/netinet/in.h:237:8: error: redefinition of ‘struct sockaddr_in6’
  struct sockaddr_in6
         ^
In file included from ../include/linux/seg6.h:23:0,
                  from iproute_lwtunnel.c:26:
../include/linux/in6.h:49:8: note: originally defined here
  struct sockaddr_in6 {
         ^
In file included from /usr/include/resolv.h:57:0,
                  from ../include/utils.h:6,
                  from iproute_lwtunnel.c:32:
/usr/include/netinet/in.h:273:8: error: redefinition of ‘struct ipv6_mreq’
  struct ipv6_mreq
         ^
In file included from ../include/linux/seg6.h:23:0,
                  from iproute_lwtunnel.c:26:
../include/linux/in6.h:59:8: note: originally defined here
  struct ipv6_mreq {
         ^
iproute_lwtunnel.c: In function ‘parse_encap_seg6’:
iproute_lwtunnel.c:375:3: warning: passing argument 3 of ‘inet_get_addr’ from incompatible pointer type [enabled by default]
    inet_get_addr(s, NULL, &srh->segments[i]);
    ^
In file included from iproute_lwtunnel.c:32:0:
../include/utils.h:241:5: note: expected ‘struct in6_addr *’ but argument is of type ‘struct in6_addr *’
  int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6);
      ^
make[1]: *** [iproute_lwtunnel.o] Error 1
make: *** [all] Error 2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] ipv6: sr: fix user space compilation error with old glibc
  2017-05-15 10:05 ` Daniel Borkmann
@ 2017-05-15 10:37   ` David Lebrun
  2017-05-15 10:43     ` Daniel Borkmann
  0 siblings, 1 reply; 6+ messages in thread
From: David Lebrun @ 2017-05-15 10:37 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: netdev


[-- Attachment #1.1: Type: text/plain, Size: 246 bytes --]

On 05/15/2017 12:05 PM, Daniel Borkmann wrote:
> 
> Or, is there still another fix for iproute2 coming after this has
> landed?

Yes, I will submit the fix to iproute2 once this one has been applied,
so that I can reference it.

David


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] ipv6: sr: fix user space compilation error with old glibc
  2017-05-15 10:37   ` David Lebrun
@ 2017-05-15 10:43     ` Daniel Borkmann
  2017-05-15 10:53       ` David Lebrun
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Borkmann @ 2017-05-15 10:43 UTC (permalink / raw)
  To: David Lebrun; +Cc: netdev

On 05/15/2017 12:37 PM, David Lebrun wrote:
> On 05/15/2017 12:05 PM, Daniel Borkmann wrote:
>>
>> Or, is there still another fix for iproute2 coming after this has
>> landed?
>
> Yes, I will submit the fix to iproute2 once this one has been applied,
> so that I can reference it.

Okay, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] ipv6: sr: fix user space compilation error with old glibc
  2017-05-15 10:43     ` Daniel Borkmann
@ 2017-05-15 10:53       ` David Lebrun
  2017-05-15 11:01         ` David Lebrun
  0 siblings, 1 reply; 6+ messages in thread
From: David Lebrun @ 2017-05-15 10:53 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: netdev


[-- Attachment #1.1: Type: text/plain, Size: 315 bytes --]

On 05/15/2017 12:43 PM, Daniel Borkmann wrote:
> 
> Okay, thanks!

Mmmh actually I can fix this without sending a patch to iproute2.
Handling the __USE_KERNEL_IPV6_DEFS case in seg6.h is wrong, as it is
already performed in netinet/in.h. I can fix the issue with a simpler ifdef.

Will send v2.

David


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] ipv6: sr: fix user space compilation error with old glibc
  2017-05-15 10:53       ` David Lebrun
@ 2017-05-15 11:01         ` David Lebrun
  0 siblings, 0 replies; 6+ messages in thread
From: David Lebrun @ 2017-05-15 11:01 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: netdev


[-- Attachment #1.1: Type: text/plain, Size: 175 bytes --]

On 05/15/2017 12:53 PM, David Lebrun wrote:
> I can fix the issue with a simpler ifdef.

The simpler ifdef works fine, but a patch to iproute2 is still needed.

David


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-15 11:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15  9:18 [PATCH net] ipv6: sr: fix user space compilation error with old glibc David Lebrun
2017-05-15 10:05 ` Daniel Borkmann
2017-05-15 10:37   ` David Lebrun
2017-05-15 10:43     ` Daniel Borkmann
2017-05-15 10:53       ` David Lebrun
2017-05-15 11:01         ` David Lebrun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).