2 * connection tracking event cache.
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/net_namespace.h>
12 #include <net/netfilter/nf_conntrack_expect.h>
14 /* Connection tracking event bits */
15 enum ip_conntrack_events
19 IPCT_NEW
= (1 << IPCT_NEW_BIT
),
21 /* Expected connection */
23 IPCT_RELATED
= (1 << IPCT_RELATED_BIT
),
25 /* Destroyed conntrack */
27 IPCT_DESTROY
= (1 << IPCT_DESTROY_BIT
),
29 /* Status has changed */
31 IPCT_STATUS
= (1 << IPCT_STATUS_BIT
),
33 /* Update of protocol info */
34 IPCT_PROTOINFO_BIT
= 4,
35 IPCT_PROTOINFO
= (1 << IPCT_PROTOINFO_BIT
),
37 /* New helper for conntrack */
39 IPCT_HELPER
= (1 << IPCT_HELPER_BIT
),
43 IPCT_MARK
= (1 << IPCT_MARK_BIT
),
45 /* NAT sequence adjustment */
46 IPCT_NATSEQADJ_BIT
= 7,
47 IPCT_NATSEQADJ
= (1 << IPCT_NATSEQADJ_BIT
),
51 IPCT_SECMARK
= (1 << IPCT_SECMARK_BIT
),
54 enum ip_conntrack_expect_events
{
56 IPEXP_NEW
= (1 << IPEXP_NEW_BIT
),
59 #ifdef CONFIG_NF_CONNTRACK_EVENTS
60 struct nf_conntrack_ecache
{
65 /* This structure is passed to event handler */
72 extern struct atomic_notifier_head nf_conntrack_chain
;
73 extern int nf_conntrack_register_notifier(struct notifier_block
*nb
);
74 extern int nf_conntrack_unregister_notifier(struct notifier_block
*nb
);
76 extern void nf_ct_deliver_cached_events(const struct nf_conn
*ct
);
77 extern void __nf_ct_event_cache_init(struct nf_conn
*ct
);
78 extern void nf_ct_event_cache_flush(struct net
*net
);
81 nf_conntrack_event_cache(enum ip_conntrack_events event
, struct nf_conn
*ct
)
83 struct net
*net
= nf_ct_net(ct
);
84 struct nf_conntrack_ecache
*ecache
;
87 ecache
= per_cpu_ptr(net
->ct
.ecache
, raw_smp_processor_id());
89 __nf_ct_event_cache_init(ct
);
90 ecache
->events
|= event
;
95 nf_conntrack_event_report(enum ip_conntrack_events event
,
100 struct nf_ct_event item
= {
105 if (nf_ct_is_confirmed(ct
) && !nf_ct_is_dying(ct
))
106 atomic_notifier_call_chain(&nf_conntrack_chain
, event
, &item
);
110 nf_conntrack_event(enum ip_conntrack_events event
, struct nf_conn
*ct
)
112 nf_conntrack_event_report(event
, ct
, 0, 0);
115 struct nf_exp_event
{
116 struct nf_conntrack_expect
*exp
;
121 extern struct atomic_notifier_head nf_ct_expect_chain
;
122 extern int nf_ct_expect_register_notifier(struct notifier_block
*nb
);
123 extern int nf_ct_expect_unregister_notifier(struct notifier_block
*nb
);
126 nf_ct_expect_event_report(enum ip_conntrack_expect_events event
,
127 struct nf_conntrack_expect
*exp
,
131 struct nf_exp_event item
= {
136 atomic_notifier_call_chain(&nf_ct_expect_chain
, event
, &item
);
140 nf_ct_expect_event(enum ip_conntrack_expect_events event
,
141 struct nf_conntrack_expect
*exp
)
143 nf_ct_expect_event_report(event
, exp
, 0, 0);
146 extern int nf_conntrack_ecache_init(struct net
*net
);
147 extern void nf_conntrack_ecache_fini(struct net
*net
);
149 #else /* CONFIG_NF_CONNTRACK_EVENTS */
151 static inline void nf_conntrack_event_cache(enum ip_conntrack_events event
,
152 struct nf_conn
*ct
) {}
153 static inline void nf_conntrack_event(enum ip_conntrack_events event
,
154 struct nf_conn
*ct
) {}
155 static inline void nf_conntrack_event_report(enum ip_conntrack_events event
,
159 static inline void nf_ct_deliver_cached_events(const struct nf_conn
*ct
) {}
160 static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event
,
161 struct nf_conntrack_expect
*exp
) {}
162 static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e
,
163 struct nf_conntrack_expect
*exp
,
166 static inline void nf_ct_event_cache_flush(struct net
*net
) {}
168 static inline int nf_conntrack_ecache_init(struct net
*net
)
173 static inline void nf_conntrack_ecache_fini(struct net
*net
)
176 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
178 #endif /*_NF_CONNTRACK_ECACHE_H*/