fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / net / netfilter / nf_conntrack.h
index 6d075ca..bd01b46 100644 (file)
 #include <linux/netfilter/nf_conntrack_common.h>
 
 #ifdef __KERNEL__
-#include <linux/config.h>
 #include <linux/bitops.h>
 #include <linux/compiler.h>
 #include <asm/atomic.h>
 
 #include <linux/netfilter/nf_conntrack_tcp.h>
 #include <linux/netfilter/nf_conntrack_sctp.h>
+#include <linux/netfilter/nf_conntrack_proto_gre.h>
 #include <net/netfilter/ipv4/nf_conntrack_icmp.h>
 #include <net/netfilter/ipv6/nf_conntrack_icmpv6.h>
 
@@ -34,6 +34,7 @@ union nf_conntrack_proto {
        struct ip_ct_tcp tcp;
        struct ip_ct_icmp icmp;
        struct nf_ct_icmpv6 icmpv6;
+       struct nf_ct_gre gre;
 };
 
 union nf_conntrack_expect_proto {
@@ -42,15 +43,20 @@ union nf_conntrack_expect_proto {
 
 /* Add protocol helper include file here */
 #include <linux/netfilter/nf_conntrack_ftp.h>
+#include <linux/netfilter/nf_conntrack_pptp.h>
+#include <linux/netfilter/nf_conntrack_h323.h>
 
 /* per conntrack: application helper private data */
 union nf_conntrack_help {
        /* insert conntrack helper private data (master) here */
-       struct ip_ct_ftp_master ct_ftp_info;
+       struct nf_ct_ftp_master ct_ftp_info;
+       struct nf_ct_pptp_master ct_pptp_info;
+       struct nf_ct_h323_master ct_h323_info;
 };
 
 #include <linux/types.h>
 #include <linux/skbuff.h>
+#include <linux/timer.h>
 
 #ifdef CONFIG_NETFILTER_DEBUG
 #define NF_CT_ASSERT(x)                                                        \
@@ -67,7 +73,21 @@ do {                                                                 \
 
 struct nf_conntrack_helper;
 
+/* nf_conn feature for connections that have a helper */
+struct nf_conn_help {
+       /* Helper. if any */
+       struct nf_conntrack_helper *helper;
+
+       union nf_conntrack_help help;
+
+       /* Current number of expected connections */
+       unsigned int expecting;
+};
+
+
 #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
+#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
+
 struct nf_conn
 {
        /* Usage count in here is 1 for hash table/destruct timer, 1 per skb,
@@ -81,6 +101,9 @@ struct nf_conn
        /* Have we seen traffic both ways yet? (bitset) */
        unsigned long status;
 
+       /* If we were expected by an expectation, this will be it */
+       struct nf_conn *master;
+
        /* Timer function; drops refcnt when it goes off. */
        struct timer_list timeout;
 
@@ -88,78 +111,28 @@ struct nf_conn
        /* Accounting Information (same cache line as other written members) */
        struct ip_conntrack_counter counters[IP_CT_DIR_MAX];
 #endif
-       /* If we were expected by an expectation, this will be it */
-       struct nf_conn *master;
-       
-       /* Current number of expected connections */
-       unsigned int expecting;
 
        /* Unique ID that identifies this conntrack*/
        unsigned int id;
 
-       /* Helper. if any */
-       struct nf_conntrack_helper *helper;
-
        /* features - nat, helper, ... used by allocating system */
        u_int32_t features;
 
-       /* Storage reserved for other modules: */
-
-       union nf_conntrack_proto proto;
-
 #if defined(CONFIG_NF_CONNTRACK_MARK)
        u_int32_t mark;
 #endif
 
-       /* These members are dynamically allocated. */
-
-       union nf_conntrack_help *help;
-
-       /* Layer 3 dependent members. (ex: NAT) */
-       union {
-               struct nf_conntrack_ipv4 *ipv4;
-       } l3proto;
-       void *data[0];
-};
-
-struct nf_conntrack_expect
-{
-       /* Internal linked list (global expectation list) */
-       struct list_head list;
-
-       /* We expect this tuple, with the following mask */
-       struct nf_conntrack_tuple tuple, mask;
-       /* Function to call after setup and insertion */
-       void (*expectfn)(struct nf_conn *new,
-                        struct nf_conntrack_expect *this);
-
-       /* The conntrack of the master connection */
-       struct nf_conn *master;
-
-       /* Timer function; deletes the expectation. */
-       struct timer_list timeout;
-
-       /* Usage count. */
-       atomic_t use;
-
-       /* Unique ID */
-       unsigned int id;
+#ifdef CONFIG_NF_CONNTRACK_SECMARK
+       u_int32_t secmark;
+#endif
 
-       /* Flags */
-       unsigned int flags;
+       /* Storage reserved for other modules: */
+       union nf_conntrack_proto proto;
 
-#ifdef CONFIG_NF_NAT_NEEDED
-       /* This is the original per-proto part, used to map the
-        * expected connection the way the recipient expects. */
-       union nf_conntrack_manip_proto saved_proto;
-       /* Direction relative to the master connection. */
-       enum ip_conntrack_dir dir;
-#endif
+       /* features dynamically at the end: helper, nat (both optional) */
+       char data[0];
 };
 
-#define NF_CT_EXPECT_PERMANENT 0x1
-
 static inline struct nf_conn *
 nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash)
 {
@@ -196,22 +169,16 @@ static inline void nf_ct_put(struct nf_conn *ct)
        nf_conntrack_put(&ct->ct_general);
 }
 
+/* Protocol module loading */
+extern int nf_ct_l3proto_try_module_get(unsigned short l3proto);
+extern void nf_ct_l3proto_module_put(unsigned short l3proto);
+
 extern struct nf_conntrack_tuple_hash *
 __nf_conntrack_find(const struct nf_conntrack_tuple *tuple,
                    const struct nf_conn *ignored_conntrack);
 
 extern void nf_conntrack_hash_insert(struct nf_conn *ct);
 
-extern struct nf_conntrack_expect *
-__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);
-
-extern struct nf_conntrack_expect *
-nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);
-
-extern void nf_ct_unlink_expect(struct nf_conntrack_expect *exp);
-
-extern void nf_ct_remove_expectations(struct nf_conn *ct);
-
 extern void nf_conntrack_flush(void);
 
 extern struct nf_conntrack_helper *
