linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / netfilter / nfnetlink_log.c
index b59d3b2..47c1a8f 100644 (file)
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * 2006-01-26 Harald Welte <laforge@netfilter.org>
- *     - Add optional local and global sequence number to detect lost
- *       events from userspace
- *
  */
 #include <linux/module.h>
 #include <linux/skbuff.h>
@@ -72,14 +68,11 @@ struct nfulnl_instance {
        unsigned int nlbufsiz;          /* netlink buffer allocation size */
        unsigned int qthreshold;        /* threshold of the queue */
        u_int32_t copy_range;
-       u_int32_t seq;                  /* instance-local sequential counter */
        u_int16_t group_num;            /* number of this queue */
-       u_int16_t flags;
        u_int8_t copy_mode;     
 };
 
 static DEFINE_RWLOCK(instances_lock);
-static atomic_t global_seq;
 
 #define INSTANCE_BUCKETS       16
 static struct hlist_head instance_table[INSTANCE_BUCKETS];
@@ -317,16 +310,6 @@ nfulnl_set_qthresh(struct nfulnl_instance *inst, u_int32_t qthresh)
        return 0;
 }
 
-static int
-nfulnl_set_flags(struct nfulnl_instance *inst, u_int16_t flags)
-{
-       spin_lock_bh(&inst->lock);
-       inst->flags = flags;
-       spin_unlock_bh(&inst->lock);
-
-       return 0;
-}
-
 static struct sk_buff *nfulnl_alloc_skb(unsigned int inst_size, 
                                        unsigned int pkt_size)
 {
@@ -397,8 +380,6 @@ static void nfulnl_timer(unsigned long data)
        spin_unlock_bh(&inst->lock);
 }
 
-/* This is an inline function, we don't really care about a long
- * list of arguments */
 static inline int 
 __build_packet_message(struct nfulnl_instance *inst,
                        const struct sk_buff *skb, 
@@ -537,17 +518,6 @@ __build_packet_message(struct nfulnl_instance *inst,
                        read_unlock_bh(&skb->sk->sk_callback_lock);
        }
 
-       /* local sequence number */
-       if (inst->flags & NFULNL_CFG_F_SEQ) {
-               tmp_uint = htonl(inst->seq++);
-               NFA_PUT(inst->skb, NFULA_SEQ, sizeof(tmp_uint), &tmp_uint);
-       }
-       /* global sequence number */
-       if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) {
-               tmp_uint = atomic_inc_return(&global_seq);
-               NFA_PUT(inst->skb, NFULA_SEQ_GLOBAL, sizeof(tmp_uint), &tmp_uint);
-       }
-
        if (data_len) {
                struct nfattr *nfa;
                int size = NFA_LENGTH(data_len);
@@ -640,11 +610,6 @@ nfulnl_log_packet(unsigned int pf,
 
        spin_lock_bh(&inst->lock);
 
-       if (inst->flags & NFULNL_CFG_F_SEQ)
-               size += NFA_SPACE(sizeof(u_int32_t));
-       if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL)
-               size += NFA_SPACE(sizeof(u_int32_t));
-
        qthreshold = inst->qthreshold;
        /* per-rule qthreshold overrides per-instance */
        if (qthreshold > li->u.ulog.qthreshold)
@@ -774,14 +739,10 @@ static const int nfula_min[NFULA_MAX] = {
        [NFULA_TIMESTAMP-1]     = sizeof(struct nfulnl_msg_packet_timestamp),
        [NFULA_IFINDEX_INDEV-1] = sizeof(u_int32_t),
        [NFULA_IFINDEX_OUTDEV-1]= sizeof(u_int32_t),
-       [NFULA_IFINDEX_PHYSINDEV-1]     = sizeof(u_int32_t),
-       [NFULA_IFINDEX_PHYSOUTDEV-1]    = sizeof(u_int32_t),
        [NFULA_HWADDR-1]        = sizeof(struct nfulnl_msg_packet_hw),
        [NFULA_PAYLOAD-1]       = 0,
        [NFULA_PREFIX-1]        = 0,
        [NFULA_UID-1]           = sizeof(u_int32_t),
-       [NFULA_SEQ-1]           = sizeof(u_int32_t),
-       [NFULA_SEQ_GLOBAL-1]    = sizeof(u_int32_t),
 };
 
 static const int nfula_cfg_min[NFULA_CFG_MAX] = {
@@ -790,7 +751,6 @@ static const int nfula_cfg_min[NFULA_CFG_MAX] = {
        [NFULA_CFG_TIMEOUT-1]   = sizeof(u_int32_t),
        [NFULA_CFG_QTHRESH-1]   = sizeof(u_int32_t),
        [NFULA_CFG_NLBUFSIZ-1]  = sizeof(u_int32_t),
-       [NFULA_CFG_FLAGS-1]     = sizeof(u_int16_t),
 };
 
 static int
@@ -902,12 +862,6 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
                nfulnl_set_qthresh(inst, ntohl(qthresh));
        }
 
-       if (nfula[NFULA_CFG_FLAGS-1]) {
-               u_int16_t flags =
-                       *(u_int16_t *)NFA_DATA(nfula[NFULA_CFG_FLAGS-1]);
-               nfulnl_set_flags(inst, ntohs(flags));
-       }
-
 out_put:
        instance_put(inst);
        return ret;
@@ -1036,13 +990,17 @@ static struct file_operations nful_file_ops = {
 
 #endif /* PROC_FS */
 
-static int __init nfnetlink_log_init(void)
+static int
+init_or_cleanup(int init)
 {
        int i, status = -ENOMEM;
 #ifdef CONFIG_PROC_FS
        struct proc_dir_entry *proc_nful;
 #endif
        
+       if (!init)
+               goto cleanup;
+
        for (i = 0; i < INSTANCE_BUCKETS; i++)
                INIT_HLIST_HEAD(&instance_table[i]);
        
@@ -1065,25 +1023,30 @@ static int __init nfnetlink_log_init(void)
                goto cleanup_subsys;
        proc_nful->proc_fops = &nful_file_ops;
 #endif
+
        return status;
 
+cleanup:
+       nf_log_unregister_logger(&nfulnl_logger);
 #ifdef CONFIG_PROC_FS
+       remove_proc_entry("nfnetlink_log", proc_net_netfilter);
 cleanup_subsys:
-       nfnetlink_subsys_unregister(&nfulnl_subsys);
 #endif
+       nfnetlink_subsys_unregister(&nfulnl_subsys);
 cleanup_netlink_notifier:
        netlink_unregister_notifier(&nfulnl_rtnl_notifier);
        return status;
 }
 
-static void __exit nfnetlink_log_fini(void)
+static int __init init(void)
 {
-       nf_log_unregister_logger(&nfulnl_logger);
-#ifdef CONFIG_PROC_FS
-       remove_proc_entry("nfnetlink_log", proc_net_netfilter);
-#endif
-       nfnetlink_subsys_unregister(&nfulnl_subsys);
-       netlink_unregister_notifier(&nfulnl_rtnl_notifier);
+       
+       return init_or_cleanup(1);
+}
+
+static void __exit fini(void)
+{
+       init_or_cleanup(0);
 }
 
 MODULE_DESCRIPTION("netfilter userspace logging");
@@ -1091,5 +1054,5 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_ULOG);
 
-module_init(nfnetlink_log_init);
-module_exit(nfnetlink_log_fini);
+module_init(init);
+module_exit(fini);