From patchwork Wed Mar 31 16:40:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Buslov X-Patchwork-Id: 12175765 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 X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27648C43461 for ; Wed, 31 Mar 2021 16:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6D2F6103D for ; Wed, 31 Mar 2021 16:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234133AbhCaQl3 (ORCPT ); Wed, 31 Mar 2021 12:41:29 -0400 Received: from mail-eopbgr760052.outbound.protection.outlook.com ([40.107.76.52]:3627 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233822AbhCaQlB (ORCPT ); Wed, 31 Mar 2021 12:41:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wy6P/DYYe1MzmR4j+GVAT3g0tn6GsqmKCR5XbSiE9FZA/FAbM3MKbTkEoxe8+NzvIILFXBh4u6mrqJ6wl+K3qSXQ7gqC5glEd+VSmtsMQBXeQNu4PaEBk4zXypY2XAHDLHY2gVtaBm6O+yDUabfARNpIwU+JLpJ37q1jETHLbPDqGtKRhkHmwBB260CmSnIq1VxvxiNbE4pYq+Omb7EpfvbXF7IMt3xUXWnhBXYIQAgFQhOw1ZVEwQ7JaqK3h/Qln69Opf5u+joNtVJ8536INuSRmcSnLj3dOJQYhKtIk1SldlXFEXXwr/6FSTRsXHnfdGj93/yqwfPKyF1MFIm4Cw== 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=V/uIBygNGFAoGfw2KmCBPfi5/dI2RAzeqZw7YXkpt+s=; b=Yl900e1bwOfm5c0nX2oOlMvGF1ASRPjPg+6tto/VO5vCNeJDd0GmwrAs3EHDmDrtLCjPe32ePKpbHFlEy1cY6Xa60hc0POpOUYjWlTSiSx+70rIlihpkVs19qW+baAfW97SjdbEQ/vtbahQbF+sE2lbWSW95HsTodB+NpHS8g7G5AcwTet8o2tC+HNiDDArrBFh2hFoIkT4QFwbrBGK19EgTy7rUMOZKQIr1qM0yCMOCpJoWDyqqmNw/GxOYGc6Ia4ls31utf9pYUiFsc4xBohDJvXp9/qCjwzd8pHAfqDUsQyZwQEcl3DmqPTnjl+7S8mK0JsVkRpz5qx0n8WLWlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=resnulli.us smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=V/uIBygNGFAoGfw2KmCBPfi5/dI2RAzeqZw7YXkpt+s=; b=bp+YK71lqptwxndQGn1hu2dW8W3Zw8LUc95QPForiKpWRLJRleclkC6099Vg5v373+21LphBEB4gy9I1j8YYvLYsPfgnuvTCAP9ylUsSMw3elGi73TMbXKEmPbu6+yoXBul1i8DXU9+7tnh0C9NlgOyBLIER5b2saRmvjiB2Q1U9MKJGQUelCN62OVHRDXkP5GjKj23E2zwF9ppCA6rtgo7LtqMdKhTAxG/XLIairqzbnfTTe7GXofRvI2dwroYWgKVFE5wFjbuO81Fa8+2pMlv7yr6TLecWCgw9CdRM/eeLMjlq8HeKvSsWMvLg16PGIpYWF0MyuLzNI+L7xDuN7A== Received: from BN6PR13CA0043.namprd13.prod.outlook.com (2603:10b6:404:13e::29) by DM6PR12MB4170.namprd12.prod.outlook.com (2603:10b6:5:219::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Wed, 31 Mar 2021 16:41:00 +0000 Received: from BN8NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:404:13e:cafe::e2) by BN6PR13CA0043.outlook.office365.com (2603:10b6:404:13e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.16 via Frontend Transport; Wed, 31 Mar 2021 16:41:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; resnulli.us; dkim=none (message not signed) header.d=none;resnulli.us; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by BN8NAM11FT019.mail.protection.outlook.com (10.13.176.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 31 Mar 2021 16:40:57 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 31 Mar 2021 16:40:56 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 31 Mar 2021 16:40:54 +0000 From: Vlad Buslov To: CC: , , , , , , , Vlad Buslov Subject: [PATCH RFC 1/4] net: sched: fix action overwrite reference counting Date: Wed, 31 Mar 2021 19:40:09 +0300 Message-ID: <20210331164012.28653-2-vladbu@nvidia.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210331164012.28653-1-vladbu@nvidia.com> References: <20210331164012.28653-1-vladbu@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf2be039-2f93-4de8-f14a-08d8f463c26a X-MS-TrafficTypeDiagnostic: DM6PR12MB4170: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WayCXWdGjAjaAlszN1qX0w6D6PQye647NqFwApf/dIeyDeO6kpmK/Wjd4g/B72iIfpaN66bHnI7WvRahRkwdTUtd/r4PcbxNPDLvsweDCTEdpC+nyE1jyzCmeYA5Uifi4VWi77ljpLVg6YzvZFW3UYW0ntX6Wi9g3ew3gI1N/rwff2JvjiND8zDKrXcdTNSOkcYOP6lDrD2vosofCPaNj53JhNzptJBGKXKil+hrscuCjlo/k4AutkK9tvj2tc+NqdZOpqpNQyXYc2j/ThqeGDJWkGJgUQ3sLbDY1fjaBnCaQpiHpIQnlYe2aNnlyrcNt0M+jL3TdZzSi/vSLHnD0fGRMvlVQ1pnsGAK68nDwq/wzLsyZEXkFiwUCT8OS8oO+tkluu3zrN9T4DgvmTZ14P+EFDtWs7MnbEPRBpevInK1I44qw1CinVrAChMOifbd8s1IgvjwRvM0fNV0clJJkRQM7bY3bJeQSXUjMbpA0xceUIToz8zUWWw7ag8PeQVtcU60+U7vHUPjkPAvLKuxVXgoJUPO00RCq91CNGvgoRq5PLNN3BSzdqMi/25rlAHXHQYUCL0RZpPteOHKFNrH2twyFODQ+DQU0/9RRoSfBvG1KwxwyvfYNPseT8lkkSq/VGaxeTFDQa4G5aYm7WwkbD9bKsLMO36DnlciwY1Siec= X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(346002)(39860400002)(376002)(136003)(46966006)(36840700001)(107886003)(7636003)(82740400003)(70586007)(356005)(70206006)(6916009)(7696005)(8676002)(2906002)(8936002)(54906003)(83380400001)(186003)(316002)(36756003)(82310400003)(426003)(478600001)(4326008)(6666004)(26005)(36906005)(1076003)(2616005)(5660300002)(86362001)(336012)(47076005)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 16:40:57.1974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf2be039-2f93-4de8-f14a-08d8f463c26a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4170 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Action init code increments reference counter when it changes an action. This is the desired behavior for cls API which needs to obtain action reference for every classifier that points to action. However, act API just needs to change the action and releases the reference before returning. This sequence breaks when the requested action doesn't exist, which causes act API init code to create new action with specified index, but action is still released before returning and is deleted (unless it was referenced concurrently by cls API). Fixes: cae422f379f3 ("net: sched: use reference counting action init") Reported-by: Kumar Kartikeya Dwivedi Signed-off-by: Vlad Buslov --- include/net/act_api.h | 5 +++-- net/sched/act_api.c | 27 +++++++++++++++++---------- net/sched/cls_api.c | 9 +++++---- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 2bf3092ae7ec..312f0f6554a0 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -185,7 +185,7 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, int nr_actions, struct tcf_result *res); int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, char *name, int ovr, int bind, - struct tc_action *actions[], size_t *attr_size, + struct tc_action *actions[], int init_res[], size_t *attr_size, bool rtnl_held, struct netlink_ext_ack *extack); struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla, bool rtnl_held, @@ -193,7 +193,8 @@ struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla, struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, char *name, int ovr, int bind, - struct tc_action_ops *ops, bool rtnl_held, + struct tc_action_ops *a_o, int *init_res, + bool rtnl_held, struct netlink_ext_ack *extack); int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int bind, int ref, bool terse); diff --git a/net/sched/act_api.c b/net/sched/act_api.c index b919826939e0..eb20a75796d5 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -777,8 +777,11 @@ static int tcf_action_put(struct tc_action *p) return __tcf_action_put(p, false); } -/* Put all actions in this array, skip those NULL's. */ -static void tcf_action_put_many(struct tc_action *actions[]) +/* Put all actions in this array, skip those NULL's. If cond array is provided + * by caller, then only put actions that match. + */ +static void tcf_action_put_many(struct tc_action *actions[], int *cond, + int match) { int i; @@ -786,7 +789,7 @@ static void tcf_action_put_many(struct tc_action *actions[]) struct tc_action *a = actions[i]; const struct tc_action_ops *ops; - if (!a) + if (!a || (cond && cond[i] != match)) continue; ops = a->ops; if (tcf_action_put(a)) @@ -992,7 +995,8 @@ struct tc_action_ops *tc_action_load_ops(char *name, struct nlattr *nla, struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, char *name, int ovr, int bind, - struct tc_action_ops *a_o, bool rtnl_held, + struct tc_action_ops *a_o, int *init_res, + bool rtnl_held, struct netlink_ext_ack *extack) { struct nla_bitfield32 flags = { 0, 0 }; @@ -1028,6 +1032,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, } if (err < 0) goto err_out; + *init_res = err; if (!name && tb[TCA_ACT_COOKIE]) tcf_set_action_cookie(&a->act_cookie, cookie); @@ -1056,7 +1061,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est, char *name, int ovr, int bind, - struct tc_action *actions[], size_t *attr_size, + struct tc_action *actions[], int init_res[], size_t *attr_size, bool rtnl_held, struct netlink_ext_ack *extack) { struct tc_action_ops *ops[TCA_ACT_MAX_PRIO] = {}; @@ -1084,7 +1089,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { act = tcf_action_init_1(net, tp, tb[i], est, name, ovr, bind, - ops[i - 1], rtnl_held, extack); + ops[i - 1], &init_res[i - 1], rtnl_held, + extack); if (IS_ERR(act)) { err = PTR_ERR(act); goto err; @@ -1462,7 +1468,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, return 0; } err: - tcf_action_put_many(actions); + tcf_action_put_many(actions, NULL, 0); return ret; } @@ -1499,10 +1505,11 @@ static int tcf_action_add(struct net *net, struct nlattr *nla, size_t attr_size = 0; int loop, ret; struct tc_action *actions[TCA_ACT_MAX_PRIO] = {}; + int init_res[TCA_ACT_MAX_PRIO] = {}; for (loop = 0; loop < 10; loop++) { ret = tcf_action_init(net, NULL, nla, NULL, NULL, ovr, 0, - actions, &attr_size, true, extack); + actions, init_res, &attr_size, true, extack); if (ret != -EAGAIN) break; } @@ -1510,8 +1517,8 @@ static int tcf_action_add(struct net *net, struct nlattr *nla, if (ret < 0) return ret; ret = tcf_add_notify(net, n, actions, portid, attr_size, extack); - if (ovr) - tcf_action_put_many(actions); + /* Only put existing actions that were changed by init (res==0). */ + tcf_action_put_many(actions, init_res, 0); return ret; } diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index d3db70865d66..f7425bb9fc3d 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3040,6 +3040,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, { #ifdef CONFIG_NET_CLS_ACT { + int init_res[TCA_ACT_MAX_PRIO] = {}; struct tc_action *act; size_t attr_size = 0; @@ -3051,8 +3052,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, return PTR_ERR(a_o); act = tcf_action_init_1(net, tp, tb[exts->police], rate_tlv, "police", ovr, - TCA_ACT_BIND, a_o, rtnl_held, - extack); + TCA_ACT_BIND, a_o, init_res, + rtnl_held, extack); if (IS_ERR(act)) { module_put(a_o->owner); return PTR_ERR(act); @@ -3067,8 +3068,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, err = tcf_action_init(net, tp, tb[exts->action], rate_tlv, NULL, ovr, TCA_ACT_BIND, - exts->actions, &attr_size, - rtnl_held, extack); + exts->actions, init_res, + &attr_size, rtnl_held, extack); if (err < 0) return err; exts->nr_actions = err; From patchwork Wed Mar 31 16:40:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Buslov X-Patchwork-Id: 12175759 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 X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF8C8C43462 for ; Wed, 31 Mar 2021 16:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 773766103E for ; Wed, 31 Mar 2021 16:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234054AbhCaQl2 (ORCPT ); Wed, 31 Mar 2021 12:41:28 -0400 Received: from mail-dm6nam12on2060.outbound.protection.outlook.com ([40.107.243.60]:33505 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233900AbhCaQlC (ORCPT ); Wed, 31 Mar 2021 12:41:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I39QGdu24SL80TgdGtC7wBbodovheYH4WVPTLwgcIUfaBiF6zmD5w2tW9Z0kzo9Tsab65oRaugJLxV9LumB/kGXjriD6RPKV8IKKlBzrVFyP/rvBQHaDY0kINROe0zMqZnFQ2gNgNnmlE1hNgWxhJkK7yVca2iKF+yn7mDA1FhXDkUbFZ+qYyfo/gWFPKPtQ5S6TL2FLrtcAsBiqRj2EZKVs6GykMiN1t+Ij3t0MF48NAz1U3wM2wmG7JcgzqpGdlKaYWRswFmtTzqhIz17a5PA7qA11fPm8V/NeiKDESjajTTe8ZzAXGJWQt+oJseRYTBLty8KJbkD0gzR08BKTEQ== 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=jOBpEIMM2rZwZ97aGYOKb0f3nR5Sey00ri45JQsT7V8=; b=bPsQSMIEuxe3kpau0/lN23ym2cltT/IEvp6r118t3oMY5TqYsLwgy8Yvh7YGT+6e7Gfbb/rdYmpCdx/UPNuJW5l0jeCEj6FcS8ZBnZcAp7lthDSuKKAbh/DvR5kUIoVj42s1Ysj314NemLCnt2+oT2+jCoQTa2KR6v5BPNxaRrefziSMMEXjAy+4pVmZXcSotjjnbKOwSi49SSW0X8GpGd5Gs1uYDnNiZscB6lzsA8eCGAJeydz8bSEx5Zk24jPQIuffYa2Aq2UpHHjvpK5YkOnxcgZ+XwIy4JmZ/oHJ8xsQVn2oYx3F77DdtDsoQOXqr4RcTbjvlhCU0KSHTE6GcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=resnulli.us smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=jOBpEIMM2rZwZ97aGYOKb0f3nR5Sey00ri45JQsT7V8=; b=cAZowgCRXhTdTEUBxUVlu3FlkJFCwZxRmU+aFrW+scDz/+08FSZoBgu07vCCYQbsSr1w8rSzSs1ZEA+PzfkAByxloU28PqML9gLMc2UAqVZKaGorUlYKJciTV0DkKIWEX5HE8ksLuajcpkya6PSdSeiRVWWH/fVrpA99txV6eB0Z7Q8tpnsExRbnMJpjCRlPNNhB9VhzyTIpkUcKSMjIkYYTO9rMrGmyQ01YFQjIrSXyrArAtCvVO4WykBUsAbhTN/TSvJJ0WLmgSdx6/wZ9uRTcuOHFMohJQ2+RvJOYlI6yXfCLYyjtEOgFFZgsrIMbCjJw81lqRTe6SCiYOuQsgQ== Received: from BN9PR03CA0446.namprd03.prod.outlook.com (2603:10b6:408:113::31) by DM6PR12MB4828.namprd12.prod.outlook.com (2603:10b6:5:1f8::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Wed, 31 Mar 2021 16:41:00 +0000 Received: from BN8NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:408:113:cafe::fb) by BN9PR03CA0446.outlook.office365.com (2603:10b6:408:113::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26 via Frontend Transport; Wed, 31 Mar 2021 16:41:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; resnulli.us; dkim=none (message not signed) header.d=none;resnulli.us; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by BN8NAM11FT018.mail.protection.outlook.com (10.13.176.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 31 Mar 2021 16:40:59 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 31 Mar 2021 09:40:59 -0700 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 31 Mar 2021 16:40:57 +0000 From: Vlad Buslov To: CC: , , , , , , , Vlad Buslov Subject: [PATCH RFC 2/4] net: sched: fix err handler in tcf_action_init() Date: Wed, 31 Mar 2021 19:40:10 +0300 Message-ID: <20210331164012.28653-3-vladbu@nvidia.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210331164012.28653-1-vladbu@nvidia.com> References: <20210331164012.28653-1-vladbu@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ddbd19e1-b994-4ca7-b337-08d8f463c40a X-MS-TrafficTypeDiagnostic: DM6PR12MB4828: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rKpry+knBHbxGk/MUPR15g6xO7DOCqffzyiKZmw7jPWc4ftaS7YazAkx+NRVYkLz5hJuy37kY0797odBoQB+fO0AwssAgtdmjbm0wiuDIpEio/E8xp6pPVN4OxNo1IpacbTCRdmE5X13eVipgIcAKB49fPl80Et4lNLyK8FD8b1xbgBPKgxQjnxgH2CuE+kdzZ3WBMsP2A7CHWN5mQDYEublgPAyBPlJrLAW+J5vAIZN05HH7f+GG0QUujeJH6FTcaeK1dxWeZcM7rT1HN8IgpVg7dIbjCfPsiAJXHCohI7XAPExVWYbT1zwWEeDhb00KOEiweC9O5F3FnMvl8lttelofM9Q4FXrtInQc3k4L/nD/mBbIcAPkjEbB/7nrNKGNSYjDTmtF1NpnCY0zvj1RthXCiO26xzyMwUVT+Mfx3q+srVW0IX0/DWmfuWXFRBUsyhED45tt7RDn94goRXC8yHlTf7LOqgabxwJtoaCzYz+aSLSrQuOwNXXKpUy3+0xhnYEPDcIIDK85TN1tdvARPslH0A5xvzor7kdLUgHuF+30pLiithG6SordJE6Lw63GizK2u3FhWThpAFUMucdJrfGzCcj5MAWlMiOkxM2kp59I7dgWeBvQEleFEZC+j+ZC2G160TeQi9WVdz6BMz1/WmYn6YKiIcr1igzCJo7zEA= X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(136003)(39860400002)(346002)(376002)(396003)(46966006)(36840700001)(4326008)(8676002)(2906002)(36756003)(2616005)(107886003)(83380400001)(82310400003)(54906003)(82740400003)(7636003)(186003)(5660300002)(36860700001)(26005)(1076003)(7696005)(86362001)(6916009)(336012)(478600001)(70586007)(70206006)(47076005)(356005)(6666004)(426003)(316002)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 16:40:59.9331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ddbd19e1-b994-4ca7-b337-08d8f463c40a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4828 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC With recent changes that separated action module load from action initialization tcf_action_init() function error handling code was modified to manually release the loaded modules if loading/initialization of any further action in same batch failed. For the case when all modules successfully loaded and some of the actions were initialized before one of them failed in init handler. In this case for all previous actions the module will be released twice by the error handler: First time by the loop that manually calls module_put() for all ops, and second time by the action destroy code that puts the module after destroying the action. Reproduction: $ sudo tc actions add action simple sdata \"2\" index 2 $ sudo tc actions add action simple sdata \"1\" index 1 action simple sdata \"2\" index 2 RTNETLINK answers: File exists We have an error talking to the kernel $ sudo tc actions ls action simple total acts 1 action order 0: Simple <"2"> index 2 ref 1 bind 0 $ sudo tc actions flush action simple $ sudo tc actions ls action simple $ sudo tc actions add action simple sdata \"2\" index 2 Error: Failed to load TC action module. We have an error talking to the kernel $ lsmod | grep simple act_simple 20480 -1 Fix the issue by refactoring tcf_action_init() error handling code to properly account for the case of partially initialized action list and only put the module for actions that haven't been initialized. Fixes: d349f9976868 ("net_sched: fix RTNL deadlock again caused by request_module()") Signed-off-by: Vlad Buslov --- net/sched/act_api.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index eb20a75796d5..4ef556906e32 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -753,20 +753,28 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, } EXPORT_SYMBOL(tcf_action_exec); -int tcf_action_destroy(struct tc_action *actions[], int bind) +static int tcf_action_destroy_1(struct tc_action *a, int bind) { const struct tc_action_ops *ops; + int ret; + + ops = a->ops; + ret = __tcf_idr_release(a, bind, true); + if (ret == ACT_P_DELETED) + module_put(ops->owner); + return ret; +} + +int tcf_action_destroy(struct tc_action *actions[], int bind) +{ struct tc_action *a; int ret = 0, i; for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) { a = actions[i]; actions[i] = NULL; - ops = a->ops; - ret = __tcf_idr_release(a, bind, true); - if (ret == ACT_P_DELETED) - module_put(ops->owner); - else if (ret < 0) + ret = tcf_action_destroy_1(a, bind); + if (ret < 0) return ret; } return ret; @@ -1082,7 +1090,7 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, a_o = tc_action_load_ops(name, tb[i], rtnl_held, extack); if (IS_ERR(a_o)) { err = PTR_ERR(a_o); - goto err_mod; + goto err; } ops[i - 1] = a_o; } @@ -1109,11 +1117,13 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, return i - 1; err: - tcf_action_destroy(actions, bind); -err_mod: for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { - if (ops[i]) + if (actions[i]) { + tcf_action_destroy_1(actions[i], bind); + actions[i] = NULL; + } else if (ops[i]) { module_put(ops[i]->owner); + } } return err; } From patchwork Wed Mar 31 16:40:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Buslov X-Patchwork-Id: 12175763 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=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCE36C43600 for ; Wed, 31 Mar 2021 16:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9659861042 for ; Wed, 31 Mar 2021 16:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234173AbhCaQla (ORCPT ); Wed, 31 Mar 2021 12:41:30 -0400 Received: from mail-mw2nam12on2073.outbound.protection.outlook.com ([40.107.244.73]:61921 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233914AbhCaQlE (ORCPT ); Wed, 31 Mar 2021 12:41:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJfoDPZfA0MR9z9uQlfjdB0ieuHXIwBP9Kn6a+v0RdKla0F0t4fcNfIfzA6YfJXUPLFqDV+5PrOuOw3OsOp4t3X+uSN6LPFgN8nV3wrDQBVQHr+mcOxBcrTIJgBYpvOagyaotlzXuhE4jNk5KfhGd1NRf+oeBh8nqXDX3sbC3tR2UX3EdiPW+Y6P1v7VmWaS5I14b9QcROsyTV6HPvl1RX4Yw8sHC18fg5NCSCtytrKshg7+/sMXsFhuSnthrMNnK3xWTz8VVDfIWsNW3GyU8k6qFP4Wfaiy6BS8H7Vy/JY/DHiQp/Jcg0FILytAlWynqiByRRA8IAQtJXiIFN7daQ== 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=j/hSpk5OTts9XZ1ORj9EMNCow1/QgYPqT31tlaTjAUg=; b=MxwZmFM0Pde/PtFVehDBbxg0SxttHLhBe3R5xwCG+Y/zJpzTv66JuR7R09hDiGpvOUp95tBa91zTDKMiqf8bVVyMOeyN4ScZ60ios47nWYSr6QcvDDt37mv1Fns9V9Z0V6dCcCZZulXEbhsA3XEUFxQ1W6MYbMzMd+Cm//yqo9coSINLYeouynSeqQHxSh7i2zpOXikvmCuSC6SvJu5GbpWtfs1yu9qS+soNs4miKcReZdjdtnWsOvQinszju7KVUfQYblYFHrIT6IbROuyj+gRTQMxjVYLgWUhwUX9T5RCHSAlu5fbYFDTx6bPsC3/0FTBcoyv1Ly3NJM1/h4mmrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=resnulli.us smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=j/hSpk5OTts9XZ1ORj9EMNCow1/QgYPqT31tlaTjAUg=; b=sckEbo0BcRlpUNjNe+2T38LM3Wfoan7GidsCxpjV6bScpxNULasXFPrIJchEkn5fFntLoRTRfQeGKCB0HgQV6pVlBXVpVAaLS6mreZObfO+qQiwy5Q39GU8AJLSIxkVdvqpEAnUgvA82vTUKhsn7ykcVIIpvvQ7yLz6UbsheOFBtOv+VYxX3ucrkYGpRYpmtHLWxQ6UyIKC64hAUjC26Yp0u+8Fy7WKlgU5UMnyi+L+iqctOuwSwtMRDikSun9uwBuwohy7aWMz2HFhzWOVfF06uNanRCRKK0MJOPe7YjibRyz8DVG/fCluKmXlxg6Ir+H5tgdQad26W5iY48+Px2Q== Received: from BN0PR02CA0006.namprd02.prod.outlook.com (2603:10b6:408:e4::11) by BYAPR12MB3544.namprd12.prod.outlook.com (2603:10b6:a03:131::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.31; Wed, 31 Mar 2021 16:41:03 +0000 Received: from BN8NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e4:cafe::39) by BN0PR02CA0006.outlook.office365.com (2603:10b6:408:e4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28 via Frontend Transport; Wed, 31 Mar 2021 16:41:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; resnulli.us; dkim=none (message not signed) header.d=none;resnulli.us; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT046.mail.protection.outlook.com (10.13.177.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 31 Mar 2021 16:41:02 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 31 Mar 2021 16:41:02 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 31 Mar 2021 16:40:59 +0000 From: Vlad Buslov To: CC: , , , , , , , Vlad Buslov Subject: [PATCH RFC 3/4] tc-testing: add simple action test to verify batch add cleanup Date: Wed, 31 Mar 2021 19:40:11 +0300 Message-ID: <20210331164012.28653-4-vladbu@nvidia.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210331164012.28653-1-vladbu@nvidia.com> References: <20210331164012.28653-1-vladbu@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 238bbe7a-95db-47d1-3be5-08d8f463c5a7 X-MS-TrafficTypeDiagnostic: BYAPR12MB3544: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1cEWLSWReHUHRCEmBwRtPlCYJGUK+DsBmOYUGoUTpSxgCfTlAVstgrOrugyVp8NAcBdM0b/3SotsBlBM1MJfqgOZAuUsn1FE+psS7NiG38ECUlwhysEMw3XyCaawKhn8HopYzQYehkWvprmHHrY4g+1GpEw8c5I7x0OqeOQwkmAI3bM523tUJz+m+C7iTkAtmi1CBtH21MRcOvhddPSSUHXNvCywjAF102JRzy6vQ5QMm7GwUJkoFVPDYzYUPhI13nXtTQAGKz9WS4P3RJ49dYoLGJmt9yMuNx544aK0tx88zbZ/vVOKBSJJ5HSj4hV4xxdujxlQ/QeWrQl5RodhACndLEbPLbMNSxRu+VpyAT7h6XqRwB8/f2DDynaTe1WXNUi8nPH1am33FUblfsWYd9uLL0W/8XLXXS6igCNTbU2kVXhjUH5yfJ5iLuPtcqKKI3DR0z9gH5KsGEdlPtmLwo5/4o5K4XWj+3ijZW6EFA5eFBxQsOSKCsRrtfNks+EBnbVSmpJXBMyaUfiaZBEP2+hC8hU2cT24av9hP4U15EGfrSROCiRa1nKFIxArcerCOtpJcyiFxWrljn4Qwq8oB2HmBKfLVg/0cey7d155Yurd1B7TTUTKu9gv0Zp32DjtKQAYOA2gULPWP1xK6WM+59QV9+AueNQuotkcqHIe30w= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(136003)(376002)(346002)(39860400002)(46966006)(36840700001)(7696005)(6666004)(5660300002)(426003)(6916009)(7636003)(15650500001)(36906005)(1076003)(4326008)(316002)(83380400001)(54906003)(82740400003)(336012)(70586007)(26005)(478600001)(47076005)(70206006)(36756003)(8936002)(36860700001)(2616005)(107886003)(2906002)(82310400003)(86362001)(8676002)(356005)(186003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 16:41:02.6417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 238bbe7a-95db-47d1-3be5-08d8f463c5a7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3544 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC Verify cleanup of failed actions batch add where second action in batch fails after successful init of first action. Signed-off-by: Vlad Buslov --- .../tc-testing/tc-tests/actions/simple.json | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json b/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json index e15f708b0fa4..d5bcbb919dcc 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json @@ -175,5 +175,35 @@ "teardown": [ "$TC actions flush action simple" ] + }, + { + "id": "8d07", + "name": "Verify cleanup of failed actions batch add", + "category": [ + "actions", + "simple" + ], + "setup": [ + [ + "$TC actions flush action simple", + 0, + 1, + 255 + ], + "$TC actions add action simple sdata \"2\" index 2", + [ + "$TC actions add action simple sdata \"1\" index 1 action simple sdata \"2\" index 2", + 255 + ], + "$TC actions flush action simple" + ], + "cmdUnderTest": "$TC actions add action simple sdata \"2\" index 2", + "expExitCode": "0", + "verifyCmd": "$TC actions list action simple", + "matchPattern": "action order [0-9]*: Simple <2>.*index 2 ref", + "matchCount": "1", + "teardown": [ + "$TC actions flush action simple" + ] } ] From patchwork Wed Mar 31 16:40:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Buslov X-Patchwork-Id: 12175761 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=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00D79C43470 for ; Wed, 31 Mar 2021 16:42:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5EBB60FE8 for ; Wed, 31 Mar 2021 16:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234204AbhCaQlb (ORCPT ); Wed, 31 Mar 2021 12:41:31 -0400 Received: from mail-bn7nam10on2046.outbound.protection.outlook.com ([40.107.92.46]:22866 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229486AbhCaQlI (ORCPT ); Wed, 31 Mar 2021 12:41:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j6bsM6Jk43zmdNJYpe+nfeyql8aOTSw/X7P/0MqleP+2OQggx4NMMacEbkQT/TkjT9Gpwm1WCCuhTd0v0H3ScYiHLVg+edTUTXqgb/apSiA62JsQ4wLVBlTajzSYi5ZFC03tB6rN8AqGaTIkYQ5hDoHShglg+hDoAs8liJcMBjy+ukIYeqerGxWKzj//lNTUAiPg32lmtfSi7yJld4zBu+bP+VUWaCEMuFvHJuZlj/TU+veBtWigcpgAzaghIUQQ+6gAumBtsIitGPhtO/7NCsYNCbgmRXcurhIs8uSRP7DjZdjlJG5DswPdo5TdThzfgm9XOmaGxFiBrxSK/VtdqA== 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=Lx7mwgv63X0PmOqcC32SIl3tWfloAfdePU0fXb5mG1w=; b=Ccg3R1Zov4/vuDFZyQ/d47WlWgJ665ev76HmdDilda+0dr8/iQA0Z0x3sP/3Ey3cNnS9lHCe/K9POhIwrb4k2+0nYrDRh3U1lWa7l6t0+gs/m1kYim8W+zSNLV5r486juW260pfGF/VsufD8JaDURzuUzQufabvUVoz8ivchsgfsJn3izHxuKLqcfhHaCRXZoImzoOmNaoqnBU0tvJCj1A/hXJMHAuV7XkUowPK7QeRnigV2LX6HfOTUBGZW74KJ93+aCeymkObe2ZbCVcxw1LIzRbnc2JLw6I0I1TkI05C6ZIFMhffUOZ7M9GHHndDznNU6nc3hDZuokj168ZKxzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=resnulli.us smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=Lx7mwgv63X0PmOqcC32SIl3tWfloAfdePU0fXb5mG1w=; b=uJGBLJQOnIfvBs9H+WAcM1hnAwMMjVRCvVF31krfO8pzXmGq91mgk7ip7x18bPk7lFMAeRU48LnWv7tW8Td8VzkWs51iDYLSVnljNkrygMXOgK5fuROmS1q9/QmfXArD5kZOIDCQCbwQc9go20BEDKADldMDS0FDX1LlWNVY7vZ5CO7BuxS3cKirIoHgJMWzFTLDIVhf/dEvAFqOHGDvMtjccoBx0XcDxXLWypB1AAMgMDV1pKaoZ98e7TRmKLrqFISmhBYh+0wCDMyAVs/+O5Ji9/XtvkOkz6kpimys9Sh7PXo5b3EJVFl5Mltdb2r+vjBprA33zg4G5gVSOU+7lw== Received: from BN9PR03CA0478.namprd03.prod.outlook.com (2603:10b6:408:139::33) by BL0PR12MB4740.namprd12.prod.outlook.com (2603:10b6:208:84::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Wed, 31 Mar 2021 16:41:06 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::24) by BN9PR03CA0478.outlook.office365.com (2603:10b6:408:139::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27 via Frontend Transport; Wed, 31 Mar 2021 16:41:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; resnulli.us; dkim=none (message not signed) header.d=none;resnulli.us; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 31 Mar 2021 16:41:05 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 31 Mar 2021 16:41:04 +0000 Received: from vdi.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 31 Mar 2021 16:41:02 +0000 From: Vlad Buslov To: CC: , , , , , , , Vlad Buslov Subject: [PATCH RFC 4/4] tc-testing: add simple action test to verify batch change cleanup Date: Wed, 31 Mar 2021 19:40:12 +0300 Message-ID: <20210331164012.28653-5-vladbu@nvidia.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210331164012.28653-1-vladbu@nvidia.com> References: <20210331164012.28653-1-vladbu@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d182b281-bd7b-4820-3192-08d8f463c793 X-MS-TrafficTypeDiagnostic: BL0PR12MB4740: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yUUFr/Hmz6PjFyXc74/fU+89ruQsQrWQcqaNnmb/OZ07FCfKvjcMEuR3QPPZkXSfkPlp1GU8OfF1Wh1YyhqLm/nDLZvdb+SqLPU6+ZVz86XnS0d1E/DIeHhWL5Ju3tRaawiZRgbDItDg15WkNUbtpZddgwy+TW9MelQl7d3IXJq6YTNxigQXs4tg7R3O9IgqEsP4mlWeaFAEqDkZEZhpCB8tTbhMzbkz8bBwsLkqfrRIjhjclU6+8GhaHH+vnZXN/lftSs/kThmx1jZcPXQxBTAunAslSU2glrRBC1/Cpy+TEVZgBFzRoGAa/QJM1ODWu+KZjlGwOLas8ieXBVizx0fiQBa+OnGi48xOP7gJ336tC235CAZDrJRuYmO4/sL+of2WTcLHc6ctMSBnrZyUY4qM+s1ek/dbQDs1AnShf4uqUzifhAFPSDokIHIzX6/oQSnJNmt7IiYdZTvjxe8STR/JUs9MqIFNsNxDgwZZBdVebjCbhUnSTtboWhEi+iJvaxoa4h/Jq4MPuIiT3btl/VksLoGS8CWAbQGUS53ue2v1gKYGYoKBBn8oDYBGPGQcH3ce5tRkxPBc+agz7GxQ/B2Ghh6QntpdP7HJdTKwcGZ0URoMEkgEq95ofBAuUw+aC/mokywazOTkuoCZ62NnR5YvfPKjJJv66jgRdOIViTY= X-Forefront-Antispam-Report: CIP:216.228.112.35;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid02.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(39860400002)(346002)(376002)(136003)(46966006)(36840700001)(8936002)(5660300002)(36860700001)(426003)(336012)(8676002)(54906003)(7696005)(316002)(86362001)(36906005)(356005)(47076005)(70206006)(2906002)(70586007)(6916009)(186003)(82740400003)(7636003)(1076003)(82310400003)(478600001)(2616005)(36756003)(107886003)(6666004)(4326008)(15650500001)(83380400001)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 16:41:05.8558 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d182b281-bd7b-4820-3192-08d8f463c793 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.35];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4740 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC Verify cleanup of failed actions batch change where second action in batch fails after successful init of first action. Signed-off-by: Vlad Buslov --- .../tc-testing/tc-tests/actions/simple.json | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json b/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json index d5bcbb919dcc..e0c5f060ccb9 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/simple.json @@ -205,5 +205,34 @@ "teardown": [ "$TC actions flush action simple" ] + }, + { + "id": "a68a", + "name": "Verify cleanup of failed actions batch change", + "category": [ + "actions", + "simple" + ], + "setup": [ + [ + "$TC actions flush action simple", + 0, + 1, + 255 + ], + [ + "$TC actions change action simple sdata \"1\" index 1 action simple sdata \"2\" goto chain 42 index 2", + 255 + ], + "$TC actions flush action simple" + ], + "cmdUnderTest": "$TC actions add action simple sdata \"1\" index 1", + "expExitCode": "0", + "verifyCmd": "$TC actions list action simple", + "matchPattern": "action order [0-9]*: Simple <1>.*index 1 ref", + "matchCount": "1", + "teardown": [ + "$TC actions flush action simple" + ] } ]