netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h
@ 2015-06-26  3:12 Stephen Hemminger
  2015-06-27 21:52 ` David Miller
  2015-06-29 18:07 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Hemminger @ 2015-06-26  3:12 UTC (permalink / raw)
  To: David Miller, Pablo Neira Ayuso; +Cc: netdev

This fixes breakage to iproute2 build with recent kernel headers
caused by:
   commit a263653ed798216c0069922d7b5237ca49436007
   Author: Pablo Neira Ayuso <pablo@netfilter.org>
   Date:   Wed Jun 17 10:28:27 2015 -0500

   netfilter: don't pull include/linux/netfilter.h from netns headers

The issue is that definitions in linux/in.h overlap with those
in netinet/in.h. This patch solves this by introducing the same
mechanism as was used to solve the same problem with linux/in6.h

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

--- a/include/uapi/linux/in.h	2015-06-25 10:55:18.142933079 -0400
+++ b/include/uapi/linux/in.h	2015-06-25 22:29:58.035452504 -0400
@@ -19,8 +19,10 @@
 #define _UAPI_LINUX_IN_H
 
 #include <linux/types.h>
+#include <linux/libc-compat.h>
 #include <linux/socket.h>
 
+#if __UAPI_DEF_IN_IPPROTO
 /* Standard well-defined IP protocols.  */
 enum {
   IPPROTO_IP = 0,		/* Dummy protocol for TCP		*/
@@ -75,12 +77,14 @@ enum {
 #define IPPROTO_RAW		IPPROTO_RAW
   IPPROTO_MAX
 };
+#endif
 
-
+#if __UAPI_DEF_IN_ADDR
 /* Internet address. */
 struct in_addr {
 	__be32	s_addr;
 };
+#endif
 
 #define IP_TOS		1
 #define IP_TTL		2
@@ -158,6 +162,7 @@ struct in_addr {
 
 /* Request struct for multicast socket ops */
 
+#if __UAPI_DEF_IP_MREQ
 struct ip_mreq  {
 	struct in_addr imr_multiaddr;	/* IP multicast address of group */
 	struct in_addr imr_interface;	/* local IP address of interface */
@@ -209,14 +214,18 @@ struct group_filter {
 #define GROUP_FILTER_SIZE(numsrc) \
 	(sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
 	+ (numsrc) * sizeof(struct __kernel_sockaddr_storage))
+#endif
 
+#if __UAPI_DEF_IN_PKTINFO
 struct in_pktinfo {
 	int		ipi_ifindex;
 	struct in_addr	ipi_spec_dst;
 	struct in_addr	ipi_addr;
 };
+#endif
 
 /* Structure describing an Internet (IP) socket address. */
+#if  __UAPI_DEF_SOCKADDR_IN
 #define __SOCK_SIZE__	16		/* sizeof(struct sockaddr)	*/
 struct sockaddr_in {
   __kernel_sa_family_t	sin_family;	/* Address family		*/
@@ -228,8 +237,9 @@ struct sockaddr_in {
 			sizeof(unsigned short int) - sizeof(struct in_addr)];
 };
 #define sin_zero	__pad		/* for BSD UNIX comp. -FvK	*/
+#endif
 
-
+#if __UAPI_DEF_IN_CLASS
 /*
  * Definitions of the bits in an Internet address integer.
  * On subnets, host and network parts are found according
@@ -280,7 +290,7 @@ struct sockaddr_in {
 #define INADDR_ALLHOSTS_GROUP 	0xe0000001U	/* 224.0.0.1   */
 #define INADDR_ALLRTRS_GROUP    0xe0000002U	/* 224.0.0.2 */
 #define INADDR_MAX_LOCAL_GROUP  0xe00000ffU	/* 224.0.0.255 */
-
+#endif
 
 /* <asm/byteorder.h> contains the htonl type stuff.. */
 #include <asm/byteorder.h> 
--- a/include/uapi/linux/libc-compat.h	2015-01-27 06:16:51.364032627 -0500
+++ b/include/uapi/linux/libc-compat.h	2015-06-25 22:30:23.871453196 -0400
@@ -56,6 +56,13 @@
 
 /* GLIBC headers included first so don't define anything
  * that would already be defined. */
+#define __UAPI_DEF_IN_ADDR		0
+#define __UAPI_DEF_IN_IPPROTO		0
+#define __UAPI_DEF_IN_PKTINFO		0
+#define __UAPI_DEF_IP_MREQ		0
+#define __UAPI_DEF_SOCKADDR_IN		0
+#define __UAPI_DEF_IN_CLASS		0
+
 #define __UAPI_DEF_IN6_ADDR		0
 /* The exception is the in6_addr macros which must be defined
  * if the glibc code didn't define them. This guard matches
@@ -78,6 +85,13 @@
 /* Linux headers included first, and we must define everything
  * we need. The expectation is that glibc will check the
  * __UAPI_DEF_* defines and adjust appropriately. */
+#define __UAPI_DEF_IN_ADDR		1
+#define __UAPI_DEF_IN_IPPROTO		1
+#define __UAPI_DEF_IN_PKTINFO		1
+#define __UAPI_DEF_IP_MREQ		1
+#define __UAPI_DEF_SOCKADDR_IN		1
+#define __UAPI_DEF_IN_CLASS		1
+
 #define __UAPI_DEF_IN6_ADDR		1
 /* We unconditionally define the in6_addr macros and glibc must
  * coordinate. */

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

* Re: [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h
  2015-06-26  3:12 [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h Stephen Hemminger
@ 2015-06-27 21:52 ` David Miller
  2015-06-27 23:20   ` David Miller
  2015-06-29 18:07 ` Pablo Neira Ayuso
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2015-06-27 21:52 UTC (permalink / raw)
  To: stephen; +Cc: pablo, netdev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Thu, 25 Jun 2015 23:12:06 -0400

