net: qede: don't restrict error codes
Subsystems (3)
cover net: qede: don't restrict error codes
This series fixes the qede driver, so that when a helper function fails, then the callee should return the returned error code, instead just assuming that the error is eg. -EINVAL.
The patches in this series, reduces the change of future bugs, so new error codes can be returned from the helpers, without having to update the call sites.
This is a follow-up to my recent series "net: qede: avoid overruling error codes", which fixed the cases where the implicit assumption of failing with specific error codes had been broken.
https://lore.kernel.org/netdev/[email protected]/
Asbjørn Sloth Tønnesen (3):
net: qede: use return from qede_parse_actions() for flow_spec
net: qede: use return from qede_flow_spec_validate_unused()
net: qede: use return from qede_flow_parse_ports()
.../net/ethernet/qlogic/qede/qede_filter.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 net: qede: use return from qede_parse_actions() for flow_spec
In qede_flow_spec_to_rule(), when calling qede_parse_actions() then the return code was only used for a non-zero check, and then -EINVAL was returned.
qede_parse_actions() can currently fail with:
* -EINVAL
* -EOPNOTSUPP
Commit 319a1d19471e ("flow_offload: check for basic action hw stats type") broke the implicit assumption that it could only fail with -EINVAL, by changing it to return -EOPNOTSUPP, when hardware stats are requested.
However AFAICT it's not possible to trigger qede_parse_actions() to return -EOPNOTSUPP, when called from qede_flow_spec_to_rule(), as hardware stats can't be requested by ethtool_rx_flow_rule_create().
This patch changes qede_flow_spec_to_rule() to use the actual return code from qede_parse_actions(), so it's no longer assumed that all errors are -EINVAL.
Only compile tested.
--- drivers/net/ethernet/qlogic/qede/qede_filter.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_filter.c +5 -2
@@ -1943,6 +1943,8 @@ static int qede_flow_spec_validate(struct qede_dev *edev,struct qede_arfs_tuple *t, __u32 location) { + int err; +if (location >=QEDE_RFS_MAX_FLTR ) {DP_INFO (edev,"Location out-of-bounds\n" );return -EINVAL ;
@@ -1963,8 +1965,9 @@ static int qede_flow_spec_validate(struct qede_dev *edev,return -EINVAL ; } -if (qede_parse_actions (edev, flow_action,NULL )) -return -EINVAL ; + err =qede_parse_actions (edev, flow_action,NULL ); +if (err) +return err;return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec
Quoted 20 lines · Asbjørn Sloth Tønnesen
In
qede_flow_spec_to_rule(), when callingqede_parse_actions()then the return code was only used for a non-zero check, and then-EINVALwas returned.
qede_parse_actions()can currently fail with:
*-EINVAL
*-EOPNOTSUPPCommit
319a1d19471e("flow_offload: check for basic action hw stats type") broke the implicit assumption that it could only fail with-EINVAL, by changing it to return-EOPNOTSUPP, when hardware stats are requested.However AFAICT it's not possible to trigger
qede_parse_actions()to return-EOPNOTSUPP, when called fromqede_flow_spec_to_rule(), as hardware stats can't be requested byethtool_rx_flow_rule_create().
Quoted 7 lines
This patch changes
qede_flow_spec_to_rule()to use the actual return code fromqede_parse_actions(), so it's no longer assumed that all errors are-EINVAL.Only compile tested.
Signed-off-by Asbjørn Sloth Tønnesen <[email protected]>
PATCH 2/3 net: qede: use return from qede_flow_spec_validate_unused()
In reply to Asbjørn Sloth TønnesenWhen calling qede_flow_spec_validate_unused() then the return code was only used for a non-zero check, and then -EOPNOTSUPP was returned.
qede_flow_spec_validate_unused() can currently fail with:
* -EOPNOTSUPP
This patch changes qede_flow_spec_to_rule() to use the actual return code from qede_flow_spec_validate_unused(), so it's no longer assumed that all errors are -EOPNOTSUPP.
Only compile tested.
--- drivers/net/ethernet/qlogic/qede/qede_filter.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_filter.c +4 -3
@@ -1979,10 +1979,11 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev,struct ethtool_rx_flow_spec_input input = {};struct ethtool_rx_flow_rule *flow;__be16 proto; -int err =0 ; +int err; -if (qede_flow_spec_validate_unused (edev, fs)) -return -EOPNOTSUPP ; + err =qede_flow_spec_validate_unused (edev, fs); +if (err) +return err;switch ((fs->flow_type & ~FLOW_EXT )) {case TCP_V4_FLOW :
Signature · 1 line
2.43.0
Re: [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused()
Quoted 7 lines · Asbjørn Sloth Tønnesen
When calling
qede_flow_spec_validate_unused()then the return code was only used for a non-zero check, and then-EOPNOTSUPPwas returned.
qede_flow_spec_validate_unused()can currently fail with:
*-EOPNOTSUPP
Quoted 7 lines
This patch changes
qede_flow_spec_to_rule()to use the actual return code fromqede_flow_spec_validate_unused(), so it's no longer assumed that all errors are-EOPNOTSUPP.Only compile tested.
Signed-off-by Asbjørn Sloth Tønnesen <[email protected]>
PATCH 3/3 net: qede: use return from qede_flow_parse_ports()
In reply to Asbjørn Sloth TønnesenWhen calling qede_flow_parse_ports(), then the return code was only used for a non-zero check, and then -EINVAL was returned.
qede_flow_parse_ports() can currently fail with:
* -EINVAL
This patch changes qede_flow_parse_v{4,6}_common() to use the actual return code from qede_flow_parse_ports(), so it's no longer assumed that all errors are -EINVAL.
Only compile tested.
--- drivers/net/ethernet/qlogic/qede/qede_filter.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_filter.c +9 -4
@@ -1725,6 +1725,7 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule, struct qede_arfs_tuple *t) {struct in6_addr zero_addr, addr; +int err;memset (&zero_addr,0 ,sizeof (addr));memset (&addr,0xff ,sizeof (addr));
@@ -1746,8 +1747,9 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,memcpy (&t->dst_ipv6, &match.key->dst,sizeof (addr)); } -if (qede_flow_parse_ports (edev, rule, t)) -return -EINVAL ; + err =qede_flow_parse_ports (edev, rule, t); +if (err) +return err;return qede_set_v6_tuple_to_profile (edev, t, &zero_addr); }
@@ -1756,6 +1758,8 @@ static int qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule, struct qede_arfs_tuple *t) { + int err; +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_IPV4_ADDRS )) {struct flow_match_ipv4_addrs match;
@@ -1770,8 +1774,9 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule, t->dst_ipv4 = match.key->dst; } -if (qede_flow_parse_ports (edev, rule, t)) -return -EINVAL ; + err =qede_flow_parse_ports (edev, rule, t); +if (err) +return err;return qede_set_v4_tuple_to_profile (edev, t); }
Signature · 1 line
2.43.0
Re: [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports()
Quoted 7 lines · Asbjørn Sloth Tønnesen
When calling
qede_flow_parse_ports(), then the return code was only used for a non-zero check, and then-EINVALwas returned.
qede_flow_parse_ports()can currently fail with:
*-EINVAL
Quoted 7 lines
This patch changes qede_flow_parse_v{4,6}_common() to use the actual return code from
qede_flow_parse_ports(), so it's no longer assumed that all errors are-EINVAL.Only compile tested.
Signed-off-by Asbjørn Sloth Tønnesen <[email protected]>
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 9 lines · On Fri, 3 May 2024 10:55:00 +0000 you wrote:
This series fixes the qede driver, so that when a helper function fails, then the callee should return the returned error code, instead just assuming that the error is eg.
-EINVAL.The patches in this series, reduces the change of future bugs, so new error codes can be returned from the helpers, without having to update the call sites.
[...]
Here is the summary with links:
- [net-next,1/3] net: qede: use return from qede_parse_actions() for flow_spec
https://git.kernel.org/netdev/net-next/c/146817ec3209 - [net-next,2/3] net: qede: use return from qede_flow_spec_validate_unused() https://git.kernel.org/netdev/net-next/c/e5ed2f0349bf - [net-next,3/3] net: qede: use return from qede_flow_parse_ports() https://git.kernel.org/netdev/net-next/c/c0c66eba6322
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html