nf_conntrack_ecache.h: Fix missing braces
[safe/jmp/linux-2.6] / include / net / netfilter / nf_conntrack_ecache.h
1 /*
2  * connection tracking event cache.
3  */
4
5 #ifndef _NF_CONNTRACK_ECACHE_H
6 #define _NF_CONNTRACK_ECACHE_H
7 #include <net/netfilter/nf_conntrack.h>
8
9 #include <linux/notifier.h>
10 #include <linux/interrupt.h>
11 #include <net/net_namespace.h>
12 #include <net/netfilter/nf_conntrack_expect.h>
13
14 #ifdef CONFIG_NF_CONNTRACK_EVENTS
15 struct nf_conntrack_ecache {
16         struct nf_conn *ct;
17         unsigned int events;
18 };
19
20 extern struct atomic_notifier_head nf_conntrack_chain;
21 extern int nf_conntrack_register_notifier(struct notifier_block *nb);
22 extern int nf_conntrack_unregister_notifier(struct notifier_block *nb);
23
24 extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
25 extern void __nf_ct_event_cache_init(struct nf_conn *ct);
26 extern void nf_ct_event_cache_flush(struct net *net);
27
28 static inline void
29 nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
30 {
31         struct net *net = nf_ct_net(ct);
32         struct nf_conntrack_ecache *ecache;
33
34         local_bh_disable();
35         ecache = per_cpu_ptr(net->ct.ecache, raw_smp_processor_id());
36         if (ct != ecache->ct)
37                 __nf_ct_event_cache_init(ct);
38         ecache->events |= event;
39         local_bh_enable();
40 }
41
42 static inline void nf_conntrack_event(enum ip_conntrack_events event,
43                                       struct nf_conn *ct)
44 {
45         if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))
46                 atomic_notifier_call_chain(&nf_conntrack_chain, event, ct);
47 }
48
49 extern struct atomic_notifier_head nf_ct_expect_chain;
50 extern int nf_ct_expect_register_notifier(struct notifier_block *nb);
51 extern int nf_ct_expect_unregister_notifier(struct notifier_block *nb);
52
53 static inline void
54 nf_ct_expect_event(enum ip_conntrack_expect_events event,
55                    struct nf_conntrack_expect *exp)
56 {
57         atomic_notifier_call_chain(&nf_ct_expect_chain, event, exp);
58 }
59
60 extern int nf_conntrack_ecache_init(struct net *net);
61 extern void nf_conntrack_ecache_fini(struct net *net);
62
63 #else /* CONFIG_NF_CONNTRACK_EVENTS */
64
65 static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
66                                             const struct sk_buff *skb) {}
67 static inline void nf_conntrack_event(enum ip_conntrack_events event,
68                                       struct nf_conn *ct) {}
69 static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
70 static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event,
71                                       struct nf_conntrack_expect *exp) {}
72 static inline void nf_ct_event_cache_flush(struct net *net) {}
73
74 static inline int nf_conntrack_ecache_init(struct net *net)
75 {
76         return 0;
77 }
78
79 static inline void nf_conntrack_ecache_fini(struct net *net)
80 {
81 }
82 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
83
84 #endif /*_NF_CONNTRACK_ECACHE_H*/
85