ACPI: ibm-acpi: organize code
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / net / netfilter / nf_conntrack_ecache.h
blobb62a8a9ec9d86cfbdb9d8b5f83257ee7ea74aa6e
1 /*
2 * connection tracking event cache.
3 */
5 #ifndef _NF_CONNTRACK_ECACHE_H
6 #define _NF_CONNTRACK_ECACHE_H
7 #include <net/netfilter/nf_conntrack.h>
9 #include <linux/notifier.h>
10 #include <linux/interrupt.h>
11 #include <net/netfilter/nf_conntrack_expect.h>
13 #ifdef CONFIG_NF_CONNTRACK_EVENTS
14 struct nf_conntrack_ecache {
15 struct nf_conn *ct;
16 unsigned int events;
18 DECLARE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache);
20 #define CONNTRACK_ECACHE(x) (__get_cpu_var(nf_conntrack_ecache).x)
22 extern struct atomic_notifier_head nf_conntrack_chain;
23 extern struct atomic_notifier_head nf_conntrack_expect_chain;
25 static inline int nf_conntrack_register_notifier(struct notifier_block *nb)
27 return atomic_notifier_chain_register(&nf_conntrack_chain, nb);
30 static inline int nf_conntrack_unregister_notifier(struct notifier_block *nb)
32 return atomic_notifier_chain_unregister(&nf_conntrack_chain, nb);
35 static inline int
36 nf_conntrack_expect_register_notifier(struct notifier_block *nb)
38 return atomic_notifier_chain_register(&nf_conntrack_expect_chain, nb);
41 static inline int
42 nf_conntrack_expect_unregister_notifier(struct notifier_block *nb)
44 return atomic_notifier_chain_unregister(&nf_conntrack_expect_chain,
45 nb);
48 extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
49 extern void __nf_ct_event_cache_init(struct nf_conn *ct);
50 extern void nf_ct_event_cache_flush(void);
52 static inline void
53 nf_conntrack_event_cache(enum ip_conntrack_events event,
54 const struct sk_buff *skb)
56 struct nf_conn *ct = (struct nf_conn *)skb->nfct;
57 struct nf_conntrack_ecache *ecache;
59 local_bh_disable();
60 ecache = &__get_cpu_var(nf_conntrack_ecache);
61 if (ct != ecache->ct)
62 __nf_ct_event_cache_init(ct);
63 ecache->events |= event;
64 local_bh_enable();
67 static inline void nf_conntrack_event(enum ip_conntrack_events event,
68 struct nf_conn *ct)
70 if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))
71 atomic_notifier_call_chain(&nf_conntrack_chain, event, ct);
74 static inline void
75 nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
76 struct nf_conntrack_expect *exp)
78 atomic_notifier_call_chain(&nf_conntrack_expect_chain, event, exp);
81 #else /* CONFIG_NF_CONNTRACK_EVENTS */
83 static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
84 const struct sk_buff *skb) {}
85 static inline void nf_conntrack_event(enum ip_conntrack_events event,
86 struct nf_conn *ct) {}
87 static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
88 static inline void
89 nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
90 struct nf_conntrack_expect *exp) {}
91 static inline void nf_ct_event_cache_flush(void) {}
92 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
94 #endif /*_NF_CONNTRACK_ECACHE_H*/