X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fipv4%2Fnetfilter%2Fipt_recent.c;h=25ab9fabdcba3d66cb4bbf015514b6d671e6ed8f;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=15472b3e9e563b9c569fc6d5e52f448323266190;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c index 15472b3e9..25ab9fabd 100644 --- a/net/ipv4/netfilter/ipt_recent.c +++ b/net/ipv4/netfilter/ipt_recent.c @@ -90,7 +90,7 @@ static struct recent_ip_tables *r_tables = NULL; /* We protect r_list with this spinlock so two processors are not modifying * the list at the same time. */ -static spinlock_t recent_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(recent_lock); #ifdef CONFIG_PROC_FS /* Our /proc/net/ipt_recent entry */ @@ -107,7 +107,7 @@ match(const struct sk_buff *skb, int *hotdrop); /* Function to hash a given address into the hash table of table_size size */ -int hash_func(unsigned int addr, int table_size) +static int hash_func(unsigned int addr, int table_size) { int result = 0; unsigned int value = addr; @@ -713,9 +713,9 @@ checkentry(const char *tablename, #endif curr_table = vmalloc(sizeof(struct recent_ip_tables)); - if(curr_table == NULL) return -ENOMEM; + if(curr_table == NULL) return 0; - curr_table->list_lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&curr_table->list_lock); curr_table->next = NULL; curr_table->count = 1; curr_table->time_pos = 0; @@ -730,7 +730,7 @@ checkentry(const char *tablename, #endif curr_table->table = vmalloc(sizeof(struct recent_ip_list)*ip_list_tot); - if(curr_table->table == NULL) { vfree(curr_table); return -ENOMEM; } + if(curr_table->table == NULL) { vfree(curr_table); return 0; } memset(curr_table->table,0,sizeof(struct recent_ip_list)*ip_list_tot); #ifdef DEBUG if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for pkt_list.\n", @@ -745,7 +745,7 @@ checkentry(const char *tablename, printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for pkt_list.\n"); vfree(curr_table->table); vfree(curr_table); - return -ENOMEM; + return 0; } for(c = 0; c < ip_list_tot; c++) { curr_table->table[c].last_pkts = hold + c*ip_pkt_list_tot; @@ -763,7 +763,7 @@ checkentry(const char *tablename, vfree(hold); vfree(curr_table->table); vfree(curr_table); - return -ENOMEM; + return 0; } for(c = 0; c < ip_list_hash_size; c++) { @@ -783,7 +783,7 @@ checkentry(const char *tablename, vfree(hold); vfree(curr_table->table); vfree(curr_table); - return -ENOMEM; + return 0; } for(c = 0; c < ip_list_tot; c++) { curr_table->time_info[c].position = c; @@ -827,7 +827,7 @@ checkentry(const char *tablename, if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, no tables.\n"); #endif spin_unlock_bh(&recent_lock); - return -ENOMEM; + return 0; } while( strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (last_table = curr_table) && (curr_table = curr_table->next) ); if(!curr_table) { @@ -835,7 +835,7 @@ checkentry(const char *tablename, if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, table already destroyed.\n"); #endif spin_unlock_bh(&recent_lock); - return -ENOMEM; + return 0; } if(last_table) last_table->next = curr_table->next; else r_tables = curr_table->next; spin_unlock_bh(&recent_lock); @@ -844,7 +844,7 @@ checkentry(const char *tablename, vfree(hold); vfree(curr_table->table); vfree(curr_table); - return -ENOMEM; + return 0; } curr_table->status_proc->owner = THIS_MODULE; @@ -959,7 +959,7 @@ static struct ipt_match recent_match = { /* Kernel module initialization. */ static int __init init(void) { - int count; + int err, count; printk(version); #ifdef CONFIG_PROC_FS @@ -983,7 +983,10 @@ static int __init init(void) if(debug) printk(KERN_INFO RECENT_NAME ": ip_list_hash_size: %d\n",ip_list_hash_size); #endif - return ipt_register_match(&recent_match); + err = ipt_register_match(&recent_match); + if (err) + remove_proc_entry("ipt_recent", proc_net); + return err; } /* Kernel module destruction. */