diff mbox series

[net,1/2] net/sched: act_ct: Make tcf_ct_flow_table_restore_skb inline

Message ID 20200614111249.6145-2-roid@mellanox.com
State Accepted
Delegated to: David Miller
Headers show
Series remove dependency between mlx5, act_ct, nf_flow_table | expand

Commit Message

Roi Dayan June 14, 2020, 11:12 a.m. UTC
From: Alaa Hleihel <alaa@mellanox.com>

Currently, tcf_ct_flow_table_restore_skb is exported by act_ct
module, therefore modules using it will have hard-dependency
on act_ct and will require loading it all the time.

This can lead to an unnecessary overhead on systems that do not
use hardware connection tracking action (ct_metadata action) in
the first place.

To relax the hard-dependency between the modules, we unexport this
function and make it a static inline one.

Fixes: 30b0cf90c6dd ("net/sched: act_ct: Support restoring conntrack info on skbs")
Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
---
 include/net/tc_act/tc_ct.h | 11 ++++++++++-
 net/sched/act_ct.c         | 11 -----------
 2 files changed, 10 insertions(+), 12 deletions(-)

Comments

Marcelo Leitner June 15, 2020, 2:06 p.m. UTC | #1
On Sun, Jun 14, 2020 at 02:12:48PM +0300, Roi Dayan wrote:
> From: Alaa Hleihel <alaa@mellanox.com>
> 
> Currently, tcf_ct_flow_table_restore_skb is exported by act_ct
> module, therefore modules using it will have hard-dependency
> on act_ct and will require loading it all the time.
> 
> This can lead to an unnecessary overhead on systems that do not
> use hardware connection tracking action (ct_metadata action) in
> the first place.
> 
> To relax the hard-dependency between the modules, we unexport this
> function and make it a static inline one.
> 
> Fixes: 30b0cf90c6dd ("net/sched: act_ct: Support restoring conntrack info on skbs")
> Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
> Reviewed-by: Roi Dayan <roid@mellanox.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/net/tc_act/tc_ct.h | 11 ++++++++++-
>  net/sched/act_ct.c         | 11 -----------
>  2 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/include/net/tc_act/tc_ct.h b/include/net/tc_act/tc_ct.h
> index 79654bcb9a29..8250d6f0a462 100644
> --- a/include/net/tc_act/tc_ct.h
> +++ b/include/net/tc_act/tc_ct.h
> @@ -66,7 +66,16 @@ static inline struct nf_flowtable *tcf_ct_ft(const struct tc_action *a)
>  #endif /* CONFIG_NF_CONNTRACK */
>  
>  #if IS_ENABLED(CONFIG_NET_ACT_CT)
> -void tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie);
> +static inline void
> +tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie)
> +{
> +	enum ip_conntrack_info ctinfo = cookie & NFCT_INFOMASK;
> +	struct nf_conn *ct;
> +
> +	ct = (struct nf_conn *)(cookie & NFCT_PTRMASK);
> +	nf_conntrack_get(&ct->ct_general);
> +	nf_ct_set(skb, ct, ctinfo);
> +}
>  #else
>  static inline void
>  tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie) { }
> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> index e29f0f45d688..e9f3576cbf71 100644
> --- a/net/sched/act_ct.c
> +++ b/net/sched/act_ct.c
> @@ -1543,17 +1543,6 @@ static void __exit ct_cleanup_module(void)
>  	destroy_workqueue(act_ct_wq);
>  }
>  
> -void tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie)
> -{
> -	enum ip_conntrack_info ctinfo = cookie & NFCT_INFOMASK;
> -	struct nf_conn *ct;
> -
> -	ct = (struct nf_conn *)(cookie & NFCT_PTRMASK);
> -	nf_conntrack_get(&ct->ct_general);
> -	nf_ct_set(skb, ct, ctinfo);
> -}
> -EXPORT_SYMBOL_GPL(tcf_ct_flow_table_restore_skb);
> -
>  module_init(ct_init_module);
>  module_exit(ct_cleanup_module);
>  MODULE_AUTHOR("Paul Blakey <paulb@mellanox.com>");
> -- 
> 2.8.4
>
diff mbox series

Patch

diff --git a/include/net/tc_act/tc_ct.h b/include/net/tc_act/tc_ct.h
index 79654bcb9a29..8250d6f0a462 100644
--- a/include/net/tc_act/tc_ct.h
+++ b/include/net/tc_act/tc_ct.h
@@ -66,7 +66,16 @@  static inline struct nf_flowtable *tcf_ct_ft(const struct tc_action *a)
 #endif /* CONFIG_NF_CONNTRACK */
 
 #if IS_ENABLED(CONFIG_NET_ACT_CT)
-void tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie);
+static inline void
+tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie)
+{
+	enum ip_conntrack_info ctinfo = cookie & NFCT_INFOMASK;
+	struct nf_conn *ct;
+
+	ct = (struct nf_conn *)(cookie & NFCT_PTRMASK);
+	nf_conntrack_get(&ct->ct_general);
+	nf_ct_set(skb, ct, ctinfo);
+}
 #else
 static inline void
 tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie) { }
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index e29f0f45d688..e9f3576cbf71 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -1543,17 +1543,6 @@  static void __exit ct_cleanup_module(void)
 	destroy_workqueue(act_ct_wq);
 }
 
-void tcf_ct_flow_table_restore_skb(struct sk_buff *skb, unsigned long cookie)
-{
-	enum ip_conntrack_info ctinfo = cookie & NFCT_INFOMASK;
-	struct nf_conn *ct;
-
-	ct = (struct nf_conn *)(cookie & NFCT_PTRMASK);
-	nf_conntrack_get(&ct->ct_general);
-	nf_ct_set(skb, ct, ctinfo);
-}
-EXPORT_SYMBOL_GPL(tcf_ct_flow_table_restore_skb);
-
 module_init(ct_init_module);
 module_exit(ct_cleanup_module);
 MODULE_AUTHOR("Paul Blakey <paulb@mellanox.com>");