From patchwork Thu Nov 30 15:20:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13474613 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="VUvOuehO" Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB76D19BC for ; Thu, 30 Nov 2023 07:21:27 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6cdd584591eso1048366b3a.2 for ; Thu, 30 Nov 2023 07:21:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701357687; x=1701962487; 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=QW07eus+osHtKsR/VuZells8epXacZLWW+VuGK4+DyY=; b=VUvOuehO6PjaXuh7j7uny7iuU/zkQaAb3S1dzjwXpRPPJbVOhdVkCCLzhQaJ/gvHEX ZRaNQMIMhw/dJJ2A5ECySKqzbJwPmCpHYQUhpoHw0huVQ/7sCS4JICHY2vclLpzl38My TtE/auoH7ukEFcpla3h1D3OXXsyb88DpxO5yJ45QyPSf5Ky6w/ps8+nzo6h9BX93E37N V8N4F3Yj5dX3pDoPRDYIVxwZVO1cy1D5mU/s51IJHi8R5EeLg5Sllaex40GFutLK/apy Ne73o1eQVHVvuLKf5BIyk8mTm3NicmmRY4yrRXAYD9ClFT07EUkNxwqSw28ceXaOpPh0 do0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701357687; x=1701962487; 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=QW07eus+osHtKsR/VuZells8epXacZLWW+VuGK4+DyY=; b=Nt3043pEn9sduESsBRBamT+EyH/SP+95VB/AkUPkohlK35KPXKs0ATmCziRVBBBJnZ xQlIw4GUpY6Z4MFthnHaN//PmM3ew0eEB6gcnI2xmlaXKzcoOjGTl6PT+jxWHve5pkRH ENnOhz5q0qxXz3cDxyZg9HF+a9sunXA8GbJSojzaSlXd/0xD/7hcCTonSOofdxG2sQ7V 5UmDb37xvhY+ObSID2PZn/5lrO5X1XQ5qT/+O+6LokKzu9S2dnjVUMa0YWUkDiS1MgAj rqpXoNSnOJzVq9c3RlaN4kUA7SJ70ZQJBeaSPhEkeOMvahYvK9mw0ys2vS+4wQpjsEcm VsqA== X-Gm-Message-State: AOJu0YxGC5ZS1jeWFF11Oew6gSIKn27XGFWHOXHGM+MeSqtMcfbtsY2L qP6lgLKkeTfwHnUggZSDTUiwWM6QIJmL26AWilM= X-Google-Smtp-Source: AGHT+IHWAPPXZZv1PbTRcK1bORhdOMA4P5xyo6Ksluj2zyzUu23ioLCbOS/uSdj69cwjlu04WX2WcA== X-Received: by 2002:aa7:981d:0:b0:6cd:f399:be00 with SMTP id e29-20020aa7981d000000b006cdf399be00mr940156pfl.28.1701357687048; Thu, 30 Nov 2023 07:21:27 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id p16-20020aa78610000000b006cc02a6d18asm1342579pfn.61.2023.11.30.07.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 07:21:26 -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 1/4] net/sched: act_api: use tcf_act_for_each_action Date: Thu, 30 Nov 2023 12:20:38 -0300 Message-Id: <20231130152041.13513-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130152041.13513-1-pctammela@mojatatu.com> References: <20231130152041.13513-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 Signed-off-by: Pedro Tammela --- 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 Thu Nov 30 15:20:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13474614 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="foggkRbf" Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA6B1FE2 for ; Thu, 30 Nov 2023 07:21:30 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6cb74a527ceso895986b3a.2 for ; Thu, 30 Nov 2023 07:21:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701357690; x=1701962490; 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=+1ev49j8lKgYcL/1riuQZsBH5ivzlj1EKhMxs0dRW8w=; b=foggkRbfyf0ZmuxHuNVfRFFO1JNes4O5+hzcoFp+6GAw8MP9TaMXUVOVA/YFr1WrdP OGV2HcQf9hLNOo3us0UlH6yQw9ZTc7FxPEtGD3LNz6HEUw6rG7mwtr9h3kgAzz4FJvci XrokDqxvHts8gaR0LYeOqB6IDJG/NtomYcb8wjXKO4B1BiKhgnS74tRCkKRcKz3KTHM+ KZHB6RJbM02rA3NPdSLG4phKdeMDSoYEqiu1OpOiKfJxrshZpL5jfNNT37CAKmvccVVD 7Qxz6D0qv1sVe1+hO0VG6wGZDvBa7rbjOryPdiKntQW3SutqnqioPuwGFRuLBdhZk1kX IxDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701357690; x=1701962490; 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=+1ev49j8lKgYcL/1riuQZsBH5ivzlj1EKhMxs0dRW8w=; b=sTqHsvhyh3g0nL9uBLzH3XHpwSa/ZbaP/SJtV/XL9TzNSo+4i/IgnU1MS0y5mLiept S0C/r7Ks//FCc6MABxq1wQSfTbS8TiirhyVTxIW/wAImi4fHp8A/TKEpoYqB3jkZYSFW T02CjiZiXUnXtJ7KE95yYEJR3O3u0qqnOjYKrb4VSY46UOGfCDklYH+TCJzTCuM+Q2D7 l/eXrI8SWRBsfSiIBEmGjnAzpthrGNQiDjiHOJtHZwYQq2Oz5U+NSTcKf+QQmIK9FkR/ bx4xGT8nbv//smxBYyuN7p7OIvSo0Bok6iFjZDYehTtqLVK/8JoKt05JxjUTtMVb/llE UUIA== X-Gm-Message-State: AOJu0YwsraslKbiKZmtrWsAr73E0EsNEx0s5M0qdnnsCFYlK00Oa1j1w 0hgkItBnorQL1v2wxShhslWIHBSXNZ7JXoNFwiQ= X-Google-Smtp-Source: AGHT+IHcTzRaheJZ4klHpLhVTDLj0DVUIgv96U9iQ98rLB6YjaFVu8aMnD/pEPDsyAiVNmBJMcHSLg== X-Received: by 2002:a05:6a00:f0b:b0:68f:dd50:aef8 with SMTP id cr11-20020a056a000f0b00b0068fdd50aef8mr24460382pfb.4.1701357690082; Thu, 30 Nov 2023 07:21:30 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id p16-20020aa78610000000b006cc02a6d18asm1342579pfn.61.2023.11.30.07.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 07:21:29 -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 2/4] net/sched: act_api: avoid non-contiguous action array Date: Thu, 30 Nov 2023 12:20:39 -0300 Message-Id: <20231130152041.13513-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130152041.13513-1-pctammela@mojatatu.com> References: <20231130152041.13513-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. Signed-off-by: Pedro Tammela --- 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 Thu Nov 30 15:20:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13474615 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="zpZfp6h+" Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E89931BD2 for ; Thu, 30 Nov 2023 07:21:33 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6cdcd790f42so1060974b3a.3 for ; Thu, 30 Nov 2023 07:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701357693; x=1701962493; 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=5fQ0E21BvJN0Iwjm/femF1Os2TlYZXPFt1b5fVnA6IY=; b=zpZfp6h+kGrYS4ziValmDIFylm3oDrzYcbNwD3yEUBAqxg94sot9DEc/nt46jHkIPt Y/lEyf6da4II2ZmBse5vp4qD9UfDL+omcsqYz719Y0rhjkmORNrBI0haKGNAprfFwJSh 2ct/gQbwgAlR1rSMFfErD83aeiCu7ePIIOwbYbvhraH3dpll0pm8uH1SS6LtUqE5wRdI Yv4N4gozgIypK8YlPHeY1Jt63zElZ0ycbFAuDwXPUqqcBFn9lvtJDrhYR5TThxwPthmu eI3AGlLvo5f3SpufGFpidcQGs+K0Y7Xaxl61SwxHudOlEuzHysXp4dnp/LafL2bCiqpZ EJRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701357693; x=1701962493; 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=5fQ0E21BvJN0Iwjm/femF1Os2TlYZXPFt1b5fVnA6IY=; b=fSN2LryGBuEgu3jEFEbOpOH2e1q/HD8VAIXe95zGU3yuswk9n3t6t7fTIuWG8AbZel LMcmHrpy/ffauyiP3u6RJuXjXwvg+xfyuRR7EmvLOEklWTEeURQqEAr00GZbhQWRrAO3 CUT7GWxj0FF3fdza+oOwitCqtgoKTMTon6EHEbm8ep7oiuxis9uoEGTtOgyg2DfACCfO UW3TWf+1zwqcVQAEX59uJ1lHYaDjPqSsAE+i6ra8cuR24jHPCeM7xSKJn5YcVw8txYD3 iPHkVcEmRuYnPrp6DuHmNxyxJ0Y3FQZ+oNexsWV5WlW5qTJS6EaA3kQAUjkvk93VJXmI yowg== X-Gm-Message-State: AOJu0Yxv8O7RyYxUuRdYC6LR3BhHJWbiK0sSvWVNssDEomkIXkJkSNlY +LjnEHWUKwP2yZAYtnJSyflXFkYijM43/EYg+eM= X-Google-Smtp-Source: AGHT+IGzDr40ylhmdKfs1ZggEL5dadBqX+6hB+XTy20vplwdEgsOKGh10Or5UNPFj8EZg/tpKKt+uA== X-Received: by 2002:a05:6a00:891:b0:6c4:d5ee:c6 with SMTP id q17-20020a056a00089100b006c4d5ee00c6mr26552902pfj.1.1701357693238; Thu, 30 Nov 2023 07:21:33 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id p16-20020aa78610000000b006cc02a6d18asm1342579pfn.61.2023.11.30.07.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 07:21:32 -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 3/4] net/sched: act_api: stop loop over ops array on NULL in tcf_action_init Date: Thu, 30 Nov 2023 12:20:40 -0300 Message-Id: <20231130152041.13513-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130152041.13513-1-pctammela@mojatatu.com> References: <20231130152041.13513-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 Signed-off-by: Pedro Tammela --- 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 Thu Nov 30 15:20:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13474616 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="02TTBh5X" Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 571D81BD5 for ; Thu, 30 Nov 2023 07:21:37 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6cbbfdf72ecso1047837b3a.2 for ; Thu, 30 Nov 2023 07:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701357696; x=1701962496; 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=PV/FnAxElgomcsnpFDOxAMkh9FJZjFm56tGPBQMJCpg=; b=02TTBh5Xvudy3ZooW9MqXRPYIJJCE6IXCYaYPZJqiNiYDt1cU0KWfItqj5G8ohmuW+ 56xta9fAY993dbgqTDVZubSezlJzzALrZm7imFMHBnmCTaoGY0K6agbBAaQ4DzLpeLuD VwR/ie7wlz8bZG9IwbxUUbXCBFS4uTGmkM5x4Bw6w+jDrETdpMNN+YqjubbEqgdOayCs 6vqygy6y981oOhJVURxXWD3VG4rDFM84MHC5jxQ8X9m95t/0YngYZgZqVZXoqPS7p1lE /eDFadkisWIqWBfCjBPQyxIhrxh1GDv6cYMhUG2Vgg2rGHiASQ7FgpqJ5KU9y6NJzFnQ b35A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701357696; x=1701962496; 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=PV/FnAxElgomcsnpFDOxAMkh9FJZjFm56tGPBQMJCpg=; b=SsXpPanEN1QGtjzMdsDU6oz11UJ2G7jPX1uIVK5hb/s/PG1eo1sGQggiLRfqNtawVT q5BrwHD/iXOHcsSQFmCpcOeA+MDIEIcnhwY5BFjPOmij6EUU/5az407fHZ6I61Cz6TYM wJgQL0XSjBGGxnyeIUR56PqOMm5AXxU/n/mbCEwCcdrQ7HDKMEra8wFcUX5x753Lh0CI OXxDzNNbNt9/VppL5eE9/wq9nRGe4bm4sVSTVeg+l3v2fUJQlH1tXe9siBUCNxVp441z gWwklyT3itjIBB6+8mYLVNkLYcKQ8uzC1TkaR5sPTk7bBZJbkwkpNJP6E7YSLSYeXyb7 9jBg== X-Gm-Message-State: AOJu0YyoDaYIQbYTozEttRRwtM/qIGAtXwCK9fJlz3Qv3oqGSELgnawR Ll6jnrvtd6fyev86wLoAHjn2K4M1ckU6+Inpi88= X-Google-Smtp-Source: AGHT+IG5vth8u1O/rujHGOtQq4NWRbPLGKGkux7W+2h906NnbxeKqMUHKHtGx8SijIeehTx/lsmrHQ== X-Received: by 2002:a05:6a20:9382:b0:18b:962c:1ead with SMTP id x2-20020a056a20938200b0018b962c1eadmr26851331pzh.3.1701357696487; Thu, 30 Nov 2023 07:21:36 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id p16-20020aa78610000000b006cc02a6d18asm1342579pfn.61.2023.11.30.07.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 07:21:36 -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 4/4] net/sched: act_api: use tcf_act_for_each_action in tcf_idr_insert_many Date: Thu, 30 Nov 2023 12:20:41 -0300 Message-Id: <20231130152041.13513-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130152041.13513-1-pctammela@mojatatu.com> References: <20231130152041.13513-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 Signed-off-by: Pedro Tammela --- 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