* [PATCH net-next 0/3] net: qede: don't restrict error codes
@ 2024-05-03 10:55 Asbjørn Sloth Tønnesen
2024-05-03 10:55 ` [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec Asbjørn Sloth Tønnesen
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2024-05-03 10:55 UTC (permalink / raw)
To: netdev
Cc: Asbjørn Sloth Tønnesen, linux-kernel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Manish Chopra
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/20240426091227.78060-1-ast@fiberby.net/
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(-)
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec
2024-05-03 10:55 [PATCH net-next 0/3] net: qede: don't restrict error codes Asbjørn Sloth Tønnesen
@ 2024-05-03 10:55 ` Asbjørn Sloth Tønnesen
2024-05-04 14:59 ` Simon Horman
2024-05-03 10:55 ` [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused() Asbjørn Sloth Tønnesen
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2024-05-03 10:55 UTC (permalink / raw)
To: netdev
Cc: Asbjørn Sloth Tønnesen, linux-kernel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Manish Chopra
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.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index cb6b33a228ea..d5ca4bf6dba5 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused()
2024-05-03 10:55 [PATCH net-next 0/3] net: qede: don't restrict error codes Asbjørn Sloth Tønnesen
2024-05-03 10:55 ` [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec Asbjørn Sloth Tønnesen
@ 2024-05-03 10:55 ` Asbjørn Sloth Tønnesen
2024-05-04 14:59 ` Simon Horman
2024-05-03 10:55 ` [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports() Asbjørn Sloth Tønnesen
2024-05-07 9:20 ` [PATCH net-next 0/3] net: qede: don't restrict error codes patchwork-bot+netdevbpf
3 siblings, 1 reply; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2024-05-03 10:55 UTC (permalink / raw)
To: netdev
Cc: Asbjørn Sloth Tønnesen, linux-kernel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Manish Chopra
When 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.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index d5ca4bf6dba5..07af0464eb1e 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -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:
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports()
2024-05-03 10:55 [PATCH net-next 0/3] net: qede: don't restrict error codes Asbjørn Sloth Tønnesen
2024-05-03 10:55 ` [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec Asbjørn Sloth Tønnesen
2024-05-03 10:55 ` [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused() Asbjørn Sloth Tønnesen
@ 2024-05-03 10:55 ` Asbjørn Sloth Tønnesen
2024-05-04 14:59 ` Simon Horman
2024-05-07 9:20 ` [PATCH net-next 0/3] net: qede: don't restrict error codes patchwork-bot+netdevbpf
3 siblings, 1 reply; 8+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2024-05-03 10:55 UTC (permalink / raw)
To: netdev
Cc: Asbjørn Sloth Tønnesen, linux-kernel, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Manish Chopra
When 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.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 07af0464eb1e..ded48523c383 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -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);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec
2024-05-03 10:55 ` [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec Asbjørn Sloth Tønnesen
@ 2024-05-04 14:59 ` Simon Horman
0 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2024-05-04 14:59 UTC (permalink / raw)
To: Asbjørn Sloth Tønnesen
Cc: netdev, linux-kernel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Manish Chopra
On Fri, May 03, 2024 at 10:55:01AM +0000, Asbjørn Sloth Tønnesen wrote:
> 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.
>
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused()
2024-05-03 10:55 ` [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused() Asbjørn Sloth Tønnesen
@ 2024-05-04 14:59 ` Simon Horman
0 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2024-05-04 14:59 UTC (permalink / raw)
To: Asbjørn Sloth Tønnesen
Cc: netdev, linux-kernel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Manish Chopra
On Fri, May 03, 2024 at 10:55:02AM +0000, Asbjørn Sloth Tønnesen wrote:
> When 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.
>
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports()
2024-05-03 10:55 ` [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports() Asbjørn Sloth Tønnesen
@ 2024-05-04 14:59 ` Simon Horman
0 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2024-05-04 14:59 UTC (permalink / raw)
To: Asbjørn Sloth Tønnesen
Cc: netdev, linux-kernel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Manish Chopra
On Fri, May 03, 2024 at 10:55:03AM +0000, Asbjørn Sloth Tønnesen wrote:
> When 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.
>
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/3] net: qede: don't restrict error codes
2024-05-03 10:55 [PATCH net-next 0/3] net: qede: don't restrict error codes Asbjørn Sloth Tønnesen
` (2 preceding siblings ...)
2024-05-03 10:55 ` [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports() Asbjørn Sloth Tønnesen
@ 2024-05-07 9:20 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-07 9:20 UTC (permalink / raw)
To: =?utf-8?b?QXNiasO4cm4gU2xvdGggVMO4bm5lc2VuIDxhc3RAZmliZXJieS5uZXQ+?=
Cc: netdev, linux-kernel, davem, edumazet, kuba, pabeni, manishc
Hello:
This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-07 9:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-03 10:55 [PATCH net-next 0/3] net: qede: don't restrict error codes Asbjørn Sloth Tønnesen
2024-05-03 10:55 ` [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec Asbjørn Sloth Tønnesen
2024-05-04 14:59 ` Simon Horman
2024-05-03 10:55 ` [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused() Asbjørn Sloth Tønnesen
2024-05-04 14:59 ` Simon Horman
2024-05-03 10:55 ` [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports() Asbjørn Sloth Tønnesen
2024-05-04 14:59 ` Simon Horman
2024-05-07 9:20 ` [PATCH net-next 0/3] net: qede: don't restrict error codes patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).