All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 0/3] ip: Provide compatibility bits to build with old glibc/kernel headers
@ 2018-02-27 12:06 Serhey Popovych
  2018-02-27 12:06 ` [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4 Serhey Popovych
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-02-27 12:06 UTC (permalink / raw)
  To: netdev; +Cc: thomas.de_schampheleire

Now last LTS kernel is 3.2 one might want to build recent version
of iproute2 package. This is quite common in embedded world where
old kernels/glibc is quite common and updating them could be
problematic or even impossible.

There are two problems at the moment preventing recent version of
iproute2 build against old headers:

   1) missing __kernel_long_t/__kernel_ulong_t

   2) AF_VSOCK/PF_VSOCK defines

There is also quite outdated copy of netinet/tcp.h header persent in
include/ that no longer required to build ss(8) tool with even old
configurations such as 3.2 and glibc-2.13 on Debian 7 (Wheezy). We
probably can get rid of it.

Since compatibility issues are quite common kind of problems I propose
to add new directory include/compat/ to keep both kernel and libc
hierarchy separately and use include_next preprocessor directive to
include old headers before/after we tweak it's contents for compat.

As usal reviews, comments and suggestions are welcome.

Thanks,
Serhii

Serhey Popovych (3):
  ip: Fix compilation with kernel headers < 3.4
  ss: Fix build with old libc headers without AF_VSOCK
  ip: Get rid of custom netinet/tcp.h

 Makefile                              |    5 +-
 include/compat/kernel/linux/sysinfo.h |   14 ++
 include/compat/libc/bits/socket.h     |   15 +++
 include/netinet/tcp.h                 |  231 ---------------------------------
 4 files changed, 33 insertions(+), 232 deletions(-)
 create mode 100644 include/compat/kernel/linux/sysinfo.h
 create mode 100644 include/compat/libc/bits/socket.h
 delete mode 100644 include/netinet/tcp.h

-- 
1.7.10.4

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

* [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4
  2018-02-27 12:06 [PATCH iproute2 0/3] ip: Provide compatibility bits to build with old glibc/kernel headers Serhey Popovych
@ 2018-02-27 12:06 ` Serhey Popovych
  2018-02-27 17:04   ` Stephen Hemminger
  2018-02-27 12:06 ` [PATCH iproute2 2/3] ss: Fix build with old libc headers without AF_VSOCK Serhey Popovych
  2018-02-27 12:06 ` [PATCH iproute2 3/3] ip: Get rid of custom netinet/tcp.h Serhey Popovych
  2 siblings, 1 reply; 10+ messages in thread
From: Serhey Popovych @ 2018-02-27 12:06 UTC (permalink / raw)
  To: netdev; +Cc: thomas.de_schampheleire

Since commit 596b1c94aa38 ("iproute: build more easily on Android"),
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>
---
 Makefile                              |    5 ++++-
 include/compat/kernel/linux/sysinfo.h |   14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 include/compat/kernel/linux/sysinfo.h

diff --git a/Makefile b/Makefile
index 32587db..c18a13f 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,10 @@ CCOPTS = -O2
 WFLAGS := -Wall -Wstrict-prototypes  -Wmissing-prototypes
 WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
 
-CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
+CCINCS := -I../include/compat/kernel -I../include/compat/libc
+CCINCS += -I../include -I../include/uapi
+
+CFLAGS := $(WFLAGS) $(CCOPTS) $(CCINCS) $(DEFINES) $(CFLAGS)
 YACCFLAGS = -d -t -v
 
 SUBDIRS=lib ip tc bridge misc netem genl tipc devlink rdma man
diff --git a/include/compat/kernel/linux/sysinfo.h b/include/compat/kernel/linux/sysinfo.h
new file mode 100644
index 0000000..78fa6d7
--- /dev/null
+++ b/include/compat/kernel/linux/sysinfo.h
@@ -0,0 +1,14 @@
+#ifndef _IP_COMPAT_LINUX_SYSINFO_H
+#define _IP_COMPAT_LINUX_SYSINFO_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 /* _IP_COMPAT_LINUX_SYSINFO_H */
-- 
1.7.10.4

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

* [PATCH iproute2 2/3] ss: Fix build with old libc headers without AF_VSOCK
  2018-02-27 12:06 [PATCH iproute2 0/3] ip: Provide compatibility bits to build with old glibc/kernel headers Serhey Popovych
  2018-02-27 12:06 ` [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4 Serhey Popovych
@ 2018-02-27 12:06 ` Serhey Popovych
  2018-03-01  0:13   ` Stephen Hemminger
  2018-02-27 12:06 ` [PATCH iproute2 3/3] ip: Get rid of custom netinet/tcp.h Serhey Popovych
  2 siblings, 1 reply; 10+ messages in thread
From: Serhey Popovych @ 2018-02-27 12:06 UTC (permalink / raw)
  To: netdev; +Cc: thomas.de_schampheleire

At the moment Linux Kernel 3.2 is the last supported LTS. It comes
without AF_VSOCK support (added only in 3.10), therefore old libcs,
such as glibc before 2.18 does not provide, cause ss(8) tool build
failures like following:

  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

Provide AF_VSOCK and PF_VSOCK defines for compatibility; adjust
AF_MAX and PF_MAX to reflect change.

Tested in Debian 7 (Wheezy) environment with glibc-2.13 and Linux
Kernel 3.2. Still supported config until 31 May 2018 according to
Debian LTS support page.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 include/compat/libc/bits/socket.h |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 include/compat/libc/bits/socket.h

diff --git a/include/compat/libc/bits/socket.h b/include/compat/libc/bits/socket.h
new file mode 100644
index 0000000..25ef0d5
--- /dev/null
+++ b/include/compat/libc/bits/socket.h
@@ -0,0 +1,15 @@
+#ifndef _IP_COMPAT_BITS_SOCKET_H
+#define _IP_COMPAT_BITS_SOCKET_H
+
+#include_next <bits/socket.h>
+
+#ifndef AF_VSOCK
+#define PF_VSOCK	40
+#define AF_VSOCK	PF_VSOCK
+#undef PF_MAX
+#undef AF_MAX
+#define PF_MAX		41
+#define AF_MAX		PF_MAX
+#endif /* AF_VSOCK */
+
+#endif /* _IP_COMPAT_BITS_SOCKET_H */
-- 
1.7.10.4

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

* [PATCH iproute2 3/3] ip: Get rid of custom netinet/tcp.h
  2018-02-27 12:06 [PATCH iproute2 0/3] ip: Provide compatibility bits to build with old glibc/kernel headers Serhey Popovych
  2018-02-27 12:06 ` [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4 Serhey Popovych
  2018-02-27 12:06 ` [PATCH iproute2 2/3] ss: Fix build with old libc headers without AF_VSOCK Serhey Popovych
@ 2018-02-27 12:06 ` Serhey Popovych
  2 siblings, 0 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-02-27 12:06 UTC (permalink / raw)
  To: netdev; +Cc: thomas.de_schampheleire

It seems to be copied from one of the versions of glibc to address
build issues caused by missing functionality.

Since then even with glibc-2.13 and Linux Kernel headers from 3.2
we able to build iproute2 tools (including ss) successfuly.

This effectively reverts commit 719b958bbdfd ("ss: report ecnseen")
and original one introducing this include commit 76e5d2c39201 ("add
include/netinet/tcp.h").

Any missing functionality and compatibility stuff must go to "compat"
subdirectory in include/.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 include/netinet/tcp.h |  231 -------------------------------------------------
 1 file changed, 231 deletions(-)
 delete mode 100644 include/netinet/tcp.h

diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h
deleted file mode 100644
index 3f890a1..0000000
--- a/include/netinet/tcp.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)tcp.h	8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _NETINET_TCP_H
-#define _NETINET_TCP_H	1
-
-#include <features.h>
-
-/*
- * User-settable options (used with setsockopt).
- */
-#define	TCP_NODELAY	 1	/* Don't delay send to coalesce packets  */
-#define	TCP_MAXSEG	 2	/* Set maximum segment size  */
-#define TCP_CORK	 3	/* Control sending of partial frames  */
-#define TCP_KEEPIDLE	 4	/* Start keeplives after this period */
-#define TCP_KEEPINTVL	 5	/* Interval between keepalives */
-#define TCP_KEEPCNT	 6	/* Number of keepalives before death */
-#define TCP_SYNCNT	 7	/* Number of SYN retransmits */
-#define TCP_LINGER2	 8	/* Life time of orphaned FIN-WAIT-2 state */
-#define TCP_DEFER_ACCEPT 9	/* Wake up listener only when data arrive */
-#define TCP_WINDOW_CLAMP 10	/* Bound advertised window */
-#define TCP_INFO	 11	/* Information about this connection. */
-#define	TCP_QUICKACK	 12	/* Bock/reenable quick ACKs.  */
-#define TCP_CONGESTION	 13	/* Congestion control algorithm.  */
-
-#ifdef __USE_MISC
-# include <sys/types.h>
-
-# ifdef __FAVOR_BSD
-typedef	u_int32_t tcp_seq;
-/*
- * TCP header.
- * Per RFC 793, September, 1981.
- */
-struct tcphdr
-  {
-    u_int16_t th_sport;		/* source port */
-    u_int16_t th_dport;		/* destination port */
-    tcp_seq th_seq;		/* sequence number */
-    tcp_seq th_ack;		/* acknowledgement number */
-#  if __BYTE_ORDER == __LITTLE_ENDIAN
-    u_int8_t th_x2:4;		/* (unused) */
-    u_int8_t th_off:4;		/* data offset */
-#  endif
-#  if __BYTE_ORDER == __BIG_ENDIAN
-    u_int8_t th_off:4;		/* data offset */
-    u_int8_t th_x2:4;		/* (unused) */
-#  endif
-    u_int8_t th_flags;
-#  define TH_FIN	0x01
-#  define TH_SYN	0x02
-#  define TH_RST	0x04
-#  define TH_PUSH	0x08
-#  define TH_ACK	0x10
-#  define TH_URG	0x20
-    u_int16_t th_win;		/* window */
-    u_int16_t th_sum;		/* checksum */
-    u_int16_t th_urp;		/* urgent pointer */
-};
-
-# else /* !__FAVOR_BSD */
-struct tcphdr
-  {
-    u_int16_t source;
-    u_int16_t dest;
-    u_int32_t seq;
-    u_int32_t ack_seq;
-#  if __BYTE_ORDER == __LITTLE_ENDIAN
-    u_int16_t res1:4;
-    u_int16_t doff:4;
-    u_int16_t fin:1;
-    u_int16_t syn:1;
-    u_int16_t rst:1;
-    u_int16_t psh:1;
-    u_int16_t ack:1;
-    u_int16_t urg:1;
-    u_int16_t res2:2;
-#  elif __BYTE_ORDER == __BIG_ENDIAN
-    u_int16_t doff:4;
-    u_int16_t res1:4;
-    u_int16_t res2:2;
-    u_int16_t urg:1;
-    u_int16_t ack:1;
-    u_int16_t psh:1;
-    u_int16_t rst:1;
-    u_int16_t syn:1;
-    u_int16_t fin:1;
-#  else
-#   error "Adjust your <bits/endian.h> defines"
-#  endif
-    u_int16_t window;
-    u_int16_t check;
-    u_int16_t urg_ptr;
-};
-# endif /* __FAVOR_BSD */
-
-enum
-{
-  TCP_ESTABLISHED = 1,
-  TCP_SYN_SENT,
-  TCP_SYN_RECV,
-  TCP_FIN_WAIT1,
-  TCP_FIN_WAIT2,
-  TCP_TIME_WAIT,
-  TCP_CLOSE,
-  TCP_CLOSE_WAIT,
-  TCP_LAST_ACK,
-  TCP_LISTEN,
-  TCP_CLOSING   /* now a valid state */
-};
-
-# define TCPOPT_EOL		0
-# define TCPOPT_NOP		1
-# define TCPOPT_MAXSEG		2
-# define TCPOLEN_MAXSEG		4
-# define TCPOPT_WINDOW		3
-# define TCPOLEN_WINDOW		3
-# define TCPOPT_SACK_PERMITTED	4		/* Experimental */
-# define TCPOLEN_SACK_PERMITTED	2
-# define TCPOPT_SACK		5		/* Experimental */
-# define TCPOPT_TIMESTAMP	8
-# define TCPOLEN_TIMESTAMP	10
-# define TCPOLEN_TSTAMP_APPA	(TCPOLEN_TIMESTAMP+2) /* appendix A */
-
-# define TCPOPT_TSTAMP_HDR	\
-    (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
-
-/*
- * Default maximum segment size for TCP.
- * With an IP MSS of 576, this is 536,
- * but 512 is probably more convenient.
- * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
- */
-# define TCP_MSS	512
-
-# define TCP_MAXWIN	65535	/* largest value for (unscaled) window */
-
-# define TCP_MAX_WINSHIFT	14	/* maximum window shift */
-
-# define SOL_TCP		6	/* TCP level */
-
-
-# define TCPI_OPT_TIMESTAMPS	1
-# define TCPI_OPT_SACK		2
-# define TCPI_OPT_WSCALE	4
-# define TCPI_OPT_ECN		8
-# define TCPI_OPT_ECN_SEEN	16
-
-/* Values for tcpi_state.  */
-enum tcp_ca_state
-{
-  TCP_CA_Open = 0,
-  TCP_CA_Disorder = 1,
-  TCP_CA_CWR = 2,
-  TCP_CA_Recovery = 3,
-  TCP_CA_Loss = 4
-};
-
-struct tcp_info
-{
-  u_int8_t	tcpi_state;
-  u_int8_t	tcpi_ca_state;
-  u_int8_t	tcpi_retransmits;
-  u_int8_t	tcpi_probes;
-  u_int8_t	tcpi_backoff;
-  u_int8_t	tcpi_options;
-  u_int8_t	tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
-
-  u_int32_t	tcpi_rto;
-  u_int32_t	tcpi_ato;
-  u_int32_t	tcpi_snd_mss;
-  u_int32_t	tcpi_rcv_mss;
-
-  u_int32_t	tcpi_unacked;
-  u_int32_t	tcpi_sacked;
-  u_int32_t	tcpi_lost;
-  u_int32_t	tcpi_retrans;
-  u_int32_t	tcpi_fackets;
-
-  /* Times. */
-  u_int32_t	tcpi_last_data_sent;
-  u_int32_t	tcpi_last_ack_sent;	/* Not remembered, sorry.  */
-  u_int32_t	tcpi_last_data_recv;
-  u_int32_t	tcpi_last_ack_recv;
-
-  /* Metrics. */
-  u_int32_t	tcpi_pmtu;
-  u_int32_t	tcpi_rcv_ssthresh;
-  u_int32_t	tcpi_rtt;
-  u_int32_t	tcpi_rttvar;
-  u_int32_t	tcpi_snd_ssthresh;
-  u_int32_t	tcpi_snd_cwnd;
-  u_int32_t	tcpi_advmss;
-  u_int32_t	tcpi_reordering;
-  u_int32_t	tcpi_rcv_rtt;
-  u_int32_t	tcpi_rcv_space;
-  u_int32_t	tcpi_total_retrans;
-
-};
-
-#endif /* Misc.  */
-
-#endif /* netinet/tcp.h */
-- 
1.7.10.4

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

* Re: [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4
  2018-02-27 12:06 ` [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4 Serhey Popovych
@ 2018-02-27 17:04   ` Stephen Hemminger
  2018-02-27 19:34     ` Serhey Popovych
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2018-02-27 17:04 UTC (permalink / raw)
  To: Serhey Popovych; +Cc: netdev, thomas.de_schampheleire

On Tue, 27 Feb 2018 14:06:50 +0200
Serhey Popovych <serhe.popovych@gmail.com> wrote:

> Since commit 596b1c94aa38 ("iproute: build more easily on Android"),
> 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>
> ---
>  Makefile                              |    5 ++++-
>  include/compat/kernel/linux/sysinfo.h |   14 ++++++++++++++

Why not just start a single file include/compat.h which is what
other software does.

Doing fine grained kernel and libc per file makes it more painful.

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

* Re: [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4
  2018-02-27 17:04   ` Stephen Hemminger
@ 2018-02-27 19:34     ` Serhey Popovych
  2018-02-28 16:07       ` Stephen Hemminger
  0 siblings, 1 reply; 10+ messages in thread
From: Serhey Popovych @ 2018-02-27 19:34 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, thomas.de_schampheleire


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

Stephen Hemminger wrote:
> On Tue, 27 Feb 2018 14:06:50 +0200
> Serhey Popovych <serhe.popovych@gmail.com> wrote:
> 
>> Since commit 596b1c94aa38 ("iproute: build more easily on Android"),
>> 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>
>> ---
>>  Makefile                              |    5 ++++-
>>  include/compat/kernel/linux/sysinfo.h |   14 ++++++++++++++
> 
> Why not just start a single file include/compat.h which is what
> other software does.

Yes it is good, but not for our case. We use include_next to define
__kernel_long_t and __kernel_ulong_t types if they not defined. If doing
single <compat.h> we need to include it in nearly all .c files as first
include file.

I also start thinking on single <compat.h> and found it bit complicated
than just adding header, (re)defining functionality and then include_next.

> 
> Doing fine grained kernel and libc per file makes it more painful.

Agree, and we already have <netinet/tcp.h> done using similar schema
that is reverted with this series.

> 



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

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

* Re: [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4
  2018-02-27 19:34     ` Serhey Popovych
@ 2018-02-28 16:07       ` Stephen Hemminger
  2018-03-02  7:55         ` Serhey Popovych
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2018-02-28 16:07 UTC (permalink / raw)
  To: Serhey Popovych; +Cc: netdev, thomas.de_schampheleire

[-- Attachment #1: Type: text/plain, Size: 2102 bytes --]

On Tue, 27 Feb 2018 21:34:56 +0200
Serhey Popovych <serhe.popovych@gmail.com> wrote:

> Stephen Hemminger wrote:
> > On Tue, 27 Feb 2018 14:06:50 +0200
> > Serhey Popovych <serhe.popovych@gmail.com> wrote:
> >   
> >> Since commit 596b1c94aa38 ("iproute: build more easily on Android"),
> >> 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>
> >> ---
> >>  Makefile                              |    5 ++++-
> >>  include/compat/kernel/linux/sysinfo.h |   14 ++++++++++++++  
> > 
> > Why not just start a single file include/compat.h which is what
> > other software does.  
> 
> Yes it is good, but not for our case. We use include_next to define
> __kernel_long_t and __kernel_ulong_t types if they not defined. If doing
> single <compat.h> we need to include it in nearly all .c files as first
> include file.
> 
> I also start thinking on single <compat.h> and found it bit complicated
> than just adding header, (re)defining functionality and then include_next.
> 
> > 
> > Doing fine grained kernel and libc per file makes it more painful.  
> 
> Agree, and we already have <netinet/tcp.h> done using similar schema
> that is reverted with this series.

This is a real rats nest. It all comes because kernel headers are including asm/posix_types.h.
Normally, I would just clone that file out of kernel headers process, but the file
is arch specific which doesn't help.



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

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

* Re: [PATCH iproute2 2/3] ss: Fix build with old libc headers without AF_VSOCK
  2018-02-27 12:06 ` [PATCH iproute2 2/3] ss: Fix build with old libc headers without AF_VSOCK Serhey Popovych
@ 2018-03-01  0:13   ` Stephen Hemminger
  2018-03-02  7:57     ` Serhey Popovych
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2018-03-01  0:13 UTC (permalink / raw)
  To: Serhey Popovych; +Cc: netdev, thomas.de_schampheleire

On Tue, 27 Feb 2018 14:06:51 +0200
Serhey Popovych <serhe.popovych@gmail.com> wrote:

> diff --git a/include/compat/libc/bits/socket.h b/include/compat/libc/bits/socket.h
> new file mode 100644
> index 0000000..25ef0d5
> --- /dev/null
> +++ b/include/compat/libc/bits/socket.h
> @@ -0,0 +1,15 @@
> +#ifndef _IP_COMPAT_BITS_SOCKET_H
> +#define _IP_COMPAT_BITS_SOCKET_H
> +
> +#include_next <bits/socket.h>
> +
> +#ifndef AF_VSOCK
> +#define PF_VSOCK	40
> +#define AF_VSOCK	PF_VSOCK
> +#undef PF_MAX
> +#undef AF_MAX
> +#define PF_MAX		41
> +#define AF_MAX		PF_MAX
> +#endif /* AF_VSOCK */
> +
> +#endif /* _IP_COMPAT_BITS_SOCKET_H */

It makes more sense to change ss.c to ifdef out the code related to AF_VSOCK
if it is not defined.  Rather than asking for unknown address family.

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

* Re: [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4
  2018-02-28 16:07       ` Stephen Hemminger
@ 2018-03-02  7:55         ` Serhey Popovych
  0 siblings, 0 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-03-02  7:55 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, thomas.de_schampheleire


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

Stephen Hemminger wrote:
> On Tue, 27 Feb 2018 21:34:56 +0200
> Serhey Popovych <serhe.popovych@gmail.com> wrote:
> 
>> Stephen Hemminger wrote:
>>> On Tue, 27 Feb 2018 14:06:50 +0200
>>> Serhey Popovych <serhe.popovych@gmail.com> wrote:
>>>   
>>>> Since commit 596b1c94aa38 ("iproute: build more easily on Android"),
>>>> 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>
>>>> ---
>>>>  Makefile                              |    5 ++++-
>>>>  include/compat/kernel/linux/sysinfo.h |   14 ++++++++++++++  
>>>
>>> Why not just start a single file include/compat.h which is what
>>> other software does.  
>>
>> Yes it is good, but not for our case. We use include_next to define
>> __kernel_long_t and __kernel_ulong_t types if they not defined. If doing
>> single <compat.h> we need to include it in nearly all .c files as first
>> include file.
>>
>> I also start thinking on single <compat.h> and found it bit complicated
>> than just adding header, (re)defining functionality and then include_next.
>>
>>>
>>> Doing fine grained kernel and libc per file makes it more painful.  
>>
>> Agree, and we already have <netinet/tcp.h> done using similar schema
>> that is reverted with this series.
> 
> This is a real rats nest. It all comes because kernel headers are including asm/posix_types.h.
> Normally, I would just clone that file out of kernel headers process, but the file
> is arch specific which doesn't help.
>

Anyway I'm still thinking that using include_next and separate kernel
and libc directories is most flexible schema to provide/track compatibility:

  1) No need to modify each .c file in package by adding custom
     <compat.h>. No need to track places where we need to include it.

  2) Way to tweak kernel/libc headers at first place and then
     continue with system/uapi headers via include_next.

  3) It is possible to completely replace system/uapi header by just
     putting it in correct location under comat/ in the same way we
     already did for <netinet/tcp.h>.

  4) Single place for all compat stuff: no need to add compatibility:
     easy to track changes.

So at the moment we have two possible approaches:

  1) Use comat directory and include_next

  2) Provide single comat.h header file and include it in all .c
     (or at least utils.h and some .c that does not include it).

