Commit a9dcd00e authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] netfilter: fix return values of ipt_recent checkentry

Peejix's nfsim test for ipt_recent, written two days ago, revealed this bugs
with ipt_recent: checkentry() returns true or false, not an error.  (Maybe it
should, but that's a much larger change).  Also, make hash_func() static.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0e4e73f8
...@@ -107,7 +107,7 @@ match(const struct sk_buff *skb, ...@@ -107,7 +107,7 @@ match(const struct sk_buff *skb,
int *hotdrop); int *hotdrop);
/* Function to hash a given address into the hash table of table_size size */ /* 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; int result = 0;
unsigned int value = addr; unsigned int value = addr;
...@@ -713,7 +713,7 @@ checkentry(const char *tablename, ...@@ -713,7 +713,7 @@ checkentry(const char *tablename,
#endif #endif
curr_table = vmalloc(sizeof(struct recent_ip_tables)); curr_table = vmalloc(sizeof(struct recent_ip_tables));
if(curr_table == NULL) return -ENOMEM; if(curr_table == NULL) return 0;
spin_lock_init(&curr_table->list_lock); spin_lock_init(&curr_table->list_lock);
curr_table->next = NULL; curr_table->next = NULL;
...@@ -730,7 +730,7 @@ checkentry(const char *tablename, ...@@ -730,7 +730,7 @@ checkentry(const char *tablename,
#endif #endif
curr_table->table = vmalloc(sizeof(struct recent_ip_list)*ip_list_tot); 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); memset(curr_table->table,0,sizeof(struct recent_ip_list)*ip_list_tot);
#ifdef DEBUG #ifdef DEBUG
if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for pkt_list.\n", if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for pkt_list.\n",
...@@ -745,7 +745,7 @@ checkentry(const char *tablename, ...@@ -745,7 +745,7 @@ checkentry(const char *tablename,
printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for pkt_list.\n"); printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for pkt_list.\n");
vfree(curr_table->table); vfree(curr_table->table);
vfree(curr_table); vfree(curr_table);
return -ENOMEM; return 0;
} }
for(c = 0; c < ip_list_tot; c++) { for(c = 0; c < ip_list_tot; c++) {
curr_table->table[c].last_pkts = hold + c*ip_pkt_list_tot; curr_table->table[c].last_pkts = hold + c*ip_pkt_list_tot;
...@@ -763,7 +763,7 @@ checkentry(const char *tablename, ...@@ -763,7 +763,7 @@ checkentry(const char *tablename,
vfree(hold); vfree(hold);
vfree(curr_table->table); vfree(curr_table->table);
vfree(curr_table); vfree(curr_table);
return -ENOMEM; return 0;
} }
for(c = 0; c < ip_list_hash_size; c++) { for(c = 0; c < ip_list_hash_size; c++) {
...@@ -783,7 +783,7 @@ checkentry(const char *tablename, ...@@ -783,7 +783,7 @@ checkentry(const char *tablename,
vfree(hold); vfree(hold);
vfree(curr_table->table); vfree(curr_table->table);
vfree(curr_table); vfree(curr_table);
return -ENOMEM; return 0;
} }
for(c = 0; c < ip_list_tot; c++) { for(c = 0; c < ip_list_tot; c++) {
curr_table->time_info[c].position = c; curr_table->time_info[c].position = c;
...@@ -827,7 +827,7 @@ checkentry(const char *tablename, ...@@ -827,7 +827,7 @@ checkentry(const char *tablename,
if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, no tables.\n"); if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, no tables.\n");
#endif #endif
spin_unlock_bh(&recent_lock); 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) ); while( strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (last_table = curr_table) && (curr_table = curr_table->next) );
if(!curr_table) { if(!curr_table) {
...@@ -835,7 +835,7 @@ checkentry(const char *tablename, ...@@ -835,7 +835,7 @@ checkentry(const char *tablename,
if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, table already destroyed.\n"); if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, table already destroyed.\n");
#endif #endif
spin_unlock_bh(&recent_lock); spin_unlock_bh(&recent_lock);
return -ENOMEM; return 0;
} }
if(last_table) last_table->next = curr_table->next; else r_tables = curr_table->next; if(last_table) last_table->next = curr_table->next; else r_tables = curr_table->next;
spin_unlock_bh(&recent_lock); spin_unlock_bh(&recent_lock);
...@@ -844,7 +844,7 @@ checkentry(const char *tablename, ...@@ -844,7 +844,7 @@ checkentry(const char *tablename,
vfree(hold); vfree(hold);
vfree(curr_table->table); vfree(curr_table->table);
vfree(curr_table); vfree(curr_table);
return -ENOMEM; return 0;
} }
curr_table->status_proc->owner = THIS_MODULE; curr_table->status_proc->owner = THIS_MODULE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment