mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
net: sched: fix erspan_opt settings in cls_flower
[ Upstream commit 292207809486d99c78068d3f459cbbbffde88415 ]
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: 79b1011cb3 ("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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8009cdcc49
commit
082b0dac78
@@ -1279,7 +1279,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)
|
||||
@@ -1308,9 +1307,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) {
|
||||
@@ -1319,10 +1318,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));
|
||||
|
||||
Reference in New Issue
Block a user