All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] Fix compilation with kernel headers < 3.4
@ 2018-02-26 19:46 Serhey Popovych
  2018-02-26 19:48 ` Serhey Popovych
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-02-26 19:46 UTC (permalink / raw)
  To: netdev; +Cc: thomas.de_schampheleire

Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
__kernel_long_t and __kernel_ulong_t but does not provide internal
definitions for it.

This means that compilation using kernel headers that are older than 3.4
(where these types were added) will fail. This situation may be uncommon for
native compilation, but not uncommon for cross compilation where the
toolchains may be a bit older.

Provide the necessary types internally if not provided by the kernel
headers to fix compilation in such cases.

Co-Developed-by: Serhii Popovych <serhe.popovych@gmail.com>
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 include/linux/sysinfo.h |   14 ++++++++++++++
 misc/ss.c               |   10 ++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 include/linux/sysinfo.h

diff --git a/include/linux/sysinfo.h b/include/linux/sysinfo.h
new file mode 100644
index 0000000..766de8d
--- /dev/null
+++ b/include/linux/sysinfo.h
@@ -0,0 +1,14 @@
+#ifndef _SYSINFO_COMPAT_H
+#define _SYSINFO_COMPAT_H
+
+/* In case the kernel header asm/posix_types.h is too old (< 3.4) to provide
+ * __kernel_long_t, provide it here
+ */
+#ifndef __kernel_long_t
+typedef long		__kernel_long_t;
+typedef unsigned long	__kernel_ulong_t;
+#endif
+
+#include_next <linux/sysinfo.h>
+
+#endif /* _SYSINFO_COMPAT_H */
diff --git a/misc/ss.c b/misc/ss.c
index e047f9c..de5a673 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -46,6 +46,16 @@
 #include <linux/sctp.h>
 #include <linux/vm_sockets_diag.h>
 
+#ifndef AF_VSOCK
+#define AF_VSOCK	40
+#if defined(AF_MAX) && AF_MAX < 41
+#undef AF_MAX
+#endif
+#ifndef AF_MAX
+#define AF_MAX		41
+#endif /* AF_MAX */
+#endif /* AF_VSOCK */
+
 #define MAGIC_SEQ 123456
 #define BUF_CHUNK (1024 * 1024)
 #define LEN_ALIGN(x) (((x) + 1) & ~1)
-- 
1.7.10.4

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-26 19:46 [PATCH iproute2] Fix compilation with kernel headers < 3.4 Serhey Popovych
@ 2018-02-26 19:48 ` Serhey Popovych
  2018-02-26 20:32 ` Thomas De Schampheleire
  2018-02-27 10:16 ` Thomas De Schampheleire
  2 siblings, 0 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-02-26 19:48 UTC (permalink / raw)
  To: netdev; +Cc: thomas.de_schampheleire


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

Serhey Popovych wrote:
> Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
> __kernel_long_t and __kernel_ulong_t but does not provide internal
> definitions for it.
> 
> This means that compilation using kernel headers that are older than 3.4
> (where these types were added) will fail. This situation may be uncommon for
> native compilation, but not uncommon for cross compilation where the
> toolchains may be a bit older.
> 
> Provide the necessary types internally if not provided by the kernel
> headers to fix compilation in such cases.
> 
> Co-Developed-by: Serhii Popovych <serhe.popovych@gmail.com>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
> ---
>  include/linux/sysinfo.h |   14 ++++++++++++++
>  misc/ss.c               |   10 ++++++++++
>  2 files changed, 24 insertions(+)
>  create mode 100644 include/linux/sysinfo.h

Oops, forgot to mention in subject: this is RFC one.

