[v3,1/4] net/sched: Add helper macros with module names

Message ID 20240112180646.13232-2-mkoutny@suse.com
State New
Headers
Series net/sched: Load modules via alias |

Commit Message

Michal Koutný Jan. 12, 2024, 6:06 p.m. UTC
  The macros are preparation for adding module aliases en mass in a
separate commit.
Although it would be tempting to create aliases like cls-foo for name
cls_foo, this could not be used because modprobe utilities treat '-' and
'_' interchangeably.
In the end, the naming follows pattern of proto modules in linux/net.h.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
---
 include/net/act_api.h   | 1 +
 include/net/pkt_cls.h   | 1 +
 include/net/pkt_sched.h | 1 +
 3 files changed, 3 insertions(+)
  

Comments

Pedro Tammela Jan. 12, 2024, 6:38 p.m. UTC | #1
On 12/01/2024 15:06, Michal Koutný wrote:
> The macros are preparation for adding module aliases en mass in a
> separate commit.
> Although it would be tempting to create aliases like cls-foo for name
> cls_foo, this could not be used because modprobe utilities treat '-' and
> '_' interchangeably.
> In the end, the naming follows pattern of proto modules in linux/net.h.
> 
> Signed-off-by: Michal Koutný <mkoutny@suse.com>
> ---
>   include/net/act_api.h   | 1 +
>   include/net/pkt_cls.h   | 1 +
>   include/net/pkt_sched.h | 1 +
>   3 files changed, 3 insertions(+)
> 
> diff --git a/include/net/act_api.h b/include/net/act_api.h
> index 4ae0580b63ca..ade63a9157f2 100644
> --- a/include/net/act_api.h
> +++ b/include/net/act_api.h
> @@ -200,6 +200,7 @@ int tcf_idr_release(struct tc_action *a, bool bind);
>   int tcf_register_action(struct tc_action_ops *a, struct pernet_operations *ops);
>   int tcf_unregister_action(struct tc_action_ops *a,
>   			  struct pernet_operations *ops);
> +#define MODULE_ALIAS_NET_ACT(kind)	MODULE_ALIAS("net-act-" __stringify(kind))
>   int tcf_action_destroy(struct tc_action *actions[], int bind);
>   int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
>   		    int nr_actions, struct tcf_result *res);
> diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
> index a76c9171db0e..906ccfea81f2 100644
> --- a/include/net/pkt_cls.h
> +++ b/include/net/pkt_cls.h
> @@ -24,6 +24,7 @@ struct tcf_walker {
>   
>   int register_tcf_proto_ops(struct tcf_proto_ops *ops);
>   void unregister_tcf_proto_ops(struct tcf_proto_ops *ops); > +#define MODULE_ALIAS_NET_CLS(kind)	MODULE_ALIAS("net-cls-" 
__stringify(kind))

I believe something like (untested):

#define TC_CLS_ALIAS_PREFIX "tc-cls-"
#define MODULE_ALIAS_TC_CLS(kind) MODULE_ALIAS(TC_CLS_ALIAS_PREFIX 
__stringify(kind))

And then reuse the macro:

request_module(TC_CLS_ALIAS_PREFIX "%s", cls_name);

Would look better. In any case, net-next is currently closed. You will 
need to repost once it reopens.

It seems you are also missing a rebase. We recently removed act_ipt :).

>   
>   struct tcf_block_ext_info {
>   	enum flow_block_binder_type binder_type;
> diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
> index 9fa1d0794dfa..88ab6d0ab08b 100644
> --- a/include/net/pkt_sched.h
> +++ b/include/net/pkt_sched.h
> @@ -100,6 +100,7 @@ struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
>   
>   int register_qdisc(struct Qdisc_ops *qops);
>   void unregister_qdisc(struct Qdisc_ops *qops);
> +#define MODULE_ALIAS_NET_SCH(id)	MODULE_ALIAS("net-sch-" __stringify(id))
>   void qdisc_get_default(char *id, size_t len);
>   int qdisc_set_default(const char *id);
>
  
Michal Koutný Jan. 15, 2024, 12:16 p.m. UTC | #2
On Fri, Jan 12, 2024 at 03:38:34PM -0300, Pedro Tammela <pctammela@mojatatu.com> wrote:
> request_module(TC_CLS_ALIAS_PREFIX "%s", cls_name);

Yeah, that would be more systemic without proliferating literal strings.

> Would look better. In any case, net-next is currently closed. You will need
> to repost once it reopens.
> 
> It seems you are also missing a rebase. We recently removed act_ipt :).

I see, I rebased only on torvalds/master then (commit de927f6c0b07
("Merge tag 's390-6.8-1' of
git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux")).
I'm not familiar with netdev tree, I will post after Jan 22 as
suggested.

Thanks,
Michal
  

Patch

diff --git a/include/net/act_api.h b/include/net/act_api.h
index 4ae0580b63ca..ade63a9157f2 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -200,6 +200,7 @@  int tcf_idr_release(struct tc_action *a, bool bind);
 int tcf_register_action(struct tc_action_ops *a, struct pernet_operations *ops);
 int tcf_unregister_action(struct tc_action_ops *a,
 			  struct pernet_operations *ops);
+#define MODULE_ALIAS_NET_ACT(kind)	MODULE_ALIAS("net-act-" __stringify(kind))
 int tcf_action_destroy(struct tc_action *actions[], int bind);
 int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
 		    int nr_actions, struct tcf_result *res);
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index a76c9171db0e..906ccfea81f2 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -24,6 +24,7 @@  struct tcf_walker {
 
 int register_tcf_proto_ops(struct tcf_proto_ops *ops);
 void unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
+#define MODULE_ALIAS_NET_CLS(kind)	MODULE_ALIAS("net-cls-" __stringify(kind))
 
 struct tcf_block_ext_info {
 	enum flow_block_binder_type binder_type;
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 9fa1d0794dfa..88ab6d0ab08b 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -100,6 +100,7 @@  struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
 
 int register_qdisc(struct Qdisc_ops *qops);
 void unregister_qdisc(struct Qdisc_ops *qops);
+#define MODULE_ALIAS_NET_SCH(id)	MODULE_ALIAS("net-sch-" __stringify(id))
 void qdisc_get_default(char *id, size_t len);
 int qdisc_set_default(const char *id);