From patchwork Thu Dec 9 07:57:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Blakey X-Patchwork-Id: 12666001 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94019C433EF for ; Thu, 9 Dec 2021 07:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234119AbhLIIBX (ORCPT ); Thu, 9 Dec 2021 03:01:23 -0500 Received: from mail-mw2nam10on2055.outbound.protection.outlook.com ([40.107.94.55]:35041 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230042AbhLIIBX (ORCPT ); Thu, 9 Dec 2021 03:01:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iPilZNUo4oOuvDrRBbl6DCCWiT5pT2t+IEFyQIS9nvTT4XJWp4sBCPDysF7NPl53ij69YtxDhqrhqm/nEMYyFizQ4xubrpxD4irY0T9+ac4UYzLLGdayT3+Y55oXSO26ChDkAKRv3A4zqgSmABw2L9p7XgyGTNuUl1z0Y/rsCLKJfzHhXLIYpaqBblLoPK2yiX5wg280+AoHsVVKbVMKFQ8KOuWNXIUtUSzHTK3V8ERbZZ3Y5EZupUBi+LWIn8NGoHmztD260W926lxwQ6Qjo7H2DstNEkJyxd7uyVH3lihcus2+VuAIwVAfMOfyCK2gi3IYECyumJXzNgx5VIHwiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=79JM/MbrmODiFRgErMjsuA+5wfvYPFNkA4dhLysjHNk=; b=RfZU26Wq+8nZIFhs9BxbWINcXYU3Z0IkFNUjaDNF1x7mEMobkxdjIBGbYr6wKXCNzJkruwE0Rr/Brlb/TRfuziefa+TsNr5FXPMTY27rlEBkJ/M9mCR+3u70bKnvrAoLZnOTPYxWabez83ZCzLd3sP6S43YVq2ql3INe/Ruqm7Rm53Fthx2BwEEEF/zKNFz8I023cO/+I/TCWYGlBh+HqpUrVN4lVO8vaJXuX9aMLrwqPE7ncqPWKQI/kx4qza8FzlDtXP6/87L+zVVal6YsPv1oNqhx9tIwgu6YhxuXQixVGUcAFDsQQFYXuzdFH2YsjYPTxSn3nH/MNXvF0kNBNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 203.18.50.13) smtp.rcpttodomain=ovn.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=79JM/MbrmODiFRgErMjsuA+5wfvYPFNkA4dhLysjHNk=; b=c8PIlYljQEaVevzX1E9+FTrYDRj4WeV4HYsQEh7neT0hGRCMyIoc8+J+ciZKqw6jXxDDtayk0dhLiM9RfRmK2+pp++UYmlag9WaVa+Ah1LekyJFuOdhNKWABfwQcyQQ0O2bo+yvO03fRZh8L/R/bKoqIQGywmhofGXYuhiYoaGLxnYIMvGnrnTjIY4DxVwJJLAh1aB0CpSxZFq+alksh2cBEtreCemkDwnmoPa0fgV8HVTJ31jaccm9We9phoNV+G6OmrLKig/Z7AeHUzh6L3xdQZnX8wRqu3A23swvRf7WZbPI2K1dAvlPflfmcIgBngF8NgKHDszu5Nud5vi8Ujg== Received: from DM5PR19CA0046.namprd19.prod.outlook.com (2603:10b6:3:9a::32) by MWHPR12MB1277.namprd12.prod.outlook.com (2603:10b6:300:f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Thu, 9 Dec 2021 07:57:48 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:3:9a:cafe::8c) by DM5PR19CA0046.outlook.office365.com (2603:10b6:3:9a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.17 via Frontend Transport; Thu, 9 Dec 2021 07:57:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 203.18.50.13) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 203.18.50.13 as permitted sender) receiver=protection.outlook.com; client-ip=203.18.50.13; helo=mail.nvidia.com; Received: from mail.nvidia.com (203.18.50.13) by DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4755.13 via Frontend Transport; Thu, 9 Dec 2021 07:57:47 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HKMAIL102.nvidia.com (10.18.16.11) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 9 Dec 2021 07:57:45 +0000 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 8 Dec 2021 23:57:43 -0800 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (172.20.187.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 9 Dec 2021 07:57:40 +0000 From: Paul Blakey To: Paul Blakey , , , Saeed Mahameed , Cong Wang , Jamal Hadi Salim , "Pravin B Shelar" , , Jiri Pirko , wenxu , Marcelo Ricardo Leitner CC: Oz Shlomo , Vlad Buslov , Roi Dayan Subject: [PATCH net v2 1/3] net/sched: Extend qdisc control block with tc control block Date: Thu, 9 Dec 2021 09:57:32 +0200 Message-ID: <20211209075734.10199-2-paulb@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20211209075734.10199-1-paulb@nvidia.com> References: <20211209075734.10199-1-paulb@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c4d89a2-11df-43b9-db0f-08d9bae99797 X-MS-TrafficTypeDiagnostic: MWHPR12MB1277:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lnyzyd24JmCdV/LcB4W0Q2urPXOoS9GifbwY51kn/xtJQ+1QaA6xgG1v+TyUIXUn0AU7mgCQVeh9iudyYJkahNGAkESR0SBL18WsVWW02OYE8DEINZnypHYL8kSVrpJd6NbdYKocNxnUZqGrAFN90qa9FKS2hj9izmstVI+dLYzRBMGkXxMfk2/TWWccv9KGqlCBk95xRUMP6RpsL2rqLyXGUV5foB+R6Ym848Be9QcUDhBxGGksZ97X2q1FIImj+z9VsKlr+yGpF/hNOuLPdVpX5kdO+nehwnDg4e7HIyC1IrlCSxk4C2r5fFHEcopOuq67J0gDaC+tdiZF3UpindFHMH/TYCqt1z/fU0xyG0onFa3NPqek6aPGZUngHB7tcK9RYIi/vIsVAVow2VhfxUeT+8/qtcWd/nOlBnFD65ef6QfwDsZ+O7hMdVK1kUXkb51LfFAcc2WPxnlOZxMzoBjSZzFDD1oVbIwVIpWZVVsYh0qx24x0ioWbU8416Vz52tUxfsT6FYniR00987hGzpl3lTdWj8X+J+sRdI7fXkRBRrh2G6eGjDCU5LtiMDnrTsLb+/9/fkmiQ8jKBnJsYIseWroxAuj1SgcQ1EDB1zSSUDrjEMwi5LcfqeVCa+iTbSCu+Si5pr+lrk4WltgWOyd9/Yq5dUPe5oamYElJ+8dm/SHaD5PZ46T460lTTSR2mbkRQ/Ue1VCcVLmrsxwwYIWXvgyDc1bRpdbndNoL4b5XI+6ygWU07ztZiupcHvU9/APBSwkXcFeiiiD4C/E+lcWryNX3BrxAUwYFWwbia4lapWquFs/qX7rieNPOZ5uq X-Forefront-Antispam-Report: CIP:203.18.50.13;CTRY:HK;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:hkhybrid02.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(40470700001)(26005)(70206006)(107886003)(83380400001)(336012)(2616005)(426003)(70586007)(4326008)(47076005)(8936002)(356005)(7636003)(5660300002)(1076003)(36860700001)(186003)(8676002)(36756003)(316002)(6666004)(86362001)(508600001)(54906003)(110136005)(82310400004)(2906002)(921005)(40460700001)(34070700002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 07:57:47.8332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c4d89a2-11df-43b9-db0f-08d9bae99797 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[203.18.50.13];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1277 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org BPF layer extends the qdisc control block via struct bpf_skb_data_end and because of that there is no more room to add variables to the qdisc layer control block without going over the skb->cb size. Extend the qdisc control block with a tc control block, and move all tc related variables to there as a pre-step for extending the tc control block with additional members. Signed-off-by: Paul Blakey --- include/net/pkt_sched.h | 15 +++++++++++++++ include/net/sch_generic.h | 2 -- net/core/dev.c | 8 ++++---- net/sched/act_ct.c | 14 +++++++------- net/sched/cls_api.c | 6 ++++-- net/sched/cls_flower.c | 3 ++- net/sched/sch_frag.c | 3 ++- 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index bf79f3a890af..05f18e81f3e8 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -193,4 +193,19 @@ static inline void skb_txtime_consumed(struct sk_buff *skb) skb->tstamp = ktime_set(0, 0); } +struct tc_skb_cb { + struct qdisc_skb_cb qdisc_cb; + + u16 mru; + bool post_ct; +}; + +static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb) +{ + struct tc_skb_cb *cb = (struct tc_skb_cb *)skb->cb; + + BUILD_BUG_ON(sizeof(*cb) > sizeof_field(struct sk_buff, cb)); + return cb; +} + #endif diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 22179b2fda72..c70e6d2b2fdd 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -447,8 +447,6 @@ struct qdisc_skb_cb { }; #define QDISC_CB_PRIV_LEN 20 unsigned char data[QDISC_CB_PRIV_LEN]; - u16 mru; - bool post_ct; }; typedef void tcf_chain_head_change_t(struct tcf_proto *tp_head, void *priv); diff --git a/net/core/dev.c b/net/core/dev.c index 2a352e668d10..c4708e2487fb 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3941,8 +3941,8 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev) return skb; /* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */ - qdisc_skb_cb(skb)->mru = 0; - qdisc_skb_cb(skb)->post_ct = false; + tc_skb_cb(skb)->mru = 0; + tc_skb_cb(skb)->post_ct = false; mini_qdisc_bstats_cpu_update(miniq, skb); switch (tcf_classify(skb, miniq->block, miniq->filter_list, &cl_res, false)) { @@ -5103,8 +5103,8 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret, } qdisc_skb_cb(skb)->pkt_len = skb->len; - qdisc_skb_cb(skb)->mru = 0; - qdisc_skb_cb(skb)->post_ct = false; + tc_skb_cb(skb)->mru = 0; + tc_skb_cb(skb)->post_ct = false; skb->tc_at_ingress = 1; mini_qdisc_bstats_cpu_update(miniq, skb); diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index 90866ae45573..98e248b9c0b1 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -690,10 +690,10 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, u8 family, u16 zone, bool *defrag) { enum ip_conntrack_info ctinfo; - struct qdisc_skb_cb cb; struct nf_conn *ct; int err = 0; bool frag; + u16 mru; /* Previously seen (loopback)? Ignore. */ ct = nf_ct_get(skb, &ctinfo); @@ -708,7 +708,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, return err; skb_get(skb); - cb = *qdisc_skb_cb(skb); + mru = tc_skb_cb(skb)->mru; if (family == NFPROTO_IPV4) { enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone; @@ -722,7 +722,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, if (!err) { *defrag = true; - cb.mru = IPCB(skb)->frag_max_size; + mru = IPCB(skb)->frag_max_size; } } else { /* NFPROTO_IPV6 */ #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) @@ -735,7 +735,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, if (!err) { *defrag = true; - cb.mru = IP6CB(skb)->frag_max_size; + mru = IP6CB(skb)->frag_max_size; } #else err = -EOPNOTSUPP; @@ -744,7 +744,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb, } if (err != -EINPROGRESS) - *qdisc_skb_cb(skb) = cb; + tc_skb_cb(skb)->mru = mru; skb_clear_hash(skb); skb->ignore_df = 1; return err; @@ -963,7 +963,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, tcf_action_update_bstats(&c->common, skb); if (clear) { - qdisc_skb_cb(skb)->post_ct = false; + tc_skb_cb(skb)->post_ct = false; ct = nf_ct_get(skb, &ctinfo); if (ct) { nf_conntrack_put(&ct->ct_general); @@ -1048,7 +1048,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, out_push: skb_push_rcsum(skb, nh_ofs); - qdisc_skb_cb(skb)->post_ct = true; + tc_skb_cb(skb)->post_ct = true; out_clear: if (defrag) qdisc_skb_cb(skb)->pkt_len = skb->len; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 2ef8f5a6205a..a5050999d607 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -1617,12 +1617,14 @@ int tcf_classify(struct sk_buff *skb, /* If we missed on some chain */ if (ret == TC_ACT_UNSPEC && last_executed_chain) { + struct tc_skb_cb *cb = tc_skb_cb(skb); + ext = tc_skb_ext_alloc(skb); if (WARN_ON_ONCE(!ext)) return TC_ACT_SHOT; ext->chain = last_executed_chain; - ext->mru = qdisc_skb_cb(skb)->mru; - ext->post_ct = qdisc_skb_cb(skb)->post_ct; + ext->mru = cb->mru; + ext->post_ct = cb->post_ct; } return ret; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index aab13ba11767..9782b93db1b3 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -309,7 +310,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res) { struct cls_fl_head *head = rcu_dereference_bh(tp->root); - bool post_ct = qdisc_skb_cb(skb)->post_ct; + bool post_ct = tc_skb_cb(skb)->post_ct; struct fl_flow_key skb_key; struct fl_flow_mask *mask; struct cls_fl_filter *f; diff --git a/net/sched/sch_frag.c b/net/sched/sch_frag.c index 8c06381391d6..5ded4c8672a6 100644 --- a/net/sched/sch_frag.c +++ b/net/sched/sch_frag.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB #include #include +#include #include #include #include @@ -137,7 +138,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb, int sch_frag_xmit_hook(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb)) { - u16 mru = qdisc_skb_cb(skb)->mru; + u16 mru = tc_skb_cb(skb)->mru; int err; if (mru && skb->len > mru + skb->dev->hard_header_len) From patchwork Thu Dec 9 07:57:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Blakey X-Patchwork-Id: 12666003 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 943D4C433EF for ; Thu, 9 Dec 2021 07:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234117AbhLIIB1 (ORCPT ); Thu, 9 Dec 2021 03:01:27 -0500 Received: from mail-dm6nam11on2045.outbound.protection.outlook.com ([40.107.223.45]:12385 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234131AbhLIIB0 (ORCPT ); Thu, 9 Dec 2021 03:01:26 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gxCpmRAT6Se8wnC5EfgbPEE7O/ye+6gU8r/5qGQ7Sb+CstGo6SCt1nrchPh/s5d/sHtX9bMlCESJw7VZMfuSnFU3Cnu1CbS+d1IIjezWaNX97F+rhi+u57Tj6NbBE9xHOaY1eLi5FDOEewXR4nGTEL7Fgsdc4so1qQJiyyOCaKSkNORa0uDyAiOXz3WzuQkjBHWw447bcdZktoIL4Ko6AAwmObX4LYPgpDoqVXvnRpHW6MjmZhY///hpnIl8kYQuxeZ9QM1kywHi8lcSYD57ptfyu8xnek1QYPqQ5j7sb4wyEAeo8PpxgYuL6gyoAMlhboOZBy9WwDp8unq/sSGv9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZlXXiG8r8e6pbaIRyMH2N1mnF7uK+P+5sq38zsgA03s=; b=h0ZChlYHaiFXcz8EQMM5STKdy/j9e3oN3JmUyMpGbaa67Bavpb+NNUtZaK34Rm7Zn1uXxkSWTFHWhuZeLHzf0EuttjKoLvhTqDKFbwt32AAYTi5XXDDE/ExEIDvCnjRqKCaJlUaymF1D9cH1/V2KsG7wj0LdLfbYn4c8a3msmzLiZnkO28qRSz2laEZKdNPxQw9Ii8N+ijeXig81pA59gOlqyk7wDTYDD0jG5EdiTjvGGBUsZ7Os9IRMstYhUVl/EXYZwjs1NX213PvPwBS/J/eWtP/CatYaLqyBYLffr39nTZe9bANsGNsZzqZU6yjCvz6L/EXRcB7SHtopQycq+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 203.18.50.14) smtp.rcpttodomain=ovn.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZlXXiG8r8e6pbaIRyMH2N1mnF7uK+P+5sq38zsgA03s=; b=K7N564DPNk+cYm2vdF07hss6J8TX2lIMGDbKPj2R6ICQ9uC/UVFpsiyAuyUqwP5fWDbUdKPccG6awSvoqlKBPqIYAQFz/7c9dpP64/lOJnVqebi+BuanUlWA0MezRtUzFxYpnjS744AWY2zeSd6AlZWXFA/DSXODDj915kgDAbg24H8UdgPfPKMWl9Z87ZJY+sRSWRnNjTKLuj2BL06/XaBCZJsf1encF7vxpP5cv7BG/g6mT9nynVpCjMOPXvJAQZCGyEWmjKb3aNv4WejeFnYETfjcFbVRoNZIw1hfaE48evNwXGWecj4DAVNxVZ7U5BJg3UZFp3J/2Zf+kpmhTw== Received: from DM5PR06CA0082.namprd06.prod.outlook.com (2603:10b6:3:4::20) by DM5PR12MB4677.namprd12.prod.outlook.com (2603:10b6:4:a4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.11; Thu, 9 Dec 2021 07:57:51 +0000 Received: from DM6NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::2b) by DM5PR06CA0082.outlook.office365.com (2603:10b6:3:4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.20 via Frontend Transport; Thu, 9 Dec 2021 07:57:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 203.18.50.14) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 203.18.50.14 as permitted sender) receiver=protection.outlook.com; client-ip=203.18.50.14; helo=mail.nvidia.com; Received: from mail.nvidia.com (203.18.50.14) by DM6NAM11FT029.mail.protection.outlook.com (10.13.173.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4755.13 via Frontend Transport; Thu, 9 Dec 2021 07:57:51 +0000 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 9 Dec 2021 07:57:49 +0000 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 9 Dec 2021 07:57:46 +0000 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (172.20.187.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 9 Dec 2021 07:57:43 +0000 From: Paul Blakey To: Paul Blakey , , , Saeed Mahameed , Cong Wang , Jamal Hadi Salim , "Pravin B Shelar" , , Jiri Pirko , wenxu , Marcelo Ricardo Leitner CC: Oz Shlomo , Vlad Buslov , Roi Dayan Subject: [PATCH net v2 2/3] net/sched: flow_dissector: Fix matching on zone id for invalid conns Date: Thu, 9 Dec 2021 09:57:33 +0200 Message-ID: <20211209075734.10199-3-paulb@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20211209075734.10199-1-paulb@nvidia.com> References: <20211209075734.10199-1-paulb@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3499898b-fc9a-4452-1eeb-08d9bae9999c X-MS-TrafficTypeDiagnostic: DM5PR12MB4677:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SYsAG5dukzK0U3oJOjE6ukZ+xToc4/gOSylEWMQp1fiK70UTw3y1hfldhLaKRqok0sv1eF9txjcjEQlX/Mc6aAReWSAYqSmCZ8raGk2aHfOYx/hOEcyhoG3dni58+gw2WUqLileuk1nogEpkC5KpGT64HYwxQ7Wln1z9FH10mOTCOPXALbXKpPFCj6xlVvC5O8d6e7+xt03E89AMrCCz9MYysAWRjMZa7luF/C1ZM4qyLUXHJIptcrw4HTl0LLhTQ8pc4KvrH3RxSKnHcWa29y/i88wJmksyXyUrcBvZ4l1IM37CPSlQKJsdyApSHjGOi+COtGiCBitb6PhoyIcHk8w5NsmB0Gh+uT8GPPn0czWsrbtbI8bH4GUyMtahMdANkKNtLomdyzbk/Yj8vKGzyhUA/7I7J84RXZf+6pJEyPbKO+k4Ea4V/ygaKOZQ1Zp+3vRKK7nm75cQ/SzdloeVktVycW4UcsmS/F1r0cUb9vqstZCp/EbhF2hLZcLAxCGh9Kn8fgebdRw46yR8W+tRZvaKGUkASHola46+h6XAY+4FrT2/VJ5fJFojzJCYtMBWz7TExUhgE5TDUdZPjEIRxQHEV6PKm0IVU/6vQJ4x6vZ5V5NVepjO6gKRkiVYv0QnNkNSVHByNXAf07kv1sB1Km7pXkr2M/zkKmpmymn+0bqm3d3yG2CW/ttff/87Cn4TajgGG79WuPVwCh+Khcf8Gms89Q3j7hTlfbOsUWGw1sNfILcYOVwUKtWjJ0SO3dSYX6LYFcrcSS8Hz1OvrJdF50Ty7kYBbfM01Uj41xESvVS0ZwW6hSgOBp1sFCgZAQnv X-Forefront-Antispam-Report: CIP:203.18.50.14;CTRY:HK;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:hkhybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(40470700001)(336012)(70586007)(508600001)(40460700001)(7636003)(8676002)(8936002)(2906002)(70206006)(86362001)(316002)(110136005)(34070700002)(6666004)(2616005)(426003)(5660300002)(82310400004)(186003)(54906003)(356005)(36756003)(4326008)(921005)(47076005)(1076003)(26005)(36860700001)(83380400001)(107886003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 07:57:51.2396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3499898b-fc9a-4452-1eeb-08d9bae9999c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[203.18.50.14];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB4677 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If ct rejects a flow, it removes the conntrack info from the skb. act_ct sets the post_ct variable so the dissector will see this case as an +tracked +invalid state, but the zone id is lost with the conntrack info. To restore the zone id on such cases, set the last executed zone, via the tc control block, when passing ct, and read it back in the dissector if there is no ct info on the skb (invalid connection). Fixes: 7baf2429a1a9 ("net/sched: cls_flower add CT_FLAGS_INVALID flag support") Signed-off-by: Paul Blakey --- include/linux/skbuff.h | 3 +-- include/net/pkt_sched.h | 1 + net/core/flow_dissector.c | 6 +++++- net/sched/act_ct.c | 1 + net/sched/cls_flower.c | 5 ++--- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index c8cb7e697d47..155eb2ec54d8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1379,8 +1379,7 @@ void skb_flow_dissect_ct(const struct sk_buff *skb, struct flow_dissector *flow_dissector, void *target_container, - u16 *ctinfo_map, size_t mapsize, - bool post_ct); + u16 *ctinfo_map, size_t mapsize); void skb_flow_dissect_tunnel_info(const struct sk_buff *skb, struct flow_dissector *flow_dissector, diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 05f18e81f3e8..9e71691c491b 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -198,6 +198,7 @@ struct tc_skb_cb { u16 mru; bool post_ct; + u16 zone; /* Only valid if post_ct = true */ }; static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 3255f57f5131..b52a4370162b 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -238,10 +239,12 @@ void skb_flow_dissect_ct(const struct sk_buff *skb, struct flow_dissector *flow_dissector, void *target_container, u16 *ctinfo_map, - size_t mapsize, bool post_ct) + size_t mapsize) { #if IS_ENABLED(CONFIG_NF_CONNTRACK) + bool post_ct = tc_skb_cb(skb)->post_ct; struct flow_dissector_key_ct *key; + u16 zone = tc_skb_cb(skb)->zone; enum ip_conntrack_info ctinfo; struct nf_conn_labels *cl; struct nf_conn *ct; @@ -260,6 +263,7 @@ skb_flow_dissect_ct(const struct sk_buff *skb, if (!ct) { key->ct_state = TCA_FLOWER_KEY_CT_FLAGS_TRACKED | TCA_FLOWER_KEY_CT_FLAGS_INVALID; + key->ct_zone = zone; return; } diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index 98e248b9c0b1..ab3591408419 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1049,6 +1049,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, skb_push_rcsum(skb, nh_ofs); tc_skb_cb(skb)->post_ct = true; + tc_skb_cb(skb)->zone = p->zone; out_clear: if (defrag) qdisc_skb_cb(skb)->pkt_len = skb->len; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 9782b93db1b3..c1a017822c6e 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -310,7 +310,6 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res) { struct cls_fl_head *head = rcu_dereference_bh(tp->root); - bool post_ct = tc_skb_cb(skb)->post_ct; struct fl_flow_key skb_key; struct fl_flow_mask *mask; struct cls_fl_filter *f; @@ -327,8 +326,8 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, skb_flow_dissect_tunnel_info(skb, &mask->dissector, &skb_key); skb_flow_dissect_ct(skb, &mask->dissector, &skb_key, fl_ct_info_to_flower_map, - ARRAY_SIZE(fl_ct_info_to_flower_map), - post_ct); + ARRAY_SIZE(fl_ct_info_to_flower_map)); + skb_flow_dissect_hash(skb, &mask->dissector, &skb_key); skb_flow_dissect(skb, &mask->dissector, &skb_key, FLOW_DISSECTOR_F_STOP_BEFORE_ENCAP); From patchwork Thu Dec 9 07:57:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Blakey X-Patchwork-Id: 12666005 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDDC8C433EF for ; Thu, 9 Dec 2021 07:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234141AbhLIIBa (ORCPT ); Thu, 9 Dec 2021 03:01:30 -0500 Received: from mail-dm3nam07on2074.outbound.protection.outlook.com ([40.107.95.74]:14432 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234124AbhLIIB3 (ORCPT ); Thu, 9 Dec 2021 03:01:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VHRUt5pOdeobjA/AGVvPbjBwGN4zjsKDsBelflJfzj/xM/BCtiDMY3ZO90k5+hft9Lvryig/6p9GhovZvOA5fP8L6D9g82OXOPLUudV30T6f+GDyEdNIcwGI+N5R4/cFY2LRQ0+S70pKkJ3e5IrikpnpgMqmvnh+olHofHPwU4nL4i51xociHFmZ9f79EiA8gjInDmMAuPsvGwXxQoNG8lB/vg4evWxnNteugSchWo6MQteWhu5ORkpKkGtxdnZ4jNNiR9VURvUPEKvbbVUpYNLmYwgjU2uNnIggFsoh6Q3XYUqZqBGWN3qqQw9ZSQTZZc8wTmE7MeE+MPiwgTtWBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mQChzFtbCG0LajkUA8sURJucOpTY8B5TqXPXoPRwYGU=; b=dcYHB7pbMTWFW5k2Mc1kB/tVi5Or40hhWvsRKkGloaCtvwzAC+5ZZWFzIj7n0xRf2qeV4809z7oHHZku8Baw2MXBZoCR3hprvExeaqSGDE9lvvHz3qyRoWN84UTNJJLDE2H4xOTtsq0poQi7nCClbRFakTIlSHhhH2X3yp3Yr95+vehYF2aUW+//s0svd+rM+tLo7LmyRvVcDc8q8Tisb0Ssr2gN+6kfiQTmmDpq710nMzgBZvddldnUxpjSjDOZhIaTlJ86KacvyRewtFWXeU5AadbZQlxGL7cSuQ3fEwKqPo6H7nXaueJR5KCf332dd4KlQLa1wAsSuMoTZxTqyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 203.18.50.13) smtp.rcpttodomain=ovn.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mQChzFtbCG0LajkUA8sURJucOpTY8B5TqXPXoPRwYGU=; b=LAUfOxaZ8LALTCuap3I9mNfTVEs7b5ffiALF+923cuBPfHlRX/pJN4OU1Zg8KwQQ4FKIZATAoZ+DcFjgeRju6eeSJfhpo9Zn7UeN9RXfzYBjL5dCm22JQMCXaJa7zS5mYyxjVjEWe0Qpgg0S/a6EQc3jJk7HA6pfXgfk6KvL+PYOISpTXmoXh8RMf5BC6lpDSg+/qcSBQDSKnfEF0gejlb1kl3csQ2FBHVb/FIxRmxzGAJTYrB+259uf04zClu8znsSnXD6Ib8btP7fPQ+TdCIeqC/TlxjjOu8dNl2iDqaQ6yaV9mHEzN6PI/nvMYHhts7rBUx4eW5R1d7nqQdULxA== Received: from DM5PR19CA0039.namprd19.prod.outlook.com (2603:10b6:3:9a::25) by SN6PR12MB2607.namprd12.prod.outlook.com (2603:10b6:805:6d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.15; Thu, 9 Dec 2021 07:57:54 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:3:9a:cafe::c9) by DM5PR19CA0039.outlook.office365.com (2603:10b6:3:9a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Thu, 9 Dec 2021 07:57:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 203.18.50.13) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 203.18.50.13 as permitted sender) receiver=protection.outlook.com; client-ip=203.18.50.13; helo=mail.nvidia.com; Received: from mail.nvidia.com (203.18.50.13) by DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4755.13 via Frontend Transport; Thu, 9 Dec 2021 07:57:53 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HKMAIL102.nvidia.com (10.18.16.11) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 9 Dec 2021 07:57:52 +0000 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 9 Dec 2021 07:57:50 +0000 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (172.20.187.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 9 Dec 2021 07:57:47 +0000 From: Paul Blakey To: Paul Blakey , , , Saeed Mahameed , Cong Wang , Jamal Hadi Salim , "Pravin B Shelar" , , Jiri Pirko , wenxu , Marcelo Ricardo Leitner CC: Oz Shlomo , Vlad Buslov , Roi Dayan Subject: [PATCH net v2 3/3] net: openvswitch: Fix matching zone id for invalid conns arriving from tc Date: Thu, 9 Dec 2021 09:57:34 +0200 Message-ID: <20211209075734.10199-4-paulb@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20211209075734.10199-1-paulb@nvidia.com> References: <20211209075734.10199-1-paulb@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a370efa8-7924-4960-7e58-08d9bae99b0d X-MS-TrafficTypeDiagnostic: SN6PR12MB2607:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dpOKaE+owhcXYUb4nThPVesGC4lzUP7iTArn/Z+aZ718N2knYc+tZ0muO4e2wc1+PoKz1R/XXWZd55JmUIv6iQutCEoPV96Tfai/iB+TZlHvrxkjuxl/AT8pp52fHmMC9CU7y7rzgg+Yco/dotmTJLyjrQm6DqbVBvl9ymv5B6qJQ/tukHmYnf48DwothHPKkVsFfr4OlcAqno0IE3hsAJnGIWJNo2MgsbIVX8Y5SB3plcNPY7DkW6jbEB8vDxaaIK5vvKpegIDdagZgtzt0gQJslMn6shyFr2GFg81fhpXStH92DrSfTKwi1Wx5zgjK+lkzttBIUkv/lWsAoX7m+hv/46ak5Y8xis4nhM3b/pznR1qdQxvgZQyAPgVPWSN8cNoH4nWB09fnouHMUv/YFQG17hgxufkS3ANIKGTlwlNXmScgJAp2g4jbx+NJqXqSeqCxIezSjbZeEJBVMyed0vf7bBTdSz9W1IOHRx39grGPQU2a49HVd3wINQsYYTPkwfXwM/SLWhvDy2S55csgF+0vYcICfLZQ/HQaaAL+Ro0aLJxbt6iag2Ptdr+qqfXftVSmgnoaOQRU9FiFajo0o852PnzTUOwxMwqxuoIMgdnxZkfzjwxGB6bREC18BpPnE/k2Ku94+uiV9d+1gsnJAlO0IC3Fm0s/fWBlThc00/SzxD0K9YOYg0y4oHP0GqX3+A6/7Sr+ObT7DFvtdrN8OxE92TdMIKu6vXfZz+Lc9gSkoi2KP70B9KN6iPtmaItZuQCXMmTKomSNoSkyDNM/HsI8TrsEGR/RAay8lSPoAs01MRyP4eD+EJC4WRP23e+y X-Forefront-Antispam-Report: CIP:203.18.50.13;CTRY:HK;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:hkhybrid02.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(40470700001)(70586007)(86362001)(70206006)(110136005)(6666004)(186003)(921005)(4326008)(356005)(5660300002)(336012)(426003)(8936002)(2616005)(316002)(508600001)(34070700002)(26005)(8676002)(54906003)(83380400001)(7636003)(36860700001)(107886003)(40460700001)(82310400004)(47076005)(36756003)(1076003)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 07:57:53.6623 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a370efa8-7924-4960-7e58-08d9bae99b0d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[203.18.50.13];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2607 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Zone id is not restored if we passed ct and ct rejected the connection, as there is no ct info on the skb. Save the zone from tc skb cb to tc skb extension and pass it on to ovs, use that info to restore the zone id for invalid connections. Fixes: d29334c15d33 ("net/sched: act_api: fix miss set post_ct for ovs after do conntrack in act_ct") Signed-off-by: Paul Blakey --- include/linux/skbuff.h | 1 + net/openvswitch/flow.c | 8 +++++++- net/sched/cls_api.c | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 155eb2ec54d8..28ad0c6bd0d5 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -286,6 +286,7 @@ struct nf_bridge_info { struct tc_skb_ext { __u32 chain; __u16 mru; + __u16 zone; bool post_ct; }; #endif diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index 9713035b89e3..6d262d9aa10e 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "conntrack.h" #include "datapath.h" @@ -860,6 +861,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, #endif bool post_ct = false; int res, err; + u16 zone = 0; /* Extract metadata from packet. */ if (tun_info) { @@ -898,6 +900,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, key->recirc_id = tc_ext ? tc_ext->chain : 0; OVS_CB(skb)->mru = tc_ext ? tc_ext->mru : 0; post_ct = tc_ext ? tc_ext->post_ct : false; + zone = post_ct ? tc_ext->zone : 0; } else { key->recirc_id = 0; } @@ -906,8 +909,11 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, #endif err = key_extract(skb, key); - if (!err) + if (!err) { ovs_ct_fill_key(skb, key, post_ct); /* Must be after key_extract(). */ + if (post_ct && !skb_get_nfct(skb)) + key->ct_zone = zone; + } return err; } diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index a5050999d607..bede2bd47065 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -1625,6 +1625,7 @@ int tcf_classify(struct sk_buff *skb, ext->chain = last_executed_chain; ext->mru = cb->mru; ext->post_ct = cb->post_ct; + ext->zone = cb->zone; } return ret;