> 
> diff --git a/include/linux/sysinfo.h b/include/linux/sysinfo.h
> new file mode 100644
> index 0000000..766de8d
> --- /dev/null
> +++ b/include/linux/sysinfo.h
> @@ -0,0 +1,14 @@
> +#ifndef _SYSINFO_COMPAT_H
> +#define _SYSINFO_COMPAT_H
> +
> +/* In case the kernel header asm/posix_types.h is too old (< 3.4) to provide
> + * __kernel_long_t, provide it here
> + */
> +#ifndef __kernel_long_t
> +typedef long		__kernel_long_t;
> +typedef unsigned long	__kernel_ulong_t;
> +#endif
> +
> +#include_next <linux/sysinfo.h>
> +
> +#endif /* _SYSINFO_COMPAT_H */
> diff --git a/misc/ss.c b/misc/ss.c
> index e047f9c..de5a673 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -46,6 +46,16 @@
>  #include <linux/sctp.h>
>  #include <linux/vm_sockets_diag.h>
>  
> +#ifndef AF_VSOCK
> +#define AF_VSOCK	40
> +#if defined(AF_MAX) && AF_MAX < 41
> +#undef AF_MAX
> +#endif
> +#ifndef AF_MAX
> +#define AF_MAX		41
> +#endif /* AF_MAX */
> +#endif /* AF_VSOCK */
> +
>  #define MAGIC_SEQ 123456
>  #define BUF_CHUNK (1024 * 1024)
>  #define LEN_ALIGN(x) (((x) + 1) & ~1)
> 



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

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-26 19:46 [PATCH iproute2] Fix compilation with kernel headers < 3.4 Serhey Popovych
  2018-02-26 19:48 ` Serhey Popovych
@ 2018-02-26 20:32 ` Thomas De Schampheleire
  2018-02-26 20:38   ` Serhey Popovych
  2018-02-27 10:16 ` Thomas De Schampheleire
  2 siblings, 1 reply; 10+ messages in thread
From: Thomas De Schampheleire @ 2018-02-26 20:32 UTC (permalink / raw)
  To: Serhey Popovych; +Cc: netdev

On Mon, Feb 26, 2018 at 09:46:41PM +0200, Serhey Popovych wrote:
> Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
> __kernel_long_t and __kernel_ulong_t but does not provide internal
> definitions for it.
> 
> This means that compilation using kernel headers that are older than 3.4
> (where these types were added) will fail. This situation may be uncommon for
> native compilation, but not uncommon for cross compilation where the
> toolchains may be a bit older.
> 
> Provide the necessary types internally if not provided by the kernel
> headers to fix compilation in such cases.
> 
> Co-Developed-by: Serhii Popovych <serhe.popovych@gmail.com>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
> ---
>  include/linux/sysinfo.h |   14 ++++++++++++++
>  misc/ss.c               |   10 ++++++++++
>  2 files changed, 24 insertions(+)
>  create mode 100644 include/linux/sysinfo.h
> 
> diff --git a/include/linux/sysinfo.h b/include/linux/sysinfo.h
> new file mode 100644
> index 0000000..766de8d
> --- /dev/null
> +++ b/include/linux/sysinfo.h
> @@ -0,0 +1,14 @@
> +#ifndef _SYSINFO_COMPAT_H
> +#define _SYSINFO_COMPAT_H
> +
> +/* In case the kernel header asm/posix_types.h is too old (< 3.4) to provide
> + * __kernel_long_t, provide it here
> + */
> +#ifndef __kernel_long_t
> +typedef long		__kernel_long_t;
> +typedef unsigned long	__kernel_ulong_t;
> +#endif
> +
> +#include_next <linux/sysinfo.h>
> +
> +#endif /* _SYSINFO_COMPAT_H */
> diff --git a/misc/ss.c b/misc/ss.c
> index e047f9c..de5a673 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -46,6 +46,16 @@
>  #include <linux/sctp.h>
>  #include <linux/vm_sockets_diag.h>
>  
> +#ifndef AF_VSOCK
> +#define AF_VSOCK	40
> +#if defined(AF_MAX) && AF_MAX < 41
> +#undef AF_MAX
> +#endif
> +#ifndef AF_MAX
> +#define AF_MAX		41
> +#endif /* AF_MAX */
> +#endif /* AF_VSOCK */
> +
>  #define MAGIC_SEQ 123456
>  #define BUF_CHUNK (1024 * 1024)
>  #define LEN_ALIGN(x) (((x) + 1) & ~1)

Thanks, this patch works fine in my use case too.

I can't judge the changes in ss.c. I did not see such problems, but my toolchain
is based on 3.3 kernel headers.

Best regards,
Thomas

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-26 20:32 ` Thomas De Schampheleire
@ 2018-02-26 20:38   ` Serhey Popovych
  0 siblings, 0 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-02-26 20:38 UTC (permalink / raw)
  To: Thomas De Schampheleire; +Cc: netdev


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

