Skip to contentSkip to conversation

remove dependency between mlx5, act_ct, nf_flow_table

PATCH In review Roi Dayan 3 participants 6 messages Jun 14, 2020 – Jun 16, 2020

Subsystems (4)
lore
Share & tools
lore

Roi Dayan

author
#0 lore raw

cover remove dependency between mlx5, act_ct, nf_flow_table

Hi,

Some exported functions from act_ct and nf_flow_table being used in mlx5_core. This leads that mlx5 module always require act_ct and nf_flow_table modules. Those small exported functions can be moved to the header files to avoid this module dependency.

Thanks,
Roi

Alaa Hleihel (2):
net/sched: act_ct: Make tcf_ct_flow_table_restore_skb inline
netfilter: flowtable: Make nf_flow_table_offload_add/del_cb inline

 include/net/netfilter/nf_flow_table.h | 49 ++++++++++++++++++++++++++++++++---
 include/net/tc_act/tc_ct.h            | 11 +++++++-
 net/netfilter/nf_flow_table_core.c    | 45 --------------------------------
 net/sched/act_ct.c                    | 11 --------
 4 files changed, 55 insertions(+), 61 deletions(-)
Signature · 1 line
2.8.4
author
#1 lore raw

PATCH 1/2 net/sched: act_ct: Make tcf_ct_flow_table_restore_skb inline

From: Alaa Hleihel <[email protected]>

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")
---
 include/net/tc_act/tc_ct.h | 11 ++++++++++-
 net/sched/act_ct.c         | 11 -----------
 2 files changed, 10 insertions(+), 12 deletions(-)
include/net/tc_act/tc_ct.h +10 -1
index 79654bcb9a29..8250d6f0a462 100644
@@ -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) { }
net/sched/act_ct.c +0 -11
index e29f0f45d688..e9f3576cbf71 100644
@@ -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 <[email protected]>");
Signature · 1 line
2.8.4
Acked-by on v1 1/2
#2 lore raw

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

Quoted 10 lines · Roi Dayan

From: Alaa Hleihel <[email protected]>

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.

Quoted 6 lines

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")
Quoted 52 lines
---
 include/net/tc_act/tc_ct.h | 11 ++++++++++-
 net/sched/act_ct.c         | 11 -----------
 2 files changed, 10 insertions(+), 12 deletions(-)
include/net/tc_act/tc_ct.h +10 -1
index 79654bcb9a29..8250d6f0a462 100644
@@ -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) { }
net/sched/act_ct.c +0 -11
index e29f0f45d688..e9f3576cbf71 100644
@@ -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 <[email protected]>");
Signature · 1 line
2.8.4
author
#3 lore raw

PATCH 2/2 netfilter: flowtable: Make nf_flow_table_offload_add/del_cb inline

In reply to Roi Dayan

From: Alaa Hleihel <[email protected]>

Currently, nf_flow_table_offload_add/del_cb are exported by nf_flow_table module, therefore modules using them will have hard-dependency on nf_flow_table and will require loading it all the time.

This can lead to an unnecessary overhead on systems that do not use this API.

To relax the hard-dependency between the modules, we unexport these functions and make them static inline.

Fixes 978703f42549 ("netfilter: flowtable: Add API for registering to flow table events")
---
 include/net/netfilter/nf_flow_table.h | 49 ++++++++++++++++++++++++++++++++---
 net/netfilter/nf_flow_table_core.c    | 45 --------------------------------
 2 files changed, 45 insertions(+), 49 deletions(-)
include/net/netfilter/nf_flow_table.h +45 -4
index c54a7f707e50..8a8f0e64edc3 100644
@@ -161,10 +161,51 @@ struct nf_flow_route {
 struct flow_offload *flow_offload_alloc(struct nf_conn *ct);
 void flow_offload_free(struct flow_offload *flow);
 
-int nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
-				 flow_setup_cb_t *cb, void *cb_priv);
-void nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
-				  flow_setup_cb_t *cb, void *cb_priv);
+static inline int
+nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
+			     flow_setup_cb_t *cb, void *cb_priv)
+{
+	struct flow_block *block = &flow_table->flow_block;
+	struct flow_block_cb *block_cb;
+	int err = 0;
+
+	down_write(&flow_table->flow_block_lock);
+	block_cb = flow_block_cb_lookup(block, cb, cb_priv);
+	if (block_cb) {
+		err = -EEXIST;
+		goto unlock;
+	}
+
+	block_cb = flow_block_cb_alloc(cb, cb_priv, cb_priv, NULL);
+	if (IS_ERR(block_cb)) {
+		err = PTR_ERR(block_cb);
+		goto unlock;
+	}
+
+	list_add_tail(&block_cb->list, &block->cb_list);
+
+unlock:
+	up_write(&flow_table->flow_block_lock);
+	return err;
+}
+
+static inline void
+nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
+			     flow_setup_cb_t *cb, void *cb_priv)
+{
+	struct flow_block *block = &flow_table->flow_block;
+	struct flow_block_cb *block_cb;
+
+	down_write(&flow_table->flow_block_lock);
+	block_cb = flow_block_cb_lookup(block, cb, cb_priv);
+	if (block_cb) {
+		list_del(&block_cb->list);
+		flow_block_cb_free(block_cb);
+	} else {
+		WARN_ON(true);
+	}
+	up_write(&flow_table->flow_block_lock);
+}
 
 int flow_offload_route_init(struct flow_offload *flow,
 			    const struct nf_flow_route *route);
