Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: cttimeout: decouple timeout policy from nfnetlink_cttimeout object

The timeout policy is currently embedded into the nfnetlink_cttimeout
object, move the policy into an independent object. This allows us to
reuse part of the existing conntrack timeout extension from nf_tables
without adding dependencies with the nfnetlink_cttimeout object layout.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

+41 -32
+15 -11
include/net/netfilter/nf_conntrack_timeout.h
··· 11 11 12 12 #define CTNL_TIMEOUT_NAME_MAX 32 13 13 14 - struct ctnl_timeout { 15 - struct list_head head; 16 - struct rcu_head rcu_head; 17 - refcount_t refcnt; 18 - char name[CTNL_TIMEOUT_NAME_MAX]; 14 + struct nf_ct_timeout { 19 15 __u16 l3num; 20 16 const struct nf_conntrack_l4proto *l4proto; 21 17 char data[0]; 22 18 }; 23 19 20 + struct ctnl_timeout { 21 + struct list_head head; 22 + struct rcu_head rcu_head; 23 + refcount_t refcnt; 24 + char name[CTNL_TIMEOUT_NAME_MAX]; 25 + struct nf_ct_timeout timeout; 26 + }; 27 + 24 28 struct nf_conn_timeout { 25 - struct ctnl_timeout __rcu *timeout; 29 + struct nf_ct_timeout __rcu *timeout; 26 30 }; 27 31 28 32 static inline unsigned int * 29 33 nf_ct_timeout_data(struct nf_conn_timeout *t) 30 34 { 31 - struct ctnl_timeout *timeout; 35 + struct nf_ct_timeout *timeout; 32 36 33 37 timeout = rcu_dereference(t->timeout); 34 38 if (timeout == NULL) ··· 53 49 54 50 static inline 55 51 struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct, 56 - struct ctnl_timeout *timeout, 52 + struct nf_ct_timeout *timeout, 57 53 gfp_t gfp) 58 54 { 59 55 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT ··· 87 83 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT 88 84 int nf_conntrack_timeout_init(void); 89 85 void nf_conntrack_timeout_fini(void); 90 - void nf_ct_untimeout(struct net *net, struct ctnl_timeout *timeout); 86 + void nf_ct_untimeout(struct net *net, struct nf_ct_timeout *timeout); 91 87 #else 92 88 static inline int nf_conntrack_timeout_init(void) 93 89 { ··· 101 97 #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ 102 98 103 99 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT 104 - extern struct ctnl_timeout *(*nf_ct_timeout_find_get_hook)(struct net *net, const char *name); 105 - extern void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout); 100 + extern struct nf_ct_timeout *(*nf_ct_timeout_find_get_hook)(struct net *net, const char *name); 101 + extern void (*nf_ct_timeout_put_hook)(struct nf_ct_timeout *timeout); 106 102 #endif 107 103 108 104 #endif /* _NF_CONNTRACK_TIMEOUT_H */
+3 -3
net/netfilter/nf_conntrack_timeout.c
··· 24 24 #include <net/netfilter/nf_conntrack_extend.h> 25 25 #include <net/netfilter/nf_conntrack_timeout.h> 26 26 27 - struct ctnl_timeout * 27 + struct nf_ct_timeout * 28 28 (*nf_ct_timeout_find_get_hook)(struct net *net, const char *name) __read_mostly; 29 29 EXPORT_SYMBOL_GPL(nf_ct_timeout_find_get_hook); 30 30 31 - void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout) __read_mostly; 31 + void (*nf_ct_timeout_put_hook)(struct nf_ct_timeout *timeout) __read_mostly; 32 32 EXPORT_SYMBOL_GPL(nf_ct_timeout_put_hook); 33 33 34 34 static int untimeout(struct nf_conn *ct, void *timeout) ··· 42 42 return 0; 43 43 } 44 44 45 - void nf_ct_untimeout(struct net *net, struct ctnl_timeout *timeout) 45 + void nf_ct_untimeout(struct net *net, struct nf_ct_timeout *timeout) 46 46 { 47 47 nf_ct_iterate_cleanup_net(net, untimeout, timeout, 0, 0); 48 48 }
+2 -2
net/netfilter/xt_CT.c
··· 104 104 } 105 105 106 106 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT 107 - static void __xt_ct_tg_timeout_put(struct ctnl_timeout *timeout) 107 + static void __xt_ct_tg_timeout_put(struct nf_ct_timeout *timeout) 108 108 { 109 109 typeof(nf_ct_timeout_put_hook) timeout_put; 110 110 ··· 121 121 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT 122 122 typeof(nf_ct_timeout_find_get_hook) timeout_find_get; 123 123 const struct nf_conntrack_l4proto *l4proto; 124 - struct ctnl_timeout *timeout; 124 + struct nf_ct_timeout *timeout; 125 125 struct nf_conn_timeout *timeout_ext; 126 126 const char *errmsg = NULL; 127 127 int ret = 0;