Skip to contentSkip to conversation

uapi: add missing ip/ipv6 header dependencies for linux/stddef.h

PATCH In review Herton R. Krzesinski 2 participants 2 messages Feb 3, 2023 – Feb 4, 2023 BPF

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uapi: add missing ip/ipv6 header dependencies for linux/stddef.h

Since commit 58e0be1ef6118 ("net: use struct_group to copy ip/ipv6 header addresses"), ip and ipv6 headers started to use the __struct_group definition, which is defined at include/uapi/linux/stddef.h. However, linux/stddef.h isn't explicitly included in include/uapi/linux/{ip,ipv6}.h, which breaks build of xskxceiver bpf selftest if you install the uapi headers in the system:

$ make V=1 xskxceiver -C tools/testing/selftests/bpf
...
make: Entering directory '(...)/tools/testing/selftests/bpf'
gcc -g -O0 -rdynamic -Wall -Werror (...)
In file included from xskxceiver.c:79:
/usr/include/linux/ip.h:103:9: error: expected specifier-qualifier-list before ‘__struct_group’
  103 |         __struct_group(/* no tag */, addrs, /* no attrs */,
      |         ^~~~~~~~~~~~~~
...

Include the missing <linux/stddef.h> dependency in ip.h and do the same for the ipv6.h header.

Fixes 58e0be1ef611 ("net: use struct_group to copy ip/ipv6 header addresses")
---
 include/uapi/linux/ip.h   | 1 +
 include/uapi/linux/ipv6.h | 1 +
 2 files changed, 2 insertions(+)
include/uapi/linux/ip.h +1 -0
index 874a92349bf5..283dec7e3645 100644
@@ -18,6 +18,7 @@
 #ifndef _UAPI_LINUX_IP_H
 #define _UAPI_LINUX_IP_H
 #include <linux/types.h>
+#include <linux/stddef.h>
 #include <asm/byteorder.h>
 
 #define IPTOS_TOS_MASK		0x1E
include/uapi/linux/ipv6.h +1 -0
index 81f4243bebb1..53326dfc59ec 100644
@@ -4,6 +4,7 @@
 
 #include <linux/libc-compat.h>
 #include <linux/types.h>
+#include <linux/stddef.h>
 #include <linux/in6.h>
 #include <asm/byteorder.h>
 
Signature · 1 line
2.38.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 17 lines · Herton R. Krzesinski

Since commit 58e0be1ef6118 ("net: use struct_group to copy ip/ipv6 header addresses"), ip and ipv6 headers started to use the __struct_group definition, which is defined at include/uapi/linux/stddef.h. However, linux/stddef.h isn't explicitly included in include/uapi/linux/{ip,ipv6}.h, which breaks build of xskxceiver bpf selftest if you install the uapi headers in the system:

$ make V=1 xskxceiver -C tools/testing/selftests/bpf
...
make: Entering directory '(...)/tools/testing/selftests/bpf'
gcc -g -O0 -rdynamic -Wall -Werror (...)
In file included from xskxceiver.c:79:
/usr/include/linux/ip.h:103:9: error: expected specifier-qualifier-list before ‘__struct_group’
  103 |         __struct_group(/* no tag */, addrs, /* no attrs */,
      |         ^~~~~~~~~~~~~~
...
Quoted 5 lines

Include the missing <linux/stddef.h> dependency in ip.h and do the same for the ipv6.h header.

Fixes 58e0be1ef611 ("net: use struct_group to copy ip/ipv6 header addresses")

LGTM, if you used it you should #include-it.

Tested with x86_64 defconfig at 0136d86b78522bbd5755f8194c97a987f0586ba5.

Tested building glibc with the new UAPI headers, and that works too.

Quoted 10 lines
---
 include/uapi/linux/ip.h   | 1 +
 include/uapi/linux/ipv6.h | 1 +
 2 files changed, 2 insertions(+)
include/uapi/linux/ip.h +0 -0
index 874a92349bf5..283dec7e3645 100644

include/uapi/linux/ip.h line 21

Quoted 4 lines
include/uapi/linux/ip.h +1 -0
@@ -18,6 +18,7 @@
 #ifndef _UAPI_LINUX_IP_H
 #define _UAPI_LINUX_IP_H
 #include <linux/types.h>
+#include <linux/stddef.h>

OK. Includes stddef.h because of __struct_group use by struct iphdr.

include/uapi/linux/ipv6.h line 7

Quoted 12 lines
include/uapi/linux/ip.h +0 -0
 #include <asm/byteorder.h>
 
 #define IPTOS_TOS_MASK		0x1E
include/uapi/linux/ipv6.h +1 -0
index 81f4243bebb1..53326dfc59ec 100644
@@ -4,6 +4,7 @@
 
 #include <linux/libc-compat.h>
 #include <linux/types.h>
+#include <linux/stddef.h>

OK. Includes stddef.h because of __struct_group use by struct ipv6hdr.

Quoted 3 lines
include/uapi/linux/ipv6.h +0 -0
 #include <linux/in6.h>
 #include <asm/byteorder.h>
 
Signature · 2 lines
Cheers,
Carlos.