From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 71862C43331 for ; Fri, 6 Sep 2019 00:04:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91FC7206BB for ; Fri, 6 Sep 2019 00:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390384AbfIFAEP (ORCPT ); Thu, 5 Sep 2019 20:04:15 -0400 Received: from correo.us.es ([193.147.175.20]:59552 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389694AbfIFAEP (ORCPT ); Thu, 5 Sep 2019 20:04:15 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 42C20DA3D8 for ; Fri, 6 Sep 2019 02:04:11 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 33DECDA4CA for ; Fri, 6 Sep 2019 02:04:11 +0200 (CEST) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id 1D3C5B8009; Fri, 6 Sep 2019 02:04:11 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id D8672DA72F; Fri, 6 Sep 2019 02:04:08 +0200 (CEST) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Fri, 06 Sep 2019 02:04:08 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from salvia.here (sys.soleta.eu [212.170.55.40]) (Authenticated sender: pneira@us.es) by entrada.int (Postfix) with ESMTPA id 769734265A5A; Fri, 6 Sep 2019 02:04:08 +0200 (CEST) X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, jakub.kicinski@netronome.com, jiri@resnulli.us, saeedm@mellanox.com, vishal@chelsio.com, vladbu@mellanox.com Subject: [PATCH net-next,v3 1/4] net: flow_offload: flip mangle action mask Date: Fri, 6 Sep 2019 02:04:00 +0200 Message-Id: <20190906000403.3701-2-pablo@netfilter.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190906000403.3701-1-pablo@netfilter.org> References: <20190906000403.3701-1-pablo@netfilter.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Userspace tc pedit action performs a bitwise NOT operation on the mask. All of the existing drivers in the tree undo this operation. Prepare the mangle mask in the way the drivers expect from the tc_setup_flow_action() function. Signed-off-by: Pablo Neira Ayuso --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 12 ++++++------ drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 +++--- drivers/net/ethernet/netronome/nfp/flower/action.c | 8 ++++---- net/sched/cls_api.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c index e447976bdd3e..2d26dbca701d 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c @@ -275,7 +275,7 @@ static int cxgb4_validate_flow_match(struct net_device *dev, static void offload_pedit(struct ch_filter_specification *fs, u32 val, u32 mask, u8 field) { - u32 set_val = val & ~mask; + u32 set_val = val & mask; u32 offset = 0; u8 size = 1; int i; @@ -301,7 +301,7 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val, offload_pedit(fs, val, mask, ETH_DMAC_31_0); break; case PEDIT_ETH_DMAC_47_32_SMAC_15_0: - if (~mask & PEDIT_ETH_DMAC_MASK) + if (mask & PEDIT_ETH_DMAC_MASK) offload_pedit(fs, val, mask, ETH_DMAC_47_32); else offload_pedit(fs, val >> 16, mask >> 16, @@ -353,7 +353,7 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val, case FLOW_ACT_MANGLE_HDR_TYPE_TCP: switch (offset) { case PEDIT_TCP_SPORT_DPORT: - if (~mask & PEDIT_TCP_UDP_SPORT_MASK) + if (mask & PEDIT_TCP_UDP_SPORT_MASK) offload_pedit(fs, cpu_to_be32(val) >> 16, cpu_to_be32(mask) >> 16, TCP_SPORT); @@ -366,7 +366,7 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val, case FLOW_ACT_MANGLE_HDR_TYPE_UDP: switch (offset) { case PEDIT_UDP_SPORT_DPORT: - if (~mask & PEDIT_TCP_UDP_SPORT_MASK) + if (mask & PEDIT_TCP_UDP_SPORT_MASK) offload_pedit(fs, cpu_to_be32(val) >> 16, cpu_to_be32(mask) >> 16, UDP_SPORT); @@ -510,7 +510,7 @@ static bool valid_pedit_action(struct net_device *dev, case FLOW_ACT_MANGLE_HDR_TYPE_TCP: switch (offset) { case PEDIT_TCP_SPORT_DPORT: - if (!valid_l4_mask(~mask)) { + if (!valid_l4_mask(mask)) { netdev_err(dev, "%s: Unsupported mask for TCP L4 ports\n", __func__); return false; @@ -525,7 +525,7 @@ static bool valid_pedit_action(struct net_device *dev, case FLOW_ACT_MANGLE_HDR_TYPE_UDP: switch (offset) { case PEDIT_UDP_SPORT_DPORT: - if (!valid_l4_mask(~mask)) { + if (!valid_l4_mask(mask)) { netdev_err(dev, "%s: Unsupported mask for UDP L4 ports\n", __func__); return false; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 30d26eba75a3..3db63cf41ee5 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -2509,7 +2509,7 @@ static int parse_tc_pedit_action(struct mlx5e_priv *priv, val = act->mangle.val; offset = act->mangle.offset; - err = set_pedit_val(htype, ~mask, val, offset, &hdrs[cmd]); + err = set_pedit_val(htype, mask, val, offset, &hdrs[cmd]); if (err) goto out_err; @@ -2609,7 +2609,7 @@ static bool is_action_keys_supported(const struct flow_action_entry *act) htype = act->mangle.htype; offset = act->mangle.offset; - mask = ~act->mangle.mask; + mask = act->mangle.mask; /* For IPv4 & IPv6 header check 4 byte word, * to determine that modified fields * are NOT ttl & hop_limit only. @@ -2733,7 +2733,7 @@ static int add_vlan_rewrite_action(struct mlx5e_priv *priv, int namespace, .id = FLOW_ACTION_MANGLE, .mangle.htype = FLOW_ACT_MANGLE_HDR_TYPE_ETH, .mangle.offset = offsetof(struct vlan_ethhdr, h_vlan_TCI), - .mangle.mask = ~(u32)be16_to_cpu(*(__be16 *)&mask16), + .mangle.mask = (u32)be16_to_cpu(*(__be16 *)&mask16), .mangle.val = (u32)be16_to_cpu(*(__be16 *)&val16), }; u8 match_prio_mask, match_prio_val; diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index 1b019fdfcd97..ee0066a7ba87 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -495,7 +495,7 @@ nfp_fl_set_eth(const struct flow_action_entry *act, u32 off, return -EOPNOTSUPP; } - mask = ~act->mangle.mask; + mask = act->mangle.mask; exact = act->mangle.val; if (exact & ~mask) { @@ -532,7 +532,7 @@ nfp_fl_set_ip4(const struct flow_action_entry *act, u32 off, __be32 exact, mask; /* We are expecting tcf_pedit to return a big endian value */ - mask = (__force __be32)~act->mangle.mask; + mask = (__force __be32)act->mangle.mask; exact = (__force __be32)act->mangle.val; if (exact & ~mask) { @@ -673,7 +673,7 @@ nfp_fl_set_ip6(const struct flow_action_entry *act, u32 off, u8 word; /* We are expecting tcf_pedit to return a big endian value */ - mask = (__force __be32)~act->mangle.mask; + mask = (__force __be32)act->mangle.mask; exact = (__force __be32)act->mangle.val; if (exact & ~mask) { @@ -713,7 +713,7 @@ nfp_fl_set_tport(const struct flow_action_entry *act, u32 off, return -EOPNOTSUPP; } - mask = ~act->mangle.mask; + mask = act->mangle.mask; exact = act->mangle.val; if (exact & ~mask) { diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 671ca905dbb5..fbab004d0075 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3379,7 +3379,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, goto err_out; } entry->mangle.htype = tcf_pedit_htype(act, k); - entry->mangle.mask = tcf_pedit_mask(act, k); + entry->mangle.mask = ~tcf_pedit_mask(act, k); entry->mangle.val = tcf_pedit_val(act, k); entry->mangle.offset = tcf_pedit_offset(act, k); entry = &flow_action->entries[++j]; -- 2.11.0