![Vladimir Davydov](/assets/img/avatar_default.png)
The patch introduces nf_conntrack_cleanup_net_list(), which cleanups nf_conntrack for a list of netns and calls synchronize_net() only once for them all. This should reduce netns destruction time. I've measured cleanup time for 1k dummy net ns. Here are the results: <without the patch> # modprobe nf_conntrack # time modprobe -r nf_conntrack real 0m10.337s user 0m0.000s sys 0m0.376s <with the patch> # modprobe nf_conntrack # time modprobe -r nf_conntrack real 0m5.661s user 0m0.000s sys 0m0.216s Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Cc: Patrick McHardy <kaber@trash.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
90 lines
2.8 KiB
C
90 lines
2.8 KiB
C
/*
|
|
* This header is used to share core functionality between the
|
|
* standalone connection tracking module, and the compatibility layer's use
|
|
* of connection tracking.
|
|
*
|
|
* 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
|
|
* - generalize L3 protocol dependent part.
|
|
*
|
|
* Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h
|
|
*/
|
|
|
|
#ifndef _NF_CONNTRACK_CORE_H
|
|
#define _NF_CONNTRACK_CORE_H
|
|
|
|
#include <linux/netfilter.h>
|
|
#include <net/netfilter/nf_conntrack_l3proto.h>
|
|
#include <net/netfilter/nf_conntrack_l4proto.h>
|
|
#include <net/netfilter/nf_conntrack_ecache.h>
|
|
|
|
/* This header is used to share core functionality between the
|
|
standalone connection tracking module, and the compatibility layer's use
|
|
of connection tracking. */
|
|
extern unsigned int nf_conntrack_in(struct net *net,
|
|
u_int8_t pf,
|
|
unsigned int hooknum,
|
|
struct sk_buff *skb);
|
|
|
|
extern int nf_conntrack_init_net(struct net *net);
|
|
extern void nf_conntrack_cleanup_net(struct net *net);
|
|
extern void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list);
|
|
|
|
extern int nf_conntrack_proto_pernet_init(struct net *net);
|
|
extern void nf_conntrack_proto_pernet_fini(struct net *net);
|
|
|
|
extern int nf_conntrack_proto_init(void);
|
|
extern void nf_conntrack_proto_fini(void);
|
|
|
|
extern int nf_conntrack_init_start(void);
|
|
extern void nf_conntrack_cleanup_start(void);
|
|
|
|
extern void nf_conntrack_init_end(void);
|
|
extern void nf_conntrack_cleanup_end(void);
|
|
|
|
extern bool
|
|
nf_ct_get_tuple(const struct sk_buff *skb,
|
|
unsigned int nhoff,
|
|
unsigned int dataoff,
|
|
u_int16_t l3num,
|
|
u_int8_t protonum,
|
|
struct nf_conntrack_tuple *tuple,
|
|
const struct nf_conntrack_l3proto *l3proto,
|
|
const struct nf_conntrack_l4proto *l4proto);
|
|
|
|
extern bool
|
|
nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
|
|
const struct nf_conntrack_tuple *orig,
|
|
const struct nf_conntrack_l3proto *l3proto,
|
|
const struct nf_conntrack_l4proto *l4proto);
|
|
|
|
/* Find a connection corresponding to a tuple. */
|
|
extern struct nf_conntrack_tuple_hash *
|
|
nf_conntrack_find_get(struct net *net, u16 zone,
|
|
const struct nf_conntrack_tuple *tuple);
|
|
|
|
extern int __nf_conntrack_confirm(struct sk_buff *skb);
|
|
|
|
/* Confirm a connection: returns NF_DROP if packet must be dropped. */
|
|
static inline int nf_conntrack_confirm(struct sk_buff *skb)
|
|
{
|
|
struct nf_conn *ct = (struct nf_conn *)skb->nfct;
|
|
int ret = NF_ACCEPT;
|
|
|
|
if (ct && !nf_ct_is_untracked(ct)) {
|
|
if (!nf_ct_is_confirmed(ct))
|
|
ret = __nf_conntrack_confirm(skb);
|
|
if (likely(ret == NF_ACCEPT))
|
|
nf_ct_deliver_cached_events(ct);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int
|
|
print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
|
|
const struct nf_conntrack_l3proto *l3proto,
|
|
const struct nf_conntrack_l4proto *proto);
|
|
|
|
extern spinlock_t nf_conntrack_lock ;
|
|
|
|
#endif /* _NF_CONNTRACK_CORE_H */
|