Re: [PATCH v06 15/36] uapi linux/socket.h: include sys/socket.h in user space
On Sun, Aug 06, 2017 at 06:44:06PM +0200, Mikko Rapeli wrote: > This libc header has sockaddr definition in user space. > > Fixes user space compilation errors like these from kernel headers including > only linux/socket.h: > > error: field ‘ifru_addr’ has incomplete type > struct sockaddr ifru_addr; > error: field ‘_sockaddr’ has incomplete type > struct sockaddr _sockaddr; > error: invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr’ > > With this following uapi headers now compile in user space: > > rdma/rdma_user_rxe.h > linux/vm_sockets.h > linux/ncp_fs.h > linux/nfc.h > linux/phonet.h > > Signed-off-by: Mikko Rapeli > Cc: netdev@vger.kernel.org > Cc: Dmitry V. Levin > --- > include/uapi/linux/socket.h | 4 > 1 file changed, 4 insertions(+) > > diff --git a/include/uapi/linux/socket.h b/include/uapi/linux/socket.h > index 76ab0c68561e..8a81197cc08b 100644 > --- a/include/uapi/linux/socket.h > +++ b/include/uapi/linux/socket.h > @@ -1,6 +1,10 @@ > #ifndef _UAPI_LINUX_SOCKET_H > #define _UAPI_LINUX_SOCKET_H > > +#ifndef __KERNEL__ > +#include > +#endif This is scary because of infamous libc vs uapi interoperability issues. Couldn't we fix affected headers instead? -- ldv signature.asc Description: PGP signature
Re: [PATCH v06 35/36] uapi linux/tls.h: don't include in user space
On Sun, Aug 06, 2017 at 06:44:26PM +0200, Mikko Rapeli wrote: > It is not needed and not part of uapi headers, but causes > user space compilation error: > > fatal error: net/tcp.h: No such file or directory > #include > ^ > > Signed-off-by: Mikko Rapeli > Cc: Dave Watson > Cc: Ilya Lesokhin > Cc: Aviad Yehezkel > --- > include/uapi/linux/tls.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/uapi/linux/tls.h b/include/uapi/linux/tls.h > index cc1d21db35d8..d87c698623f2 100644 > --- a/include/uapi/linux/tls.h > +++ b/include/uapi/linux/tls.h > @@ -37,7 +37,9 @@ > #include > #include > #include > +#ifdef __KERNEL__ > #include > +#endif Let's move it to include/net/tls.h instead. -- ldv signature.asc Description: PGP signature
Re: uapi: MAX_ADDR_LEN vs. numeric 32
Hi, On Sat, Aug 05, 2017 at 12:33:25AM +0300, Mikko Rapeli wrote: > First, thanks Dmitry for fixing several uapi compilation problems in > user space. I got a bit demotivated That's quite understandable. > about the slow review progress, e.g. > no feedback what so ever, on some of the patches, but lets try again... > > I rebased my tree now and saw > > commit 745cb7f8a5de0805cade3de3991b7a95317c7c73 > Author: Dmitry V. Levin > Date: Tue Mar 7 23:50:50 2017 +0300 > > uapi: fix linux/packet_diag.h userspace compilation error > > which does: > > --- a/include/uapi/linux/packet_diag.h > +++ b/include/uapi/linux/packet_diag.h > @@ -64,7 +64,7 @@ struct packet_diag_mclist { > __u32 pdmc_count; > __u16 pdmc_type; > __u16 pdmc_alen; > - __u8pdmc_addr[MAX_ADDR_LEN]; > + __u8pdmc_addr[32]; /* MAX_ADDR_LEN */ > }; > > struct packet_diag_ring { > > In my tree I had fixed that case with: > > --- a/include/uapi/linux/packet_diag.h > +++ b/include/uapi/linux/packet_diag.h > @@ -2,6 +2,7 @@ > #define __PACKET_DIAG_H__ > > #include > +#include > > struct packet_diag_req { > __u8sdiag_family; > > since netdevice.h has the definition also in user space > > #define MAX_ADDR_LEN32 /* Largest hardware address length */ > > I find using MAX_ADDR_LEN better than numeric 32, though I doubt this will > change any time soon. Would you mind if I change packet_diag.h and > if_link.h to use that instead and fix the userspace compilation > problems by including netdevice.h? The alternative fix, that is, to include which pulls in other headers and a lot of definitions with them, has been mentioned in the discussion, too. We decided that the fix that was applied would be the least of all evils. -- ldv signature.asc Description: PGP signature
Re: [PATCH v06 35/36] uapi linux/tls.h: don't include in user space
On Wed, Aug 09, 2017 at 02:25:54AM +0300, Dmitry V. Levin wrote: > On Sun, Aug 06, 2017 at 06:44:26PM +0200, Mikko Rapeli wrote: > > It is not needed and not part of uapi headers, but causes > > user space compilation error: > > > > fatal error: net/tcp.h: No such file or directory > > #include > > ^ > > > > Signed-off-by: Mikko Rapeli > > Cc: Dave Watson > > Cc: Ilya Lesokhin > > Cc: Aviad Yehezkel > > --- > > include/uapi/linux/tls.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/include/uapi/linux/tls.h b/include/uapi/linux/tls.h > > index cc1d21db35d8..d87c698623f2 100644 > > --- a/include/uapi/linux/tls.h > > +++ b/include/uapi/linux/tls.h > > @@ -37,7 +37,9 @@ > > #include > > #include > > #include > > +#ifdef __KERNEL__ > > #include > > +#endif > > Let's move it to include/net/tls.h instead. So everybody ignored this and *new* uapi header was released in a totally unusable form along with v4.13. -- ldv signature.asc Description: PGP signature
[PATCH] uapi: fix linux/rxrpc.h userspace compilation errors
Consistently use types provided by to fix the following linux/rxrpc.h userspace compilation errors: /usr/include/linux/rxrpc.h:24:2: error: unknown type name 'u16' u16 srx_service; /* service desired */ /usr/include/linux/rxrpc.h:25:2: error: unknown type name 'u16' u16 transport_type; /* type of transport socket (SOCK_DGRAM) */ /usr/include/linux/rxrpc.h:26:2: error: unknown type name 'u16' u16 transport_len; /* length of transport address */ Use __kernel_sa_family_t instead of sa_family_t the same way as uapi/linux/in.h does, to fix the following linux/rxrpc.h userspace compilation errors: /usr/include/linux/rxrpc.h:23:2: error: unknown type name 'sa_family_t' sa_family_t srx_family; /* address family */ /usr/include/linux/rxrpc.h:28:3: error: unknown type name 'sa_family_t' sa_family_t family; /* transport address family */ Fixes: 727f8914477e ("rxrpc: Expose UAPI definitions to userspace") Cc: # v4.14 Signed-off-by: Dmitry V. Levin --- include/uapi/linux/rxrpc.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/rxrpc.h b/include/uapi/linux/rxrpc.h index 9656aad8f8f7..9d4afea308a4 100644 --- a/include/uapi/linux/rxrpc.h +++ b/include/uapi/linux/rxrpc.h @@ -20,12 +20,12 @@ * RxRPC socket address */ struct sockaddr_rxrpc { - sa_family_t srx_family; /* address family */ - u16 srx_service;/* service desired */ - u16 transport_type; /* type of transport socket (SOCK_DGRAM) */ - u16 transport_len; /* length of transport address */ + __kernel_sa_family_tsrx_family; /* address family */ + __u16 srx_service;/* service desired */ + __u16 transport_type; /* type of transport socket (SOCK_DGRAM) */ + __u16 transport_len; /* length of transport address */ union { - sa_family_t family; /* transport address family */ + __kernel_sa_family_t family;/* transport address family */ struct sockaddr_in sin; /* IPv4 transport address */ struct sockaddr_in6 sin6; /* IPv6 transport address */ } transport; -- ldv
[PATCH] uapi: fix linux/tls.h userspace compilation error
Move inclusion of a private kernel header from uapi/linux/tls.h to its only user - net/tls.h, to fix the following linux/tls.h userspace compilation error: /usr/include/linux/tls.h:41:21: fatal error: net/tcp.h: No such file or directory As to this point uapi/linux/tls.h was totaly unusuable for userspace, cleanup this header file further by moving other redundant includes to net/tls.h. Fixes: 3c4d7559159b ("tls: kernel TLS support") Cc: # v4.13+ Signed-off-by: Dmitry V. Levin --- include/net/tls.h| 4 include/uapi/linux/tls.h | 4 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index b89d397dd62f..c06db1eadac2 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -35,6 +35,10 @@ #define _TLS_OFFLOAD_H #include +#include +#include +#include +#include #include diff --git a/include/uapi/linux/tls.h b/include/uapi/linux/tls.h index d5e0682ab837..293b2cdad88d 100644 --- a/include/uapi/linux/tls.h +++ b/include/uapi/linux/tls.h @@ -35,10 +35,6 @@ #define _UAPI_LINUX_TLS_H #include -#include -#include -#include -#include /* TLS socket options */ #define TLS_TX 1 /* Set transmit parameters */ -- ldv
[PATCH] unix_diag: fix incorrect sign extension in unix_lookup_by_ino
The value passed by unix_diag_get_exact to unix_lookup_by_ino has type __u32, but unix_lookup_by_ino's argument ino has type int, which is not a problem yet. However, when ino is compared with sock_i_ino return value of type unsigned long, ino is sign extended to signed long, and this results to incorrect comparison on 64-bit architectures for inode numbers greater than INT_MAX. This bug was found by strace test suite. Signed-off-by: Dmitry V. Levin Cc: --- net/unix/diag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/unix/diag.c b/net/unix/diag.c index c512f64..4d96797 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -220,23 +220,23 @@ done: return skb->len; } -static struct sock *unix_lookup_by_ino(int ino) +static struct sock *unix_lookup_by_ino(unsigned int ino) { int i; struct sock *sk; spin_lock(&unix_table_lock); for (i = 0; i < ARRAY_SIZE(unix_socket_table); i++) { sk_for_each(sk, &unix_socket_table[i]) if (ino == sock_i_ino(sk)) { sock_hold(sk); spin_unlock(&unix_table_lock); return sk; } } spin_unlock(&unix_table_lock); return NULL; } -- ldv
Re: [PATCH] uapi: fix linux/if.h userspace compilation errors
On Tue, Feb 21, 2017 at 12:10:22PM -0500, David Miller wrote: > From: "Dmitry V. Levin" > Date: Mon, 20 Feb 2017 14:58:41 +0300 > > > Include (guarded by ifndef __KERNEL__) to fix > > the following linux/if.h userspace compilation errors: > > Wouldn't it be so much better to do this in include/uapi/linux/socket.h? Yes, it would be nicer if we could afford it. However, changing uapi/linux/socket.h to include is less conservative than changing every uapi header that fails to compile because of its use of struct sockaddr. It's risky because pulls in other types that might conflict with definitions provided by uapi headers. I've checked all uapi headers that have no compilation errors whether inclusion of before them causes any issues, and found that linux/time.h and linux/uio.h (and their users) stop compiling because of type conflicts: $ gcc -S -o/dev/null -xc /dev/null -include /usr/include/sys/socket.h -include /usr/include/linux/time.h In file included from :32:0: /usr/include/linux/time.h:9:8: error: redefinition of 'struct timespec' struct timespec { ^~~~ In file included from /usr/include/sys/select.h:45:0, from /usr/include/sys/types.h:219, from /usr/include/sys/uio.h:23, from /usr/include/sys/socket.h:26, from :32: /usr/include/time.h:120:8: note: originally defined here struct timespec ^~~~ In file included from :32:0: /usr/include/linux/time.h:15:8: error: redefinition of 'struct timeval' struct timeval { ^~~ In file included from /usr/include/sys/select.h:47:0, from /usr/include/sys/types.h:219, from /usr/include/sys/uio.h:23, from /usr/include/sys/socket.h:26, from :32: /usr/include/bits/time.h:30:8: note: originally defined here struct timeval ^~~ $ gcc -S -o/dev/null -xc /dev/null -include /usr/include/sys/socket.h -include /usr/include/linux/uio.h In file included from :32:0: /usr/include/linux/uio.h:16:8: error: redefinition of 'struct iovec' struct iovec ^ In file included from /usr/include/sys/uio.h:28:0, from /usr/include/sys/socket.h:26, from :32: /usr/include/bits/uio.h:43:8: note: originally defined here struct iovec ^ We can try to workaround these ancient against and against conflicts on uapi side by introducing __UAPI_DEF_TIMESPEC, __UAPI_DEF_TIMEVAL, and __UAPI_DEF_IOVEC guards, but these workarounds will work only one way (when libc headers are included before uapi ones) until glibc catches up, and the latter may take a lot of time. > I mean, look at the comment right by the change you are making: > > > @@ -24,6 +24,10 @@ > > #include /* for "struct sockaddr" et al */ > > Anyone including linux/socket.h is trying to obtain that type. I think this comment is true for #ifdef __KERNEL__ code only. -- ldv pgpEWxGYJuyJe.pgp Description: PGP signature
Re: [PATCH] uapi: fix linux/if.h userspace compilation errors
On Tue, Feb 21, 2017 at 11:19:14PM +0300, Dmitry V. Levin wrote: > On Tue, Feb 21, 2017 at 12:10:22PM -0500, David Miller wrote: > > From: "Dmitry V. Levin" > > Date: Mon, 20 Feb 2017 14:58:41 +0300 > > > > > Include (guarded by ifndef __KERNEL__) to fix > > > the following linux/if.h userspace compilation errors: > > > > Wouldn't it be so much better to do this in include/uapi/linux/socket.h? [...] > We can try to workaround these ancient against > and against conflicts on uapi side by > introducing __UAPI_DEF_TIMESPEC, __UAPI_DEF_TIMEVAL, and __UAPI_DEF_IOVEC > guards, but these workarounds will work only one way (when libc headers > are included before uapi ones) until glibc catches up, and the latter > may take a lot of time. OK, these conflicts need to be fixed regardless of the way how struct sockaddr related uapi compilation errors are fixed. I'll submit these fixes shortly. -- ldv pgpK68wpXRdp_.pgp Description: PGP signature
[PATCH 1/2] uapi: add a compatibility layer between linux/time.h and glibc
Do not define struct itimerspec, struct timespec, struct timeval, and TIMER_ABSTIME in linux/time.h when is already included and provides these definitions. This fixes the following compilation errors and warnings when is included before : /usr/include/linux/time.h:9:8: error: redefinition of 'struct timespec' /usr/include/linux/time.h:15:8: error: redefinition of 'struct timeval' /usr/include/linux/time.h:34:8: error: redefinition of 'struct itimerspec' /usr/include/linux/time.h:67:0: warning: "TIMER_ABSTIME" redefined Do not define struct itimerval, struct timespec, struct timeval, struct timezone, ITIMER_REAL, ITIMER_VIRTUAL, and ITIMER_PROF in linux/time.h when is already included and provides these definitions. This fixes the following compilation errors and warnings when is included before : /usr/include/linux/time.h:9:8: error: redefinition of 'struct timespec' /usr/include/linux/time.h:15:8: error: redefinition of 'struct timeval' /usr/include/linux/time.h:20:8: error: redefinition of 'struct timezone' /usr/include/linux/time.h:30:0: warning: "ITIMER_REAL" redefined /usr/include/linux/time.h:31:0: warning: "ITIMER_VIRTUAL" redefined /usr/include/linux/time.h:32:0: warning: "ITIMER_PROF" redefined /usr/include/linux/time.h:39:8: error: redefinition of 'struct itimerval' Signed-off-by: Dmitry V. Levin --- include/uapi/linux/libc-compat.h | 56 include/uapi/linux/time.h| 31 -- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index 44b8a6b..481e3b1 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -158,6 +158,53 @@ #endif /* defined(__NETIPX_IPX_H) */ +/* Coordinate with glibc time.h header. */ +#if (defined(__itimerspec_defined) && __itimerspec_defined) || \ +(defined(_TIME_H) && defined(__USE_POSIX199309)) +/* __itimerspec_defined was introduced in glibc-2.25 */ +#define __UAPI_DEF_ITIMERSPEC 0 +#else +#define __UAPI_DEF_ITIMERSPEC 1 +#endif + +#if (defined(__timespec_defined) && __timespec_defined) || \ +(defined(_STRUCT_TIMESPEC) && _STRUCT_TIMESPEC) +/* __timespec_defined was introduced in glibc-2.3.2 */ +#define __UAPI_DEF_TIMESPEC0 +#else +#define __UAPI_DEF_TIMESPEC1 +#endif + +#if (defined(__timeval_defined) && __timeval_defined) || \ +(defined(_STRUCT_TIMEVAL) && _STRUCT_TIMEVAL) +/* __timeval_defined was introduced in glibc-2.25 */ +#define __UAPI_DEF_TIMEVAL 0 +#else +#define __UAPI_DEF_TIMEVAL 1 +#endif + +/* Coordinate with glibc bits/time.h header. */ +#if defined(_BITS_TIME_H) && defined(__USE_POSIX199309) +#define __UAPI_DEF_TIMER_ABSTIME 0 +#else +#define __UAPI_DEF_TIMER_ABSTIME 1 +#endif + +/* Coordinate with glibc sys/time.h header. */ +#if defined(_SYS_TIME_H) +#define __UAPI_DEF_ITIMERVAL 0 +#define __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF0 +#else +#define __UAPI_DEF_ITIMERVAL 1 +#define __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF1 +#endif + +#if defined(_SYS_TIME_H) && defined(__USE_MISC) +#define __UAPI_DEF_TIMEZONE0 +#else +#define __UAPI_DEF_TIMEZONE1 +#endif + /* Definitions for xattr.h */ #if defined(_SYS_XATTR_H) #define __UAPI_DEF_XATTR 0 @@ -205,6 +252,15 @@ #define __UAPI_DEF_IPX_CONFIG_DATA 1 #define __UAPI_DEF_IPX_ROUTE_DEF 1 +/* Definitions for time.h */ +#define __UAPI_DEF_ITIMERSPEC 1 +#define __UAPI_DEF_ITIMERVAL 1 +#define __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF1 +#define __UAPI_DEF_TIMER_ABSTIME 1 +#define __UAPI_DEF_TIMESPEC1 +#define __UAPI_DEF_TIMEVAL 1 +#define __UAPI_DEF_TIMEZONE1 + /* Definitions for xattr.h */ #define __UAPI_DEF_XATTR 1 diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h index e75e1b6..9d03ca4 100644 --- a/include/uapi/linux/time.h +++ b/include/uapi/linux/time.h @@ -1,45 +1,70 @@ #ifndef _UAPI_LINUX_TIME_H #define _UAPI_LINUX_TIME_H +#include #include +#if __UAPI_DEF_TIMESPEC +#ifndef __timespec_defined +#define __timespec_defined 1 +#endif #ifndef _STRUCT_TIMESPEC -#define _STRUCT_TIMESPEC +#define _STRUCT_TIMESPEC 1 +#endif struct timespec { __kernel_time_t tv_sec; /* seconds */ longtv_nsec;/* nanoseconds */ }; -#endif +#endif /* __UAPI_DEF_TIMESPEC */ +#if __UAPI_DEF_TIMEVAL +#ifndef __timeval_defined +#define __timeval_defined 1 +#endif +#ifndef _STRUCT_TIMEVAL +#define _STRUCT_TIMEVAL1 +#endif struct timeval
[PATCH 2/2] uapi: add a compatibility layer between linux/uio.h and glibc
Do not define struct iovec in linux/uio.h when or is already included and provides these definitions. This fixes the following compilation error when or is included before : /usr/include/linux/uio.h:16:8: error: redefinition of 'struct iovec' Signed-off-by: Dmitry V. Levin --- include/uapi/linux/libc-compat.h | 10 ++ include/uapi/linux/uio.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index 481e3b1..9b88586 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -205,6 +205,13 @@ #define __UAPI_DEF_TIMEZONE1 #endif +/* Coordinate with glibc bits/uio.h header. */ +#if defined(_SYS_UIO_H) || defined(_FCNTL_H) +#define __UAPI_DEF_IOVEC 0 +#else +#define __UAPI_DEF_IOVEC 1 +#endif + /* Definitions for xattr.h */ #if defined(_SYS_XATTR_H) #define __UAPI_DEF_XATTR 0 @@ -261,6 +268,9 @@ #define __UAPI_DEF_TIMEVAL 1 #define __UAPI_DEF_TIMEZONE1 +/* Definitions for uio.h */ +#define __UAPI_DEF_IOVEC 1 + /* Definitions for xattr.h */ #define __UAPI_DEF_XATTR 1 diff --git a/include/uapi/linux/uio.h b/include/uapi/linux/uio.h index 2731d56..e6e12cf 100644 --- a/include/uapi/linux/uio.h +++ b/include/uapi/linux/uio.h @@ -9,15 +9,18 @@ #ifndef _UAPI__LINUX_UIO_H #define _UAPI__LINUX_UIO_H +#include #include #include +#if __UAPI_DEF_IOVEC struct iovec { void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ __kernel_size_t iov_len; /* Must be size_t (1003.1g) */ }; +#endif /* __UAPI_DEF_IOVEC */ /* * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1) -- ldv
[PATCH] uapi: fix linux/ip6_tunnel.h userspace compilation errors
Include and to fix the following linux/ip6_tunnel.h userspace compilation errors: /usr/include/linux/ip6_tunnel.h:23:12: error: 'IFNAMSIZ' undeclared here (not in a function) char name[IFNAMSIZ]; /* name of tunnel device */ /usr/include/linux/ip6_tunnel.h:30:18: error: field 'laddr' has incomplete type struct in6_addr laddr; /* local tunnel end-point address */ Signed-off-by: Dmitry V. Levin --- include/uapi/linux/ip6_tunnel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/ip6_tunnel.h b/include/uapi/linux/ip6_tunnel.h index 48af63c..425926c 100644 --- a/include/uapi/linux/ip6_tunnel.h +++ b/include/uapi/linux/ip6_tunnel.h @@ -2,6 +2,8 @@ #define _IP6_TUNNEL_H #include +#include /* For IFNAMSIZ. */ +#include /* For struct in6_addr. */ #define IPV6_TLV_TNL_ENCAP_LIMIT 4 #define IPV6_DEFAULT_TNL_ENCAP_LIMIT 4 -- ldv
[PATCH] uapi: fix linux/llc.h userspace compilation error
Include to fix the following linux/llc.h userspace compilation error: /usr/include/linux/llc.h:26:27: error: 'IFHWADDRLEN' undeclared here (not in a function) unsigned char sllc_mac[IFHWADDRLEN]; Signed-off-by: Dmitry V. Levin --- include/uapi/linux/llc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/llc.h b/include/uapi/linux/llc.h index 9c987a4..a6c17f6 100644 --- a/include/uapi/linux/llc.h +++ b/include/uapi/linux/llc.h @@ -14,6 +14,7 @@ #define _UAPI__LINUX_LLC_H #include +#include /* For IFHWADDRLEN. */ #define __LLC_SOCK_SIZE__ 16 /* sizeof(sockaddr_llc), word align. */ struct sockaddr_llc { -- ldv
[PATCH] uapi: fix linux/rds.h userspace compilation errors
Consistently use types from linux/types.h to fix the following linux/rds.h userspace compilation errors: /usr/include/linux/rds.h:198:2: error: unknown type name 'u8' u8 rx_traces; /usr/include/linux/rds.h:199:2: error: unknown type name 'u8' u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; /usr/include/linux/rds.h:203:2: error: unknown type name 'u8' u8 rx_traces; /usr/include/linux/rds.h:204:2: error: unknown type name 'u8' u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; /usr/include/linux/rds.h:205:2: error: unknown type name 'u64' u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX]; Fixes: 3289025a("RDS: add receive message trace used by application") Signed-off-by: Dmitry V. Levin --- include/uapi/linux/rds.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h index 47c03ca..198892b 100644 --- a/include/uapi/linux/rds.h +++ b/include/uapi/linux/rds.h @@ -195,14 +195,14 @@ enum rds_message_rxpath_latency { }; struct rds_rx_trace_so { - u8 rx_traces; - u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; + __u8 rx_traces; + __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; }; struct rds_cmsg_rx_trace { - u8 rx_traces; - u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; - u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX]; + __u8 rx_traces; + __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; + __u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX]; }; /* -- ldv
[PATCH] uapi: fix linux/seg6.h and linux/seg6_iptunnel.h userspace compilation errors
Include in uapi/linux/seg6.h to fix the following linux/seg6.h userspace compilation error: /usr/include/linux/seg6.h:31:18: error: array type has incomplete element type 'struct in6_addr' struct in6_addr segments[0]; Include in uapi/linux/seg6_iptunnel.h to fix the following linux/seg6_iptunnel.h userspace compilation error: /usr/include/linux/seg6_iptunnel.h:26:21: error: array type has incomplete element type 'struct ipv6_sr_hdr' struct ipv6_sr_hdr srh[0]; Fixes: a50a05f4("ipv6: sr: add missing Kbuild export for header files") Signed-off-by: Dmitry V. Levin --- include/uapi/linux/seg6.h | 1 + include/uapi/linux/seg6_iptunnel.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h index 61df8d3..7278511 100644 --- a/include/uapi/linux/seg6.h +++ b/include/uapi/linux/seg6.h @@ -15,6 +15,7 @@ #define _UAPI_LINUX_SEG6_H #include +#include /* For struct in6_addr. */ /* * SRH diff --git a/include/uapi/linux/seg6_iptunnel.h b/include/uapi/linux/seg6_iptunnel.h index 7a7183d..b6e5a0a 100644 --- a/include/uapi/linux/seg6_iptunnel.h +++ b/include/uapi/linux/seg6_iptunnel.h @@ -14,6 +14,8 @@ #ifndef _UAPI_LINUX_SEG6_IPTUNNEL_H #define _UAPI_LINUX_SEG6_IPTUNNEL_H +#include /* For struct ipv6_sr_hdr. */ + enum { SEG6_IPTUNNEL_UNSPEC, SEG6_IPTUNNEL_SRH, -- ldv
[PATCH v2] uapi: fix linux/seg6.h and linux/seg6_iptunnel.h userspace compilation errors
Include in uapi/linux/seg6.h to fix the following linux/seg6.h userspace compilation error: /usr/include/linux/seg6.h:31:18: error: array type has incomplete element type 'struct in6_addr' struct in6_addr segments[0]; Include in uapi/linux/seg6_iptunnel.h to fix the following linux/seg6_iptunnel.h userspace compilation error: /usr/include/linux/seg6_iptunnel.h:26:21: error: array type has incomplete element type 'struct ipv6_sr_hdr' struct ipv6_sr_hdr srh[0]; Fixes: a50a05f497a2 ("ipv6: sr: add missing Kbuild export for header files") Signed-off-by: Dmitry V. Levin --- v2: fixed "Fixes:" line include/uapi/linux/seg6.h | 1 + include/uapi/linux/seg6_iptunnel.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h index 61df8d3..7278511 100644 --- a/include/uapi/linux/seg6.h +++ b/include/uapi/linux/seg6.h @@ -15,6 +15,7 @@ #define _UAPI_LINUX_SEG6_H #include +#include /* For struct in6_addr. */ /* * SRH diff --git a/include/uapi/linux/seg6_iptunnel.h b/include/uapi/linux/seg6_iptunnel.h index 7a7183d..b6e5a0a 100644 --- a/include/uapi/linux/seg6_iptunnel.h +++ b/include/uapi/linux/seg6_iptunnel.h @@ -14,6 +14,8 @@ #ifndef _UAPI_LINUX_SEG6_IPTUNNEL_H #define _UAPI_LINUX_SEG6_IPTUNNEL_H +#include /* For struct ipv6_sr_hdr. */ + enum { SEG6_IPTUNNEL_UNSPEC, SEG6_IPTUNNEL_SRH, -- ldv
[PATCH v2] uapi: fix linux/rds.h userspace compilation errors
Consistently use types from linux/types.h to fix the following linux/rds.h userspace compilation errors: /usr/include/linux/rds.h:198:2: error: unknown type name 'u8' u8 rx_traces; /usr/include/linux/rds.h:199:2: error: unknown type name 'u8' u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; /usr/include/linux/rds.h:203:2: error: unknown type name 'u8' u8 rx_traces; /usr/include/linux/rds.h:204:2: error: unknown type name 'u8' u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; /usr/include/linux/rds.h:205:2: error: unknown type name 'u64' u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX]; Fixes: 3289025aedc0 ("RDS: add receive message trace used by application") Signed-off-by: Dmitry V. Levin Acked-by: Santosh Shilimkar --- v2: fixed "Fixes:" line include/uapi/linux/rds.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h index 47c03ca..198892b 100644 --- a/include/uapi/linux/rds.h +++ b/include/uapi/linux/rds.h @@ -195,14 +195,14 @@ enum rds_message_rxpath_latency { }; struct rds_rx_trace_so { - u8 rx_traces; - u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; + __u8 rx_traces; + __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; }; struct rds_cmsg_rx_trace { - u8 rx_traces; - u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; - u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX]; + __u8 rx_traces; + __u8 rx_trace_pos[RDS_MSG_RX_DGRAM_TRACE_MAX]; + __u64 rx_trace[RDS_MSG_RX_DGRAM_TRACE_MAX]; }; /* -- ldv
[PATCH] uapi: fix rdma/mlx5-abi.h userspace compilation errors
Consistently use types from linux/types.h to fix the following rdma/mlx5-abi.h userspace compilation errors: /usr/include/rdma/mlx5-abi.h:69:25: error: 'u64' undeclared here (not in a function) MLX5_LIB_CAP_4K_UAR = (u64)1 << 0, /usr/include/rdma/mlx5-abi.h:69:29: error: expected ',' or '}' before numeric constant MLX5_LIB_CAP_4K_UAR = (u64)1 << 0, Include to fix the following rdma/mlx5-abi.h userspace compilation error: /usr/include/rdma/mlx5-abi.h:286:12: error: 'ETH_ALEN' undeclared here (not in a function) __u8 dmac[ETH_ALEN]; Signed-off-by: Dmitry V. Levin --- include/uapi/rdma/mlx5-abi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/rdma/mlx5-abi.h b/include/uapi/rdma/mlx5-abi.h index da7cd62..0b3d308 100644 --- a/include/uapi/rdma/mlx5-abi.h +++ b/include/uapi/rdma/mlx5-abi.h @@ -34,6 +34,7 @@ #define MLX5_ABI_USER_H #include +#include /* For ETH_ALEN. */ enum { MLX5_QP_FLAG_SIGNATURE = 1 << 0, @@ -66,7 +67,7 @@ struct mlx5_ib_alloc_ucontext_req { }; enum mlx5_lib_caps { - MLX5_LIB_CAP_4K_UAR = (u64)1 << 0, + MLX5_LIB_CAP_4K_UAR = (__u64)1 << 0, }; struct mlx5_ib_alloc_ucontext_req_v2 { -- ldv
[RFC PATCH] uapi: fix linux/packet_diag.h userspace compilation error
Replace MAX_ADDR_LEN with its numeric value to fix the following linux/packet_diag.h userspace compilation error: /usr/include/linux/packet_diag.h:67:17: error: 'MAX_ADDR_LEN' undeclared here (not in a function) __u8 pdmc_addr[MAX_ADDR_LEN]; This is not the first case in the UAPI where the numeric value of MAX_ADDR_LEN is used, uapi/linux/if_link.h already does the same, and there are no UAPI headers besides these two that use MAX_ADDR_LEN. The alternative fix would be to include which pulls in other headers and a lot of definitions with them. Signed-off-by: Dmitry V. Levin --- I'm not quite comfortable with this approach but the alternative has its own drawbacks. include/uapi/linux/packet_diag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/packet_diag.h b/include/uapi/linux/packet_diag.h index d08c63f..0c5d5dd 100644 --- a/include/uapi/linux/packet_diag.h +++ b/include/uapi/linux/packet_diag.h @@ -64,7 +64,7 @@ struct packet_diag_mclist { __u32 pdmc_count; __u16 pdmc_type; __u16 pdmc_alen; - __u8pdmc_addr[MAX_ADDR_LEN]; + __u8pdmc_addr[32]; /* MAX_ADDR_LEN */ }; struct packet_diag_ring { -- ldv
Re: [RFC PATCH] uapi: fix linux/packet_diag.h userspace compilation error
On Tue, Mar 07, 2017 at 12:16:49PM -0800, David Miller wrote: > From: "Dmitry V. Levin" > Date: Tue, 28 Feb 2017 04:39:30 +0300 > > > Replace MAX_ADDR_LEN with its numeric value to fix the following > > linux/packet_diag.h userspace compilation error: > > > > /usr/include/linux/packet_diag.h:67:17: error: 'MAX_ADDR_LEN' undeclared > > here (not in a function) > > __u8 pdmc_addr[MAX_ADDR_LEN]; > > > > This is not the first case in the UAPI where the numeric value > > of MAX_ADDR_LEN is used, uapi/linux/if_link.h already does the same, > > and there are no UAPI headers besides these two that use MAX_ADDR_LEN. > > > > The alternative fix would be to include which > > pulls in other headers and a lot of definitions with them. > > > > Signed-off-by: Dmitry V. Levin > > If if_link.h includes netdevice.h properly, let's try to do the same here as > well. Sorry if my words weren't clear enough: no, if_link.h doesn't include netdevice.h, it uses the _numeric_ value instead: $ grep MAX_ADDR_LEN include/uapi/linux/if_link.h __u8 mac[32]; /* MAX_ADDR_LEN */ -- ldv
[PATCH] uapi: fix linux/packet_diag.h userspace compilation error
Replace MAX_ADDR_LEN with its numeric value to fix the following linux/packet_diag.h userspace compilation error: /usr/include/linux/packet_diag.h:67:17: error: 'MAX_ADDR_LEN' undeclared here (not in a function) __u8 pdmc_addr[MAX_ADDR_LEN]; This is not the first case in the UAPI where the numeric value of MAX_ADDR_LEN is used instead of symbolic one, uapi/linux/if_link.h already does the same: $ grep MAX_ADDR_LEN include/uapi/linux/if_link.h __u8 mac[32]; /* MAX_ADDR_LEN */ There are no UAPI headers besides these two that use MAX_ADDR_LEN. Signed-off-by: Dmitry V. Levin Acked-by: Pavel Emelyanov --- include/uapi/linux/packet_diag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/packet_diag.h b/include/uapi/linux/packet_diag.h index d08c63f..0c5d5dd 100644 --- a/include/uapi/linux/packet_diag.h +++ b/include/uapi/linux/packet_diag.h @@ -64,7 +64,7 @@ struct packet_diag_mclist { __u32 pdmc_count; __u16 pdmc_type; __u16 pdmc_alen; - __u8pdmc_addr[MAX_ADDR_LEN]; + __u8pdmc_addr[32]; /* MAX_ADDR_LEN */ }; struct packet_diag_ring { -- ldv
[PATCH] uapi: fix linux/if_pppol2tp.h userspace compilation errors
Move inclusion of before 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 --- 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 +#include #include #include -#include /* Structure used to connect() the socket to a particular tunnel UDP * socket over IPv4. -- ldv
Re: [PATCH] uapi: fix linux/if_pppol2tp.h userspace compilation errors
On Tue, Feb 14, 2017 at 02:37:23PM -0500, David Miller wrote: > From: "Dmitry V. Levin" > 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 :32:0: /usr/include/netinet/in.h:31:8: error: redefinition of 'struct in_addr' struct in_addr ^~~ In file included from :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
[PATCH v2] uapi: fix linux/if_pppol2tp.h userspace compilation errors
Because of interface limitations, provided by libc cannot be included after , therefore any header that includes cannot be included after . Change uapi/linux/l2tp.h, the last uapi header that includes , to include and instead of 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 --- v2: change uapi/linux/l2tp.h to fix 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 #include -#ifndef __KERNEL__ -#include -#endif +#include +#include #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
[PATCH v2] uapi: fix linux/ipv6_route.h userspace compilation errors
Include to fix the following linux/ipv6_route.h userspace compilation errors: /usr/include/linux/ipv6_route.h:42:19: error: field 'rtmsg_dst' has incomplete type struct in6_addr rtmsg_dst; /usr/include/linux/ipv6_route.h:43:19: error: field 'rtmsg_src' has incomplete type struct in6_addr rtmsg_src; /ust/include/linux/ipv6_route.h:44:19: error: field 'rtmsg_gateway' has incomplete type struct in6_addr rtmsg_gateway; Signed-off-by: Dmitry V. Levin --- v2: Cc'ed netdev include/uapi/linux/ipv6_route.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/ipv6_route.h b/include/uapi/linux/ipv6_route.h index f6598d1..85bbb17 100644 --- a/include/uapi/linux/ipv6_route.h +++ b/include/uapi/linux/ipv6_route.h @@ -14,6 +14,7 @@ #define _UAPI_LINUX_IPV6_ROUTE_H #include +#include /* For struct in6_addr. */ #define RTF_DEFAULT0x0001 /* default - learned via ND */ #define RTF_ALLONLINK 0x0002 /* (deprecated and will be removed) -- ldv
[PATCH v2] uapi: fix linux/mroute6.h userspace compilation errors
Include to fix the following linux/mroute6.h userspace compilation errors: /usr/include/linux/mroute6.h:80:22: error: field 'mf6cc_origin' has incomplete type struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */ /usr/include/linux/mroute6.h:81:22: error: field 'mf6cc_mcastgrp' has incomplete type struct sockaddr_in6 mf6cc_mcastgrp; /* Group in question */ /usr/include/linux/mroute6.h:91:22: error: field 'src' has incomplete type struct sockaddr_in6 src; /usr/include/linux/mroute6.h:92:22: error: field 'grp' has incomplete type struct sockaddr_in6 grp; /usr/include/linux/mroute6.h:132:18: error: field 'im6_src' has incomplete type struct in6_addr im6_src, im6_dst; /usr/include/linux/mroute6.h:132:27: error: field 'im6_dst' has incomplete type struct in6_addr im6_src, im6_dst; Signed-off-by: Dmitry V. Levin --- v2: Cc'ed netdev include/uapi/linux/mroute6.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/mroute6.h b/include/uapi/linux/mroute6.h index 5062fb5..ed57211 100644 --- a/include/uapi/linux/mroute6.h +++ b/include/uapi/linux/mroute6.h @@ -4,6 +4,7 @@ #include #include #include +#include /* For struct sockaddr_in6. */ /* * Based on the MROUTING 3.5 defines primarily to keep -- ldv
[PATCH v2] uapi: fix linux/mroute.h userspace compilation errors
Include to fix the following linux/mroute.h userspace compilation errors: /usr/include/linux/mroute.h:58:18: error: field 'vifc_lcl_addr' has incomplete type struct in_addr vifc_lcl_addr; /* Local interface address */ /usr/include/linux/mroute.h:61:17: error: field 'vifc_rmt_addr' has incomplete type struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */ /usr/include/linux/mroute.h:72:17: error: field 'mfcc_origin' has incomplete type struct in_addr mfcc_origin; /* Origin of mcast */ /usr/include/linux/mroute.h:73:17: error: field 'mfcc_mcastgrp' has incomplete type struct in_addr mfcc_mcastgrp; /* Group in question */ /usr/include/linux/mroute.h:84:17: error: field 'src' has incomplete type struct in_addr src; /usr/include/linux/mroute.h:85:17: error: field 'grp' has incomplete type struct in_addr grp; /usr/include/linux/mroute.h:109:17: error: field 'im_src' has incomplete type struct in_addr im_src,im_dst; /usr/include/linux/mroute.h:109:24: error: field 'im_dst' has incomplete type struct in_addr im_src,im_dst; Signed-off-by: Dmitry V. Levin --- v2: Cc'ed netdev include/uapi/linux/mroute.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/mroute.h b/include/uapi/linux/mroute.h index cf94301..1fe4c1e 100644 --- a/include/uapi/linux/mroute.h +++ b/include/uapi/linux/mroute.h @@ -3,6 +3,7 @@ #include #include +#include /* For struct in_addr. */ /* Based on the MROUTING 3.5 defines primarily to keep * source compatibility with BSD. -- ldv
[PATCH v2 1/2] uapi: fix linux/rds.h userspace compilation errors
Consistently use types from linux/types.h to fix the following linux/rds.h userspace compilation errors: /usr/include/linux/rds.h:106:2: error: unknown type name 'uint8_t' uint8_t name[32]; /usr/include/linux/rds.h:107:2: error: unknown type name 'uint64_t' uint64_t value; /usr/include/linux/rds.h:117:2: error: unknown type name 'uint64_t' uint64_t next_tx_seq; /usr/include/linux/rds.h:118:2: error: unknown type name 'uint64_t' uint64_t next_rx_seq; /usr/include/linux/rds.h:121:2: error: unknown type name 'uint8_t' uint8_t transport[TRANSNAMSIZ]; /* null term ascii */ /usr/include/linux/rds.h:122:2: error: unknown type name 'uint8_t' uint8_t flags; /usr/include/linux/rds.h:129:2: error: unknown type name 'uint64_t' uint64_t seq; /usr/include/linux/rds.h:130:2: error: unknown type name 'uint32_t' uint32_t len; /usr/include/linux/rds.h:135:2: error: unknown type name 'uint8_t' uint8_t flags; /usr/include/linux/rds.h:139:2: error: unknown type name 'uint32_t' uint32_t sndbuf; /usr/include/linux/rds.h:144:2: error: unknown type name 'uint32_t' uint32_t rcvbuf; /usr/include/linux/rds.h:145:2: error: unknown type name 'uint64_t' uint64_t inum; /usr/include/linux/rds.h:153:2: error: unknown type name 'uint64_t' uint64_t hdr_rem; /usr/include/linux/rds.h:154:2: error: unknown type name 'uint64_t' uint64_t data_rem; /usr/include/linux/rds.h:155:2: error: unknown type name 'uint32_t' uint32_t last_sent_nxt; /usr/include/linux/rds.h:156:2: error: unknown type name 'uint32_t' uint32_t last_expected_una; /usr/include/linux/rds.h:157:2: error: unknown type name 'uint32_t' uint32_t last_seen_una; /usr/include/linux/rds.h:164:2: error: unknown type name 'uint8_t' uint8_t src_gid[RDS_IB_GID_LEN]; /usr/include/linux/rds.h:165:2: error: unknown type name 'uint8_t' uint8_t dst_gid[RDS_IB_GID_LEN]; /usr/include/linux/rds.h:167:2: error: unknown type name 'uint32_t' uint32_t max_send_wr; /usr/include/linux/rds.h:168:2: error: unknown type name 'uint32_t' uint32_t max_recv_wr; /usr/include/linux/rds.h:169:2: error: unknown type name 'uint32_t' uint32_t max_send_sge; /usr/include/linux/rds.h:170:2: error: unknown type name 'uint32_t' uint32_t rdma_mr_max; /usr/include/linux/rds.h:171:2: error: unknown type name 'uint32_t' uint32_t rdma_mr_size; /usr/include/linux/rds.h:212:9: error: unknown type name 'uint64_t' typedef uint64_t rds_rdma_cookie_t; /usr/include/linux/rds.h:215:2: error: unknown type name 'uint64_t' uint64_t addr; /usr/include/linux/rds.h:216:2: error: unknown type name 'uint64_t' uint64_t bytes; /usr/include/linux/rds.h:221:2: error: unknown type name 'uint64_t' uint64_t cookie_addr; /usr/include/linux/rds.h:222:2: error: unknown type name 'uint64_t' uint64_t flags; /usr/include/linux/rds.h:228:2: error: unknown type name 'uint64_t' uint64_t cookie_addr; /usr/include/linux/rds.h:229:2: error: unknown type name 'uint64_t' uint64_t flags; /usr/include/linux/rds.h:234:2: error: unknown type name 'uint64_t' uint64_t flags; /usr/include/linux/rds.h:240:2: error: unknown type name 'uint64_t' uint64_t local_vec_addr; /usr/include/linux/rds.h:241:2: error: unknown type name 'uint64_t' uint64_t nr_local; /usr/include/linux/rds.h:242:2: error: unknown type name 'uint64_t' uint64_t flags; /usr/include/linux/rds.h:243:2: error: unknown type name 'uint64_t' uint64_t user_token; /usr/include/linux/rds.h:248:2: error: unknown type name 'uint64_t' uint64_t local_addr; /usr/include/linux/rds.h:249:2: error: unknown type name 'uint64_t' uint64_t remote_addr; /usr/include/linux/rds.h:252:4: error: unknown type name 'uint64_t' uint64_t compare; /usr/include/linux/rds.h:253:4: error: unknown type name 'uint64_t' uint64_t swap; /usr/include/linux/rds.h:256:4: error: unknown type name 'uint64_t' uint64_t add; /usr/include/linux/rds.h:259:4: error: unknown type name 'uint64_t' uint64_t compare; /usr/include/linux/rds.h:260:4: error: unknown type name 'uint64_t' uint64_t swap; /usr/include/linux/rds.h:261:4: error: unknown type name 'uint64_t' uint64_t compare_mask; /usr/include/linux/rds.h:262:4: error: unknown type name 'uint64_t' uint64_t swap_mask; /usr/include/linux/rds.h:265:4: error: unknown type name 'uint64_t' uint64_t add; /usr/include/linux/rds.h:266:4: error: unknown type name 'uint64_t' uint64_t nocarry_mask; /usr/include/linux/rds.h:269:2: error: unknown type name 'uint64_t' uint64_t flags; /usr/include/l
[PATCH v2 2/2] uapi: fix linux/rds.h userspace compilation error
On the kernel side, sockaddr_storage is #define'd to __kernel_sockaddr_storage. Replacing struct sockaddr_storage with struct __kernel_sockaddr_storage defined by fixes the following linux/rds.h userspace compilation error: /usr/include/linux/rds.h:226:26: error: field 'dest_addr' has incomplete type struct sockaddr_storage dest_addr; Signed-off-by: Dmitry V. Levin --- v2: Cc'ed netdev include/uapi/linux/rds.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h index 3ff5cc2..804c9b2 100644 --- a/include/uapi/linux/rds.h +++ b/include/uapi/linux/rds.h @@ -35,6 +35,7 @@ #define _LINUX_RDS_H #include +#include /* For __kernel_sockaddr_storage. */ #define RDS_IB_ABI_VERSION 0x301 @@ -223,7 +224,7 @@ struct rds_get_mr_args { }; struct rds_get_mr_for_dest_args { - struct sockaddr_storage dest_addr; + struct __kernel_sockaddr_storage dest_addr; struct rds_iovecvec; __u64 cookie_addr; __u64 flags; -- ldv
[PATCH] uapi: fix linux/if.h userspace compilation errors
Include (guarded by ifndef __KERNEL__) to fix the following linux/if.h userspace compilation errors: /usr/include/linux/if.h:234:19: error: field 'ifru_addr' has incomplete type struct sockaddr ifru_addr; /usr/include/linux/if.h:235:19: error: field 'ifru_dstaddr' has incomplete type struct sockaddr ifru_dstaddr; /usr/include/linux/if.h:236:19: error: field 'ifru_broadaddr' has incomplete type struct sockaddr ifru_broadaddr; /usr/include/linux/if.h:237:19: error: field 'ifru_netmask' has incomplete type struct sockaddr ifru_netmask; /usr/include/linux/if.h:238:20: error: field 'ifru_hwaddr' has incomplete type struct sockaddr ifru_hwaddr; This also fixes userspace compilation of the following uapi headers: linux/atmbr2684.h linux/gsmmux.h linux/if_arp.h linux/if_bonding.h linux/if_frad.h linux/if_pppox.h linux/if_tunnel.h linux/netdevice.h linux/route.h linux/wireless.h As no uapi header provides a definition of struct sockaddr, inclusion of seems to be the most conservative and the only safe fix available. All current users of are very likely to be including already because the latter is the sole provider of struct sockaddr definition in libc, so adding a uapi header with a definition of struct sockaddr would create a potential conflict with . Replacing struct sockaddr in the definition of struct ifreq with a different type would create a potential incompatibility with current users of struct ifreq who might rely on ifru_addr et al members being of type struct sockaddr. Signed-off-by: Dmitry V. Levin --- include/uapi/linux/if.h | 4 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h index 1158a04..259617a 100644 --- a/include/uapi/linux/if.h +++ b/include/uapi/linux/if.h @@ -24,6 +24,10 @@ #include /* for "struct sockaddr" et al */ #include /* for "__user" et al */ +#ifndef __KERNEL__ +#include /* for struct sockaddr. */ +#endif + #if __UAPI_DEF_IF_IFNAMSIZ #defineIFNAMSIZ16 #endif /* __UAPI_DEF_IF_IFNAMSIZ */ -- ldv
Re: [PATCH v2] bpf: fix uapi bpf_prog_info fields alignment
On Tue, Jun 25, 2019 at 07:16:55AM -0700, Alexei Starovoitov wrote: > On Tue, Jun 25, 2019 at 4:07 AM Baruch Siach wrote: > > > > Merge commit 1c8c5a9d38f60 ("Merge > > git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next") undid the > > fix from commit 36f9814a494 ("bpf: fix uapi hole for 32 bit compat > > applications") by taking the gpl_compatible 1-bit field definition from > > commit b85fab0e67b162 ("bpf: Add gpl_compatible flag to struct > > bpf_prog_info") as is. That breaks architectures with 16-bit alignment > > like m68k. Embed gpl_compatible into an anonymous union with 32-bit pad > > member to restore alignment of following fields. > > > > Thanks to Dmitry V. Levin his analysis of this bug history. > > > > Cc: Jiri Olsa > > Cc: Daniel Borkmann > > Cc: Geert Uytterhoeven > > Cc: Linus Torvalds > > Signed-off-by: Baruch Siach > > --- > > v2: > > Use anonymous union with pad to make it less likely to break again in > > the future. > > --- > > include/uapi/linux/bpf.h | 5 - > > tools/include/uapi/linux/bpf.h | 5 - > > 2 files changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > > index a8b823c30b43..766eae02d7ae 100644 > > --- a/include/uapi/linux/bpf.h > > +++ b/include/uapi/linux/bpf.h > > @@ -3142,7 +3142,10 @@ struct bpf_prog_info { > > __aligned_u64 map_ids; > > char name[BPF_OBJ_NAME_LEN]; > > __u32 ifindex; > > - __u32 gpl_compatible:1; > > + union { > > + __u32 gpl_compatible:1; > > + __u32 pad; > > + }; > > Nack for the reasons explained in the previous thread > on the same subject. > Why cannot you go with earlier suggestion of _u32 :31; ? By the way, why not use aligned types as suggested by Geert? They are already used for other members of struct bpf_prog_info anyway. FWIW, we use aligned types for bpf in strace and that approach proved to be more robust than manual padding. -- ldv signature.asc Description: PGP signature
Re: [PATCH v2] bpf: fix uapi bpf_prog_info fields alignment
On Tue, Jun 25, 2019 at 08:19:35AM -0700, Alexei Starovoitov wrote: > On Tue, Jun 25, 2019 at 8:08 AM Dmitry V. Levin wrote: > > On Tue, Jun 25, 2019 at 07:16:55AM -0700, Alexei Starovoitov wrote: > > > On Tue, Jun 25, 2019 at 4:07 AM Baruch Siach wrote: > > > > > > > > Merge commit 1c8c5a9d38f60 ("Merge > > > > git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next") undid the > > > > fix from commit 36f9814a494 ("bpf: fix uapi hole for 32 bit compat > > > > applications") by taking the gpl_compatible 1-bit field definition from > > > > commit b85fab0e67b162 ("bpf: Add gpl_compatible flag to struct > > > > bpf_prog_info") as is. That breaks architectures with 16-bit alignment > > > > like m68k. Embed gpl_compatible into an anonymous union with 32-bit pad > > > > member to restore alignment of following fields. > > > > > > > > Thanks to Dmitry V. Levin his analysis of this bug history. > > > > > > > > Cc: Jiri Olsa > > > > Cc: Daniel Borkmann > > > > Cc: Geert Uytterhoeven > > > > Cc: Linus Torvalds > > > > Signed-off-by: Baruch Siach > > > > --- > > > > v2: > > > > Use anonymous union with pad to make it less likely to break again in > > > > the future. > > > > --- > > > > include/uapi/linux/bpf.h | 5 - > > > > tools/include/uapi/linux/bpf.h | 5 - > > > > 2 files changed, 8 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > > > > index a8b823c30b43..766eae02d7ae 100644 > > > > --- a/include/uapi/linux/bpf.h > > > > +++ b/include/uapi/linux/bpf.h > > > > @@ -3142,7 +3142,10 @@ struct bpf_prog_info { > > > > __aligned_u64 map_ids; > > > > char name[BPF_OBJ_NAME_LEN]; > > > > __u32 ifindex; > > > > - __u32 gpl_compatible:1; > > > > + union { > > > > + __u32 gpl_compatible:1; > > > > + __u32 pad; > > > > + }; > > > > > > Nack for the reasons explained in the previous thread > > > on the same subject. > > > Why cannot you go with earlier suggestion of _u32 :31; ? > > > > By the way, why not use aligned types as suggested by Geert? > > They are already used for other members of struct bpf_prog_info anyway. > > > > FWIW, we use aligned types for bpf in strace and that approach > > proved to be more robust than manual padding. > > because __aligned_u64 is used for pointers. Does the fact that __aligned_u64 is used for pointers mean that __aligned_u64 should not be used for anything but pointers? -- ldv signature.asc Description: PGP signature
Re: "bpf: Improve the info.func_info and info.func_info_rec_size behavior" breaks strace self tests
On Fri, Jan 04, 2019 at 10:25:24AM +0100, Heiko Carstens wrote: > On Thu, Jan 03, 2019 at 11:52:51PM +, Martin Lau wrote: > > On Thu, Jan 03, 2019 at 11:41:18PM +0100, Heiko Carstens wrote: > > > On Thu, Jan 03, 2019 at 07:12:05PM +, Martin Lau wrote: > > > > On Thu, Jan 03, 2019 at 12:46:13PM +0100, Heiko Carstens wrote: > > > > > Hello, > > > > > > > > > > the kernel commit 7337224fc150 ("bpf: Improve the info.func_info and > > > > > info.func_info_rec_size behavior") breaks one of strace's self tests: > > > > > > > > > > FAIL: bpf-obj_get_info_by_fd-prog-v.gen > ... > > I am running against linux-next. I don't see how root and non-root affect > > thing here. I guess the test has been running without jit so far? > > Yes, it was disabled. Enabling jit and adding your memset fix leads to > what you report with 2) below. > > > 1) root or not, if jit is enabled, > >without the memset() fix in the bpf-obj_get_info_by_fd.c in my last > > email, > >they all failed: > >[root@arch-fb-vm1 tests]# ./bpf-obj_get_info_by_fd-prog-v.gen.test > >BPF_OBJ_GET_INFO_BY_FD prog 2 failed: Bad address > >bpf-obj_get_info_by_fd-prog-v.gen.test: skipped test: > > ../bpf-obj_get_info_by_fd-prog-v exited with code 77 > > > >Please fix this first. > > > > 2) After having the memset fix: > >Root or not, for jited program, if I run > >./bpf-obj_get_info_by_fd-prog-v.gen.test, they failed. If I read the > >init.sh correclty, it fails because there is a diff between the > >./bpf-obj_get_info_by_fd-prog-v stdout and the "strace -o log". I think > >"strace -o log" only has the /* bytes 104..151 */ part if some bytes > >are non-zero? > > > >Regardless, the test program "bpf-obj_get_info_by_fd.c" is telling > >the kernel that the userspace "info" is in size 168 bytes. > >The kernel then tells as much details as possible about > >a bpf prog in "info". I don't see a ABI breakage here. > > > >I believe the test just happens to work so far because it has been > > running > >without jit? > > > >If I run it with jit enabled: > > -bpf(BPF_OBJ_GET_INFO_BY_FD, {info={bpf_fd=4, > > info_len=168, info={type=BPF_PROG_TYPE_SOCKET_FILTER, id=35, > > tag="\xda\xbf\x02\x07\xd1\x99\x24\x86", jited_prog_len=0 => 110, > > jited_prog_insns=NULL, xlated_prog_len=0 => 120, xlated_prog_insns=[], > > load_time=2476906063975, created_by_uid=0, nr_map_ids=0 => 1, map_ids=[], > > name="test_prog", ifindex=0, netns_dev=makedev(0, 0), netns_ino=0}}}, 16) = > > 0 > > -bpf(BPF_OBJ_GET_INFO_BY_FD, {info={bpf_fd=4, > > info_len=168, info={type=BPF_PROG_TYPE_SOCKET_FILTER, id=35, > > tag="\xda\xbf\x02\x07\xd1\x99\x24\x86", jited_prog_len=0 => 110, > > jited_prog_insns=NULL, xlated_prog_len=0 => 120, xlated_prog_insns=[], > > load_time=2476906063975, created_by_uid=0, nr_map_ids=2 => 1, map_ids=[36], > > name="test_prog", ifindex=0, netns_dev=makedev(0, 0), netns_ino=0}}}, 16) = > > 0 > > +bpf(BPF_OBJ_GET_INFO_BY_FD, {info={bpf_fd=4, > > info_len=168, info={type=BPF_PROG_TYPE_SOCKET_FILTER, id=35, > > tag="\xda\xbf\x02\x07\xd1\x99\x24\x86", jited_prog_len=0 => 110, > > jited_prog_insns=NULL, xlated_prog_len=0 => 120, xlated_prog_insns=[], > > load_time=2476906063975, created_by_uid=0, nr_map_ids=0 => 1, map_ids=[], > > name="test_prog", ifindex=0, netns_dev=makedev(0, 0), netns_ino=0, /* bytes > > 104..167 */ > > "\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"}}}, > > 16) = 0 > > +bpf(BPF_OBJ_GET_INFO_BY_FD, {info={bpf_fd=4, > > info_len=168, info={type=BPF_PROG_TYPE_SOCKET_FILTER, id=35, > > tag="\xda\xbf\x02\x07\xd1\x99\x24\x86", jited_prog_len=0 => 110, > > jited_prog_insns=NULL, xlated_prog_len=0 => 120, xlated_prog_insns=[], > > load_time=2476906063975, created_by_uid=0, nr_map_ids=2 => 1, map_ids=[36], > > name="test_prog", ifindex=0, netns_dev=makedev(0, 0), netns_ino=0, /* bytes > > 104..167 */ > > "\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"}}}, > > 16) = 0 > > > > The diff comes in as early as byte 104-th which is the nr_jited_ksyms == > > 1. > > > > Please fix the test program. A protential fix is in > > bpf-obj_get_info_by_fd.c > > to printf the non-zero "/* bytes 104..1xx */..." the same way as the > > "strace -o log" does. > > Thanks a lot for looking into this! > Eugene, Dmitry will you take care of fixing this? Thanks for reporting this! AFAICT, the test in question was specifically designed to check whether the strace printer of BPF_OBJ_GET_INFO_BY_FD command is up to date with the kernel, and this f
[PATCH iproute2] configure: fix typo in check_xt_old_internal_h
Fixes: 377a09902a57 ("configure: Minor code cleanup") Signed-off-by: Dmitry V. Levin --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index b85eb58b..45fcffb6 100755 --- a/configure +++ b/configure @@ -115,7 +115,7 @@ EOF check_xt_old_internal_h() { # bail if previous XT checks has already succeeded. -grep -q if grep -q TC_CONFIG_XT $CONFIG && return +grep -q TC_CONFIG_XT $CONFIG && return #check if we need our own internal.h cat >$TMPDIR/ipttest.c <