diff mbox series

[bpf-next] bpf: Sync include/uapi/linux/bpf.h with tools/include/uapi/linux/bpf.h

Message ID 20220817010504.4072757-1-davemarchevsky@fb.com (mailing list archive)
State Awaiting Upstream
Delegated to: BPF
Headers show
Series [bpf-next] bpf: Sync include/uapi/linux/bpf.h with tools/include/uapi/linux/bpf.h | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1724 this patch: 1724
netdev/cc_maintainers warning 8 maintainers not CCed: john.fastabend@gmail.com song@kernel.org sdf@google.com martin.lau@linux.dev kpsingh@kernel.org jolsa@kernel.org haoluo@google.com yhs@fb.com
netdev/build_clang success Errors and warnings before: 177 this patch: 177
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1718 this patch: 1718
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-3 fail Logs for Kernel LATEST on z15 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-1 fail Logs for Kernel LATEST on ubuntu-latest with gcc
bpf/vmtest-bpf-next-VM_Test-2 fail Logs for Kernel LATEST on ubuntu-latest with llvm-16

Commit Message

Dave Marchevsky Aug. 17, 2022, 1:05 a.m. UTC
Commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with
flexible-array members") modified bpf_lpm_trie_key struct's data member
in include/uapi/linux/bpf.h, but didn't make the same change in tools
dir's copy. Propagate it over and fix comment indentation as well.

This is a nonfunctional change.

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
---
 include/uapi/linux/bpf.h       | 2 +-
 tools/include/uapi/linux/bpf.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Daniel Borkmann Aug. 17, 2022, 9:21 p.m. UTC | #1
[ +Gustavo ]

On 8/17/22 3:05 AM, Dave Marchevsky wrote:
> Commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with
> flexible-array members") modified bpf_lpm_trie_key struct's data member
> in include/uapi/linux/bpf.h, but didn't make the same change in tools
> dir's copy. Propagate it over and fix comment indentation as well.
> 
> This is a nonfunctional change.
> 
> Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>

Gustavo, 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members")
breaks BPF when copied from include/uapi/linux/bpf.h to tools/include/uapi/linux/bpf.h :

CI: https://github.com/kernel-patches/bpf/runs/7885234999?check_suite_focus=true

   [...]
     CLNG-BPF [test_maps] map_ptr_kern.o
     CLNG-BPF [test_maps] btf__core_reloc_arrays___diff_arr_val_sz.o
     CLNG-BPF [test_maps] test_bpf_cookie.o
   progs/map_ptr_kern.c:314:26: error: field 'trie_key' with variable sized type 'struct bpf_lpm_trie_key' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
           struct bpf_lpm_trie_key trie_key;
                                   ^
     CLNG-BPF [test_maps] btf__core_reloc_type_based___diff.o
   1 error generated.
   make: *** [Makefile:521: /tmp/runner/work/bpf/bpf/tools/testing/selftests/bpf/map_ptr_kern.o] Error 1
   make: *** Waiting for unfinished jobs....

If you look at the selftest tools/testing/selftests/bpf/progs/map_ptr_kern.c +314 :

   /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
   struct bpf_lpm_trie_key {
         __u32   prefixlen;      /* up to 32 for AF_INET, 128 for AF_INET6 */
         __u8    data[];         /* Arbitrary size */
   };

   struct lpm_key {
         struct bpf_lpm_trie_key trie_key;
         __u32 data;
   };

Did you try to compile the tree (or selftests) with LLVM? I doubt the UX will be nice if everyone
now has to add -Wno-gnu-variable-sized-type-not-at-end ..

