From patchwork Wed Apr 14 23:16:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 421525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C2D4C43460 for ; Wed, 14 Apr 2021 23:16:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48D7161164 for ; Wed, 14 Apr 2021 23:16:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236926AbhDNXQg (ORCPT ); Wed, 14 Apr 2021 19:16:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:48944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233061AbhDNXQe (ORCPT ); Wed, 14 Apr 2021 19:16:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8F2E611CC; Wed, 14 Apr 2021 23:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618442172; bh=zkggHjS2SLIru19Y3l9SQjQUyTCqTvGaIw9d87uhwCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXZ1bTgF/FKpE9CwapIqA5LQYvw57PQrTy2YDiIOmwBNoSuLoDDI/egxDhofY5LbT +X6YmoauL4VSbE8DoOfjQNv1OATItDx+2BZBf+/L671IcuAD7MH89Q6ymU0556AORJ Zz7pGq31rcjSMNzeU2uS6JN3f+fKBv3qXhGiaV8cwzVQmlz+sO/ZFwQkbADEETbp8N yXTfWiejOL+JJ0tARg36sVou+VkE0CBHIMo/2MhPIDicpF6ffjkmrGIsVDO1Iy2N4e gCEs2D50jP6fg8hFzh1lX8ARkxun1rFbrhmUyQcU9Nx5C5/SVcsnCBPO18u2GGPrAn YEpxaSh7kG4Gg== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , Aya Levin , Moshe Shemesh , Roi Dayan , Saeed Mahameed Subject: [net 1/3] net/mlx5: Fix setting of devlink traps in switchdev mode Date: Wed, 14 Apr 2021 16:16:08 -0700 Message-Id: <20210414231610.136376-2-saeed@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414231610.136376-1-saeed@kernel.org> References: <20210414231610.136376-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Aya Levin Prevent setting of devlink traps on the uplink while in switchdev mode. In this mode, it is the SW switch responsibility to handle both packets with a mismatch in destination MAC or VLAN ID. Therefore, there are no flow steering tables to trap undesirable packets and driver crashes upon setting a trap. Fixes: 241dc159391f ("net/mlx5: Notify on trap action by blocking event") Signed-off-by: Aya Levin Reviewed-by: Moshe Shemesh Reviewed-by: Roi Dayan Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index d7d8a68ef23d..d0f9d3cee97d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -246,6 +246,11 @@ static int mlx5_devlink_trap_action_set(struct devlink *devlink, struct mlx5_devlink_trap *dl_trap; int err = 0; + if (is_mdev_switchdev_mode(dev)) { + NL_SET_ERR_MSG_MOD(extack, "Devlink traps can't be set in switchdev mode"); + return -EOPNOTSUPP; + } + dl_trap = mlx5_find_trap_by_id(dev, trap->id); if (!dl_trap) { mlx5_core_err(dev, "Devlink trap: Set action on invalid trap id 0x%x", trap->id); From patchwork Wed Apr 14 23:25:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 421522 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CDADC433ED for ; Wed, 14 Apr 2021 23:25:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EA2D61220 for ; Wed, 14 Apr 2021 23:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237481AbhDNX0S (ORCPT ); Wed, 14 Apr 2021 19:26:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:49902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233459AbhDNX0O (ORCPT ); Wed, 14 Apr 2021 19:26:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B38CE61242; Wed, 14 Apr 2021 23:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618442753; bh=T7KqcsJXuzCajU7swIRrYJFoQd5vgDu/miTpVfFOxRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DmmiQomsK14szSeFW/FfGOVbOivgka0CCqvkJ4KLfHQG/5x1/Q09uu6x4uma9geoz SxWdjew002fr9h77VA6n84pD2Wc3LihbLILe4qSSqmGwWPfCncNG8aGXQNJA56EM+0 OVGVfVvhkn1/eX5HsNo1EIh9EqPyscXoLfCU5gAkeCjNZI1u2mKT5b382/pE8ILsDR WL9/QR0n1dw/r4CTv8yK4F3VoC3v0nvyMqAPKMslNxIpLjEOFM22N5dItBd9Vd+n/P s9RF1v15nJVLch/+JAwizRX98tLjDdXeg4wLWD6TyWDETLwDEFEfiz2SK3ZuVeDXaR 6yNxjDS9VtfhA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, "Cc : Steffen Klassert" , Huy Nguyen , Raed Salem Subject: [PATCH net 2/3] net/xfrm: Add inner_ipproto into sec_path Date: Wed, 14 Apr 2021 16:25:39 -0700 Message-Id: <20210414232540.138232-3-saeed@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414232540.138232-1-saeed@kernel.org> References: <20210414232540.138232-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Huy Nguyen The inner_ipproto saves the inner IP protocol of the plain text packet. This allows vendor's IPsec feature making offload decision at skb's features_check and configuring hardware at ndo_start_xmit. For example, ConnectX6-DX IPsec device needs the plaintext's IP protocol to support partial checksum offload on VXLAN/GENEVE packet over IPsec transport mode tunnel. Signed-off-by: Raed Salem Signed-off-by: Huy Nguyen Cc: Steffen Klassert --- include/net/xfrm.h | 1 + net/xfrm/xfrm_output.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index c58a6d4eb610..e535700431fb 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1032,6 +1032,7 @@ struct sec_path { struct xfrm_state *xvec[XFRM_MAX_DEPTH]; struct xfrm_offload ovec[XFRM_MAX_OFFLOAD_DEPTH]; + u8 inner_ipproto; }; struct sec_path *secpath_set(struct sk_buff *skb); diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index e4cb0ff4dcf4..da412928093b 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c @@ -565,6 +565,36 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb return 0; } +/* Save inner ip protocol for vendor offload usage */ +static void get_inner_ipproto(struct sk_buff *skb, struct sec_path *sp) +{ + const struct ethhdr *eth; + + if (!skb->inner_protocol) + return; + + if (skb->inner_protocol_type == ENCAP_TYPE_IPPROTO) { + sp->inner_ipproto = skb->inner_protocol; + return; + } + + if (skb->inner_protocol_type != ENCAP_TYPE_ETHER) + return; + + eth = (struct ethhdr *)skb_inner_mac_header(skb); + + switch (eth->h_proto) { + case ntohs(ETH_P_IPV6): + sp->inner_ipproto = inner_ipv6_hdr(skb)->nexthdr; + break; + case ntohs(ETH_P_IP): + sp->inner_ipproto = inner_ip_hdr(skb)->protocol; + break; + default: + return; + } +} + int xfrm_output(struct sock *sk, struct sk_buff *skb) { struct net *net = dev_net(skb_dst(skb)->dev); @@ -594,8 +624,12 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb) kfree_skb(skb); return -ENOMEM; } - skb->encapsulation = 1; + sp->inner_ipproto = 0; + if (skb->encapsulation) + get_inner_ipproto(skb, sp); + + skb->encapsulation = 1; sp->olen++; sp->xvec[sp->len++] = x; xfrm_state_hold(x); From patchwork Wed Apr 14 23:16:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 421524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEE38C433B4 for ; Wed, 14 Apr 2021 23:16:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 997806121E for ; Wed, 14 Apr 2021 23:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237033AbhDNXQo (ORCPT ); Wed, 14 Apr 2021 19:16:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:48958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235787AbhDNXQf (ORCPT ); Wed, 14 Apr 2021 19:16:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7DBE61244; Wed, 14 Apr 2021 23:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618442173; bh=yO+zByxMetjppPRmftdw3a+yBJ2CIIiTNlJer3JPl/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OSTXcHTuLaks0KwL5MFG6HGAjBruDQN/cFvkr2rSN2xzf9otpFvz8869FUeBPuHA1 lz+lhbbL4uPCSLNCWLiIfbRt2NfaysOgytsDU3yNlZbyj3ys9MLmKjvT0rx+7YmBoc c5qxn6BIj9JJOQ/YKW0S6jS4JoWfrXTr8ndbvsT/FaqZ46/znsvOekuCTrproxIOIC D0S+jylZN3gFH2Yd7fs8vysyw6brGVU7nLy7JmeluhuyPIg4p5a6iFdiN0dinFUFPy MvEyY7azGi2Tnt7+Qz632VK9XS0AmWQQFR45AoY8BbMJWAc4Wh2y5tREw8s4JnHBiO vYE3BCW0cw4sQ== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Tariq Toukan , wenxu , Pablo Neira Ayuso , Saeed Mahameed Subject: [net 3/3] net/mlx5e: fix ingress_ifindex check in mlx5e_flower_parse_meta Date: Wed, 14 Apr 2021 16:16:10 -0700 Message-Id: <20210414231610.136376-4-saeed@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414231610.136376-1-saeed@kernel.org> References: <20210414231610.136376-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: wenxu In the nft_offload there is the mate flow_dissector with no ingress_ifindex but with ingress_iftype that only be used in the software. So if the mask of ingress_ifindex in meta is 0, this meta check should be bypass. Fixes: 6d65bc64e232 ("net/mlx5e: Add mlx5e_flower_parse_meta support") Signed-off-by: wenxu Acked-by: Pablo Neira Ayuso Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index df2a0af854bb..d675107d9eca 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -1895,6 +1895,9 @@ static int mlx5e_flower_parse_meta(struct net_device *filter_dev, return 0; flow_rule_match_meta(rule, &match); + if (!match.mask->ingress_ifindex) + return 0; + if (match.mask->ingress_ifindex != 0xFFFFFFFF) { NL_SET_ERR_MSG_MOD(extack, "Unsupported ingress ifindex mask"); return -EOPNOTSUPP;