> This fixes breakage to iproute2 build with recent kernel headers
> caused by:
>    commit a263653ed798216c0069922d7b5237ca49436007
>    Author: Pablo Neira Ayuso <pablo@netfilter.org>
>    Date:   Wed Jun 17 10:28:27 2015 -0500
> 
>    netfilter: don't pull include/linux/netfilter.h from netns headers
> 
> The issue is that definitions in linux/in.h overlap with those
> in netinet/in.h. This patch solves this by introducing the same
> mechanism as was used to solve the same problem with linux/in6.h
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Applied.

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

* Re: [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h
  2015-06-27 21:52 ` David Miller
@ 2015-06-27 23:20   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2015-06-27 23:20 UTC (permalink / raw)
  To: stephen; +Cc: pablo, netdev

From: David Miller <davem@davemloft.net>
Date: Sat, 27 Jun 2015 14:52:48 -0700 (PDT)

> Applied.

Reverted, as it breaks the build.

Please test your patches.

In file included from include/linux/in.h:23:0,
                 from include/uapi/linux/netfilter.h:7,
                 from include/linux/netfilter_defs.h:4,
                 from include/net/netns/netfilter.h:4,
                 from include/net/net_namespace.h:22,
                 from include/linux/init_task.h:15,
                 from kernel/fork.c:562:
include/uapi/linux/in.h:25:5: warning: "__UAPI_DEF_IN_IPPROTO" is not defined [-Wundef]
 #if __UAPI_DEF_IN_IPPROTO
     ^
include/uapi/linux/in.h:82:5: warning: "__UAPI_DEF_IN_ADDR" is not defined [-Wundef]
 #if __UAPI_DEF_IN_ADDR
     ^
include/uapi/linux/in.h:165:5: warning: "__UAPI_DEF_IP_MREQ" is not defined [-Wundef]
 #if __UAPI_DEF_IP_MREQ
     ^
include/uapi/linux/in.h:219:5: warning: "__UAPI_DEF_IN_PKTINFO" is not defined [-Wundef]
 #if __UAPI_DEF_IN_PKTINFO
     ^
include/uapi/linux/in.h:228:6: warning: "__UAPI_DEF_SOCKADDR_IN" is not defined [-Wundef]
 #if  __UAPI_DEF_SOCKADDR_IN
      ^
include/uapi/linux/in.h:242:5: warning: "__UAPI_DEF_IN_CLASS" is not defined [-Wundef]
 #if __UAPI_DEF_IN_CLASS
     ^

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

* Re: [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h
  2015-06-26  3:12 [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h Stephen Hemminger
  2015-06-27 21:52 ` David Miller
@ 2015-06-29 18:07 ` Pablo Neira Ayuso
  2015-06-30  0:55   ` Stephen Hemminger
  1 sibling, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2015-06-29 18:07 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, netdev

On Thu, Jun 25, 2015 at 11:12:06PM -0400, Stephen Hemminger wrote:
> This fixes breakage to iproute2 build with recent kernel headers
> caused by:
>    commit a263653ed798216c0069922d7b5237ca49436007
>    Author: Pablo Neira Ayuso <pablo@netfilter.org>
>    Date:   Wed Jun 17 10:28:27 2015 -0500
> 
>    netfilter: don't pull include/linux/netfilter.h from netns headers
> 
> The issue is that definitions in linux/in.h overlap with those
> in netinet/in.h. This patch solves this by introducing the same
> mechanism as was used to solve the same problem with linux/in6.h

My patch also modifies non-exposed net/netns/ headers, I'm not sure
how this can be causing problems to uapi headers.

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

* Re: [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h
  2015-06-29 18:07 ` Pablo Neira Ayuso
@ 2015-06-30  0:55   ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2015-06-30  0:55 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: David Miller, netdev

On Mon, 29 Jun 2015 20:07:20 +0200
Pablo Neira Ayuso <pablo@netfilter.org> wrote:

> On Thu, Jun 25, 2015 at 11:12:06PM -0400, Stephen Hemminger wrote:
> > This fixes breakage to iproute2 build with recent kernel headers
> > caused by:
> >    commit a263653ed798216c0069922d7b5237ca49436007
> >    Author: Pablo Neira Ayuso <pablo@netfilter.org>
> >    Date:   Wed Jun 17 10:28:27 2015 -0500
> > 
> >    netfilter: don't pull include/linux/netfilter.h from netns headers
> > 
> > The issue is that definitions in linux/in.h overlap with those
> > in netinet/in.h. This patch solves this by introducing the same
> > mechanism as was used to solve the same problem with linux/in6.h
> 
> My patch also modifies non-exposed net/netns/ headers, I'm not sure
> how this can be causing problems to uapi headers.

The problem is that your patch changes include/uapi/linux/netfilter.h
to include linux/in.h. Some programs have already include <netinet/in.h>
(often through a complex chain of headers).
If both headers are included it causes errors and warnings about duplicate
definitions. My patch fixes that.

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

end of thread, other threads:[~2015-06-30  0:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26  3:12 [PATCH net] uapi: fix compatability of linux/in.h with netinet/in.h Stephen Hemminger
2015-06-27 21:52 ` David Miller
2015-06-27 23:20   ` David Miller
2015-06-29 18:07 ` Pablo Neira Ayuso
2015-06-30  0:55   ` Stephen Hemminger

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).