> ---
>   include/uapi/linux/bpf.h       | 2 +-
>   tools/include/uapi/linux/bpf.h | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 934a2a8beb87..0b09b5463afd 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -79,7 +79,7 @@ struct bpf_insn {
>   /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
>   struct bpf_lpm_trie_key {
>   	__u32	prefixlen;	/* up to 32 for AF_INET, 128 for AF_INET6 */
> -	__u8	data[];	/* Arbitrary size */
> +	__u8	data[];		/* Arbitrary size */
>   };
>   
>   struct bpf_cgroup_storage_key {
> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> index 1d6085e15fc8..0b09b5463afd 100644
> --- a/tools/include/uapi/linux/bpf.h
> +++ b/tools/include/uapi/linux/bpf.h
> @@ -79,7 +79,7 @@ struct bpf_insn {
>   /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
>   struct bpf_lpm_trie_key {
>   	__u32	prefixlen;	/* up to 32 for AF_INET, 128 for AF_INET6 */
> -	__u8	data[0];	/* Arbitrary size */
> +	__u8	data[];		/* Arbitrary size */
>   };
>   
>   struct bpf_cgroup_storage_key {
>
Daniel Borkmann Aug. 17, 2022, 9:48 p.m. UTC | #2
On 8/17/22 11:21 PM, Daniel Borkmann wrote:
> [ +Gustavo ]
> 
> On 8/17/22 3:05 AM, Dave Marchevsky wrote:
>> Commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with
>> flexible-array members") modified bpf_lpm_trie_key struct's data member
>> in include/uapi/linux/bpf.h, but didn't make the same change in tools
>> dir's copy. Propagate it over and fix comment indentation as well.
>>
>> This is a nonfunctional change.
>>
>> Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
> 
> Gustavo, 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members")
> breaks BPF when copied from include/uapi/linux/bpf.h to tools/include/uapi/linux/bpf.h :
> 
> CI: https://github.com/kernel-patches/bpf/runs/7885234999?check_suite_focus=true
> 
>    [...]
>      CLNG-BPF [test_maps] map_ptr_kern.o
>      CLNG-BPF [test_maps] btf__core_reloc_arrays___diff_arr_val_sz.o
>      CLNG-BPF [test_maps] test_bpf_cookie.o
>    progs/map_ptr_kern.c:314:26: error: field 'trie_key' with variable sized type 'struct bpf_lpm_trie_key' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
>            struct bpf_lpm_trie_key trie_key;
>                                    ^
>      CLNG-BPF [test_maps] btf__core_reloc_type_based___diff.o
>    1 error generated.
>    make: *** [Makefile:521: /tmp/runner/work/bpf/bpf/tools/testing/selftests/bpf/map_ptr_kern.o] Error 1
>    make: *** Waiting for unfinished jobs....
> 
> If you look at the selftest tools/testing/selftests/bpf/progs/map_ptr_kern.c +314 :
> 
>    /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
>    struct bpf_lpm_trie_key {
>          __u32   prefixlen;      /* up to 32 for AF_INET, 128 for AF_INET6 */
>          __u8    data[];         /* Arbitrary size */
>    };
> 
>    struct lpm_key {
>          struct bpf_lpm_trie_key trie_key;
>          __u32 data;
>    };
> 
> Did you try to compile the tree (or selftests) with LLVM? I doubt the UX will be nice if everyone
> now has to add -Wno-gnu-variable-sized-type-not-at-end ..

Undone here until a different workaround can be found (affects both bpf and bpf-next):

   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=3024d95a4c521c278a7504ee9e80c57c3a9750e0

Thanks,
Daniel
diff mbox series

Patch

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 934a2a8beb87..0b09b5463afd 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -79,7 +79,7 @@  struct bpf_insn {
 /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
 struct bpf_lpm_trie_key {
 	__u32	prefixlen;	/* up to 32 for AF_INET, 128 for AF_INET6 */
-	__u8	data[];	/* Arbitrary size */
+	__u8	data[];		/* Arbitrary size */
 };
 
 struct bpf_cgroup_storage_key {
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 1d6085e15fc8..0b09b5463afd 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -79,7 +79,7 @@  struct bpf_insn {
 /* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */
 struct bpf_lpm_trie_key {
 	__u32	prefixlen;	/* up to 32 for AF_INET, 128 for AF_INET6 */
-	__u8	data[0];	/* Arbitrary size */
+	__u8	data[];		/* Arbitrary size */
 };
 
 struct bpf_cgroup_storage_key {