@@ -282,101 +249,67 @@ static inline int nf_ct_is_dying(struct nf_conn *ct)
 }
 
 extern unsigned int nf_conntrack_htable_size;
+extern int nf_conntrack_checksum;
+extern atomic_t nf_conntrack_count;
+extern int nf_conntrack_max;
 
+DECLARE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
 #define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++)
 
-#ifdef CONFIG_NF_CONNTRACK_EVENTS
-#include <linux/notifier.h>
-#include <linux/interrupt.h>
-
-struct nf_conntrack_ecache {
-       struct nf_conn *ct;
-       unsigned int events;
-};
-DECLARE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache);
-
-#define CONNTRACK_ECACHE(x)    (__get_cpu_var(nf_conntrack_ecache).x)
+/* no helper, no nat */
+#define        NF_CT_F_BASIC   0
+/* for helper */
+#define        NF_CT_F_HELP    1
+/* for nat. */
+#define        NF_CT_F_NAT     2
+#define NF_CT_F_NUM    4
 
-extern struct notifier_block *nf_conntrack_chain;
-extern struct notifier_block *nf_conntrack_expect_chain;
+extern int
+nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size);
+extern void
+nf_conntrack_unregister_cache(u_int32_t features);
 
-static inline int nf_conntrack_register_notifier(struct notifier_block *nb)
+/* valid combinations:
+ * basic: nf_conn, nf_conn .. nf_conn_help
+ * nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat .. nf_conn help
+ */
+#ifdef CONFIG_NF_NAT_NEEDED
+static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
 {
-       return notifier_chain_register(&nf_conntrack_chain, nb);
-}
+       unsigned int offset = sizeof(struct nf_conn);
 
