Skip to content

Commit

Permalink
net/sched: act_ct: Make tcf_ct_flow_table_restore_skb inline
Browse files Browse the repository at this point in the history
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: 30b0cf9 ("net/sched: act_ct: Support restoring conntrack info on skbs")
Signed-off-by: Alaa Hleihel <[email protected]>
Reviewed-by: Roi Dayan <[email protected]>
Acked-by: Marcelo Ricardo Leitner <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
alaahl authored and davem330 committed Jun 16, 2020
1 parent c92cbae commit 762f926
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 10 additions & 1 deletion include/net/tc_act/tc_ct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand Down
11 changes: 0 additions & 11 deletions net/sched/act_ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]>");
Expand Down

0 comments on commit 762f926

Please sign in to comment.