Skip to content

Commit a537cfd

Browse files
committed
Merge branch 'uapi-ethtool-avoid-flex-array-in-struct-ethtool_link_settings'
Kees Cook says: ==================== UAPI: ethtool: Avoid flex-array in struct ethtool_link_settings This reverts the tagged struct group in struct ethtool_link_settings and instead just removes the flexible array member from Linux's view as it is entirely unused. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 920efe3 + 96c677f commit a537cfd

File tree

10 files changed

+44
-44
lines changed

10 files changed

+44
-44
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,7 +2780,7 @@ u32 bnxt_fw_to_ethtool_speed(u16 fw_link_speed)
27802780
static void bnxt_get_default_speeds(struct ethtool_link_ksettings *lk_ksettings,
27812781
struct bnxt_link_info *link_info)
27822782
{
2783-
struct ethtool_link_settings_hdr *base = &lk_ksettings->base;
2783+
struct ethtool_link_settings *base = &lk_ksettings->base;
27842784

27852785
if (link_info->link_state == BNXT_LINK_STATE_UP) {
27862786
base->speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
@@ -2799,7 +2799,7 @@ static void bnxt_get_default_speeds(struct ethtool_link_ksettings *lk_ksettings,
27992799
static int bnxt_get_link_ksettings(struct net_device *dev,
28002800
struct ethtool_link_ksettings *lk_ksettings)
28012801
{
2802-
struct ethtool_link_settings_hdr *base = &lk_ksettings->base;
2802+
struct ethtool_link_settings *base = &lk_ksettings->base;
28032803
enum ethtool_link_mode_bit_indices link_mode;
28042804
struct bnxt *bp = netdev_priv(dev);
28052805
struct bnxt_link_info *link_info;
@@ -3022,9 +3022,9 @@ u16 bnxt_get_fw_auto_link_speeds(const unsigned long *mode)
30223022
static int bnxt_set_link_ksettings(struct net_device *dev,
30233023
const struct ethtool_link_ksettings *lk_ksettings)
30243024
{
3025-
const struct ethtool_link_settings_hdr *base = &lk_ksettings->base;
30263025
struct bnxt *bp = netdev_priv(dev);
30273026
struct bnxt_link_info *link_info = &bp->link_info;
3027+
const struct ethtool_link_settings *base = &lk_ksettings->base;
30283028
bool set_pause = false;
30293029
u32 speed, lanes = 0;
30303030
int rc = 0;

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ static unsigned int lmm_to_fw_caps(const unsigned long *link_mode_mask)
662662
static int get_link_ksettings(struct net_device *dev,
663663
struct ethtool_link_ksettings *link_ksettings)
664664
{
665-
struct ethtool_link_settings_hdr *base = &link_ksettings->base;
666665
struct port_info *pi = netdev_priv(dev);
666+
struct ethtool_link_settings *base = &link_ksettings->base;
667667

668668
/* For the nonce, the Firmware doesn't send up Port State changes
669669
* when the Virtual Interface attached to the Port is down. So
@@ -717,9 +717,9 @@ static int get_link_ksettings(struct net_device *dev,
717717
static int set_link_ksettings(struct net_device *dev,
718718
const struct ethtool_link_ksettings *link_ksettings)
719719
{
720-
const struct ethtool_link_settings_hdr *base = &link_ksettings->base;
721720
struct port_info *pi = netdev_priv(dev);
722721
struct link_config *lc = &pi->link_cfg;
722+
const struct ethtool_link_settings *base = &link_ksettings->base;
723723
struct link_config old_lc;
724724
unsigned int fw_caps;
725725
int ret = 0;

drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,8 +1436,8 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
14361436
static int cxgb4vf_get_link_ksettings(struct net_device *dev,
14371437
struct ethtool_link_ksettings *link_ksettings)
14381438
{
1439-
struct ethtool_link_settings_hdr *base = &link_ksettings->base;
14401439
struct port_info *pi = netdev_priv(dev);
1440+
struct ethtool_link_settings *base = &link_ksettings->base;
14411441

14421442
/* For the nonce, the Firmware doesn't send up Port State changes
14431443
* when the Virtual Interface attached to the Port is down. So

drivers/net/ethernet/cisco/enic/enic_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ static void enic_intr_coal_set_rx(struct enic *enic, u32 timer)
129129
static int enic_get_ksettings(struct net_device *netdev,
130130
struct ethtool_link_ksettings *ecmd)
131131
{
132-
struct ethtool_link_settings_hdr *base = &ecmd->base;
133132
struct enic *enic = netdev_priv(netdev);
133+
struct ethtool_link_settings *base = &ecmd->base;
134134

135135
ethtool_link_ksettings_add_link_mode(ecmd, supported,
136136
10000baseT_Full);

drivers/net/ethernet/qlogic/qede/qede_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ static int qede_get_link_ksettings(struct net_device *dev,
504504
struct ethtool_link_ksettings *cmd)
505505
{
506506
typeof(cmd->link_modes) *link_modes = &cmd->link_modes;
507-
struct ethtool_link_settings_hdr *base = &cmd->base;
507+
struct ethtool_link_settings *base = &cmd->base;
508508
struct qede_dev *edev = netdev_priv(dev);
509509
struct qed_link_output current_link;
510510

@@ -537,7 +537,7 @@ static int qede_get_link_ksettings(struct net_device *dev,
537537
static int qede_set_link_ksettings(struct net_device *dev,
538538
const struct ethtool_link_ksettings *cmd)
539539
{
540-
const struct ethtool_link_settings_hdr *base = &cmd->base;
540+
const struct ethtool_link_settings *base = &cmd->base;
541541
const struct ethtool_forced_speed_map *map;
542542
struct qede_dev *edev = netdev_priv(dev);
543543
struct qed_link_output current_link;

include/linux/ethtool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id);
211211
* fields, but they are allowed to overwrite them (will be ignored).
212212
*/
213213
struct ethtool_link_ksettings {
214-
struct ethtool_link_settings_hdr base;
214+
struct ethtool_link_settings base;
215215
struct {
216216
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
217217
__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);

include/uapi/linux/ethtool.h

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,30 +2511,34 @@ enum ethtool_reset_flags {
25112511
* autonegotiation; 0 if unknown or not applicable. Read-only.
25122512
*/
25132513
struct ethtool_link_settings {
2514-
/* New members MUST be added within the __struct_group() macro below. */
2515-
__struct_group(ethtool_link_settings_hdr, hdr, /* no attrs */,
2516-
__u32 cmd;
2517-
__u32 speed;
2518-
__u8 duplex;
2519-
__u8 port;
2520-
__u8 phy_address;
2521-
__u8 autoneg;
2522-
__u8 mdio_support;
2523-
__u8 eth_tp_mdix;
2524-
__u8 eth_tp_mdix_ctrl;
2525-
__s8 link_mode_masks_nwords;
2526-
__u8 transceiver;
2527-
__u8 master_slave_cfg;
2528-
__u8 master_slave_state;
2529-
__u8 rate_matching;
2530-
__u32 reserved[7];
2531-
);
2514+
__u32 cmd;
2515+
__u32 speed;
2516+
__u8 duplex;
2517+
__u8 port;
2518+
__u8 phy_address;
2519+
__u8 autoneg;
2520+
__u8 mdio_support;
2521+
__u8 eth_tp_mdix;
2522+
__u8 eth_tp_mdix_ctrl;
2523+
__s8 link_mode_masks_nwords;
2524+
__u8 transceiver;
2525+
__u8 master_slave_cfg;
2526+
__u8 master_slave_state;
2527+
__u8 rate_matching;
2528+
__u32 reserved[7];
2529+
#ifndef __KERNEL__
2530+
/* Linux builds with -Wflex-array-member-not-at-end but does
2531+
* not use the "link_mode_masks" member. Leave it defined for
2532+
* userspace for now, and when userspace wants to start using
2533+
* -Wfamnae, we'll need a new solution.
2534+
*/
25322535
__u32 link_mode_masks[];
25332536
/* layout of link_mode_masks fields:
25342537
* __u32 map_supported[link_mode_masks_nwords];
25352538
* __u32 map_advertising[link_mode_masks_nwords];
25362539
* __u32 map_lp_advertising[link_mode_masks_nwords];
25372540
*/
2541+
#endif
25382542
};
25392543

25402544
/**

net/ethtool/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ convert_link_ksettings_to_legacy_settings(
425425

426426
/* layout of the struct passed from/to userland */
427427
struct ethtool_link_usettings {
428-
struct ethtool_link_settings_hdr base;
428+
struct ethtool_link_settings base;
429429
struct {
430430
__u32 supported[__ETHTOOL_LINK_MODE_MASK_NU32];
431431
__u32 advertising[__ETHTOOL_LINK_MODE_MASK_NU32];

net/ethtool/linkinfo.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ struct linkinfo_req_info {
88
};
99

1010
struct linkinfo_reply_data {
11-
struct ethnl_reply_data base;
12-
struct ethtool_link_ksettings ksettings;
13-
struct ethtool_link_settings_hdr *lsettings;
11+
struct ethnl_reply_data base;
12+
struct ethtool_link_ksettings ksettings;
13+
struct ethtool_link_settings *lsettings;
1414
};
1515

1616
#define LINKINFO_REPDATA(__reply_base) \
@@ -98,7 +98,7 @@ static int
9898
ethnl_set_linkinfo(struct ethnl_req_info *req_info, struct genl_info *info)
9999
{
100100
struct ethtool_link_ksettings ksettings = {};
101-
struct ethtool_link_settings_hdr *lsettings;
101+
struct ethtool_link_settings *lsettings;
102102
struct net_device *dev = req_info->dev;
103103
struct nlattr **tb = info->attrs;
104104
bool mod = false;

net/ethtool/linkmodes.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ struct linkmodes_req_info {
1111
};
1212

1313
struct linkmodes_reply_data {
14-
struct ethnl_reply_data base;
15-
struct ethtool_link_ksettings ksettings;
16-
struct ethtool_link_settings_hdr *lsettings;
17-
bool peer_empty;
14+
struct ethnl_reply_data base;
15+
struct ethtool_link_ksettings ksettings;
16+
struct ethtool_link_settings *lsettings;
17+
bool peer_empty;
1818
};
1919

2020
#define LINKMODES_REPDATA(__reply_base) \
@@ -62,12 +62,10 @@ static int linkmodes_reply_size(const struct ethnl_req_info *req_base,
6262
{
6363
const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);
6464
const struct ethtool_link_ksettings *ksettings = &data->ksettings;
65+
const struct ethtool_link_settings *lsettings = &ksettings->base;
6566
bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;
66-
const struct ethtool_link_settings_hdr *lsettings;
6767
int len, ret;
6868

69-
lsettings = &ksettings->base;
70-
7169
len = nla_total_size(sizeof(u8)) /* LINKMODES_AUTONEG */
7270
+ nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */
7371
+ nla_total_size(sizeof(u32)) /* LINKMODES_LANES */
@@ -105,12 +103,10 @@ static int linkmodes_fill_reply(struct sk_buff *skb,
105103
{
106104
const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);
107105
const struct ethtool_link_ksettings *ksettings = &data->ksettings;
106+
const struct ethtool_link_settings *lsettings = &ksettings->base;
108107
bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;
109-
const struct ethtool_link_settings_hdr *lsettings;
110108
int ret;
111109

112-
lsettings = &ksettings->base;
113-
114110
if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_AUTONEG, lsettings->autoneg))
115111
return -EMSGSIZE;
116112

@@ -241,7 +237,7 @@ static int ethnl_update_linkmodes(struct genl_info *info, struct nlattr **tb,
241237
struct ethtool_link_ksettings *ksettings,
242238
bool *mod, const struct net_device *dev)
243239
{
244-
struct ethtool_link_settings_hdr *lsettings = &ksettings->base;
240+
struct ethtool_link_settings *lsettings = &ksettings->base;
245241
bool req_speed, req_lanes, req_duplex;
246242
const struct nlattr *master_slave_cfg, *lanes_cfg;
247243
int ret;

0 commit comments

Comments
 (0)