* [PATCHv2 net] net: sched: fix erspan_opt settings in cls_flower
@ 2024-12-02 15:21 Xin Long
2024-12-04 0:19 ` Cong Wang
2024-12-04 10:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Xin Long @ 2024-12-02 15:21 UTC (permalink / raw)
To: network dev
Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Jamal Hadi Salim,
Cong Wang, Jiri Pirko, Davide Caratti, Simon Horman, Shuang Li
When matching erspan_opt in cls_flower, only the (version, dir, hwid)
fields are relevant. However, in fl_set_erspan_opt() it initializes
all bits of erspan_opt and its mask to 1. This inadvertently requires
packets to match not only the (version, dir, hwid) fields but also the
other fields that are unexpectedly set to 1.
This patch resolves the issue by ensuring that only the (version, dir,
hwid) fields are configured in fl_set_erspan_opt(), leaving the other
fields to 0 in erspan_opt.
Fixes: 79b1011cb33d ("net: sched: allow flower to match erspan options")
Reported-by: Shuang Li <shuali@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
v1 -> v2:
- Initialize the hwid by invoking set_hwid() with 0xff instead of 0x3f,
as suggested by Cong.
---
net/sched/cls_flower.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index e280c27cb9f9..1008ec8a464c 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -1369,7 +1369,6 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
int err;
md = (struct erspan_metadata *)&key->enc_opts.data[key->enc_opts.len];
- memset(md, 0xff, sizeof(*md));
md->version = 1;
if (!depth)
@@ -1398,9 +1397,9 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option index");
return -EINVAL;
}
+ memset(&md->u.index, 0xff, sizeof(md->u.index));
if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]) {
nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX];
- memset(&md->u, 0x00, sizeof(md->u));
md->u.index = nla_get_be32(nla);
}
} else if (md->version == 2) {
@@ -1409,10 +1408,12 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option dir or hwid");
return -EINVAL;
}
+ md->u.md2.dir = 1;
if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR]) {
nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR];
md->u.md2.dir = nla_get_u8(nla);
}
+ set_hwid(&md->u.md2, 0xff);
if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID]) {
nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID];
set_hwid(&md->u.md2, nla_get_u8(nla));
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCHv2 net] net: sched: fix erspan_opt settings in cls_flower
2024-12-02 15:21 [PATCHv2 net] net: sched: fix erspan_opt settings in cls_flower Xin Long
@ 2024-12-04 0:19 ` Cong Wang
2024-12-04 10:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Cong Wang @ 2024-12-04 0:19 UTC (permalink / raw)
To: Xin Long
Cc: network dev, davem, kuba, Eric Dumazet, Paolo Abeni,
Jamal Hadi Salim, Jiri Pirko, Davide Caratti, Simon Horman,
Shuang Li
On Mon, Dec 02, 2024 at 10:21:38AM -0500, Xin Long wrote:
> When matching erspan_opt in cls_flower, only the (version, dir, hwid)
> fields are relevant. However, in fl_set_erspan_opt() it initializes
> all bits of erspan_opt and its mask to 1. This inadvertently requires
> packets to match not only the (version, dir, hwid) fields but also the
> other fields that are unexpectedly set to 1.
>
> This patch resolves the issue by ensuring that only the (version, dir,
> hwid) fields are configured in fl_set_erspan_opt(), leaving the other
> fields to 0 in erspan_opt.
>
> Fixes: 79b1011cb33d ("net: sched: allow flower to match erspan options")
> Reported-by: Shuang Li <shuali@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Looking forward to your selftest. :)
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCHv2 net] net: sched: fix erspan_opt settings in cls_flower
2024-12-02 15:21 [PATCHv2 net] net: sched: fix erspan_opt settings in cls_flower Xin Long
2024-12-04 0:19 ` Cong Wang
@ 2024-12-04 10:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-04 10:40 UTC (permalink / raw)
To: Xin Long
Cc: netdev, davem, kuba, edumazet, pabeni, jhs, xiyou.wangcong, jiri,
dcaratti, horms, shuali
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Mon, 2 Dec 2024 10:21:38 -0500 you wrote:
> When matching erspan_opt in cls_flower, only the (version, dir, hwid)
> fields are relevant. However, in fl_set_erspan_opt() it initializes
> all bits of erspan_opt and its mask to 1. This inadvertently requires
> packets to match not only the (version, dir, hwid) fields but also the
> other fields that are unexpectedly set to 1.
>
> This patch resolves the issue by ensuring that only the (version, dir,
> hwid) fields are configured in fl_set_erspan_opt(), leaving the other
> fields to 0 in erspan_opt.
>
> [...]
Here is the summary with links:
- [PATCHv2,net] net: sched: fix erspan_opt settings in cls_flower
https://git.kernel.org/netdev/net/c/292207809486
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] 3+ messages in thread
end of thread, other threads:[~2024-12-04 10:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02 15:21 [PATCHv2 net] net: sched: fix erspan_opt settings in cls_flower Xin Long
2024-12-04 0:19 ` Cong Wang
2024-12-04 10:40 ` 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