From patchwork Fri Dec 1 17:50:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476232 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="dWGL38WU" Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE68FC for ; Fri, 1 Dec 2023 09:50:36 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1cfbce92362so6031795ad.1 for ; Fri, 01 Dec 2023 09:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701453036; x=1702057836; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TPiKsCCgA2C4rEsExgFz/FQnyM6xy20WmctuQWGyukM=; b=dWGL38WUimaB0IKg/4WDwF2XMIte8nnduDltskwQcIMpgu9usljhaDLSmjeumOKuGo Xf8VCMBIHQKWm+4cd77eBnEFdJCdqReuhuKF4UADUR8pg5nCepPoS3LYE4h7rwTXehRF jUlCj5J1reXez9DONKPn/PrMuMJ9LhVtccjG1Ktd3B39Sk2H0tFmcKtq1f5YnYhYvVeF +PK1yjKMcVa0zfg6SnCHMmvySTuhP69q0ICkclQbanhMruf3a2yRGj5ukeGMWYxEH7z7 IsABYSzPolqMCUMSYaAZGJkW0lUbr2CwQRkcT1UUaXad6q/u5lYlqH4wvvTg1rF45bgN imyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701453036; x=1702057836; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TPiKsCCgA2C4rEsExgFz/FQnyM6xy20WmctuQWGyukM=; b=PCwh9Gbrw80KCyqKjtyt0w8/TKkZjM3zN0mdIVKJTCPhw+A4zFGRL304d32uFFcnzs IXFeYndy5j++JL+CxG0GK6JRRGVSQJldCqumq1x6ySeKbulZms1udDkiIc8GHX1k5HJ+ vcOJSBOMLgla0WTkhJM5yN8+FIUCF2SQmUlmMt7kXBLrOi6CqadSUJYyb87UfXXGcGAZ OyTx0ULtfWoclk7ml60+RshD9SgCed4KvH+KIxdVDPpm5G8SV5VjKbIJ74tM41oknWg0 ExLg6MlJUiXrsR2puLQniuN5RtGb6gwqTWpHXRxqLm+8TzCp0a8RH58aA3tF7bpp/Uv7 iilA== X-Gm-Message-State: AOJu0YwLNPpOodtckWzWeTAz9f/QepDO06TJsrCLABSqgdhqX5zWclh8 JsftG48BO5G632f9cMtF9OPjfTEgIaBXjdwewQQ= X-Google-Smtp-Source: AGHT+IF+gV41Y1G+V1C0T7kMSJnGIip8P9qm/tIHzKz42jzMWffVWpIePQzMAC5nBRIg4AiLkjlcWQ== X-Received: by 2002:a17:903:184:b0:1cf:bd98:633f with SMTP id z4-20020a170903018400b001cfbd98633fmr28782615plg.30.1701453036024; Fri, 01 Dec 2023 09:50:36 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id v11-20020a1709028d8b00b001cca8a01e68sm3619729plo.278.2023.12.01.09.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 09:50:35 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, mleitner@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 1/4] net/sched: act_api: use tcf_act_for_each_action Date: Fri, 1 Dec 2023 14:50:12 -0300 Message-Id: <20231201175015.214214-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201175015.214214-1-pctammela@mojatatu.com> References: <20231201175015.214214-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the auxiliary macro tcf_act_for_each_action in all the functions that expect a contiguous action array Suggested-by: Marcelo Ricardo Leitner Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela Acked-by: Marcelo Ricardo Leitner --- net/sched/act_api.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index c39252d61ebb..05aae374c159 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1118,8 +1118,7 @@ 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]; + tcf_act_for_each_action(i, a, actions) { actions[i] = NULL; ops = a->ops; ret = __tcf_idr_release(a, bind, true); @@ -1211,8 +1210,7 @@ int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int err = -EINVAL, i; struct nlattr *nest; - for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) { - a = actions[i]; + tcf_act_for_each_action(i, a, actions) { nest = nla_nest_start_noflag(skb, i + 1); if (nest == NULL) goto nla_put_failure; @@ -1753,10 +1751,10 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, static int tcf_action_delete(struct net *net, struct tc_action *actions[]) { + struct tc_action *a; int i; - for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) { - struct tc_action *a = actions[i]; + tcf_act_for_each_action(i, a, actions) { const struct tc_action_ops *ops = a->ops; /* Actions can be deleted concurrently so we must save their * type and id to search again after reference is released. @@ -1768,7 +1766,7 @@ static int tcf_action_delete(struct net *net, struct tc_action *actions[]) if (tcf_action_put(a)) { /* last reference, action was deleted concurrently */ module_put(ops->owner); - } else { + } else { int ret; /* now do the delete */ From patchwork Fri Dec 1 17:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476233 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="1yrGcL7j" Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086DCAC for ; Fri, 1 Dec 2023 09:50:40 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1cfc3f50504so7051665ad.3 for ; Fri, 01 Dec 2023 09:50:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701453039; x=1702057839; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XRhesmXXYI6gg/faEEULuV9LqMXx7NbwJMsVvZWkiYw=; b=1yrGcL7jS4OtuwQfqZ51BQrVcWg3+lPuv24Lsm78WlpbtT4AOgfbywUUHBg3G+GD7m E5P0BeH2G3Yoxa2DmU9Ibk3sJxgvJrM7z7gyOaBj045lDzpizq+TUTUUD0WBF26mS5YL vbVHXnTzfC787VJ7IjhCIcj0kFKoB/wOY9AWU2mNOCW3Vvhkl6epSpFSvXmbzY46wXSZ mDKTEZ8KjsLxLqGczPBwAfS7ZVRGSZVtbYk7pCO51vwjCXmfpUFjOorMe3DK+8FTRj5o UnCRedaWCC8URLB2d75+oAI8zy5LYbDYaJ5070Hkz/7SBcc87/hQG2pPfhKpYe8LGlxy 1O4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701453039; x=1702057839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XRhesmXXYI6gg/faEEULuV9LqMXx7NbwJMsVvZWkiYw=; b=wbBIVxlgh094kuP+mQy3mDMAjezHo7GJM3iomA9bWdNRo9lU/URdM0bgekN3gsvkYM fA+gYWUgfCjVdoRTiJijWf0lWMnvJC6a3+Moy/jmA9Iueqr6YF8QOZzoSGe6+1ePdNQY BsNArjEQHsR5eNho4y+I0Fc0c7DWLFsLm09qvWJx6nv5ELx+/vPGrYgDO+1zmYcmBgGN g+to6HZMD4ljjDilK4dOv5QEXllfNq7Qpbk3KC2ayCJo9Drchollw6VEgWbsytjGKrc9 i+N1IrSsM/jKoA8xVnoXfGBvLA9GN6c11AZAegIJnefhWgzjOFnP/6XfUmdPr0F7RjaN vlsA== X-Gm-Message-State: AOJu0Yw0i0PHtyYVn4yLcB5udyZjij03oOrk65wTk9BCj+H5s0WR2Ygj j71S2yNj6gp6NSKEp52AAP3cnaA07ic2pzQJV9o= X-Google-Smtp-Source: AGHT+IFKaYmuSsnTmU8+S7g1ulLc34BmwaRtgirSn/OXZ3ibQqRXeK91r+ApMWkT4NAq7kIxVG0cyg== X-Received: by 2002:a17:902:bb17:b0:1d0:67a7:2ebe with SMTP id im23-20020a170902bb1700b001d067a72ebemr927123plb.66.1701453039208; Fri, 01 Dec 2023 09:50:39 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id v11-20020a1709028d8b00b001cca8a01e68sm3619729plo.278.2023.12.01.09.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 09:50:38 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, mleitner@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 2/4] net/sched: act_api: avoid non-contiguous action array Date: Fri, 1 Dec 2023 14:50:13 -0300 Message-Id: <20231201175015.214214-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201175015.214214-1-pctammela@mojatatu.com> References: <20231201175015.214214-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org In tcf_action_add, when putting the reference for the bound actions it assigns NULLs to just created actions passing a non contiguous array to tcf_action_put_many. Refactor the code so the actions array is always contiguous. Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela Acked-by: Marcelo Ricardo Leitner --- net/sched/act_api.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 05aae374c159..2e948e5992b6 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1135,18 +1135,29 @@ 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[]) { + struct tc_action *a; int i; - for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { - struct tc_action *a = actions[i]; - const struct tc_action_ops *ops; + tcf_act_for_each_action(i, a, actions) { + const struct tc_action_ops *ops = a->ops; + if (tcf_action_put(a)) + module_put(ops->owner); + } +} - if (!a) +static void tca_put_bound_many(struct tc_action *actions[], int init_res[]) +{ + struct tc_action *a; + int i; + + tcf_act_for_each_action(i, a, actions) { + const struct tc_action_ops *ops = a->ops; + + if (init_res[i] == ACT_P_CREATED) continue; - ops = a->ops; + if (tcf_action_put(a)) module_put(ops->owner); } @@ -1975,7 +1986,7 @@ static int tcf_action_add(struct net *net, struct nlattr *nla, struct netlink_ext_ack *extack) { size_t attr_size = 0; - int loop, ret, i; + int loop, ret; struct tc_action *actions[TCA_ACT_MAX_PRIO] = {}; int init_res[TCA_ACT_MAX_PRIO] = {}; @@ -1988,13 +1999,11 @@ 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); - /* only put existing actions */ - for (i = 0; i < TCA_ACT_MAX_PRIO; i++) - if (init_res[i] == ACT_P_CREATED) - actions[i] = NULL; - tcf_action_put_many(actions); + /* only put bound actions */ + tca_put_bound_many(actions, init_res); return ret; } From patchwork Fri Dec 1 17:50:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476234 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="RVChvPV2" Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06073AC for ; Fri, 1 Dec 2023 09:50:43 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d05e4a94c3so5324545ad.1 for ; Fri, 01 Dec 2023 09:50:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701453042; x=1702057842; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Negl3oSbs7nvJG91Jt9lug4Hwh/K36CKFflQqJcvQVs=; b=RVChvPV2tSy05naG4Ga5RQOX1Bdou4SICEjTvccg/Rf2YeFsfvl1q4bQ00DtgSunms +xT0QE0cGH7rxK0T6HWhWebHeU1axQ6gKmHKRViUhtBX5lC+Mvu9rd6owmWpGeYeHX4S YuvaRvxqpgwNACgi+F0h0UXASSqclWCazwdbNPsoPgAs3FbOPgrQ8tu1H4JskWsn+t+W XR6YhKKJ3AH6FUYalDB8H4NYlfNZxqi1Fo/srBtewKSO+Ov0nkEifJb+10tkLNkCQgtu MhkWkpvWZxBtj5jBxkx+tg6ucD/nrITmEkH8M2I/Hi55aw9L0cD6IaKIo7t6TPMYioYu 0oJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701453042; x=1702057842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Negl3oSbs7nvJG91Jt9lug4Hwh/K36CKFflQqJcvQVs=; b=B5+9+YqknLquYBhVN7AWnXaH5Ulze9NDo/BZbdRv2pEh9B1m9s/TvsGs4ige4EvU07 oNa9Tyqj1zJyrzBZgqLTU4O7cpdYONoL0tq0X0i9CPdovNjBghEQQpidkI+JaSeHWblv 1C37a/sJn5fMK7UYrHV5boFAhAEyW5x3CfENQ9qXfP8HsVyXmhXrnPkcB/FIWGNa1FjB BYYvdvVV5xLAp9IYiZuIjauSoBQc5Wb0rRoI/s3L+Ty8YvnHwybl+RsLdOW91Gj+r5MS eiZIiT5NqNB5tFhtaGCnWwZbmefiMKbWWGyRDXnrj1P00t0Cbmpmi1vFi5mspgYx2V3h qAAA== X-Gm-Message-State: AOJu0Yx0C5Gjz9PNEp2ddlE4jzMHuxy3mveqgqu97LWHi/UcXUP0ilbN 4qTPXjBpGJV/IY6oHIVV5d+Kvd2knHUqdpqo7cE= X-Google-Smtp-Source: AGHT+IHQn2qalnNKOu0vLLOeMBUUknb2wH8NV9NwL5akyqqxNaZEWjyrj1cNKHE/9ihvlY0WX7RHBg== X-Received: by 2002:a17:902:efc2:b0:1d0:4b44:8590 with SMTP id ja2-20020a170902efc200b001d04b448590mr3101282plb.54.1701453042348; Fri, 01 Dec 2023 09:50:42 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id v11-20020a1709028d8b00b001cca8a01e68sm3619729plo.278.2023.12.01.09.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 09:50:42 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, mleitner@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 3/4] net/sched: act_api: stop loop over ops array on NULL in tcf_action_init Date: Fri, 1 Dec 2023 14:50:14 -0300 Message-Id: <20231201175015.214214-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201175015.214214-1-pctammela@mojatatu.com> References: <20231201175015.214214-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The ops array is contiguous, so stop processing whenever a NULL is found Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela Acked-by: Marcelo Ricardo Leitner --- net/sched/act_api.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 2e948e5992b6..d3cb9f5b25da 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1506,10 +1506,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, err: tcf_action_destroy(actions, flags & TCA_ACT_FLAGS_BIND); err_mod: - for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { - if (ops[i]) - module_put(ops[i]->owner); - } + for (i = 0; i < TCA_ACT_MAX_PRIO && ops[i]; i++) + module_put(ops[i]->owner); return err; } From patchwork Fri Dec 1 17:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476235 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="j2s96Z+p" Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3129BFE for ; Fri, 1 Dec 2023 09:50:46 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d06d4d685aso317705ad.3 for ; Fri, 01 Dec 2023 09:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701453045; x=1702057845; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z8UbiZzVKTY2CyZBpGCSMO183vb/TeddNACUB/GPxAk=; b=j2s96Z+pMmSGtYPrVeXPg9X6BlEgfhZLoxjA0XEtMMbVbbN6PkKM6Xb44XvxZrh5tG 12F3KGySh2peVHg3IVHSIyoaJrwNz7z3ba8r5R1RJHQ9+tCUAZ80m5tZAmn5oO2LaEFr FBFOIG3Xmh5wILAt1b/XZOwamMeY1JbGhGxkcLT6JIKTj9efMVS/wTYIUQ9VUuqkneH8 Fjv0ZTku/L8xIHHjv1ZigKBbkTTm0VtLhTp/9Jxk60EiBPWpdMam5U0fnxTkJq0rxDhr 2SV3QwlPFlJM6vLm3AIkfRhi6fDg0qJ0N4cRQuCfAi+stonuwBjFeMzC8UhPbFo7HE9j C8zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701453045; x=1702057845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z8UbiZzVKTY2CyZBpGCSMO183vb/TeddNACUB/GPxAk=; b=LITR6Rh/jRTK/nuOgyK/yAXeNTxOZCyHzrUlX+u1Ztz9LdGOuaZhXH4oIdz7dpwYfL pxe4PcpYGoA6rd8N6Ma2ZrWORbPVZ8D+fodmIO2HceF9gOB4oiaIiIoQI99O/ZSeI4Aj WovoM/e+BlxfZQB+jTrgpdASIrcAwWZiyR5YhmTJtENvDgoidZs+jmRCRQtyDNlk0JR6 iSmFGW5JXEab4q74JcvIq1SBqUgC9f0uE3OOtT/YOgFBbdiel4wuwlywuuqs6sgfkRYw qG50PngwZ00bhuOVxZk8CwZv2EBks+R3bisCe0qSz3fOPZLpUg/JbCarzec6fkx16ciZ 3o1Q== X-Gm-Message-State: AOJu0YxYFZt5Vt5CnZS20dYXp6JRClyvQ1rr/MmLZF6dTnnORMnihmA2 dGm6T60KheKW3+T4X6L9NRaXLXZNNSl2+o0A8i8= X-Google-Smtp-Source: AGHT+IFwr71re8/A+xmXcVnBVZ41QVq+Lvn+k9uQ7Gz2mxpaju+WnLa3Ok1u4ZXIbgnQdaitJ48OTA== X-Received: by 2002:a17:902:c408:b0:1cf:7c3d:df68 with SMTP id k8-20020a170902c40800b001cf7c3ddf68mr28263310plk.39.1701453045476; Fri, 01 Dec 2023 09:50:45 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id v11-20020a1709028d8b00b001cca8a01e68sm3619729plo.278.2023.12.01.09.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 09:50:45 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, mleitner@redhat.com, Pedro Tammela Subject: [PATCH net-next v2 4/4] net/sched: act_api: use tcf_act_for_each_action in tcf_idr_insert_many Date: Fri, 1 Dec 2023 14:50:15 -0300 Message-Id: <20231201175015.214214-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201175015.214214-1-pctammela@mojatatu.com> References: <20231201175015.214214-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The actions array is contiguous, so stop processing whenever a NULL is found. This is already the assumption for tcf_action_destroy[1], which is called from tcf_actions_init. [1] https://elixir.bootlin.com/linux/v6.7-rc3/source/net/sched/act_api.c#L1115 Acked-by: Jamal Hadi Salim Signed-off-by: Pedro Tammela Acked-by: Marcelo Ricardo Leitner --- net/sched/act_api.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index d3cb9f5b25da..abec5c45b5a4 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1285,14 +1285,12 @@ static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { void tcf_idr_insert_many(struct tc_action *actions[]) { + struct tc_action *a; int i; - for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { - struct tc_action *a = actions[i]; + tcf_act_for_each_action(i, a, actions) { struct tcf_idrinfo *idrinfo; - if (!a) - continue; idrinfo = a->idrinfo; mutex_lock(&idrinfo->lock); /* Replace ERR_PTR(-EBUSY) allocated by tcf_idr_check_alloc if