linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] uapi: fix linux/if_pppol2tp.h userspace compilation errors
@ 2017-02-14 10:33 Dmitry V. Levin
  2017-02-14 19:37 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry V. Levin @ 2017-02-14 10:33 UTC (permalink / raw)
  To: James Chapman, netdev, linux-kernel

Move inclusion of <linux/l2tp.h> before <linux/in.h>
to fix userspace compilation errors like this:

In file included from /usr/include/linux/l2tp.h:12:0,
                 from /usr/include/linux/if_pppol2tp.h:21,
/usr/include/netinet/in.h:31:8: error: redefinition of 'struct in_addr'

Fixes: 47c3e7783be4 ("net: l2tp: deprecate PPPOL2TP_MSG_* in favour of L2TP_MSG_*")
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 include/uapi/linux/if_pppol2tp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/if_pppol2tp.h b/include/uapi/linux/if_pppol2tp.h
index 6418c4d..54a404e 100644
--- a/include/uapi/linux/if_pppol2tp.h
+++ b/include/uapi/linux/if_pppol2tp.h
@@ -16,9 +16,9 @@
 #define _UAPI__LINUX_IF_PPPOL2TP_H
 
 #include <linux/types.h>
+#include <linux/l2tp.h>
 #include <linux/in.h>
 #include <linux/in6.h>
-#include <linux/l2tp.h>
 
 /* Structure used to connect() the socket to a particular tunnel UDP
  * socket over IPv4.
-- 
ldv

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

* Re: [PATCH] uapi: fix linux/if_pppol2tp.h userspace compilation errors
  2017-02-14 10:33 [PATCH] uapi: fix linux/if_pppol2tp.h userspace compilation errors Dmitry V. Levin
@ 2017-02-14 19:37 ` David Miller
  2017-02-14 20:29   ` Dmitry V. Levin
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2017-02-14 19:37 UTC (permalink / raw)
  To: ldv; +Cc: jchapman, netdev, linux-kernel

From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Tue, 14 Feb 2017 13:33:53 +0300

> In file included from /usr/include/linux/l2tp.h:12:0,
>                  from /usr/include/linux/if_pppol2tp.h:21,
> /usr/include/netinet/in.h:31:8: error: redefinition of 'struct in_addr'

This is protected properly by __UAPI_DEF_IN_ADDR, so whichever gets
included first makes the definition.

This whole thing is designed so that if GLIBC headers are included
first, __UAPI_DEF_IN_ADDR will be defined to zero, therefore
linux/in.h won't try to make the definition.  Otherwise it will.

The facility should not be so fragile that we have to play all
kinds of header ordering games.  We would be imposing the same
strange rules on userspace applications including these headers
which is completely unacceptable.

So if the facility isn't working correctly, let's fix that instead
of fidgeting with include ordering all over the tree.

Thanks.

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

* Re: [PATCH] uapi: fix linux/if_pppol2tp.h userspace compilation errors
  2017-02-14 19:37 ` David Miller
@ 2017-02-14 20:29   ` Dmitry V. Levin
  2017-02-15  2:23     ` [PATCH v2] " Dmitry V. Levin
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry V. Levin @ 2017-02-14 20:29 UTC (permalink / raw)
  To: David Miller
  Cc: Asbjørn Sloth Tønnesen, jchapman, netdev, linux-kernel

On Tue, Feb 14, 2017 at 02:37:23PM -0500, David Miller wrote:
> From: "Dmitry V. Levin" <ldv@altlinux.org>
> Date: Tue, 14 Feb 2017 13:33:53 +0300
> 
> > In file included from /usr/include/linux/l2tp.h:12:0,
> >                  from /usr/include/linux/if_pppol2tp.h:21,
> > /usr/include/netinet/in.h:31:8: error: redefinition of 'struct in_addr'
> 
> This is protected properly by __UAPI_DEF_IN_ADDR, so whichever gets
> included first makes the definition.
> 
> This whole thing is designed so that if GLIBC headers are included
> first, __UAPI_DEF_IN_ADDR will be defined to zero, therefore
> linux/in.h won't try to make the definition.  Otherwise it will.
> 
> The facility should not be so fragile that we have to play all
> kinds of header ordering games.  We would be imposing the same
> strange rules on userspace applications including these headers
> which is completely unacceptable.

The facility is so fragile that netinet/in.h cannot be included after
linux/in.h:

$ gcc -S -o/dev/null -xc /dev/null -include /usr/include/linux/in.h -include /usr/include/netinet/in.h
In file included from <command-line>:32:0:
/usr/include/netinet/in.h:31:8: error: redefinition of 'struct in_addr'
 struct in_addr
        ^~~~~~~
In file included from <command-line>:32:0:
/usr/include/linux/in.h:84:8: note: originally defined here
 struct in_addr {
        ^~~~~~~

> So if the facility isn't working correctly, let's fix that instead
> of fidgeting with include ordering all over the tree.

I don't mind if the whole facility will get fixed someday.
My humble objective was just to fix the regression introduced in v4.10-rc1
by commit 47c3e7783be4.


-- 
ldv

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

* [PATCH v2] uapi: fix linux/if_pppol2tp.h userspace compilation errors
  2017-02-14 20:29   ` Dmitry V. Levin
@ 2017-02-15  2:23     ` Dmitry V. Levin
  2017-02-15  3:18       ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry V. Levin @ 2017-02-15  2:23 UTC (permalink / raw)
  To: David Miller
  Cc: Asbjørn Sloth Tønnesen, James Chapman, netdev, linux-kernel

Because of <linux/libc-compat.h> interface limitations, <netinet/in.h>
provided by libc cannot be included after <linux/in.h>, therefore any
header that includes <netinet/in.h> cannot be included after <linux/in.h>.

Change uapi/linux/l2tp.h, the last uapi header that includes
<netinet/in.h>, to include <linux/in.h> and <linux/in6.h> instead of
<netinet/in.h> and use __SOCK_SIZE__ instead of sizeof(struct sockaddr)
the same way as uapi/linux/in.h does, to fix linux/if_pppol2tp.h userspace
compilation errors like this:

In file included from /usr/include/linux/l2tp.h:12:0,
                 from /usr/include/linux/if_pppol2tp.h:21,
/usr/include/netinet/in.h:31:8: error: redefinition of 'struct in_addr'

Fixes: 47c3e7783be4 ("net: l2tp: deprecate PPPOL2TP_MSG_* in favour of L2TP_MSG_*")
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: change uapi/linux/l2tp.h to fix <linux/if_pppol2tp.h>

 include/uapi/linux/l2tp.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/l2tp.h b/include/uapi/linux/l2tp.h
index 85ddb74..b23c191 100644
--- a/include/uapi/linux/l2tp.h
+++ b/include/uapi/linux/l2tp.h
@@ -9,9 +9,8 @@
 
 #include <linux/types.h>
 #include <linux/socket.h>
-#ifndef __KERNEL__
-#include <netinet/in.h>
-#endif
+#include <linux/in.h>
+#include <linux/in6.h>
 
 #define IPPROTO_L2TP		115
 
@@ -31,7 +30,7 @@ struct sockaddr_l2tpip {
 	__u32		l2tp_conn_id;	/* Connection ID of tunnel */
 
 	/* Pad to size of `struct sockaddr'. */