Thomas De Schampheleire wrote:
> On Mon, Feb 26, 2018 at 09:46:41PM +0200, Serhey Popovych wrote:
>> Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
>> __kernel_long_t and __kernel_ulong_t but does not provide internal
>> definitions for it.
>>
>> This means that compilation using kernel headers that are older than 3.4
>> (where these types were added) will fail. This situation may be uncommon for
>> native compilation, but not uncommon for cross compilation where the
>> toolchains may be a bit older.
>>
>> Provide the necessary types internally if not provided by the kernel
>> headers to fix compilation in such cases.
>>
>> Co-Developed-by: Serhii Popovych <serhe.popovych@gmail.com>
>> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
>> ---
>>  include/linux/sysinfo.h |   14 ++++++++++++++
>>  misc/ss.c               |   10 ++++++++++
>>  2 files changed, 24 insertions(+)
>>  create mode 100644 include/linux/sysinfo.h
>>
>> diff --git a/include/linux/sysinfo.h b/include/linux/sysinfo.h
>> new file mode 100644
>> index 0000000..766de8d
>> --- /dev/null
>> +++ b/include/linux/sysinfo.h
>> @@ -0,0 +1,14 @@
>> +#ifndef _SYSINFO_COMPAT_H
>> +#define _SYSINFO_COMPAT_H
>> +
>> +/* In case the kernel header asm/posix_types.h is too old (< 3.4) to provide
>> + * __kernel_long_t, provide it here
>> + */
>> +#ifndef __kernel_long_t
>> +typedef long		__kernel_long_t;
>> +typedef unsigned long	__kernel_ulong_t;
>> +#endif
>> +
>> +#include_next <linux/sysinfo.h>
>> +
>> +#endif /* _SYSINFO_COMPAT_H */
>> diff --git a/misc/ss.c b/misc/ss.c
>> index e047f9c..de5a673 100644
>> --- a/misc/ss.c
>> +++ b/misc/ss.c
>> @@ -46,6 +46,16 @@
>>  #include <linux/sctp.h>
>>  #include <linux/vm_sockets_diag.h>
>>  
>> +#ifndef AF_VSOCK
>> +#define AF_VSOCK	40
>> +#if defined(AF_MAX) && AF_MAX < 41
>> +#undef AF_MAX
>> +#endif
>> +#ifndef AF_MAX
>> +#define AF_MAX		41
>> +#endif /* AF_MAX */
>> +#endif /* AF_VSOCK */
>> +
>>  #define MAGIC_SEQ 123456
>>  #define BUF_CHUNK (1024 * 1024)
>>  #define LEN_ALIGN(x) (((x) + 1) & ~1)
> 
> Thanks, this patch works fine in my use case too.
> 
> I can't judge the changes in ss.c. I did not see such problems, but my toolchain
> is based on 3.3 kernel headers.

Well, I tested this with 3.2 kernels (oldest supported) in Debian 7
(Wheezy) environment:

