Skip to content

Commit

Permalink
net/mlx5: fix CVLAN tag set in IP item translation
Browse files Browse the repository at this point in the history
[ upstream commit 1908cab ]

Previous fix added, at the end of functions
flow_dv_translate_item_ipv4() and flow_dv_translate_item_ipv6(), the
setting of cvlan_tag mask.
In the case of unspecified item (item->spec == null) these functions
return, and the new code section is not reached.

This patch moves the setting of cvlan_tag mask to be done before the
check of item->spec, to make sure it is always executed.

Fixes: 797329d ("net/mlx5: fix match on ethertype and CVLAN tag")

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
  • Loading branch information
dekelp authored and kevintraynor committed May 27, 2020
1 parent 55239b5 commit 87bfc24
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions drivers/net/mlx5/mlx5_flow_dv.c
Expand Up @@ -1307,6 +1307,13 @@ flow_dv_translate_item_ipv4(void *matcher, void *key,
}
MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0xf);
MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_version, 4);
/*
* On outer header (which must contains L2), or inner header with L2,
* set cvlan_tag mask bit to mark this packet as untagged.
* This should be done even if item->spec is empty.
*/
if (!inner || item_flags & MLX5_FLOW_LAYER_INNER_L2)
MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1);
if (!ipv4_v)
return;
if (!ipv4_m)
Expand Down Expand Up @@ -1334,12 +1341,6 @@ flow_dv_translate_item_ipv4(void *matcher, void *key,
ipv4_m->hdr.next_proto_id);
MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
ipv4_v->hdr.next_proto_id & ipv4_m->hdr.next_proto_id);
/*
* On outer header (which must contains L2), or inner header with L2,
* set cvlan_tag mask bit to mark this packet as untagged.
*/
if (!inner || item_flags & MLX5_FLOW_LAYER_INNER_L2)
MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1);
}

/**
Expand Down Expand Up @@ -1399,6 +1400,13 @@ flow_dv_translate_item_ipv6(void *matcher, void *key,
}
MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_version, 0xf);
MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_version, 6);
/*
* On outer header (which must contains L2), or inner header with L2,
* set cvlan_tag mask bit to mark this packet as untagged.
* This should be done even if item->spec is empty.
*/
if (!inner || item_flags & MLX5_FLOW_LAYER_INNER_L2)
MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1);
if (!ipv6_v)
return;
if (!ipv6_m)
Expand Down Expand Up @@ -1442,12 +1450,6 @@ flow_dv_translate_item_ipv6(void *matcher, void *key,
ipv6_m->hdr.proto);
MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol,
ipv6_v->hdr.proto & ipv6_m->hdr.proto);
/*
* On outer header (which must contains L2), or inner header with L2,
* set cvlan_tag mask bit to mark this packet as untagged.
*/
if (!inner || item_flags & MLX5_FLOW_LAYER_INNER_L2)
MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1);
}

/**
Expand Down

0 comments on commit 87bfc24

Please sign in to comment.