* [PATCH net-next v2] net/sched: simplify tc_action_load_ops parameters
@ 2024-01-05 0:38 Pedro Tammela
2024-01-05 1:28 ` Jamal Hadi Salim
2024-01-07 15:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Pedro Tammela @ 2024-01-05 0:38 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, jhs, xiyou.wangcong, jiri,
Pedro Tammela, Jiri Pirko
Instead of using two bools derived from a flags passed as arguments to
the parent function of tc_action_load_ops, just pass the flags itself
to tc_action_load_ops to simplify its parameters.
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
---
include/net/act_api.h | 3 +--
net/sched/act_api.c | 10 +++++-----
net/sched/cls_api.c | 5 ++---
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 447985a45ef6..e1e5e72b901e 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -208,8 +208,7 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
struct nlattr *est,
struct tc_action *actions[], int init_res[], size_t *attr_size,
u32 flags, u32 fl_flags, struct netlink_ext_ack *extack);
-struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police,
- bool rtnl_held,
+struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, u32 flags,
struct netlink_ext_ack *extack);
struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
struct nlattr *nla, struct nlattr *est,
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index ef70d4771811..3e30d7260493 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -1324,10 +1324,10 @@ void tcf_idr_insert_many(struct tc_action *actions[], int init_res[])
}
}
-struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police,
- bool rtnl_held,
+struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, u32 flags,
struct netlink_ext_ack *extack)
{
+ bool police = flags & TCA_ACT_FLAGS_POLICE;
struct nlattr *tb[TCA_ACT_MAX + 1];
struct tc_action_ops *a_o;
char act_name[IFNAMSIZ];
@@ -1359,6 +1359,8 @@ struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police,
a_o = tc_lookup_action_n(act_name);
if (a_o == NULL) {
#ifdef CONFIG_MODULES
+ bool rtnl_held = !(flags & TCA_ACT_FLAGS_NO_RTNL);
+
if (rtnl_held)
rtnl_unlock();
request_module("act_%s", act_name);
@@ -1475,9 +1477,7 @@ 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++) {
struct tc_action_ops *a_o;
- a_o = tc_action_load_ops(tb[i], flags & TCA_ACT_FLAGS_POLICE,
- !(flags & TCA_ACT_FLAGS_NO_RTNL),
- extack);
+ a_o = tc_action_load_ops(tb[i], flags, extack);
if (IS_ERR(a_o)) {
err = PTR_ERR(a_o);
goto err_mod;
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index adf5de1ff773..4b8ff5b4eb18 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3300,12 +3300,11 @@ int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **
if (exts->police && tb[exts->police]) {
struct tc_action_ops *a_o;
- a_o = tc_action_load_ops(tb[exts->police], true,
- !(flags & TCA_ACT_FLAGS_NO_RTNL),
+ flags |= TCA_ACT_FLAGS_POLICE | TCA_ACT_FLAGS_BIND;
+ a_o = tc_action_load_ops(tb[exts->police], flags,
extack);
if (IS_ERR(a_o))
return PTR_ERR(a_o);
- flags |= TCA_ACT_FLAGS_POLICE | TCA_ACT_FLAGS_BIND;
act = tcf_action_init_1(net, tp, tb[exts->police],
rate_tlv, a_o, init_res, flags,
extack);
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] net/sched: simplify tc_action_load_ops parameters
2024-01-05 0:38 [PATCH net-next v2] net/sched: simplify tc_action_load_ops parameters Pedro Tammela
@ 2024-01-05 1:28 ` Jamal Hadi Salim
2024-01-07 15:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jamal Hadi Salim @ 2024-01-05 1:28 UTC (permalink / raw)
To: Pedro Tammela
Cc: netdev, davem, edumazet, kuba, pabeni, xiyou.wangcong, jiri,
Jiri Pirko
On Thu, Jan 4, 2024 at 7:38 PM Pedro Tammela <pctammela@mojatatu.com> wrote:
>
> Instead of using two bools derived from a flags passed as arguments to
> the parent function of tc_action_load_ops, just pass the flags itself
> to tc_action_load_ops to simplify its parameters.
>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
> ---
> include/net/act_api.h | 3 +--
> net/sched/act_api.c | 10 +++++-----
> net/sched/cls_api.c | 5 ++---
> 3 files changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/include/net/act_api.h b/include/net/act_api.h
> index 447985a45ef6..e1e5e72b901e 100644
> --- a/include/net/act_api.h
> +++ b/include/net/act_api.h
> @@ -208,8 +208,7 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
> struct nlattr *est,
> struct tc_action *actions[], int init_res[], size_t *attr_size,
> u32 flags, u32 fl_flags, struct netlink_ext_ack *extack);
> -struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police,
> - bool rtnl_held,
> +struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, u32 flags,
> struct netlink_ext_ack *extack);
> struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
> struct nlattr *nla, struct nlattr *est,
> diff --git a/net/sched/act_api.c b/net/sched/act_api.c
> index ef70d4771811..3e30d7260493 100644
> --- a/net/sched/act_api.c
> +++ b/net/sched/act_api.c
> @@ -1324,10 +1324,10 @@ void tcf_idr_insert_many(struct tc_action *actions[], int init_res[])
> }
> }
>
> -struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police,
> - bool rtnl_held,
> +struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, u32 flags,
> struct netlink_ext_ack *extack)
> {
> + bool police = flags & TCA_ACT_FLAGS_POLICE;
> struct nlattr *tb[TCA_ACT_MAX + 1];
> struct tc_action_ops *a_o;
> char act_name[IFNAMSIZ];
> @@ -1359,6 +1359,8 @@ struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police,
> a_o = tc_lookup_action_n(act_name);
> if (a_o == NULL) {
> #ifdef CONFIG_MODULES
> + bool rtnl_held = !(flags & TCA_ACT_FLAGS_NO_RTNL);
> +
> if (rtnl_held)
> rtnl_unlock();
> request_module("act_%s", act_name);
> @@ -1475,9 +1477,7 @@ 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++) {
> struct tc_action_ops *a_o;
>
> - a_o = tc_action_load_ops(tb[i], flags & TCA_ACT_FLAGS_POLICE,
> - !(flags & TCA_ACT_FLAGS_NO_RTNL),
> - extack);
> + a_o = tc_action_load_ops(tb[i], flags, extack);
> if (IS_ERR(a_o)) {
> err = PTR_ERR(a_o);
> goto err_mod;
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index adf5de1ff773..4b8ff5b4eb18 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -3300,12 +3300,11 @@ int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **
> if (exts->police && tb[exts->police]) {
> struct tc_action_ops *a_o;
>
> - a_o = tc_action_load_ops(tb[exts->police], true,
> - !(flags & TCA_ACT_FLAGS_NO_RTNL),
> + flags |= TCA_ACT_FLAGS_POLICE | TCA_ACT_FLAGS_BIND;
> + a_o = tc_action_load_ops(tb[exts->police], flags,
> extack);
> if (IS_ERR(a_o))
> return PTR_ERR(a_o);
> - flags |= TCA_ACT_FLAGS_POLICE | TCA_ACT_FLAGS_BIND;
> act = tcf_action_init_1(net, tp, tb[exts->police],
> rate_tlv, a_o, init_res, flags,
> extack);
> --
> 2.40.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] net/sched: simplify tc_action_load_ops parameters
2024-01-05 0:38 [PATCH net-next v2] net/sched: simplify tc_action_load_ops parameters Pedro Tammela
2024-01-05 1:28 ` Jamal Hadi Salim
@ 2024-01-07 15:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-07 15:00 UTC (permalink / raw)
To: Pedro Tammela
Cc: netdev, davem, edumazet, kuba, pabeni, jhs, xiyou.wangcong, jiri,
jiri
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 4 Jan 2024 21:38:10 -0300 you wrote:
> Instead of using two bools derived from a flags passed as arguments to
> the parent function of tc_action_load_ops, just pass the flags itself
> to tc_action_load_ops to simplify its parameters.
>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
>
> [...]
Here is the summary with links:
- [net-next,v2] net/sched: simplify tc_action_load_ops parameters
https://git.kernel.org/netdev/net-next/c/405cd9fc6f44
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-07 15:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-05 0:38 [PATCH net-next v2] net/sched: simplify tc_action_load_ops parameters Pedro Tammela
2024-01-05 1:28 ` Jamal Hadi Salim
2024-01-07 15:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).