ss.c:294:15: error: 'AF_VSOCK' undeclared here (not in a function)
ss.c:323:2: error: array index in initializer not of integer type
ss.c:323:2: error: (near initialization for 'default_afs')
make[1]: *** [ss.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

Look at your 3.3 headers, probably they provide some redefine for
AF_VSOCK. In stock linux-stable/linux-3.3.y I see no AF_VSOCK, so
probably I will get same error as above (however not checked yet).

> 
> Best regards,
> Thomas
> 


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

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-26 19:46 [PATCH iproute2] Fix compilation with kernel headers < 3.4 Serhey Popovych
  2018-02-26 19:48 ` Serhey Popovych
  2018-02-26 20:32 ` Thomas De Schampheleire
@ 2018-02-27 10:16 ` Thomas De Schampheleire
  2018-02-27 12:21   ` Serhey Popovych
  2 siblings, 1 reply; 10+ messages in thread
From: Thomas De Schampheleire @ 2018-02-27 10:16 UTC (permalink / raw)
  To: Serhey Popovych; +Cc: netdev

On Mon, Feb 26, 2018 at 09:46:41PM +0200, Serhey Popovych wrote:
> Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
> __kernel_long_t and __kernel_ulong_t but does not provide internal
> definitions for it.
> 
> This means that compilation using kernel headers that are older than 3.4
> (where these types were added) will fail. This situation may be uncommon for
> native compilation, but not uncommon for cross compilation where the
> toolchains may be a bit older.
> 
> Provide the necessary types internally if not provided by the kernel
> headers to fix compilation in such cases.
> 
> Co-Developed-by: Serhii Popovych <serhe.popovych@gmail.com>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
> ---
>  include/linux/sysinfo.h |   14 ++++++++++++++
>  misc/ss.c               |   10 ++++++++++
>  2 files changed, 24 insertions(+)
>  create mode 100644 include/linux/sysinfo.h
> 
> diff --git a/include/linux/sysinfo.h b/include/linux/sysinfo.h
> new file mode 100644
> index 0000000..766de8d
> --- /dev/null
> +++ b/include/linux/sysinfo.h
> @@ -0,0 +1,14 @@
> +#ifndef _SYSINFO_COMPAT_H
> +#define _SYSINFO_COMPAT_H
> +
> +/* In case the kernel header asm/posix_types.h is too old (< 3.4) to provide
> + * __kernel_long_t, provide it here
> + */
> +#ifndef __kernel_long_t
> +typedef long		__kernel_long_t;
> +typedef unsigned long	__kernel_ulong_t;
> +#endif
> +
> +#include_next <linux/sysinfo.h>
> +
> +#endif /* _SYSINFO_COMPAT_H */

Actually, I now wonder: instead of applying this trick with #include_next on
sysinfo.h, why not do it on linux/types.h ? That would be more correct and more
robust for the future, no?

/Thomas

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-27 10:16 ` Thomas De Schampheleire
@ 2018-02-27 12:21   ` Serhey Popovych
  0 siblings, 0 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-02-27 12:21 UTC (permalink / raw)
  To: Thomas De Schampheleire; +Cc: netdev


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

Thomas De Schampheleire wrote:
> On Mon, Feb 26, 2018 at 09:46:41PM +0200, Serhey Popovych wrote:
>> Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
>> __kernel_long_t and __kernel_ulong_t but does not provide internal
>> definitions for it.
>>
>> This means that compilation using kernel headers that are older than 3.4
>> (where these types were added) will fail. This situation may be uncommon for
>> native compilation, but not uncommon for cross compilation where the
>> toolchains may be a bit older.
>>
>> Provide the necessary types internally if not provided by the kernel
>> headers to fix compilation in such cases.
>>
>> Co-Developed-by: Serhii Popovych <serhe.popovych@gmail.com>
>> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
>> ---
>>  include/linux/sysinfo.h |   14 ++++++++++++++
>>  misc/ss.c               |   10 ++++++++++
>>  2 files changed, 24 insertions(+)
>>  create mode 100644 include/linux/sysinfo.h
>>
>> diff --git a/include/linux/sysinfo.h b/include/linux/sysinfo.h
>> new file mode 100644
>> index 0000000..766de8d
>> --- /dev/null
>> +++ b/include/linux/sysinfo.h
>> @@ -0,0 +1,14 @@
>> +#ifndef _SYSINFO_COMPAT_H
>> +#define _SYSINFO_COMPAT_H
>> +
>> +/* In case the kernel header asm/posix_types.h is too old (< 3.4) to provide
>> + * __kernel_long_t, provide it here
>> + */
>> +#ifndef __kernel_long_t
>> +typedef long		__kernel_long_t;
>> +typedef unsigned long	__kernel_ulong_t;
>> +#endif
>> +
>> +#include_next <linux/sysinfo.h>
>> +
>> +#endif /* _SYSINFO_COMPAT_H */
> 
> Actually, I now wonder: instead of applying this trick with #include_next on
> sysinfo.h, why not do it on linux/types.h ? That would be more correct and more
> robust for the future, no?

No. Headers in include/uapi updated automatically from newer kernel
versions. If we do any hacks in iproute2 uapi directory updating headers
automatically would be problematic.

As for me using #include_next presents better approach.

Better to provide means for compatibility and that I propose to do with
series "ip: Provide compatibility bits to build with old glibc/kernel
headers".

> 
> /Thomas
> 



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

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-26 18:51 Thomas De Schampheleire
  2018-02-26 18:58 ` Stephen Hemminger
@ 2018-02-26 19:27 ` Serhey Popovych
  1 sibling, 0 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-02-26 19:27 UTC (permalink / raw)
  To: Thomas De Schampheleire, netdev


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

Thomas De Schampheleire wrote:
> Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
> __kernel_long_t and __kernel_ulong_t but does not provide internal
> definitions for it.

I tried one time to build with headers from 3.2 (last supported LTS at
the moment) and found that AF_VSOCK is missing. As result of defining
AF_VSOCK we need to adjust AF_MAX. Not sure this is correct at all but
this helps to build with old headers.

diff --git a/misc/ss.c b/misc/ss.c
index 49f9c49..2849bc6 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -46,6 +46,16 @@
 #include <linux/sctp.h>
 #include <linux/vm_sockets_diag.h>

+#ifndef AF_VSOCK
+#define AF_VSOCK       40
+#if defined(AF_MAX) && AF_MAX < 41
+#undef AF_MAX
+#endif
+#ifndef AF_MAX
+#define AF_MAX         41
+#endif /* AF_MAX */
+#endif /* AF_VSOCK */

> 
> This means that compilation using kernel headers that are older than 3.4
> (where these types were added) will fail. This situation may be uncommon for
> native compilation, but not uncommon for cross compilation where the
> toolchains may be a bit older.
> 
> Provide the necessary types internally if not provided by the kernel
> headers to fix compilation in such cases.
> 
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
>  include/uapi/linux/posix_types.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/uapi/linux/posix_types.h b/include/uapi/linux/posix_types.h
> index 9a7a740b..60f3d378 100644
> --- a/include/uapi/linux/posix_types.h
> +++ b/include/uapi/linux/posix_types.h
> @@ -35,4 +35,13 @@ typedef int __kernel_mqd_t;
>  
>  #include <asm/posix_types.h>
>  
> +/* in case the kernel header asm/posix_types.h is too old (< 3.4) to provide
> + * __kernel_long_t, provide it here */
> +#ifndef __kernel_long_t
> +typedef long		__kernel_long_t;
> +#endif
> +#ifndef __kernel_ulong_t
There is no such define. Only __kernel_long_t.

> +typedef unsigned long	__kernel_ulong_t;
> +#endif
> +
>  #endif /* _LINUX_POSIX_TYPES_H */
> 



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

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-26 18:58 ` Stephen Hemminger
@ 2018-02-26 19:21   ` Thomas De Schampheleire
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas De Schampheleire @ 2018-02-26 19:21 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Mon, Feb 26, 2018 at 10:58:10AM -0800, Stephen Hemminger wrote:
> On Mon, 26 Feb 2018 19:51:12 +0100
> Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> wrote:
> 
> > Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
> > __kernel_long_t and __kernel_ulong_t but does not provide internal
> > definitions for it.
> > 
> > This means that compilation using kernel headers that are older than 3.4
> > (where these types were added) will fail. This situation may be uncommon for
> > native compilation, but not uncommon for cross compilation where the
> > toolchains may be a bit older.
> > 
> > Provide the necessary types internally if not provided by the kernel
> > headers to fix compilation in such cases.
> > 
> > Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> > ---
> >  include/uapi/linux/posix_types.h | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/include/uapi/linux/posix_types.h b/include/uapi/linux/posix_types.h
> > index 9a7a740b..60f3d378 100644
> > --- a/include/uapi/linux/posix_types.h
> > +++ b/include/uapi/linux/posix_types.h
> > @@ -35,4 +35,13 @@ typedef int __kernel_mqd_t;
> >  
> >  #include <asm/posix_types.h>
> >  
> > +/* in case the kernel header asm/posix_types.h is too old (< 3.4) to provide
> > + * __kernel_long_t, provide it here */
> > +#ifndef __kernel_long_t
> > +typedef long		__kernel_long_t;
> > +#endif
> > +#ifndef __kernel_ulong_t
> > +typedef unsigned long	__kernel_ulong_t;
> > +#endif
> > +
> >  #endif /* _LINUX_POSIX_TYPES_H */
> 
> No.
> 
> The headers in uapi are automatically generated from the upstream kernel
> headers. If there are places that need to have backwards compatibility,
> fix it in the main iproute2 source.

Thanks.
But this means modifying several iproute2 source files, essentially every file
that includes (possibly indirectly) kernel.h, because that one includes
sysinfo.h which uses the __kernel_long_t type.

How do you propose to handle this? Add a new header file in include/ to hold the
two definitions with guards like above, then include that header file
unconditionally from the required files?
Something like: include/kernel_compat.h ?

Thanks,
Thomas

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

* Re: [PATCH iproute2] Fix compilation with kernel headers < 3.4
  2018-02-26 18:51 Thomas De Schampheleire
@ 2018-02-26 18:58 ` Stephen Hemminger
  2018-02-26 19:21   ` Thomas De Schampheleire
  2018-02-26 19:27 ` Serhey Popovych
  1 sibling, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2018-02-26 18:58 UTC (permalink / raw)
  To: Thomas De Schampheleire; +Cc: netdev

On Mon, 26 Feb 2018 19:51:12 +0100
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> wrote:

> Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
> __kernel_long_t and __kernel_ulong_t but does not provide internal
> definitions for it.
> 
> This means that compilation using kernel headers that are older than 3.4
> (where these types were added) will fail. This situation may be uncommon for
> native compilation, but not uncommon for cross compilation where the
> toolchains may be a bit older.
> 
> Provide the necessary types internally if not provided by the kernel
> headers to fix compilation in such cases.
> 
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
>  include/uapi/linux/posix_types.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/uapi/linux/posix_types.h b/include/uapi/linux/posix_types.h
> index 9a7a740b..60f3d378 100644
> --- a/include/uapi/linux/posix_types.h
> +++ b/include/uapi/linux/posix_types.h
> @@ -35,4 +35,13 @@ typedef int __kernel_mqd_t;
>  
>  #include <asm/posix_types.h>
>  
> +/* in case the kernel header asm/posix_types.h is too old (< 3.4) to provide
> + * __kernel_long_t, provide it here */
> +#ifndef __kernel_long_t
> +typedef long		__kernel_long_t;
> +#endif
> +#ifndef __kernel_ulong_t
> +typedef unsigned long	__kernel_ulong_t;
> +#endif
> +
>  #endif /* _LINUX_POSIX_TYPES_H */

No.

The headers in uapi are automatically generated from the upstream kernel
headers. If there are places that need to have backwards compatibility,
fix it in the main iproute2 source.

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

* [PATCH iproute2] Fix compilation with kernel headers < 3.4
@ 2018-02-26 18:51 Thomas De Schampheleire
  2018-02-26 18:58 ` Stephen Hemminger
  2018-02-26 19:27 ` Serhey Popovych
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas De Schampheleire @ 2018-02-26 18:51 UTC (permalink / raw)
  To: netdev; +Cc: Thomas De Schampheleire

Since commit 596b1c94aa38e21b7a8c8562e8b61ccb744255d2, iproute2 uses types
__kernel_long_t and __kernel_ulong_t but does not provide internal
definitions for it.

This means that compilation using kernel headers that are older than 3.4
(where these types were added) will fail. This situation may be uncommon for
native compilation, but not uncommon for cross compilation where the
toolchains may be a bit older.

Provide the necessary types internally if not provided by the kernel
headers to fix compilation in such cases.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 include/uapi/linux/posix_types.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/uapi/linux/posix_types.h b/include/uapi/linux/posix_types.h
index 9a7a740b..60f3d378 100644
--- a/include/uapi/linux/posix_types.h
+++ b/include/uapi/linux/posix_types.h
@@ -35,4 +35,13 @@ typedef int __kernel_mqd_t;
 
 #include <asm/posix_types.h>
 
+/* in case the kernel header asm/posix_types.h is too old (< 3.4) to provide
+ * __kernel_long_t, provide it here */
+#ifndef __kernel_long_t
+typedef long		__kernel_long_t;
+#endif
+#ifndef __kernel_ulong_t
+typedef unsigned long	__kernel_ulong_t;
+#endif
+
 #endif /* _LINUX_POSIX_TYPES_H */
-- 
2.16.1

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

end of thread, other threads:[~2018-02-27 12:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26 19:46 [PATCH iproute2] Fix compilation with kernel headers < 3.4 Serhey Popovych
2018-02-26 19:48 ` Serhey Popovych
2018-02-26 20:32 ` Thomas De Schampheleire
2018-02-26 20:38   ` Serhey Popovych
2018-02-27 10:16 ` Thomas De Schampheleire
2018-02-27 12:21   ` Serhey Popovych
  -- strict thread matches above, loose matches on Subject: below --
2018-02-26 18:51 Thomas De Schampheleire
2018-02-26 18:58 ` Stephen Hemminger
2018-02-26 19:21   ` Thomas De Schampheleire
2018-02-26 19:27 ` Serhey Popovych

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.