Is this correct? Other options are welcome. If you prefer to use
compat.h I can prepare series, but at this moment I think this could
potentially have side effects (like missing include of compat.h in
some .c files in some setups).

> 



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

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

* Re: [PATCH iproute2 2/3] ss: Fix build with old libc headers without AF_VSOCK
  2018-03-01  0:13   ` Stephen Hemminger
@ 2018-03-02  7:57     ` Serhey Popovych
  0 siblings, 0 replies; 10+ messages in thread
From: Serhey Popovych @ 2018-03-02  7:57 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, thomas.de_schampheleire


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

Stephen Hemminger wrote:
> On Tue, 27 Feb 2018 14:06:51 +0200
> Serhey Popovych <serhe.popovych@gmail.com> wrote:
> 
>> diff --git a/include/compat/libc/bits/socket.h b/include/compat/libc/bits/socket.h
>> new file mode 100644
>> index 0000000..25ef0d5
>> --- /dev/null
>> +++ b/include/compat/libc/bits/socket.h
>> @@ -0,0 +1,15 @@
>> +#ifndef _IP_COMPAT_BITS_SOCKET_H
>> +#define _IP_COMPAT_BITS_SOCKET_H
>> +
>> +#include_next <bits/socket.h>
>> +
>> +#ifndef AF_VSOCK
>> +#define PF_VSOCK	40
>> +#define AF_VSOCK	PF_VSOCK
>> +#undef PF_MAX
>> +#undef AF_MAX
>> +#define PF_MAX		41
>> +#define AF_MAX		PF_MAX
>> +#endif /* AF_VSOCK */
>> +
>> +#endif /* _IP_COMPAT_BITS_SOCKET_H */
> 
> It makes more sense to change ss.c to ifdef out the code related to AF_VSOCK
> if it is not defined.  Rather than asking for unknown address family.
> 

Yes, I did this as v0 before sending series. But now I'm thinking that
single place for all compat stuff would ease tracking of changes.


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

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

end of thread, other threads:[~2018-03-02  7:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 12:06 [PATCH iproute2 0/3] ip: Provide compatibility bits to build with old glibc/kernel headers Serhey Popovych
2018-02-27 12:06 ` [PATCH iproute2 1/3] ip: Fix compilation with kernel headers < 3.4 Serhey Popovych
2018-02-27 17:04   ` Stephen Hemminger
2018-02-27 19:34     ` Serhey Popovych
2018-02-28 16:07       ` Stephen Hemminger
2018-03-02  7:55         ` Serhey Popovych
2018-02-27 12:06 ` [PATCH iproute2 2/3] ss: Fix build with old libc headers without AF_VSOCK Serhey Popovych
2018-03-01  0:13   ` Stephen Hemminger
2018-03-02  7:57     ` Serhey Popovych
2018-02-27 12:06 ` [PATCH iproute2 3/3] ip: Get rid of custom netinet/tcp.h 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.