nfsd: track last inode only in use_wgather case
[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 /* This structure is passed to event handler */
21 struct nf_ct_event {
22         struct nf_conn *ct;
23         u32 pid;
24         int report;
25 };
26
27 extern struct atomic_notifier_head nf_conntrack_chain;
28 extern int nf_conntrack_register_notifier(struct notifier_block *nb);
29 extern int nf_conntrack_unregister_notifier(struct notifier_block *nb);
30
31 extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
32 extern void __nf_ct_event_cache_init(struct nf_conn *ct);
33 extern void nf_ct_event_cache_flush(struct net *net);
34
35 static inline void
36 nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
37 {
38         struct net *net = nf_ct_net(ct);
39         struct nf_conntrack_ecache *ecache;
40
41         local_bh_disable();
42         ecache = per_cpu_ptr(net->ct.ecache, raw_smp_processor_id());
43         if (ct != ecache->ct)
44                 __nf_ct_event_cache_init(ct);
45         ecache->events |= event;
46         local_bh_enable();
47 }
48
49 static inline void
50 nf_conntrack_event_report(enum ip_conntrack_events event,
51                           struct nf_conn *ct,
52                           u32 pid,
53                           int report)
54 {
55         struct nf_ct_event item = {
56                 .ct     = ct,
57                 .pid    = pid,
58                 .report = report
59         };
60         if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))
61                 atomic_notifier_call_chain(&nf_conntrack_chain, event, &item);
62 }
63
64 static inline void
65 nf_conntrack_event(enum ip_conntrack_events event, struct nf_conn *ct)
66 {
67         nf_conntrack_event_report(event, ct, 0, 0);
68 }
69
70 struct nf_exp_event {
71         struct nf_conntrack_expect *exp;
72         u32 pid;
73         int report;
74 };
75
76 extern struct atomic_notifier_head nf_ct_expect_chain;
77 extern int nf_ct_expect_register_notifier(struct notifier_block *nb);
78 extern int nf_ct_expect_unregister_notifier(struct notifier_block *nb);
79
80 static inline void
81 nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
82                           struct nf_conntrack_expect *exp,
83                           u32 pid,
84                           int report)
85 {
86         struct nf_exp_event item = {
87                 .exp    = exp,
88                 .pid    = pid,
89                 .report = report
90         };
91         atomic_notifier_call_chain(&nf_ct_expect_chain, event, &item);
92 }
93
94 static inline void
95 nf_ct_expect_event(enum ip_conntrack_expect_events event,
96                    struct nf_conntrack_expect *exp)
97 {
98         nf_ct_expect_event_report(event, exp, 0, 0);
99 }
100
101 extern int nf_conntrack_ecache_init(struct net *net);
102 extern void nf_conntrack_ecache_fini(struct net *net);
103
104 #else /* CONFIG_NF_CONNTRACK_EVENTS */
105
106 static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
107                                             struct nf_conn *ct) {}
108 static inline void nf_conntrack_event(enum ip_conntrack_events event,
109                                       struct nf_conn *ct) {}
110 static inline void nf_conntrack_event_report(enum ip_conntrack_events event,
111                                              struct nf_conn *ct,
112                                              u32 pid,
113                                              int report) {}
114 static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
115 static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event,
116                                       struct nf_conntrack_expect *exp) {}
117 static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
118                                              struct nf_conntrack_expect *exp,
119                                              u32 pid,
120                                              int report) {}
121 static inline void nf_ct_event_cache_flush(struct net *net) {}
122
123 static inline int nf_conntrack_ecache_init(struct net *net)
124 {
125         return 0;
126 }
127
128 static inline void nf_conntrack_ecache_fini(struct net *net)
129 {
130 }
131 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
132
133 #endif /*_NF_CONNTRACK_ECACHE_H*/
134