net: sched: initialize with 0 before setting erspan md->u

In fl_set_erspan_opt(), all bits of erspan md was set 1, as this
function is also used to set opt MASK. However, when setting for
md->u.index for opt VALUE, the rest bits of the union md->u will
be left 1. It would cause to fail the match of the whole md when
version is 1 and only index is set.

This patch is to fix by initializing with 0 before setting erspan
md->u.

Reported-by: Shuang Li <shuali@redhat.com>
Fixes: 79b1011cb3 ("net: sched: allow flower to match erspan options")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Xin Long 2020-09-13 19:43:03 +08:00 committed by David S. Miller
parent ad7b27c9e6
commit 8e1b3ac478
1 changed files with 1 additions and 0 deletions

View File

@ -1223,6 +1223,7 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
} }
if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]) { if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]) {
nla = 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); md->u.index = nla_get_be32(nla);
} }
} else if (md->version == 2) { } else if (md->version == 2) {