-static inline int nf_conntrack_unregister_notifier(struct notifier_block *nb)
-{
-       return notifier_chain_unregister(&nf_conntrack_chain, nb);
-}
+       if (!(ct->features & NF_CT_F_NAT))
+               return NULL;
 
-static inline int
-nf_conntrack_expect_register_notifier(struct notifier_block *nb)
-{
-       return notifier_chain_register(&nf_conntrack_expect_chain, nb);
+       offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
+       return (struct nf_conn_nat *) ((void *)ct + offset);
 }
 
-static inline int
-nf_conntrack_expect_unregister_notifier(struct notifier_block *nb)
+static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
 {
-       return notifier_chain_unregister(&nf_conntrack_expect_chain, nb);
-}
+       unsigned int offset = sizeof(struct nf_conn);
 
-extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
-extern void __nf_ct_event_cache_init(struct nf_conn *ct);
+       if (!(ct->features & NF_CT_F_HELP))
+               return NULL;
+       if (ct->features & NF_CT_F_NAT) {
+               offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
+               offset += sizeof(struct nf_conn_nat);
+       }
 
-static inline void
-nf_conntrack_event_cache(enum ip_conntrack_events event,
-                        const struct sk_buff *skb)
-{
-       struct nf_conn *ct = (struct nf_conn *)skb->nfct;
-       struct nf_conntrack_ecache *ecache;
-
-       local_bh_disable();
-       ecache = &__get_cpu_var(nf_conntrack_ecache);
-       if (ct != ecache->ct)
-               __nf_ct_event_cache_init(ct);
-       ecache->events |= event;
-       local_bh_enable();
+       offset = ALIGN(offset, __alignof__(struct nf_conn_help));
+       return (struct nf_conn_help *) ((void *)ct + offset);
 }
-
-static inline void nf_conntrack_event(enum ip_conntrack_events event,
-                                     struct nf_conn *ct)
+#else /* No NAT */
+static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
 {
-       if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))
-               notifier_call_chain(&nf_conntrack_chain, event, ct);
-}
+       unsigned int offset = sizeof(struct nf_conn);
 
-static inline void
-nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
-                         struct nf_conntrack_expect *exp)
-{
-       notifier_call_chain(&nf_conntrack_expect_chain, event, exp);
-}
-#else /* CONFIG_NF_CONNTRACK_EVENTS */
-static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
-                                           const struct sk_buff *skb) {}
-static inline void nf_conntrack_event(enum ip_conntrack_events event,
-                                     struct nf_conn *ct) {}
-static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
-static inline void
-nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
-                         struct nf_conntrack_expect *exp) {}
-#endif /* CONFIG_NF_CONNTRACK_EVENTS */
-
-/* no helper, no nat */
-#define        NF_CT_F_BASIC   0
-/* for helper */
-#define        NF_CT_F_HELP    1
-/* for nat. */
-#define        NF_CT_F_NAT     2
-#define NF_CT_F_NUM    4
-
-extern int
-nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size,
-                           int (*init_conntrack)(struct nf_conn *, u_int32_t));
-extern void
-nf_conntrack_unregister_cache(u_int32_t features);
+       if (!(ct->features & NF_CT_F_HELP))
+               return NULL;
 
+       offset = ALIGN(offset, __alignof__(struct nf_conn_help));
+       return (struct nf_conn_help *) ((void *)ct + offset);
+}
+#endif /* CONFIG_NF_NAT_NEEDED */
 #endif /* __KERNEL__ */
 #endif /* _NF_CONNTRACK_H */