summaryrefslogtreecommitdiffstats
path: root/net/ethtool
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2023-04-18 13:14:55 +0200
committerJakub Kicinski <kuba@kernel.org>2023-04-21 05:03:21 +0200
commit35b288d6e3d467f6f7bf466fee6184b275999f14 (patch)
tree0715846cd3a23682f8cb36a09cf8e77d211375c9 /net/ethtool
parentnet: enetc: include MAC Merge / FP registers in register dump (diff)
downloadlinux-35b288d6e3d467f6f7bf466fee6184b275999f14.tar.xz
linux-35b288d6e3d467f6f7bf466fee6184b275999f14.zip
net: ethtool: mm: sanitize some UAPI configurations
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 <vladimir.oltean@nxp.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/ethtool')
-rw-r--r--net/ethtool/mm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c
index e00d7d5cea7e..4058a557b5a4 100644
--- a/net/ethtool/mm.c
+++ b/net/ethtool/mm.c
@@ -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;
}