]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/net/netfilter/nf_conntrack_core.h
netfilter: nf_conntrack: speed up module removal path if netns in use
[karo-tx-linux.git] / include / net / netfilter / nf_conntrack_core.h
1 /*
2  * This header is used to share core functionality between the
3  * standalone connection tracking module, and the compatibility layer's use
4  * of connection tracking.
5  *
6  * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
7  *      - generalize L3 protocol dependent part.
8  *
9  * Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h
10  */
11
12 #ifndef _NF_CONNTRACK_CORE_H
13 #define _NF_CONNTRACK_CORE_H
14
15 #include <linux/netfilter.h>
16 #include <net/netfilter/nf_conntrack_l3proto.h>
17 #include <net/netfilter/nf_conntrack_l4proto.h>
18 #include <net/netfilter/nf_conntrack_ecache.h>
19
20 /* This header is used to share core functionality between the
21    standalone connection tracking module, and the compatibility layer's use
22    of connection tracking. */
23 extern unsigned int nf_conntrack_in(struct net *net,
24                                     u_int8_t pf,
25                                     unsigned int hooknum,
26                                     struct sk_buff *skb);
27
28 extern int nf_conntrack_init_net(struct net *net);
29 extern void nf_conntrack_cleanup_net(struct net *net);
30 extern void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list);
31
32 extern int nf_conntrack_proto_pernet_init(struct net *net);
33 extern void nf_conntrack_proto_pernet_fini(struct net *net);
34
35 extern int nf_conntrack_proto_init(void);
36 extern void nf_conntrack_proto_fini(void);
37
38 extern int nf_conntrack_init_start(void);
39 extern void nf_conntrack_cleanup_start(void);
40
41 extern void nf_conntrack_init_end(void);
42 extern void nf_conntrack_cleanup_end(void);
43
44 extern bool
45 nf_ct_get_tuple(const struct sk_buff *skb,
46                 unsigned int nhoff,
47                 unsigned int dataoff,
48                 u_int16_t l3num,
49                 u_int8_t protonum,
50                 struct nf_conntrack_tuple *tuple,
51                 const struct nf_conntrack_l3proto *l3proto,
52                 const struct nf_conntrack_l4proto *l4proto);
53
54 extern bool
55 nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
56                    const struct nf_conntrack_tuple *orig,
57                    const struct nf_conntrack_l3proto *l3proto,
58                    const struct nf_conntrack_l4proto *l4proto);
59
60 /* Find a connection corresponding to a tuple. */
61 extern struct nf_conntrack_tuple_hash *
62 nf_conntrack_find_get(struct net *net, u16 zone,
63                       const struct nf_conntrack_tuple *tuple);
64
65 extern int __nf_conntrack_confirm(struct sk_buff *skb);
66
67 /* Confirm a connection: returns NF_DROP if packet must be dropped. */
68 static inline int nf_conntrack_confirm(struct sk_buff *skb)
69 {
70         struct nf_conn *ct = (struct nf_conn *)skb->nfct;
71         int ret = NF_ACCEPT;
72
73         if (ct && !nf_ct_is_untracked(ct)) {
74                 if (!nf_ct_is_confirmed(ct))
75                         ret = __nf_conntrack_confirm(skb);
76                 if (likely(ret == NF_ACCEPT))
77                         nf_ct_deliver_cached_events(ct);
78         }
79         return ret;
80 }
81
82 int
83 print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
84             const struct nf_conntrack_l3proto *l3proto,
85             const struct nf_conntrack_l4proto *proto);
86
87 extern spinlock_t nf_conntrack_lock ;
88
89 #endif /* _NF_CONNTRACK_CORE_H */