Commit bf2f3bca authored by Eli Britstein's avatar Eli Britstein Committed by Saeed Mahameed

net/mlx5e: Deny VLAN rewrite if there is no VLAN header match

Rewrite of the packet in the VLAN offset may corrupt the packet if it's
not VLAN tagged. Deny the rewrite in this case.

Fixes: 37410902874c ("net/mlx5e: Support VLAN modify action")
Signed-off-by: default avatarEli Britstein <elibr@mellanox.com>
Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 8377629e
...@@ -2292,8 +2292,19 @@ static int add_vlan_rewrite_action(struct mlx5e_priv *priv, int namespace, ...@@ -2292,8 +2292,19 @@ static int add_vlan_rewrite_action(struct mlx5e_priv *priv, int namespace,
.mangle.mask = ~(u32)be16_to_cpu(*(__be16 *)&mask16), .mangle.mask = ~(u32)be16_to_cpu(*(__be16 *)&mask16),
.mangle.val = (u32)be16_to_cpu(*(__be16 *)&val16), .mangle.val = (u32)be16_to_cpu(*(__be16 *)&val16),
}; };
void *headers_c, *headers_v;
int err; int err;
headers_c = get_match_headers_criteria(*action, &parse_attr->spec);
headers_v = get_match_headers_value(*action, &parse_attr->spec);
if (!(MLX5_GET(fte_match_set_lyr_2_4, headers_c, cvlan_tag) &&
MLX5_GET(fte_match_set_lyr_2_4, headers_v, cvlan_tag))) {
NL_SET_ERR_MSG_MOD(extack,
"VLAN rewrite action must have VLAN protocol match");
return -EOPNOTSUPP;
}
if (act->vlan.prio) { if (act->vlan.prio) {
NL_SET_ERR_MSG_MOD(extack, "Setting VLAN prio is not supported"); NL_SET_ERR_MSG_MOD(extack, "Setting VLAN prio is not supported");
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment