Commit 43d34870 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Jakub Kicinski
Browse files

UAPI: ethtool: Use __struct_group() in struct ethtool_link_settings

Use the `__struct_group()` helper to create a new tagged
`struct ethtool_link_settings_hdr`. This structure groups together
all the members of the flexible `struct ethtool_link_settings`
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: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Link: https://patch.msgid.link/9e9fb0bd72e5ba1e916acbb4995b1e358b86a689.1730238285.git.gustavoars@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f12b3638
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -2511,6 +2511,8 @@ enum ethtool_reset_flags {
 *	autonegotiation; 0 if unknown or not applicable.  Read-only.
 */
struct ethtool_link_settings {
	/* New members MUST be added within the __struct_group() macro below. */
	__struct_group(ethtool_link_settings_hdr, hdr, /* no attrs */,
		__u32	cmd;
		__u32	speed;
		__u8	duplex;
@@ -2526,6 +2528,7 @@ struct ethtool_link_settings {
		__u8	master_slave_state;
		__u8	rate_matching;
		__u32	reserved[7];
	);
	__u32	link_mode_masks[];
	/* layout of link_mode_masks fields:
	 * __u32 map_supported[link_mode_masks_nwords];