Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3426734pxf; Mon, 29 Mar 2021 01:46:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUaobzhqMKlT3PLT32CyE86XElnZSANDKEAsJEcf2sQe7FZWJoY7uiP3UlPVw7TN3oc2mF X-Received: by 2002:a05:6402:13ca:: with SMTP id a10mr27387909edx.320.1617007579046; Mon, 29 Mar 2021 01:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007579; cv=none; d=google.com; s=arc-20160816; b=LDMPkv14Q7Bko1iZuQ9t9b/poz3+LQIR5zZAVvZwnFlOXDSsTBlv96smAUB66bTqKY x3uXZoVVsgSiPy3b0nzyQB8Ga8N9is8AF2fDBzBTHOv1Kl5pxMHh4Eet2XqfdE6E2M9j HfkKuwmdlhyuoLbX6IhR9y4wMV3Z8bgmhSQBrcPHg8b6XMa7loLcceFyZ3RIAUhZVdfJ +qdh77JJBtkfVe7jST/O3HvwOtspr6ZP0Hz9ft5NTbkM5rXPcS5eesc6tmsUyQlrR/ps pfcEC4kzZlaDhzeJ5QvPc3G6C58SK/ECQFErnlY+X9H/qCXW3ehfcEe5OWPs/3h0WnNf MTlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mwerJKjNQdCJ7Tsa202CXAKIKsssK/ZRfTuHpmEUb/s=; b=mHB25cTt++NGBRgUVLd2tRlxOsnc9Wvkr1fTWw/7IE7+Hgn2spTywT/pIpy6vidgA4 dNfaTT2YsrPdZ3C866rxU27Ir3UZuepaM4OBbCtSb79hfb3l9ZjXfLqcviaFSoiNoaSL Evm7cxI71YcMfiA/wDypwzqMe2rE/zRlF20hwBkDnwbkwadoOvnImnyC4HaVln0uKflI xo5oboA7MMax8OQL2Zm9+Waib668Nc0LYmaGWNDQMX2i3DeORy8E6xxahSvmwcu9VeFO neO0Sy5GVpA5WHTRfOsMFofneucRI+5RYGVDxfiaLBG3VUUplz+imzoAaSek+6rUXTWp sxdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cc4UhNT8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd42si12894827ejc.727.2021.03.29.01.45.56; Mon, 29 Mar 2021 01:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cc4UhNT8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235346AbhC2Imm (ORCPT + 99 others); Mon, 29 Mar 2021 04:42:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:42390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232736AbhC2IYX (ORCPT ); Mon, 29 Mar 2021 04:24:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5AFC61581; Mon, 29 Mar 2021 08:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006252; bh=7CXtOLV9GsnVvCr7BJ+Vlm1+8Y2DrCcxIorQIc2cc0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cc4UhNT8sVVU6HyY7fBEZ+NooorDWV4e85ayIviTvZxtmtObDjcSZAmx2+47GITow Ogn5OVczzw45Ucu5yMNe2unv6ebSBNWnAtxFmBewdIUoaCsRA2cn/WqjZtJ0Iqnv0H KhC3jYYuk8anAkyV61zWMRpACgG654+6nQivORJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dima Chumak , Paul Blakey , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.10 172/221] net/mlx5e: Offload tuple rewrite for non-CT flows Date: Mon, 29 Mar 2021 09:58:23 +0200 Message-Id: <20210329075634.893922952@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dima Chumak [ Upstream commit 96b5b4585843e3c83fb1930e5dfbefd0fb889c55 ] Setting connection tracking OVS flows and then setting non-CT flows that use tuple rewrite action (e.g. mod_tp_dst), causes the latter flows not being offloaded. Fix by using a stricter condition in modify_header_match_supported() to check tuple rewrite support only for flows with CT action. The check is factored out into standalone modify_tuple_supported() function to aid readability. Fixes: 7e36feeb0467 ("net/mlx5e: CT: Don't offload tuple rewrites for established tuples") Signed-off-by: Dima Chumak Reviewed-by: Paul Blakey Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 3 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 44 ++++++++++++++----- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c index 24e2c0d955b9..b42396df3111 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c @@ -1182,7 +1182,8 @@ int mlx5_tc_ct_add_no_trk_match(struct mlx5_flow_spec *spec) mlx5e_tc_match_to_reg_get_match(spec, CTSTATE_TO_REG, &ctstate, &ctstate_mask); - if (ctstate_mask) + + if ((ctstate & ctstate_mask) == MLX5_CT_STATE_TRK_BIT) return -EOPNOTSUPP; ctstate_mask |= MLX5_CT_STATE_TRK_BIT; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 77ee24d52203..930f19c598bb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3210,6 +3210,37 @@ static int is_action_keys_supported(const struct flow_action_entry *act, return 0; } +static bool modify_tuple_supported(bool modify_tuple, bool ct_clear, + bool ct_flow, struct netlink_ext_ack *extack, + struct mlx5e_priv *priv, + struct mlx5_flow_spec *spec) +{ + if (!modify_tuple || ct_clear) + return true; + + if (ct_flow) { + NL_SET_ERR_MSG_MOD(extack, + "can't offload tuple modification with non-clear ct()"); + netdev_info(priv->netdev, + "can't offload tuple modification with non-clear ct()"); + return false; + } + + /* Add ct_state=-trk match so it will be offloaded for non ct flows + * (or after clear action), as otherwise, since the tuple is changed, + * we can't restore ct state + */ + if (mlx5_tc_ct_add_no_trk_match(spec)) { + NL_SET_ERR_MSG_MOD(extack, + "can't offload tuple modification with ct matches and no ct(clear) action"); + netdev_info(priv->netdev, + "can't offload tuple modification with ct matches and no ct(clear) action"); + return false; + } + + return true; +} + static bool modify_header_match_supported(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec, struct flow_action *flow_action, @@ -3248,18 +3279,9 @@ static bool modify_header_match_supported(struct mlx5e_priv *priv, return err; } - /* Add ct_state=-trk match so it will be offloaded for non ct flows - * (or after clear action), as otherwise, since the tuple is changed, - * we can't restore ct state - */ - if (!ct_clear && modify_tuple && - mlx5_tc_ct_add_no_trk_match(spec)) { - NL_SET_ERR_MSG_MOD(extack, - "can't offload tuple modify header with ct matches"); - netdev_info(priv->netdev, - "can't offload tuple modify header with ct matches"); + if (!modify_tuple_supported(modify_tuple, ct_clear, ct_flow, extack, + priv, spec)) return false; - } ip_proto = MLX5_GET(fte_match_set_lyr_2_4, headers_v, ip_protocol); if (modify_ip_header && ip_proto != IPPROTO_TCP && -- 2.30.1