From patchwork Wed Jun 16 10:02:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 461899 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 DBE2BC48BE8 for ; Wed, 16 Jun 2021 10:02:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEDD56109D for ; Wed, 16 Jun 2021 10:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232307AbhFPKEw (ORCPT ); Wed, 16 Jun 2021 06:04:52 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231931AbhFPKEl (ORCPT ); Wed, 16 Jun 2021 06:04:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4sqyHaCBgxeUuzPp7d5wShjg3qG7iLwUS0zYOSwW1lBNTddoCaWQqFsDfUmNa/XxvpSAQY4Nv0l4PR0dtQlfjvsDvBbg9fACKKe5C7v7fP45UujCrn2EANlHETb8YXDARMTsJDhHygvDMGv74hRCHbKU9LKMR91mqEz/yXsQwyaICO6/HOa4l7fDzwzkF2oAIfCtzMwHCCUmnGr6zmxxUOMcG7UQWNJDsRYyJqUfvSFs8etiG2CoIk4mPi0oRv93tlnRbS+WVbb/dbR0guhLfgSPFRFDPH86repemnY1k0PlHmzdRw54iVzB3SM4EfaVCPHcxBb7LWOHIQH5bkQmw== 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-SenderADCheck; bh=j5jPKs4OvZv4XUWnf3Tb1yx9S46w/P2ePKl9QuzCaVc=; b=Z2sXIXs06bIVS9j7lQujTKDz6V35MXXxGYicGyOn22UkCN/Xzy+MIt42GxeqcmqlzHrmdFgOG6NcVh9sNET4qxqIz4UJQo+BYz/8bkC2VKnVyS8UY/rWY/f8hYP5nHEb9emUrD4nK+oRbGhSpmwQJfLh+OUTzvN6sVMZWp4kJdBCw2DshMUTNZTdh/oKjKsh5wkwlaxwH5Dr5NAed27bS6FQ2F0pytfRpJvKBvd3Xa6ODIlpDQ6k6SGBsWTp0yznoAiRfkN9wQPBKbPXfOnvrz+XKL7nNTNN3er/iRFlGihk9QYQJR4dKzmpPEt0SdDcHt8lX5bTOCBKsDkezT3DtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j5jPKs4OvZv4XUWnf3Tb1yx9S46w/P2ePKl9QuzCaVc=; b=rThYFnWpJUQPzJTZFxmtQMWXE+lbzN/OTG3wsHaEHL5Te9B0KNlYjgMPPlyfpqc5pytsWcmN6/dOEGHVs/D7YwBTilzTV3Lc+U8qplvS86yZa6VXLk5AS14zTVm+yIrQf1K/dEmCM18RO+4aan8jZFxZpsd2weFhdAvil0R/Ctg= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:28 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:28 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 2/9] nfp: flower-ct: add nft callback stubs Date: Wed, 16 Jun 2021 12:02:00 +0200 Message-Id: <20210616100207.14415-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6be393b1-e36d-49d8-f84d-08d930add97b X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: haI9X7zM4/MmdFbUqsDGOTc+9qrMU9qwn+AqMz6xVFxwCGy7SJZC9G1tx3dIpNti5uFRqaBm7qdztE/sscW00Jqw2TE3ltzj9rKKuchRXN1sTGjzB/oBPVKWL3mFSkZ/MJEgUfWavy5KzDseYE+F3ul65Y0i4ZIiQnUHKN+ObAi01aGlD4B5h0s4oPWypMcONsJTTIRHWW8NWeTmxIJ+p2RYkT/p1b/tnWc6GJuZ/mrDu0cYaruihCeLDFy4JlIYo10I4pSEap3t8PgdG8X+b9vRPL7VadgqZ8LHr/EiNdijES277vSRYNPP2wKfa+wq3V7GVuTu+3KI6uRt0zqzIwcENE32jBvP5xd4oS1I4PCF+1Dcp58PuIWCKqFFrMmeXGW+4sdvuiwQL3cspZAoWDe7wwVc6LzR+ttjnN0kUMDm5ddS3QWi5d/qljdhYGNafAMuBQigIUoa2AMoX72g0kd5JfMqD+B6RbjEU/zS1UQcSTlenUR6R5u0TXuwnSj84Zd5/Jln1GPctlTJ/aEbwQ6KJJ+CEGzJAn3v4mmH30V9EskBq0rBMPYFpJJx7Ru2NQhzthdqb2o4ZFMuLHpllwoCDAt178EpNf9IfQ3k6wMtv+wR9HObUmWe9T5Hdfba8YVlWARg7Z/rvmTmnuzE6A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GooI5M73KgtGCc/BjQj7IjuGmVCOjhD+usQK3epnr0SXK3DZyjv6IMOCsYSXifxJgq6Q/A8ksYu3E2g/1TFNfavS1cgfdpXTe/7cDFLwKq5a5Bb1k0SIDTYFRknDzEnXTxt8yETqLw9huOxpVSVxhi7b2lNACt/st2lxcY0axOTv8jz6obnfRO3IwmP98iTTVWh3t4MJ7eLNRhogxl3x9v6xawvf3LfcXu5wL/2vp3KAdH5GnyBa/ztVSe0GbAy0Ld3AbXj3qD5EyU3ysnG/TIToTHGZGuIcXCcppLrakOcKWuRqLSa9LxbTnDYA2cI8ORu8/iUYQllxfDwz3V1CPJ4XmQZLDkXrDWeIZH90EL8K9znH7NuaKLbwXSDfzCzUkBep8ussqYGVVOTihWEbrwt7ilzWg7OXy2916VTBFAdrVjeRdE/aWIPaJaGGJdGOUTELxF56xNldUhi2RHmq1dy5vtdh51Yybnxps/Dijpxbu3NonTMzpSDgctu37lmcNKpZbehnTzGOn+1m9mRWK8/FUhYNYASBYUeIpHJvd5+jN8V1WD/N7pur05ipdoyNrq9xwGQnB+GIYJGRJlCpm4tgsnRhidUZtSjmhr08DJ2t3ugQf6gIjIRZTTxbCbgfNhtyBs7YNuUIVhbP3pyR+3cn9lBrdr4MDK7n9AV791zZYjirJQ1S/cDx4tIonFHTCRZGVKj1h2IgnuZoVVYzkmXBxdQTyrQTeVM3KKxeLkwl+qswCY4Ttpyy/BgEUcN0V2/2/a45wjKeGMOTRJUMAc/UWHMA2UeKMGpTj1Hk/CjToEwQ2OO8bBQCbCzKeA21WwzgEJR3gUyjNQQ77xIbaFSiCQZFpCydXOq+N9IHTs4aZ3IHwD4kzUr9eg+sJa9qGNNLgYoOqzDS7S05yNTNjdfRR/4ZO4Va72L6rxDGBtRYucHEroo1+H4Y8WPu463fln+B969Jz9KKq+n4/PxlWsjf8jGNa/I7INoCMu6WI2YvN3r4rQQ7mg1MIDpaL++jrlA0srCWE7QLlTBQ5yyjUDmi5F7ohHf7U7k9kmkrnsH7uiE/p6VkZEP7mR0xDu55a/uWmiPLxbs4pfJegkY4EW3Is6LNiJZMsTaOwu/GJyEh7/nG0xbeyzPFPORqhhqJE9UKEQ/QIEhlHqA7n/ckjg2M0xUHVGqpunpCteDznj+vvXxf6PH3Ff+OJrcIGHtVRQY/fWI9HqW7y5JHSUvQOm9gDw3nAGP8fuBsr/ZJlOqbGepFDu4wfk0e0U/9TYhCoaeRXyCbeoIfxZSgAQYQFelEoBiaZBIQPnhRcoqhuGTJnkt+8uTRq6HM1vqaudk40V3FZBeX1z8k8RYPzd1dB72RwtpD6yIFKL27lu2gr00QvsLd0xdx5pCwzoQhYkzJ X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6be393b1-e36d-49d8-f84d-08d930add97b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:28.6986 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rvyTYVLJWbNYQ+1ni2iGfhPSrmJZ1mfkiPPc+vgM1kB8sHzAmpUBT8l3e2r2P9p8XkrmfxHXWinvVPy5scvZl0K2nF4LjkYskr0rJJzRW7I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add register/unregister of the nft callback. For now just add stub code to accept the flows, but don't do anything with it. Decided to accept the flows since netfilter will keep on trying to offload a flow if it was rejected, which is quite noisy. Follow-up patches will start implementing the functions to add nft flows to the relevant tables. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 63 ++++++++++++++++++- .../ethernet/netronome/nfp/flower/conntrack.h | 11 ++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index ea70e02d170e..7fb51e13faea 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -384,6 +384,7 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct flow_action_entry *ct_act, *ct_goto; struct nfp_fl_ct_flow_entry *ct_entry; struct nfp_fl_ct_zone_entry *zt; + int err; ct_act = get_flow_act(flow, FLOW_ACTION_CT); if (!ct_act) { @@ -406,8 +407,15 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, return PTR_ERR(zt); } - if (!zt->nft) + if (!zt->nft) { zt->nft = ct_act->ct.flow_table; + err = nf_flow_table_offload_add_cb(zt->nft, nfp_fl_ct_handle_nft_flow, zt); + if (err) { + NL_SET_ERR_MSG_MOD(extack, + "offload error: Could not register nft_callback"); + return err; + } + } /* Add entry to pre_ct_list */ ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); @@ -489,6 +497,42 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, return 0; } +static int +nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offload *flow) +{ + ASSERT_RTNL(); + + switch (flow->command) { + case FLOW_CLS_REPLACE: + return 0; + case FLOW_CLS_DESTROY: + return 0; + case FLOW_CLS_STATS: + return 0; + default: + break; + } + return -EINVAL; +} + +int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data, void *cb_priv) +{ + struct flow_cls_offload *flow = type_data; + struct nfp_fl_ct_zone_entry *zt = cb_priv; + int err = -EOPNOTSUPP; + + switch (type) { + case TC_SETUP_CLSFLOWER: + rtnl_lock(); + err = nfp_fl_ct_offload_nft_flow(zt, flow); + rtnl_unlock(); + break; + default: + return -EOPNOTSUPP; + } + return err; +} + int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) { struct nfp_fl_ct_flow_entry *ct_entry; @@ -506,6 +550,23 @@ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) nfp_ct_map_params); nfp_fl_ct_clean_flow_entry(ct_entry); kfree(ct_map_ent); + + /* If this is the last pre_ct_rule it means that it is + * very likely that the nft table will be cleaned up next, + * as this happens on the removal of the last act_ct flow. + * However we cannot deregister the callback on the removal + * of the last nft flow as this runs into a deadlock situation. + * So deregister the callback on removal of the last pre_ct flow + * and remove any remaining nft flow entries. We also cannot + * save this state and delete the callback later since the + * nft table would already have been freed at that time. + */ + if (!zt->pre_ct_count) { + nf_flow_table_offload_del_cb(zt->nft, + nfp_fl_ct_handle_nft_flow, + zt); + zt->nft = NULL; + } break; case CT_TYPE_POST_CT: zt->post_ct_count--; diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index dbb18fbbae69..b6e750dad929 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -4,6 +4,7 @@ #ifndef __NFP_FLOWER_CONNTRACK_H__ #define __NFP_FLOWER_CONNTRACK_H__ 1 +#include #include "main.h" #define NFP_FL_CT_NO_TUN 0xff @@ -158,4 +159,14 @@ void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry); * @ct_map_ent: ct map entry for the flow that needs deleting */ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent); + +/** + * nfp_fl_ct_handle_nft_flow() - Handle flower flow callbacks for nft table + * @type: Type provided by callback + * @type_data: Callback data + * @cb_priv: Pointer to data provided when registering the callback, in this + * case it's the zone table. + */ +int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data, + void *cb_priv); #endif From patchwork Wed Jun 16 10:02:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 461898 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 530A7C48BE6 for ; Wed, 16 Jun 2021 10:02:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 306526109D for ; Wed, 16 Jun 2021 10:02:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232272AbhFPKE5 (ORCPT ); Wed, 16 Jun 2021 06:04:57 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232110AbhFPKEo (ORCPT ); Wed, 16 Jun 2021 06:04:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ef3OBl5Qr2vshSmE1CANRL94/vXttNU9YylgJtQ3GnzeaVB39PPkDsInMJ+PlEV+3KlnfMSe4Jlvfx2KO514golh6sHr8yXxMDVHDYvzqxN5oqBBz3grCI+p4ZPyXjtL4mUqy8O/q5nNTJl9gJbWMAYfKs9F3mErWN68LRFvMHjra4DeD5RN4xVr+xj/3mHlzhFCgGXnA15YBE4CdXdwpmIWCd+NqI2PcwsCk+dclt/GWMbM76hnUHomORM5+h/8QcWt+MX1BFguXP/8fye0R0Q7tlNqbPgnq07DeUjd25FO+WMtvvLAN1RDl8ofp7eQzPXeTElVG+7sG4oOVmMGHA== 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-SenderADCheck; bh=6WWEvIETZASNikfojdEylJxGQ6jzCteaeYiYnJliRqY=; b=CGh7/PHh7RDSkvvlgJ/Ea+P7brSOXwzWaf5DZqwSQ0XICbBJGjhTZStqnlCfURa3J1n0lIPrDNuYloTLUNJrqXSeE2U1lV9K9QpY6XkaMru9fsoFYSVij2mHyCJtQnQzjgdiMHCMX6/9g6xvFk3YTvoJ6j2pF+TKYBJaauzp9g2B0RXNZBVBYHreLK35lkcsPidclhN1lkc/bmFEtnzOTq9U1wCFTzVF9vk9Buj4lSxTH0gEmVSteKZjw1CXdvAQiLQaLJwv2rnXcSq5ovC8r5kN/EfBYh4/NnvdpSrPJBYgRTFyX3SF9qmddIyyaNDVFYfOi2uM3YHdF8UpobviPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6WWEvIETZASNikfojdEylJxGQ6jzCteaeYiYnJliRqY=; b=L3o73i2ryH55Yh2DGC4jkGcJ8DPo4IRORMEYDL7T0N2JM5pSL04lusuDtLyeEEksFdsg7DYm5Lh1M8mu1U4rRU3P/DSL2HB1VMyJOgbHFKa5y2NSVIctaLWle484VjgMHnsusS+a6bpDMKa03GmYTV5BsStZQYCJp4+8YoFt3GI= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:32 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:32 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 4/9] nfp: flower-ct: make a full copy of the rule when it is a NFT flow Date: Wed, 16 Jun 2021 12:02:02 +0200 Message-Id: <20210616100207.14415-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66772efb-3540-4d91-8f99-08d930addb69 X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y9GVUtnKgx3f/zG8OjXweJERD336xBYR2s5h7XJwalTznVwyI49COReUzzGqryM9ByypOaYrqEXTvVOISYaPwZmy9T+CYSwGzt5+J5Mdxi5CS+/o2D9LS+DP0foxybQfKHzKKEJIIudQvHmeqcTZHmQH6mfolwbmJ/7umY0rym3UNzOHLMYdMIcBRZgYstNIRO2acXhrgdcbRR46zE9hDQJHI9L9tO0vP9/yGJMtNmeKABU5giAm2tLaeU4Fcf3B0S2AIFmswPHLwceRT1106cigyKboGaKbwJqGYTBXi2XOl26UtrqFEU1n3kGOAnotWkgoFgumatzviREmef5smbeKwPkT8nLC6+pMAZJTuq+U0ehF+30TRJ2fJ85ruodcFqbG4Rucp4AZ02pPPhg91p9kWq2Hq2E+vm3WVhU8RMCB5aTb3/EO6DjKXWqKsArMvyWoYKjwFWkxUAVtJhu8dgFnBD1SGOSIyLvwDC8GU9JmQX73O6O+yeps6b00waVcnJ0ovhPfAvdpIMgrPP1OYBD6Ld5RRSqmORrXsnjOf8Sv4pJrHB9O0fkXDFulT/Y90wIjOdb7q1UGtE2ONbX6lgFaI/AI7ji/tpfFG9RMzebltVA5JyBrBnaMOmaJx7wZ1//ITxT8s1WFKJsTceiRYw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KuEHRHMn3ujUbSHybDgvCZkb5zC2nYczGlQgepf2U7ljFnN77EUMbwnPcfcxzlxuVX++bqlzUw+9sGb5YEU7uRjWiNwPrudhhvbW31FseQTk778VGsrEGAIN49TFaQvRr7+Vft4EqC4tlv6tp1ig6oUHulouAVuYkLieOc4cWTFHC9VsANxC4q3yS58+i1rT1pIsFDfNJS+VXedZHws8gpY82K9qsIhXc4yOSE00+xZT1b6TL9YucQyuI4+sWfNdV+F5r5MlCuftyCl34bLM0ojn8eIu8P7Ro/hUmKK/O+4bZHv7d6kKzJbackrXC2i7YyRqM84p1KtZZ1FdtDDClGj8GBqRQWArynZHlm3FtF+vEbHd1m9fe0WH7FI1J+QNTfrrOyGrBa+LAfwER4fCZxEloP1X5v0Gm3hKkgmWNhbFg1fvMtvt0Xr1RyMF9oYmzj13PypSJV2tmjLrirvUKkXOLOxAfy8wh6JYGvkaQesUK3NSrjLaWeDc9zqrl5jaJyUycTV0s5iLDlKsGTTAbwoQCuQoL9ndxbO5mDoozMlBX6DnMRscG3bRbsQnFSHE5RvAYzZlH/13d8B2EvehrFTD+w9JSDWqag6K856rCISV2BU2U5wmxSKBsI9H0Gd0dCl0uWDq5VNvfL8zmjCqAtAjR9Dq65cixDjg10sgQb9yinF/IQkc0BJb5dbAngoPcjXCgVH1EHFQjRkbqB/jU2+CoaOQDwmvObsrJZUslxYIFDoZEgoPnwKGQNiF3lwwOJytNVGJRStmmtlL9ZU/pbci/rixtl5CZSebhYX+limpef/YBEdIHdKFTc92WgqOb/E93hJ67Z8qyyiZ2cbVYssWiB62IH6j8mmZj5XSD8dPgqH+h050wHwtdfynAEFhcCUvOK/67dvPlS+OxBw+ZvVYh4A1jb3jWpEHNfmWSr3rOKKjp1CqNB/PbBnjDpi/8Yhv57aGgwXD9Bxw9DVf3Co/Lr/7RWDFewgauE4US4RieJuCA3nGVHanyMvs/VJgUFx3TgcGb3ZeD95LLT025FjL/KVel36oB1Zj2TU6NZmokCbQarnnJHgr5WLjWjDMbdgaR8UKkBWj97whATjmcZW/Jew5zoJSQTlGwYVuVP8LmWoMop+wiQl3hHe3SXcbNF4R3wgEUAa/Hk1GMG8pWq9HfgMhUfrlr7Bg73Mcj6ys8hVSjTXOkLUFEcB+JaqW2OCFKnaILuX2m4GvWpeqcBeKQJx6TLB1D1h9Avo27bKK2jSPdUxFN7IHnqOzZZ8CwcmwACdrFO8taM15GjhBom/U/72HCe/C3qCQhOD95Uqfd7vNvUrz6gQiSh9BK3D8Pkii3M+jWbDeRO6H33y0+86+SEYOqgQRi4sc7G40od+MVEHEHYjJAeBSwjFhIXxh X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66772efb-3540-4d91-8f99-08d930addb69 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:31.9295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y8l0AxWNOBpZfAQzF71S8Ch4WHNGnphQcm5um0fvrrIOAG81bDMAZ/8w3cc+L730dWhyZbKI1G6PWn4spJtgBB076f2TUgikaKCgmYYcM8M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yinjun Zhang The nft flow will be destroyed after offload cb returns. This means we need save a full copy of it since it can be referenced through other paths other than just the offload cb, for example when a new pre_ct or post_ct entry is added, and it needs to be merged with an existing nft entry. Signed-off-by: Yinjun Zhang Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 1b527f0660a7..2c636f8490e1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -194,8 +194,9 @@ static struct nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, struct net_device *netdev, struct flow_cls_offload *flow, - struct netlink_ext_ack *extack) + bool is_nft, struct netlink_ext_ack *extack) { + struct nf_flow_match *nft_match = NULL; struct nfp_fl_ct_flow_entry *entry; struct nfp_fl_ct_map_entry *map; struct flow_action_entry *act; @@ -205,17 +206,39 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, if (!entry) return ERR_PTR(-ENOMEM); - entry->zt = zt; - entry->netdev = netdev; - entry->cookie = flow->cookie; entry->rule = flow_rule_alloc(flow->rule->action.num_entries); if (!entry->rule) { err = -ENOMEM; - goto err_pre_ct_act; + goto err_pre_ct_rule; } - entry->rule->match.dissector = flow->rule->match.dissector; - entry->rule->match.mask = flow->rule->match.mask; - entry->rule->match.key = flow->rule->match.key; + + /* nft flows gets destroyed after callback return, so need + * to do a full copy instead of just a reference. + */ + if (is_nft) { + nft_match = kzalloc(sizeof(*nft_match), GFP_KERNEL); + if (!nft_match) { + err = -ENOMEM; + goto err_pre_ct_act; + } + memcpy(&nft_match->dissector, flow->rule->match.dissector, + sizeof(nft_match->dissector)); + memcpy(&nft_match->mask, flow->rule->match.mask, + sizeof(nft_match->mask)); + memcpy(&nft_match->key, flow->rule->match.key, + sizeof(nft_match->key)); + entry->rule->match.dissector = &nft_match->dissector; + entry->rule->match.mask = &nft_match->mask; + entry->rule->match.key = &nft_match->key; + } else { + entry->rule->match.dissector = flow->rule->match.dissector; + entry->rule->match.mask = flow->rule->match.mask; + entry->rule->match.key = flow->rule->match.key; + } + + entry->zt = zt; + entry->netdev = netdev; + entry->cookie = flow->cookie; entry->chain_index = flow->common.chain_index; entry->tun_offset = NFP_FL_CT_NO_TUN; @@ -276,8 +299,10 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, if (entry->tun_offset != NFP_FL_CT_NO_TUN) kfree(entry->rule->action.entries[entry->tun_offset].tunnel); err_pre_ct_tun_cp: - kfree(entry->rule); + kfree(nft_match); err_pre_ct_act: + kfree(entry->rule); +err_pre_ct_rule: kfree(entry); return ERR_PTR(err); } @@ -339,6 +364,15 @@ void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry) if (entry->tun_offset != NFP_FL_CT_NO_TUN) kfree(entry->rule->action.entries[entry->tun_offset].tunnel); + + if (entry->type == CT_TYPE_NFT) { + struct nf_flow_match *nft_match; + + nft_match = container_of(entry->rule->match.dissector, + struct nf_flow_match, dissector); + kfree(nft_match); + } + kfree(entry->rule); kfree(entry); } @@ -419,7 +453,7 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, } /* Add entry to pre_ct_list */ - ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, false, extack); if (IS_ERR(ct_entry)) return PTR_ERR(ct_entry); ct_entry->type = CT_TYPE_PRE_CT; @@ -464,7 +498,7 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, } /* Add entry to post_ct_list */ - ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, false, extack); if (IS_ERR(ct_entry)) return PTR_ERR(ct_entry); @@ -516,7 +550,7 @@ nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offl ct_map_ent = rhashtable_lookup_fast(&zt->priv->ct_map_table, &flow->cookie, nfp_ct_map_params); if (!ct_map_ent) { - ct_entry = nfp_fl_ct_add_flow(zt, NULL, flow, extack); + ct_entry = nfp_fl_ct_add_flow(zt, NULL, flow, true, extack); ct_entry->type = CT_TYPE_NFT; list_add(&ct_entry->list_node, &zt->nft_flows_list); zt->nft_flows_count++; From patchwork Wed Jun 16 10:02:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 461897 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 2E804C49361 for ; Wed, 16 Jun 2021 10:03:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1695E610CA for ; Wed, 16 Jun 2021 10:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbhFPKFF (ORCPT ); Wed, 16 Jun 2021 06:05:05 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231931AbhFPKEx (ORCPT ); Wed, 16 Jun 2021 06:04:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n0XClGCTSAbuO3oo48+dWFtmW8wxR012caGFxRrZaMnahE/9LxMRhQmDRWAZ+pXqIOnqgfyV6daO8DJPGP+v3pqVM6fUms0OsEJ2PoCCNiXZU14wBJ97Zjhg5G0FJndNjX5wTOHdIRaw58bMzZLVADQi2PYx8GRc6qQVFt+RGBCfG87miHHyWkIy68DbPG4wHgj7x4Jdi4zo/vFHscnwSnwYfWoik/YRUlBfsnYIc/YdHJQ9BlrRIpoLMBx8RwUeLmCn6Mrm//VJPPJvAUR1S4Otwh4Psuds4LAJS8Jov+euZzQaflXSTsjgmmHVrpumUnVkN/N5NvJPJ0uU4dcg+A== 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-SenderADCheck; bh=Bc91i0xtuHqREnaM/aV4kk6GdZxHUp2FJJ7EM/j6CD4=; b=ZcwmwXUk9Ucs0NgaILj9yk0ZfyAiXSjERLuhekJxle1oZweR2zLQV5I241q181/bWygXZINcFkg3gr2v4qn8QMNYlcLxKjQ2B9ezX1JC6CVqb1gCHRWPM7UMCb5GbzkPdKuIVwp6PZ6izc1FwNIpWbopXIZ0gND4RsFXT51otU+qUAcqqs1IDjd8OPxiSgMZJkEWnJ3++FtVA//R68PlW2ahfZHBSuGshjaqWrkPsynxdxmWx4DTIG1jMoev45EaQb1b6aCwKgZMyp+pmbrdhvcB1ue0Iink6D6d1MTUhD+ThP7h9k7kMaYTStsDWzRCsl2pg1/KUa5aH1e31fIv5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bc91i0xtuHqREnaM/aV4kk6GdZxHUp2FJJ7EM/j6CD4=; b=jgLu1VOmuOUIRfVwJrgMzcICv50SqEvS890PfGKceUk1ydlWu1sw6XVUNg/VA89Bv9AZT2KP8EGvtvXtHtG6uFFxIBh+sCvYsjngblLw0lm/QudlXOdvwQSe80TjMTJAaVGmJutgsYeMpNFDhd7HoRBUCYCAZXFtPW5EX/lcYPg= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:35 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:35 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 6/9] nfp: flower-ct: implement code to save merge of tc and nft flows Date: Wed, 16 Jun 2021 12:02:04 +0200 Message-Id: <20210616100207.14415-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d7501c9-c03a-45fd-1a16-08d930addd5b X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FDA16UFyfn40u+W16deDjnxpinkp6FPHEFQpOpvepS67X5be7PSvX/oJGbXGDqAhPXuE4E9xQmarGbkXbIOn/QkYySXtYSNi8P09EAOKWXSBCzvj4HdmVEYoB1dj4itIc1egSaLKItnUniS5jMi2TIGo1vkCFkE3K0YFkXll0L2wzzSWXWj1u8/Cb9Y8xd3Vhw85MBpBvurzJl+yDCGIL2vFjmn1OE1Tmz6U3reJkd9GWNTaOo0vtEwJm8tpPYj9KojTimhbNgd42Iyy7bVyO4ajRCy1KKVh4HiwK0su/IhNizh9VsHCsj5AiV0PKrUZns3C+IX6tOtv9kaL01eZl/4wmUw4bpSoSn9VFSGGXQgrI7rSgw1QU3E4gqHX9HC2lgadBK9Xb6jAO2CtwkTsZc/BL9O+yiTxP4tw6EfAiP4PjgMQG1Eu1SooSwFnyrNQr4ytcJqoHPZkKBaTJ77JK5ToFxzCtz+vnX6QCUEASvlWGgqj4FsyQ6WxUYcz4K5IXSSy+2HXFrL8teawXkX/fsLCBMCRxuPR1+wALT0x17SPBtv6tJbQ869Q/J9Xc0UNctDJLls4i4/Xfn1OimjR7muE/XXYOTXzy3YrL3mcEbbimGNZ4QNz2gEgJZ2k7bg4Bq755VVYoMXkUhSJKs9ayg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qicpwqeHxjg45Pat+x4kPPpVVNbOexHBMIBTUL76uozvaaUtNw7D46gGjO/NCGcoFPMjyPwAEOE/R3lzz4amaoNHSYrBoEYT14fTIc1m6PiOTBSY3RV45SuOm6JX75xSLAj4uVl/89x1NvpRHFsvt3YOD4qNNR0Zx5GiGPeUqgxfdZx6f6rmh2waYoKAXD8dWhpCTb3m4Re3XXWhk7svkuJZJMR6myTeNX5i6NeiaROTfqN3HzLc6ocKUjZh7KDb1UqSIGwygeuTPrY/6GqPUN5RQBLKIKPGbROqzK4JyRsVgCK9tC8/tCPCMSExiI2AbRA+q6HscFzNYDLO+U5DafVk8ZC5zw5BmQct65TGVx2SpiFHzpW5x8LOkYpZ/rWBFyrxZoLhu9Yxm3hJ/GyW3OA0xMlFBtey188D6EyKRxx5LBqJzS3agFnuT/T7tGfyFYZe2UI1UsxEA5FRwEgrhomXWcXVWNKNVyas6kXfFSyKGERrds8t5eBiGi9e3VY6MlOkVM+oMch2tlhVQsN6nQKxp/MTKdDT+qvbeGPOevcXsYgc8Iedoxsnvq5GhCKShUsSf87dEo2kkBDsuId8sCXgaAB5xVBE31K/UKGdcV7ZqjHbjf00NIxMjb6Zrj6LkIryYnf1CWlal2vB7AurJ7qWT1HjWnA9DM8uoi9upc2EtamxKdcsOoi1CqmPyroLQEgsvpAmy2otHA0kXDWeO3ew2hh+5cPpQPuyPkUDYq5lcFcwb1+AyI8XZHPbzpwiPNGjsO6C7uv7R0aqfLtsmzuuHsLCNNdbHyJidy9BLFG9GbOBQqvsVzaF3BT37ZTki4GVNdiUL4MeyenNUzfrTU70Ci7ZjlFG1iTfbxXlzRB/BU0mAy1I22SyI2ZqMokDqzlOJH92dfbJq3UntUIKYaB4r8vUI60EQ2+p53EcQunnRngBDSJKiQFvhlJ6B15a80QQ3yeXLj1feNyDUs2MoNAG26ZGPxhRqlz2ph2v5H/BLyylf6xwPyS7GJbAAhybDj70a3c3TmM8ijBlerToFS96N9cIkvB/6+0uQBrgqsxGx7fRLgYhNmeneNZAQQXEdBHBixIKmlrHd9CY7tA6aZ2LLibvo6k/eea+gLHWQUF9wUYtiUmFzrIDmDCr8r6bgsW766Hx9QZGkHOV4+i/rhgh1KQUvPJFvl2vWlE9Bo4LjSgsge5s+TdU7XUb5f72c5q1KzSq21i9AHvwUJjDAmvNPTWFEefM3mrv3tpDaEvQqW4iFZFWZUVk+/s4VSU6Tg9vHnb1yxVIicQbyiYOCfoDvGYxoVOM/a7mH5JMRsp9QQwOGEJxhMqiHm0Pkmi1xRX4OazS86A79//tWx2zH7Qvf2e0OJuy/EGJVpZG1HLjsLR0OTPjGxwudI7MEbmD X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d7501c9-c03a-45fd-1a16-08d930addd5b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:35.2041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zBwbHzsm8Mla5fWbmzKqOWrVD1bklEvjxp11Iz+pFxIP76x7VcNeXDBfBj3X5p3QwTR0yalBfe78Z+HH0FlPXFPRm6dC2YA9CY4ZdTdkM9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add in the code to merge the tc_merge objects with the flows received from nft. At the moment flows are just merged blindly as the validity check functions are stubbed out, this will be populated in follow-up patches. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 187 ++++++++++++++++++ 1 file changed, 187 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 3ab09d040d4c..e5d5ce7f0ead 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -78,11 +78,122 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, return 0; } +static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, + struct nfp_fl_ct_flow_entry *post_ct_entry, + struct nfp_fl_ct_flow_entry *nft_entry) +{ + return 0; +} + +static int nfp_ct_check_meta(struct nfp_fl_ct_flow_entry *post_ct_entry, + struct nfp_fl_ct_flow_entry *nft_entry) +{ + return 0; +} + +static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) +{ + return 0; +} + +static int nfp_fl_ct_del_offload(struct nfp_app *app, unsigned long cookie, + struct net_device *netdev) +{ + return 0; +} + +static int nfp_ct_do_nft_merge(struct nfp_fl_ct_zone_entry *zt, + struct nfp_fl_ct_flow_entry *nft_entry, + struct nfp_fl_ct_tc_merge *tc_m_entry) +{ + struct nfp_fl_ct_flow_entry *post_ct_entry, *pre_ct_entry; + struct nfp_fl_nft_tc_merge *nft_m_entry; + unsigned long new_cookie[3]; + int err; + + pre_ct_entry = tc_m_entry->pre_ct_parent; + post_ct_entry = tc_m_entry->post_ct_parent; + + err = nfp_ct_merge_act_check(pre_ct_entry, post_ct_entry, nft_entry); + if (err) + return err; + + /* Check that the two tc flows are also compatible with + * the nft entry. No need to check the pre_ct and post_ct + * entries as that was already done during pre_merge. + * The nft entry does not have a netdev or chain populated, so + * skip this check. + */ + err = nfp_ct_merge_check(pre_ct_entry, nft_entry); + if (err) + return err; + err = nfp_ct_merge_check(post_ct_entry, nft_entry); + if (err) + return err; + err = nfp_ct_check_meta(post_ct_entry, nft_entry); + if (err) + return err; + + /* Combine tc_merge and nft cookies for this cookie. */ + new_cookie[0] = tc_m_entry->cookie[0]; + new_cookie[1] = tc_m_entry->cookie[1]; + new_cookie[2] = nft_entry->cookie; + nft_m_entry = get_hashentry(&zt->nft_merge_tb, + &new_cookie, + nfp_nft_ct_merge_params, + sizeof(*nft_m_entry)); + + if (IS_ERR(nft_m_entry)) + return PTR_ERR(nft_m_entry); + + /* nft_m_entry already present, not merging again */ + if (!memcmp(&new_cookie, nft_m_entry->cookie, sizeof(new_cookie))) + return 0; + + memcpy(&nft_m_entry->cookie, &new_cookie, sizeof(new_cookie)); + nft_m_entry->zt = zt; + nft_m_entry->tc_m_parent = tc_m_entry; + nft_m_entry->nft_parent = nft_entry; + nft_m_entry->tc_flower_cookie = 0; + /* Copy the netdev from one the pre_ct entry. When the tc_m_entry was created + * it only combined them if the netdevs were the same, so can use any of them. + */ + nft_m_entry->netdev = pre_ct_entry->netdev; + + /* Add this entry to the tc_m_list and nft_flow lists */ + list_add(&nft_m_entry->tc_merge_list, &tc_m_entry->children); + list_add(&nft_m_entry->nft_flow_list, &nft_entry->children); + + /* Generate offload structure and send to nfp */ + err = nfp_fl_ct_add_offload(nft_m_entry); + if (err) + goto err_nft_ct_offload; + + err = rhashtable_insert_fast(&zt->nft_merge_tb, &nft_m_entry->hash_node, + nfp_nft_ct_merge_params); + if (err) + goto err_nft_ct_merge_insert; + + zt->nft_merge_count++; + + return err; + +err_nft_ct_merge_insert: + nfp_fl_ct_del_offload(zt->priv->app, nft_m_entry->tc_flower_cookie, + nft_m_entry->netdev); +err_nft_ct_offload: + list_del(&nft_m_entry->tc_merge_list); + list_del(&nft_m_entry->nft_flow_list); + kfree(nft_m_entry); + return err; +} + static int nfp_ct_do_tc_merge(struct nfp_fl_ct_zone_entry *zt, struct nfp_fl_ct_flow_entry *ct_entry1, struct nfp_fl_ct_flow_entry *ct_entry2) { struct nfp_fl_ct_flow_entry *post_ct_entry, *pre_ct_entry; + struct nfp_fl_ct_flow_entry *nft_entry, *nft_tmp; struct nfp_fl_ct_tc_merge *m_entry; unsigned long new_cookie[2]; int err; @@ -134,6 +245,12 @@ static int nfp_ct_do_tc_merge(struct nfp_fl_ct_zone_entry *zt, goto err_ct_tc_merge_insert; zt->tc_merge_count++; + /* Merge with existing nft flows */ + list_for_each_entry_safe(nft_entry, nft_tmp, &zt->nft_flows_list, + list_node) { + nfp_ct_do_nft_merge(zt, nft_entry, m_entry); + } + return 0; err_ct_tc_merge_insert: @@ -321,8 +438,57 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, return ERR_PTR(err); } +static void cleanup_nft_merge_entry(struct nfp_fl_nft_tc_merge *m_entry) +{ + struct nfp_fl_ct_zone_entry *zt; + int err; + + zt = m_entry->zt; + + /* Flow is in HW, need to delete */ + if (m_entry->tc_flower_cookie) { + err = nfp_fl_ct_del_offload(zt->priv->app, m_entry->tc_flower_cookie, + m_entry->netdev); + if (err) + return; + } + + WARN_ON_ONCE(rhashtable_remove_fast(&zt->nft_merge_tb, + &m_entry->hash_node, + nfp_nft_ct_merge_params)); + zt->nft_merge_count--; + list_del(&m_entry->tc_merge_list); + list_del(&m_entry->nft_flow_list); + + kfree(m_entry); +} + static void nfp_free_nft_merge_children(void *entry, bool is_nft_flow) { + struct nfp_fl_nft_tc_merge *m_entry, *tmp; + + /* These post entries are parts of two lists, one is a list of nft_entries + * and the other is of from a list of tc_merge structures. Iterate + * through the relevant list and cleanup the entries. + */ + + if (is_nft_flow) { + /* Need to iterate through list of nft_flow entries*/ + struct nfp_fl_ct_flow_entry *ct_entry = entry; + + list_for_each_entry_safe(m_entry, tmp, &ct_entry->children, + nft_flow_list) { + cleanup_nft_merge_entry(m_entry); + } + } else { + /* Need to iterate through list of tc_merged_flow entries*/ + struct nfp_fl_ct_tc_merge *ct_entry = entry; + + list_for_each_entry_safe(m_entry, tmp, &ct_entry->children, + tc_merge_list) { + cleanup_nft_merge_entry(m_entry); + } + } } static void nfp_del_tc_merge_entry(struct nfp_fl_ct_tc_merge *m_ent) @@ -425,6 +591,26 @@ nfp_ct_merge_tc_entries(struct nfp_fl_ct_flow_entry *ct_entry1, } } +static void +nfp_ct_merge_nft_with_tc(struct nfp_fl_ct_flow_entry *nft_entry, + struct nfp_fl_ct_zone_entry *zt) +{ + struct nfp_fl_ct_tc_merge *tc_merge_entry; + struct rhashtable_iter iter; + + rhashtable_walk_enter(&zt->tc_merge_tb, &iter); + rhashtable_walk_start(&iter); + while ((tc_merge_entry = rhashtable_walk_next(&iter)) != NULL) { + if (IS_ERR(tc_merge_entry)) + continue; + rhashtable_walk_stop(&iter); + nfp_ct_do_nft_merge(zt, nft_entry, tc_merge_entry); + rhashtable_walk_start(&iter); + } + rhashtable_walk_stop(&iter); + rhashtable_walk_exit(&iter); +} + int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct net_device *netdev, struct flow_cls_offload *flow, @@ -568,6 +754,7 @@ nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offl ct_entry->type = CT_TYPE_NFT; list_add(&ct_entry->list_node, &zt->nft_flows_list); zt->nft_flows_count++; + nfp_ct_merge_nft_with_tc(ct_entry, zt); } return 0; case FLOW_CLS_DESTROY: From patchwork Wed Jun 16 10:02:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 461896 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 A5C08C48BE8 for ; Wed, 16 Jun 2021 10:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BFE861246 for ; Wed, 16 Jun 2021 10:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232427AbhFPKFN (ORCPT ); Wed, 16 Jun 2021 06:05:13 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232279AbhFPKE7 (ORCPT ); Wed, 16 Jun 2021 06:04:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WHwvUOwfLDP6fsPRiz/EPETcgaiJdbqW2o/wEd9FS7ecHOTP6wM1DJ7ApN5rEsZ63vnd7WZtZMaX+N2R9GLDmUw5pHzAO/P3cU0GKJn9RyFs4295Y8EMVfHYwiAZub3Bh/kPHAYX/+fJqe7St9vg4rJc9sZMKCkRulZb8nJbMoo5H+HDjwHRQGzAGPeURNGZ68ESEhGKvZke5rpH+k5fQ/w9l2ru4aAlvDBia6T8E80FXspze2i46S2lRWtSDPKgBwBXEbifK/fRORrrWQWaM5nUMCw+6QQg5lIJpfjmm08bcbCky/iv38SFk06R1aUKirOqopkibXI5QMDFGJ8JFw== 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-SenderADCheck; bh=WBkWBPXkAzdD91b6W43DLCVijcmWHOo2AMsqdXM5rRk=; b=cIoWSs6U9vTHD/l9UXwNPPGRqPzNzE2WAMq0/tSflZ8s5GMoiuM8jDFuK+HG+z/bcIppl7Rr/YrJMfSfwdLGGuO063xG6IlMcXOwVFWQgNdPkuzE3YSxL7XwqzbQcwy3q8Qn7jL5d3GBLF1tlpNkFi+q+8v4Ehf/6q84MtEBCDS1Q1HsXmfvU0yn//2cxc6Hc8JZ0YsiIlO1gteZU3Lx2LVjLXrkr5Z3kO7Qf9eDuaqjcXIwuw6fwUq0MhWJI5YbvIuz36+vYDmE9CKJqocAcTp0jN14rUvfoR8htPITIxfbg+Ve+IjGEnBXmF48TPToBb6ld2jOhRa97PVSew6Iqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WBkWBPXkAzdD91b6W43DLCVijcmWHOo2AMsqdXM5rRk=; b=pJBwzIR3u1efHyX7a3ymhYbBljGyq9bG7PV++8N0w+ulGKca6uGppAmMBFl9FeEU3uEhBiSjCvGp/g1pYpGDnqeImFlQAECDc0nudZWalhimTqCPESFyljKAsp9vSEAQZRUT7cLmkrIvmMY/i16RlIAgMrrk3v1mtLDApw89YdU= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:38 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:38 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 8/9] nfp: flower-ct: fill ct metadata check function Date: Wed, 16 Jun 2021 12:02:06 +0200 Message-Id: <20210616100207.14415-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbc5d0de-e3f1-47b0-b1cc-08d930addf54 X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dS84D8dHX8oBYKnIs//F8e3DIpLFcrW/TIptFk7JaoSRnnIKs9DOdGI2IzqkVoabYJviPtEIJecrz0QyIYf5ho68XFBHQlk0hiWNHXOikufIQtmlMORpOYwn2IH215RTVX65c05A3FtcMyh/SF5jWM7NqMX3xqFgSKp3Xy2okl0SFLE4S8S0ng1rrR/bv+QuOeCdipOgqdLpTdoJoiMmvDzyD7gVQZxbDXsbh7xDL3toBYYzwLSru8H8qx9PA85XdH0yPjmZqbIORM8n8a85DN2iRu8ch0QQX/Zjy3XE960Pw9Y6Jsenv7+0O85bVSlGCT3SznSfeQihBcpjC9hmZWewihcIJGKCCXDOesK4Ui1/kN/QxxIdAE9KQT5LiRwp7Tu4BO5VynZhh5urzcbTKsZJ3qtHwCOUVm8bSRYih1NN13Rp26s+0E/cEBAC6CpEv/xO9z6XJzfpPphDIWJH9N7ho3zWGOov41wk3HpDrBx2mIcsj8geeGIADKNEMqwWbyl/nBBcd3gxoLxC6mFXauNey4RD3EzD9tAwqyEPhawzYYN08kHKmPInAFFdAvUaWSm19SLmUyKdHr1M1MBSOjDFHsbLkzB9s76DE1LvsNpv9ekvbjwOnAdF7UTHn73x7ec0TY4+mDoN2uHKqMinhg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A6C6S4wdlCYuQRjSd9BpgJfGF3eVywfkC69xuIjs4/hT/k0zaa/0vB7hvZJnl5EdY6C/NHUGICyDI7QW2G5Aphs2HeprgpcRuYBFenwwtBNP6i/jb9CBvEq7geFGG2yOojuZl1fNnOu7Mjofk8/zyYP6kbyafviHViilKiBGB2yXw67VDZ/evRCD9w8jnG3AT4ULRiPEzoCeOUPpgeDruIcV9m/+c+BRVYbdjpCgLl8k0ZPicmO4JytQ8jr6gfHTw6zF+4vJ5WhWNAjuHvzJbt+oIHQgq26Mk4MDt7k7XqYXiuPBGKgxeZXX0Lk0UT9zgdV6P3oYONHcbi0tQZ38brF3po8xBRSFxauiETeSF8KThddh1Bt+Pyw7kh2cCVB5QsJtpyQKUpifUSHGJWcbM7uXeFppH701/AX5I3U7YngCSEagKEWMC8dc2lYHFBz0ZUCMStxtJMxvo+GQfmmDtndbBoqHXWTVlob0SPKc1v4MBA4ZFkLpUo3JWaqOzb0Y72sbhV1J+mjRouiiBeNrXe4fbkGzhwHg1Oad+9EEHPQ78GeN3xESsmzea8enYAh+iEM8kW8lFTTSLiFP01XK3MRBLEntiMeUHYkV8fb1EhY7o6Gj+CTjoFPeN7DrxJRs06bucYbfQExpkHyueGQ0stC1ughSntuonTKgv/ekJhCOkfmPxn6LF1PuwjzesU+bSRcfJroHYH0qivZAytBkGekXT5pCxfdnx0AqpJD6Nso544sK06VF56/aKtk2mZsPtORsNyBnvFP15G5//oCfZaG0e1lMTpVXnJm5Ioh0oyicz0rPvdxDPc6ic3W8wEWIBqZtTRih5CC4l7KSGMy1nSKqL5ytoUP+7vsCNvDWWmoIiL0ah6wWdfdhJm4y5pS8lXxZsbwWbdrNDgfHSZT6HBAOrL0BP+eEmoSe1JGDw3jZJMtW0k/Nlmcc04L2f6ilHz3kde2hGgZEnZMAUK1IlWmpTYWmZLIjs6B8xeyCFon0AkPQSPdtQq8k8S63F2qSkft1yFdw3hkK4qeNL6V0Zm1uKnfZakb047ivtylVjjoT8RT6BhicH+3MCLcoBAH1O7MA3GOSK+Mb4xRbJOUR4V0vrgON/V/qjd1AQv4e31vN5gGF31AULx3V0V1yhR9VEz56h0FK2V/D62/yLIS11oPq1URAzPkHivpcOeTfUpI32G1Q1b4Bn9j0Tuj2VQvy5eLUZ9KPzLN/hZtdYuYbl+vTPegLsz3FJN8Ytknf6lnJVYQQIKKqxPi/sqabF0lmhxCIGlk4DeDvLJukLhCcVj49NdyVouGdCvKuD8DVEU4bH6opqihlC6CkJnnp0UTVKN9yf3E1slngEjPWXNf+oVXP8HiWhauQwwWSTX66I3AQP6PMZYnXqAqHd+qogaoI X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbc5d0de-e3f1-47b0-b1cc-08d930addf54 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:38.5524 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GBDhEzrew3LaRENQe4AfcHCRhQA27a+hn5ynnTBXurOmH0X8USYzuBCvYe0Q7X2FtjkKrGzW/j4F3Jdl6J5GmFoOZmrTteyescpFF/VAfcw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Fill in check_meta stub to check that ct_metadata action fields in the nft flow matches the ct_match data of the post_ct flow. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 8bab890390cf..6aecaf41d9cd 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -19,6 +19,9 @@ const struct rhashtable_params nfp_nft_ct_merge_params = { .automatic_shrinking = true, }; +static struct flow_action_entry *get_flow_act(struct flow_rule *rule, + enum flow_action_id act_id); + /** * get_hashentry() - Wrapper around hashtable lookup. * @ht: hashtable where entry could be found @@ -258,7 +261,31 @@ static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, static int nfp_ct_check_meta(struct nfp_fl_ct_flow_entry *post_ct_entry, struct nfp_fl_ct_flow_entry *nft_entry) { - return 0; + struct flow_dissector *dissector = post_ct_entry->rule->match.dissector; + struct flow_action_entry *ct_met; + struct flow_match_ct ct; + int i; + + ct_met = get_flow_act(nft_entry->rule, FLOW_ACTION_CT_METADATA); + if (ct_met && (dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CT))) { + u32 *act_lbl; + + act_lbl = ct_met->ct_metadata.labels; + flow_rule_match_ct(post_ct_entry->rule, &ct); + for (i = 0; i < 4; i++) { + if ((ct.key->ct_labels[i] & ct.mask->ct_labels[i]) ^ + (act_lbl[i] & ct.mask->ct_labels[i])) + return -EINVAL; + } + + if ((ct.key->ct_mark & ct.mask->ct_mark) ^ + (ct_met->ct_metadata.mark & ct.mask->ct_mark)) + return -EINVAL; + + return 0; + } + + return -EINVAL; } static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) @@ -727,13 +754,13 @@ void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry) kfree(entry); } -static struct flow_action_entry *get_flow_act(struct flow_cls_offload *flow, +static struct flow_action_entry *get_flow_act(struct flow_rule *rule, enum flow_action_id act_id) { struct flow_action_entry *act = NULL; int i; - flow_action_for_each(i, act, &flow->rule->action) { + flow_action_for_each(i, act, &rule->action) { if (act->id == act_id) return act; } @@ -791,14 +818,14 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct nfp_fl_ct_zone_entry *zt; int err; - ct_act = get_flow_act(flow, FLOW_ACTION_CT); + ct_act = get_flow_act(flow->rule, FLOW_ACTION_CT); if (!ct_act) { NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack action empty in conntrack offload"); return -EOPNOTSUPP; } - ct_goto = get_flow_act(flow, FLOW_ACTION_GOTO); + ct_goto = get_flow_act(flow->rule, FLOW_ACTION_GOTO); if (!ct_goto) { NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack requires ACTION_GOTO");