* [PATCH 1/2][next] UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel
2024-08-13 22:13 [PATCH 0/2][next] UAPI: net/sched - cxgb4: Fix -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2024-08-13 22:15 ` Gustavo A. R. Silva
2024-08-13 22:15 ` [PATCH 2/2][next] cxgb4: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2024-08-15 3:50 ` [PATCH 0/2][next] UAPI: net/sched - cxgb4: Fix " patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2024-08-13 22:15 UTC (permalink / raw)
To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, Potnuri Bharat Teja,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Gustavo A. R. Silva, linux-hardening
Use the `__struct_group()` helper to create a new tagged
`struct tc_u32_sel_hdr`. This structure groups together all the
members of the flexible `struct tc_u32_sel` except the flexible
array. As a result, the array is effectively separated from the
rest of the members without modifying the memory layout of the
flexible structure.
This new tagged struct will be used to fix problematic declarations
of middle-flex-arrays in composite structs[1].
[1] https://git.kernel.org/linus/d88cabfd9abc
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
include/uapi/linux/pkt_cls.h | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index d36d9cdf0c00..2c32080416b5 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -246,16 +246,19 @@ struct tc_u32_key {
};
struct tc_u32_sel {
- unsigned char flags;
- unsigned char offshift;
- unsigned char nkeys;
-
- __be16 offmask;
- __u16 off;
- short offoff;
-
- short hoff;
- __be32 hmask;
+ /* New members MUST be added within the __struct_group() macro below. */
+ __struct_group(tc_u32_sel_hdr, hdr, /* no attrs */,
+ unsigned char flags;
+ unsigned char offshift;
+ unsigned char nkeys;
+
+ __be16 offmask;
+ __u16 off;
+ short offoff;
+
+ short hoff;
+ __be32 hmask;
+ );
struct tc_u32_key keys[];
};
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2][next] cxgb4: Avoid -Wflex-array-member-not-at-end warning
2024-08-13 22:13 [PATCH 0/2][next] UAPI: net/sched - cxgb4: Fix -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2024-08-13 22:15 ` [PATCH 1/2][next] UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel Gustavo A. R. Silva
@ 2024-08-13 22:15 ` Gustavo A. R. Silva
2024-08-15 3:50 ` [PATCH 0/2][next] UAPI: net/sched - cxgb4: Fix " patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2024-08-13 22:15 UTC (permalink / raw)
To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, Potnuri Bharat Teja,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Gustavo A. R. Silva, linux-hardening
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.
Change the type of the middle struct member currently causing
trouble from `struct tc_u32_sel` to `struct tc_u32_sel_hdr`.
Fix the following warning:
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:245:27: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h
index 9050568a034c..64663112cad8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h
@@ -242,7 +242,7 @@ struct cxgb4_next_header {
* field's value to jump to next header such as IHL field
* in IPv4 header.
*/
- struct tc_u32_sel sel;
+ struct tc_u32_sel_hdr sel;
struct tc_u32_key key;
/* location of jump to make */
const struct cxgb4_match_field *jump;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2][next] UAPI: net/sched - cxgb4: Fix -Wflex-array-member-not-at-end warning
2024-08-13 22:13 [PATCH 0/2][next] UAPI: net/sched - cxgb4: Fix -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2024-08-13 22:15 ` [PATCH 1/2][next] UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel Gustavo A. R. Silva
2024-08-13 22:15 ` [PATCH 2/2][next] cxgb4: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2024-08-15 3:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-15 3:50 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: jhs, xiyou.wangcong, jiri, bharat, davem, edumazet, kuba, pabeni,
netdev, linux-kernel, linux-hardening
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 13 Aug 2024 16:13:58 -0600 you wrote:
> Small patch series aimed at fixing a -Wflex-array-member-not-at-end
> warning by creating a new tagged struct within a flexible structure.
> We then use this new struct type to fix a problematic middle-flex-array
> declaration in a composite struct.
>
> Gustavo A. R. Silva (2):
> UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel
> cxgb4: Avoid -Wflex-array-member-not-at-end warning
>
> [...]
Here is the summary with links:
- [1/2,next] UAPI: net/sched: Use __struct_group() in flex struct tc_u32_sel
https://git.kernel.org/netdev/net-next/c/216203bdc228
- [2/2,next] cxgb4: Avoid -Wflex-array-member-not-at-end warning
https://git.kernel.org/netdev/net-next/c/6c5cdabb3ec3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread