aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmytro Linkin <dmitrolin@mellanox.com>2019-09-13 06:42:21 -0400
committerSaeed Mahameed <saeedm@mellanox.com>2019-09-24 05:38:08 -0400
commitfe1587a7de94912ed75ba5ddbfabf0741f9f8239 (patch)
tree7be29a8d434b63f8c8a454e709705bdb789209e5
parentd22fcc806b84b9818de08b32e494f3c05dd236c7 (diff)
net/mlx5e: Fix matching on tunnel addresses type
In mlx5 parse_tunnel_attr() function dispatch on encap IP address type is performed by directly checking flow_rule_match_key() on FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS, and then on FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS. However, since those are stored in union, first check is always true if any type of encap address is set, which leads to IPv6 tunnel encap address being parsed as IPv4 by mlx5. Determine correct IP address type by checking control key first and if it set, take address type from match.key->addr_type. Fixes: d1bda7eecd88 ("net/mlx5e: Allow matching only enc_key_id/enc_dst_port for decapsulation action") Signed-off-by: Dmytro Linkin <dmitrolin@mellanox.com> Reviewed-by: Vlad Buslov <vladbu@mellanox.com> Reviewed-by: Eli Britstein <elibr@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c89
1 files changed, 53 insertions, 36 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index da7555fdb4d5..3e78a727f3e6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1664,46 +1664,63 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
1664 return err; 1664 return err;
1665 } 1665 }
1666 1666
1667 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS)) { 1667 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
1668 struct flow_match_ipv4_addrs match; 1668 struct flow_match_control match;
1669 u16 addr_type;
1669 1670
1670 flow_rule_match_enc_ipv4_addrs(rule, &match); 1671 flow_rule_match_enc_control(rule, &match);
1671 MLX5_SET(fte_match_set_lyr_2_4, headers_c, 1672 addr_type = match.key->addr_type;
1672 src_ipv4_src_ipv6.ipv4_layout.ipv4,
1673 ntohl(match.mask->src));
1674 MLX5_SET(fte_match_set_lyr_2_4, headers_v,
1675 src_ipv4_src_ipv6.ipv4_layout.ipv4,
1676 ntohl(match.key->src));
1677
1678 MLX5_SET(fte_match_set_lyr_2_4, headers_c,
1679 dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
1680 ntohl(match.mask->dst));
1681 MLX5_SET(fte_match_set_lyr_2_4, headers_v,
1682 dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
1683 ntohl(match.key->dst));
1684
1685 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype);
1686 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype, ETH_P_IP);
1687 } else if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS)) {
1688 struct flow_match_ipv6_addrs match;
1689 1673
1690 flow_rule_match_enc_ipv6_addrs(rule, &match); 1674 /* For tunnel addr_type used same key id`s as for non-tunnel */
1691 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c, 1675 if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
1692 src_ipv4_src_ipv6.ipv6_layout.ipv6), 1676 struct flow_match_ipv4_addrs match;
1693 &match.mask->src, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6));
1694 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
1695 src_ipv4_src_ipv6.ipv6_layout.ipv6),
1696 &match.key->src, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6));
1697 1677
1698 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c, 1678 flow_rule_match_enc_ipv4_addrs(rule, &match);
1699 dst_ipv4_dst_ipv6.ipv6_layout.ipv6), 1679 MLX5_SET(fte_match_set_lyr_2_4, headers_c,
1700 &match.mask->dst, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6)); 1680 src_ipv4_src_ipv6.ipv4_layout.ipv4,
1701 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v, 1681 ntohl(match.mask->src));
1702 dst_ipv4_dst_ipv6.ipv6_layout.ipv6), 1682 MLX5_SET(fte_match_set_lyr_2_4, headers_v,
1703 &match.key->dst, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6)); 1683 src_ipv4_src_ipv6.ipv4_layout.ipv4,
1684 ntohl(match.key->src));
1704 1685
1705 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype); 1686 MLX5_SET(fte_match_set_lyr_2_4, headers_c,
1706 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype, ETH_P_IPV6); 1687 dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
1688 ntohl(match.mask->dst));
1689 MLX5_SET(fte_match_set_lyr_2_4, headers_v,
1690 dst_ipv4_dst_ipv6.ipv4_layout.ipv4,
1691 ntohl(match.key->dst));
1692
1693 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
1694 ethertype);
1695 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype,
1696 ETH_P_IP);
1697 } else if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
1698 struct flow_match_ipv6_addrs match;
1699
1700 flow_rule_match_enc_ipv6_addrs(rule, &match);
1701 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
1702 src_ipv4_src_ipv6.ipv6_layout.ipv6),
1703 &match.mask->src, MLX5_FLD_SZ_BYTES(ipv6_layout,
1704 ipv6));
1705 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
1706 src_ipv4_src_ipv6.ipv6_layout.ipv6),
1707 &match.key->src, MLX5_FLD_SZ_BYTES(ipv6_layout,
1708 ipv6));
1709
1710 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
1711 dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
1712 &match.mask->dst, MLX5_FLD_SZ_BYTES(ipv6_layout,
1713 ipv6));
1714 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
1715 dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
1716 &match.key->dst, MLX5_FLD_SZ_BYTES(ipv6_layout,
1717 ipv6));
1718
1719 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c,
1720 ethertype);
1721 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype,
1722 ETH_P_IPV6);
1723 }
1707 } 1724 }
1708 1725
1709 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IP)) { 1726 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IP)) {