Skip to content

Commit

Permalink
net: ethtool: mm: sanitize some UAPI configurations
Browse files Browse the repository at this point in the history
The verify-enabled boolean (ETHTOOL_A_MM_VERIFY_ENABLED) was intended to
be a sub-setting of tx-enabled (ETHTOOL_A_MM_TX_ENABLED). IOW, MAC Merge
TX can be enabled with or without verification, but verification with TX
disabled makes no sense.

The pmac-enabled boolean (ETHTOOL_A_MM_PMAC_ENABLED) was intended to be
a global toggle from an API perspective, whereas tx-enabled just handles
the TX direction. IOW, the pMAC can be enabled with or without TX, but
it doesn't make sense to enable TX if the pMAC is not enabled.

Add two checks which sanitize and reject these invalid cases.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
vladimiroltean authored and kuba-moo committed Apr 21, 2023
1 parent 16a2c76 commit 35b288d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions net/ethtool/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ static int ethnl_set_mm(struct ethnl_req_info *req_info, struct genl_info *info)
return -ERANGE;
}

if (cfg.verify_enabled && !cfg.tx_enabled) {
NL_SET_ERR_MSG(extack, "Verification requires TX enabled");
return -EINVAL;
}

if (cfg.tx_enabled && !cfg.pmac_enabled) {
NL_SET_ERR_MSG(extack, "TX enabled requires pMAC enabled");
return -EINVAL;
}

ret = dev->ethtool_ops->set_mm(dev, &cfg, extack);
return ret < 0 ? ret : 1;
}
Expand Down

0 comments on commit 35b288d

Please sign in to comment.