Skip to content

Commit 2922078

Browse files
lxindavem330
authored andcommitted
net: sched: fix erspan_opt settings in cls_flower
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: 79b1011 ("net: sched: allow flower to match erspan options") Reported-by: Shuang Li <[email protected]> Signed-off-by: Xin Long <[email protected]> Reviewed-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9407190 commit 2922078

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/sched/cls_flower.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,6 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
13691369
int err;
13701370

13711371
md = (struct erspan_metadata *)&key->enc_opts.data[key->enc_opts.len];
1372-
memset(md, 0xff, sizeof(*md));
13731372
md->version = 1;
13741373

13751374
if (!depth)
@@ -1398,9 +1397,9 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
13981397
NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option index");
13991398
return -EINVAL;
14001399
}
1400+
memset(&md->u.index, 0xff, sizeof(md->u.index));
14011401
if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]) {
14021402
nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX];
1403-
memset(&md->u, 0x00, sizeof(md->u));
14041403
md->u.index = nla_get_be32(nla);
14051404
}
14061405
} else if (md->version == 2) {
@@ -1409,10 +1408,12 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
14091408
NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option dir or hwid");
14101409
return -EINVAL;
14111410
}
1411+
md->u.md2.dir = 1;
14121412
if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR]) {
14131413
nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR];
14141414
md->u.md2.dir = nla_get_u8(nla);
14151415
}
1416+
set_hwid(&md->u.md2, 0xff);
14161417
if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID]) {
14171418
nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID];
14181419
set_hwid(&md->u.md2, nla_get_u8(nla));

0 commit comments

Comments
 (0)