From: Simon Horman <hidden> Date: 2021-02-23 13:26:01
From: Yinjun Zhang <redacted>
The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
count and skip the error path, since the attrs
tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
are NULL in this case when recent ethtool is used.
Tested using ethtool v5.10.
Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core")
Signed-off-by: Yinjun Zhang <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Louis Peens <redacted>
---
net/ethtool/channels.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
@@ -175,14 +175,14 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)/* ensure there is at least one RX and one TX channel */if(!channels.combined_count&&!channels.rx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_RX_COUNT];elseif(!channels.combined_count&&!channels.tx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_TX_COUNT];elseerr_attr=NULL;if(err_attr){-if(mod_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];ret=-EINVAL;NL_SET_ERR_MSG_ATTR(info->extack,err_attr,"requested channel counts would result in no RX or TX channel being configured");gotoout_ops;
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-02-23 17:02:26
On Tue, 23 Feb 2021 14:24:40 +0100 Simon Horman wrote:
From: Yinjun Zhang <redacted>
The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
count and skip the error path, since the attrs
tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
are NULL in this case when recent ethtool is used.
Tested using ethtool v5.10.
Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core")
Signed-off-by: Yinjun Zhang <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Louis Peens <redacted>
Please make sure you CC Michal on ethtool patches.
@@ -175,14 +175,14 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)/* ensure there is at least one RX and one TX channel */if(!channels.combined_count&&!channels.rx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_RX_COUNT];elseif(!channels.combined_count&&!channels.tx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_TX_COUNT];elseerr_attr=NULL;if(err_attr){-if(mod_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];ret=-EINVAL;NL_SET_ERR_MSG_ATTR(info->extack,err_attr,"requested channel counts would result in no RX or TX channel being configured");gotoout_ops;
In case driver decides to adjust max counts - I'd lean towards:
@@ -157,34 +157,34 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)/* ensure new channel counts are within limits */if(channels.rx_count>channels.max_rx)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_RX_COUNT;elseif(channels.tx_count>channels.max_tx)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_TX_COUNT;elseif(channels.other_count>channels.max_other)-err_attr=tb[ETHTOOL_A_CHANNELS_OTHER_COUNT];+err_attr=ETHTOOL_A_CHANNELS_OTHER_COUNT;elseif(channels.combined_count>channels.max_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];+err_attr=ETHTOOL_A_CHANNELS_COMBINED_COUNT;else-err_attr=NULL;+err_attr=0;if(err_attr){ret=-EINVAL;-NL_SET_ERR_MSG_ATTR(info->extack,err_attr,+NL_SET_ERR_MSG_ATTR(info->extack,tb[err_attr],"requested channel count exceeds maximum");gotoout_ops;}/* ensure there is at least one RX and one TX channel */if(!channels.combined_count&&!channels.rx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_RX_COUNT;elseif(!channels.combined_count&&!channels.tx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_TX_COUNT;else-err_attr=NULL;+err_attr=0;if(err_attr){if(mod_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];+err_attr=ETHTOOL_A_CHANNELS_COMBINED_COUNT;ret=-EINVAL;-NL_SET_ERR_MSG_ATTR(info->extack,err_attr,"requested channel counts would result in no RX or TX channel being configured");+NL_SET_ERR_MSG_ATTR(info->extack,tb[err_attr],"requested channel counts would result in no RX or TX channel being configured");gotoout_ops;}
From: Michal Kubecek <hidden> Date: 2021-02-24 01:05:46
On Tue, Feb 23, 2021 at 09:01:06AM -0800, Jakub Kicinski wrote:
On Tue, 23 Feb 2021 14:24:40 +0100 Simon Horman wrote:
quoted
From: Yinjun Zhang <redacted>
The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
count and skip the error path, since the attrs
tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
are NULL in this case when recent ethtool is used.
Tested using ethtool v5.10.
Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core")
Signed-off-by: Yinjun Zhang <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Louis Peens <redacted>
Please make sure you CC Michal on ethtool patches.
@@ -175,14 +175,14 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)/* ensure there is at least one RX and one TX channel */if(!channels.combined_count&&!channels.rx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_RX_COUNT];elseif(!channels.combined_count&&!channels.tx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_TX_COUNT];elseerr_attr=NULL;if(err_attr){-if(mod_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];ret=-EINVAL;NL_SET_ERR_MSG_ATTR(info->extack,err_attr,"requested channel counts would result in no RX or TX channel being configured");gotoout_ops;
In case driver decides to adjust max counts - I'd lean towards:
I missed this note while reading the e-mail for the first time so I
thouoght this was just a cleanup. You are right, this would address both
issues.
Michal
@@ -157,34 +157,34 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)/* ensure new channel counts are within limits */if(channels.rx_count>channels.max_rx)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_RX_COUNT;elseif(channels.tx_count>channels.max_tx)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_TX_COUNT;elseif(channels.other_count>channels.max_other)-err_attr=tb[ETHTOOL_A_CHANNELS_OTHER_COUNT];+err_attr=ETHTOOL_A_CHANNELS_OTHER_COUNT;elseif(channels.combined_count>channels.max_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];+err_attr=ETHTOOL_A_CHANNELS_COMBINED_COUNT;else-err_attr=NULL;+err_attr=0;if(err_attr){ret=-EINVAL;-NL_SET_ERR_MSG_ATTR(info->extack,err_attr,+NL_SET_ERR_MSG_ATTR(info->extack,tb[err_attr],"requested channel count exceeds maximum");gotoout_ops;}/* ensure there is at least one RX and one TX channel */if(!channels.combined_count&&!channels.rx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_RX_COUNT;elseif(!channels.combined_count&&!channels.tx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=ETHTOOL_A_CHANNELS_TX_COUNT;else-err_attr=NULL;+err_attr=0;if(err_attr){if(mod_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];+err_attr=ETHTOOL_A_CHANNELS_COMBINED_COUNT;ret=-EINVAL;-NL_SET_ERR_MSG_ATTR(info->extack,err_attr,"requested channel counts would result in no RX or TX channel being configured");+NL_SET_ERR_MSG_ATTR(info->extack,tb[err_attr],"requested channel counts would result in no RX or TX channel being configured");gotoout_ops;}
From: Michal Kubecek <hidden> Date: 2021-02-24 01:05:48
On Tue, Feb 23, 2021 at 02:24:40PM +0100, Simon Horman wrote:
From: Yinjun Zhang <redacted>
The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
count and skip the error path, since the attrs
tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
are NULL in this case when recent ethtool is used.
Tested using ethtool v5.10.
Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core")
Signed-off-by: Yinjun Zhang <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Louis Peens <redacted>
@@ -175,14 +175,14 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)/* ensure there is at least one RX and one TX channel */if(!channels.combined_count&&!channels.rx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_RX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_RX_COUNT];elseif(!channels.combined_count&&!channels.tx_count)-err_attr=tb[ETHTOOL_A_CHANNELS_TX_COUNT];+err_attr=mod_combined?tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]:+tb[ETHTOOL_A_CHANNELS_TX_COUNT];elseerr_attr=NULL;if(err_attr){-if(mod_combined)-err_attr=tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT];ret=-EINVAL;NL_SET_ERR_MSG_ATTR(info->extack,err_attr,"requested channel counts would result in no RX or TX channel being configured");gotoout_ops;
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-02-24 01:08:39
On Wed, 24 Feb 2021 01:32:51 +0100 Michal Kubecek wrote:
On Tue, Feb 23, 2021 at 02:24:40PM +0100, Simon Horman wrote:
quoted
From: Yinjun Zhang <redacted>
The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
count and skip the error path, since the attrs
tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
are NULL in this case when recent ethtool is used.
Tested using ethtool v5.10.
Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core")
Signed-off-by: Yinjun Zhang <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Louis Peens <redacted>
From: Michal Kubecek <hidden> Date: 2021-02-24 01:27:58
On Tue, Feb 23, 2021 at 05:02:06PM -0800, Jakub Kicinski wrote:
On Wed, 24 Feb 2021 01:32:51 +0100 Michal Kubecek wrote:
quoted
On Tue, Feb 23, 2021 at 02:24:40PM +0100, Simon Horman wrote:
quoted
From: Yinjun Zhang <redacted>
The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
count and skip the error path, since the attrs
tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
are NULL in this case when recent ethtool is used.
Tested using ethtool v5.10.
Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core")
Signed-off-by: Yinjun Zhang <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Louis Peens <redacted>
Reviewed-by: Michal Kubecek <redacted>
IOW you prefer this to what I proposed?
No, that was my misunderstanding, please see my reply to your e-mail.
Michal
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-02-24 01:28:36
On Tue, 23 Feb 2021 17:02:06 -0800 Jakub Kicinski wrote:
On Wed, 24 Feb 2021 01:32:51 +0100 Michal Kubecek wrote:
quoted
On Tue, Feb 23, 2021 at 02:24:40PM +0100, Simon Horman wrote:
quoted
From: Yinjun Zhang <redacted>
The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
count and skip the error path, since the attrs
tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
are NULL in this case when recent ethtool is used.
Tested using ethtool v5.10.
Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core")
Signed-off-by: Yinjun Zhang <redacted>
Signed-off-by: Simon Horman <redacted>
Signed-off-by: Louis Peens <redacted>