diff mbox series

net/ipv4: Fix error: type name requires a specifier or qualifier

Message ID tencent_3E0335A1CE2C91CB09159057B15138441F07@qq.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series net/ipv4: Fix error: type name requires a specifier or qualifier | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch, async

Commit Message

Rong Tao Nov. 10, 2022, 3:17 p.m. UTC
From: Rong Tao <rongtao@cestc.cn>

since commit 5854a09b4957("net/ipv4: Use __DECLARE_FLEX_ARRAY() helper")
linux/in.h use __DECLARE_FLEX_ARRAY() macro, and sync to tools/ in commit
036b8f5b8970("tools headers uapi: Update linux/in.h copy"), this macro
define in linux/stddef.h, which introduced in commit 3080ea5553cc("stddef:
Introduce DECLARE_FLEX_ARRAY() helper"), thus, stddef.h should be included
in in.h, which resolves the compilation error below:

How to reproduce this compilation error:

$ make -C tools/testing/selftests/bpf/
In file included from progs/bpf_flow.c:8:
linux/in.h:199:3: error: type name requires a specifier or qualifier
                __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex);
                ^
linux/in.h:199:32: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
                __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex);
                                             ^
2 errors generated.

Same error occurs with cgroup_skb_sk_lookup_kern.c, connect_force_port4.c,
connect_force_port6.c, etc. that contain the header linux/in.h.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
 include/uapi/linux/in.h       | 1 +
 tools/include/uapi/linux/in.h | 1 +
 2 files changed, 2 insertions(+)

Comments

Yonghong Song Nov. 10, 2022, 4:59 p.m. UTC | #1
On 11/10/22 7:17 AM, Rong Tao wrote:
> From: Rong Tao <rongtao@cestc.cn>
> 
> since commit 5854a09b4957("net/ipv4: Use __DECLARE_FLEX_ARRAY() helper")
> linux/in.h use __DECLARE_FLEX_ARRAY() macro, and sync to tools/ in commit
> 036b8f5b8970("tools headers uapi: Update linux/in.h copy"), this macro
> define in linux/stddef.h, which introduced in commit 3080ea5553cc("stddef:
> Introduce DECLARE_FLEX_ARRAY() helper"), thus, stddef.h should be included
> in in.h, which resolves the compilation error below:
> 
> How to reproduce this compilation error:
> 
> $ make -C tools/testing/selftests/bpf/
> In file included from progs/bpf_flow.c:8:
> linux/in.h:199:3: error: type name requires a specifier or qualifier
>                  __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex);
>                  ^
> linux/in.h:199:32: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
>                  __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex);
>                                               ^
> 2 errors generated.
> 
> Same error occurs with cgroup_skb_sk_lookup_kern.c, connect_force_port4.c,
> connect_force_port6.c, etc. that contain the header linux/in.h.

It has been fixed in bpf tree:
    https://lore.kernel.org/bpf/20221102182517.2675301-1-andrii@kernel.org/
The fix will be merged to bpf-next once it reached to linus tree and 
went back to bpf-next.

At the same time, you can workaround the issue locally.

> 
> Signed-off-by: Rong Tao <rongtao@cestc.cn>
> ---
>   include/uapi/linux/in.h       | 1 +
>   tools/include/uapi/linux/in.h | 1 +
>   2 files changed, 2 insertions(+)
> 
> diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
> index f243ce665f74..07a4cb149305 100644
> --- a/include/uapi/linux/in.h
> +++ b/include/uapi/linux/in.h
> @@ -20,6 +20,7 @@
>   #define _UAPI_LINUX_IN_H
>   
>   #include <linux/types.h>
> +#include <linux/stddef.h>
>   #include <linux/libc-compat.h>
>   #include <linux/socket.h>
>   
> diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h
> index f243ce665f74..07a4cb149305 100644
> --- a/tools/include/uapi/linux/in.h
> +++ b/tools/include/uapi/linux/in.h
> @@ -20,6 +20,7 @@
>   #define _UAPI_LINUX_IN_H
>   
>   #include <linux/types.h>
> +#include <linux/stddef.h>
>   #include <linux/libc-compat.h>
>   #include <linux/socket.h>
>
Rong Tao Nov. 11, 2022, 2:18 a.m. UTC | #2
Hi, Song, thanks for your reply. I'm wondering if i want to fix code in
tools/include/uapi/linux/in.h next time, should i just modify
include/uapi/linux/in.h, and it will auto 'Sync' to tools/include/uapi/
linux/in.h? Or i need to modify tools/include/uapi/linux/in.h at the
same time?
Rong Tao Nov. 11, 2022, 2:23 a.m. UTC | #3
I'm sorry, The subject of the previous email error. Please Just Ignore 

https://lore.kernel.org/lkml/tencent_754AAA6CBDDE8DB223CE1BF009D566E55E0A@qq.com/

It's not a PATCH.
Yonghong Song Nov. 11, 2022, 3:49 a.m. UTC | #4
On 11/10/22 6:18 PM, Rong Tao wrote:
> Hi, Song, thanks for your reply. I'm wondering if i want to fix code in
> tools/include/uapi/linux/in.h next time, should i just modify
> include/uapi/linux/in.h, and it will auto 'Sync' to tools/include/uapi/
> linux/in.h? Or i need to modify tools/include/uapi/linux/in.h at the
> same time?

Either way is okay. If you do 'git log' on tools/include/uapi/linux
directory, you can find examples for both approaches.
diff mbox series

Patch

diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index f243ce665f74..07a4cb149305 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -20,6 +20,7 @@ 
 #define _UAPI_LINUX_IN_H
 
 #include <linux/types.h>
+#include <linux/stddef.h>
 #include <linux/libc-compat.h>
 #include <linux/socket.h>
 
diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h
index f243ce665f74..07a4cb149305 100644
--- a/tools/include/uapi/linux/in.h
+++ b/tools/include/uapi/linux/in.h
@@ -20,6 +20,7 @@ 
 #define _UAPI_LINUX_IN_H
 
 #include <linux/types.h>
+#include <linux/stddef.h>
 #include <linux/libc-compat.h>
 #include <linux/socket.h>