2024-05-03 10:55:49

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 0/3] 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(-)

--
2.43.0



2024-05-03 10:56:03

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports()

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 <[email protected]>
---
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


2024-05-03 10:56:13

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 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.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
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


2024-05-03 10:57:07

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused()

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 <[email protected]>
---
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


2024-05-04 14:59:36

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH net-next 1/3] net: qede: use return from qede_parse_actions() for flow_spec

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 <[email protected]>

Reviewed-by: Simon Horman <[email protected]>


2024-05-04 14:59:50

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH net-next 2/3] net: qede: use return from qede_flow_spec_validate_unused()

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 <[email protected]>

Reviewed-by: Simon Horman <[email protected]>


2024-05-04 15:00:26

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH net-next 3/3] net: qede: use return from qede_flow_parse_ports()

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 <[email protected]>

Reviewed-by: Simon Horman <[email protected]>


2024-05-07 09:20:55

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next 0/3] net: qede: don't restrict error codes

Hello:

This series was applied to netdev/net-next.git (main)
by Paolo Abeni <[email protected]>:

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