net/netfilter/nf_flow_table_core.c +0 -45

51 lines not on this page · raw message

Signature · 1 line
2.8.4
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH net 2/2] netfilter: flowtable: Make nf_flow_table_offload_add/del_cb inline

Quoted 9 lines · Roi Dayan

From: Alaa Hleihel <[email protected]>

Currently, nf_flow_table_offload_add/del_cb are exported by nf_flow_table module, therefore modules using them will have hard-dependency on nf_flow_table and will require loading it all the time.

This can lead to an unnecessary overhead on systems that do not use this API.

Quoted 6 lines

To relax the hard-dependency between the modules, we unexport these functions and make them static inline.

Fixes 978703f42549 ("netfilter: flowtable: Add API for registering to flow table events")
Quoted 124 lines
---
 include/net/netfilter/nf_flow_table.h | 49 ++++++++++++++++++++++++++++++++---
 net/netfilter/nf_flow_table_core.c    | 45 --------------------------------
 2 files changed, 45 insertions(+), 49 deletions(-)
include/net/netfilter/nf_flow_table.h +45 -4
index c54a7f707e50..8a8f0e64edc3 100644
@@ -161,10 +161,51 @@ struct nf_flow_route {
 struct flow_offload *flow_offload_alloc(struct nf_conn *ct);
 void flow_offload_free(struct flow_offload *flow);
 
-int nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
-				 flow_setup_cb_t *cb, void *cb_priv);
-void nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
-				  flow_setup_cb_t *cb, void *cb_priv);
+static inline int
+nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
+			     flow_setup_cb_t *cb, void *cb_priv)
+{
+	struct flow_block *block = &flow_table->flow_block;
+	struct flow_block_cb *block_cb;
+	int err = 0;
+
+	down_write(&flow_table->flow_block_lock);
+	block_cb = flow_block_cb_lookup(block, cb, cb_priv);
+	if (block_cb) {
+		err = -EEXIST;
+		goto unlock;
+	}
+
+	block_cb = flow_block_cb_alloc(cb, cb_priv, cb_priv, NULL);
+	if (IS_ERR(block_cb)) {
+		err = PTR_ERR(block_cb);
+		goto unlock;
+	}
+
+	list_add_tail(&block_cb->list, &block->cb_list);
+
+unlock:
+	up_write(&flow_table->flow_block_lock);
+	return err;
+}
+
+static inline void
+nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
+			     flow_setup_cb_t *cb, void *cb_priv)
+{
+	struct flow_block *block = &flow_table->flow_block;
+	struct flow_block_cb *block_cb;
+
+	down_write(&flow_table->flow_block_lock);
+	block_cb = flow_block_cb_lookup(block, cb, cb_priv);
+	if (block_cb) {
+		list_del(&block_cb->list);
+		flow_block_cb_free(block_cb);
+	} else {
+		WARN_ON(true);
+	}
+	up_write(&flow_table->flow_block_lock);
+}
 
 int flow_offload_route_init(struct flow_offload *flow,
 			    const struct nf_flow_route *route);
net/netfilter/nf_flow_table_core.c +0 -45
index 42da6e337276..647680175213 100644
@@ -387,51 +387,6 @@ static void nf_flow_offload_work_gc(struct work_struct *work)
 	queue_delayed_work(system_power_efficient_wq, &flow_table->gc_work, HZ);
 }
 
-int nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
-				 flow_setup_cb_t *cb, void *cb_priv)
-{
-	struct flow_block *block = &flow_table->flow_block;
-	struct flow_block_cb *block_cb;
-	int err = 0;
-
-	down_write(&flow_table->flow_block_lock);
-	block_cb = flow_block_cb_lookup(block, cb, cb_priv);
-	if (block_cb) {
-		err = -EEXIST;
-		goto unlock;
-	}
-
-	block_cb = flow_block_cb_alloc(cb, cb_priv, cb_priv, NULL);
-	if (IS_ERR(block_cb)) {
-		err = PTR_ERR(block_cb);
-		goto unlock;
-	}
-
-	list_add_tail(&block_cb->list, &block->cb_list);
-
-unlock:
-	up_write(&flow_table->flow_block_lock);
-	return err;
-}
-EXPORT_SYMBOL_GPL(nf_flow_table_offload_add_cb);
-
-void nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
-				  flow_setup_cb_t *cb, void *cb_priv)
-{
-	struct flow_block *block = &flow_table->flow_block;
-	struct flow_block_cb *block_cb;
-
-	down_write(&flow_table->flow_block_lock);
-	block_cb = flow_block_cb_lookup(block, cb, cb_priv);
-	if (block_cb) {
-		list_del(&block_cb->list);
-		flow_block_cb_free(block_cb);
-	} else {
-		WARN_ON(true);
-	}
-	up_write(&flow_table->flow_block_lock);
-}
-EXPORT_SYMBOL_GPL(nf_flow_table_offload_del_cb);
 
 static int nf_flow_nat_port_tcp(struct sk_buff *skb, unsigned int thoff,
 				__be16 port, __be16 new_port)
Signature · 1 line
2.8.4
maintainer
#5 lore raw
In reply to Roi Dayan

From: Roi Dayan <[email protected]>
Date: Sun, 14 Jun 2020 14:12:47 +0300

Quoted 4 lines

Some exported functions from act_ct and nf_flow_table being used in mlx5_core. This leads that mlx5 module always require act_ct and nf_flow_table modules. Those small exported functions can be moved to the header files to avoid this module dependency.

Series applied, thanks.