-	unsigned char	__pad[sizeof(struct sockaddr) -
+	unsigned char	__pad[__SOCK_SIZE__ -
 			      sizeof(__kernel_sa_family_t) -
 			      sizeof(__be16) - sizeof(struct in_addr) -
 			      sizeof(__u32)];
-- 
ldv

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

* Re: [PATCH v2] uapi: fix linux/if_pppol2tp.h userspace compilation errors
  2017-02-15  2:23     ` [PATCH v2] " Dmitry V. Levin
@ 2017-02-15  3:18       ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-02-15  3:18 UTC (permalink / raw)
  To: ldv; +Cc: asbjorn, jchapman, netdev, linux-kernel

From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Wed, 15 Feb 2017 05:23:26 +0300

> Because of <linux/libc-compat.h> interface limitations, <netinet/in.h>
> provided by libc cannot be included after <linux/in.h>, therefore any
> header that includes <netinet/in.h> cannot be included after <linux/in.h>.
> 
> Change uapi/linux/l2tp.h, the last uapi header that includes
> <netinet/in.h>, to include <linux/in.h> and <linux/in6.h> instead of
> <netinet/in.h> and use __SOCK_SIZE__ instead of sizeof(struct sockaddr)
> the same way as uapi/linux/in.h does, to fix linux/if_pppol2tp.h userspace
> compilation errors like this:
> 
> In file included from /usr/include/linux/l2tp.h:12:0,
>                  from /usr/include/linux/if_pppol2tp.h:21,
> /usr/include/netinet/in.h:31:8: error: redefinition of 'struct in_addr'
> 
> Fixes: 47c3e7783be4 ("net: l2tp: deprecate PPPOL2TP_MSG_* in favour of L2TP_MSG_*")
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
> v2: change uapi/linux/l2tp.h to fix <linux/if_pppol2tp.h>

This looks a lot better.

Applied and queued up for -stable, thanks.

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

end of thread, other threads:[~2017-02-15  3:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-14 10:33 [PATCH] uapi: fix linux/if_pppol2tp.h userspace compilation errors Dmitry V. Levin
2017-02-14 19:37 ` David Miller
2017-02-14 20:29   ` Dmitry V. Levin
2017-02-15  2:23     ` [PATCH v2] " Dmitry V. Levin
2017-02-15  3:18       ` David Miller

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