X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fipv6%2Fnetfilter%2Fip6_tables.c;h=d2ce00d81d4c5d21864d4a7905b456a8c3cf582c;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=b8ef96fd32f9210b0bb283c4db8677b04614d0a2;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index b8ef96fd3..d2ce00d81 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -66,8 +66,6 @@ do { \ #endif #define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1)) -/* Mutex protects lists (only traversed in user context). */ -static DECLARE_MUTEX(ip6t_mutex); /* Must have mutex */ #define ASSERT_READ_LOCK(x) IP_NF_ASSERT(down_trylock(&ip6t_mutex) != 0) @@ -544,7 +542,7 @@ find_inlist_lock(struct list_head *head, #endif static inline struct ip6t_table * -find_table_lock(const char *name, int *error, struct semaphore *mutex) +ip6t_find_table_lock(const char *name, int *error, struct semaphore *mutex) { return find_inlist_lock(&ip6t_tables, name, "ip6table_", error, mutex); } @@ -555,8 +553,8 @@ find_match_lock(const char *name, int *error, struct semaphore *mutex) return find_inlist_lock(&ip6t_match, name, "ip6t_", error, mutex); } -static inline struct ip6t_target * -find_target_lock(const char *name, int *error, struct semaphore *mutex) +struct ip6t_target * +ip6t_find_target_lock(const char *name, int *error, struct semaphore *mutex) { return find_inlist_lock(&ip6t_target, name, "ip6t_", error, mutex); } @@ -771,7 +769,7 @@ check_entry(struct ip6t_entry *e, const char *name, unsigned int size, goto cleanup_matches; t = ip6t_get_target(e); - target = find_target_lock(t->u.user.name, &ret, &ip6t_mutex); + target = ip6t_find_target_lock(t->u.user.name, &ret, &ip6t_mutex); if (!target) { duprintf("check_entry: `%s' not found\n", t->u.user.name); goto cleanup_matches; @@ -1028,7 +1026,7 @@ get_counters(const struct ip6t_table_info *t, static int copy_entries_to_user(unsigned int total_size, struct ip6t_table *table, - void *userptr) + void __user *userptr) { unsigned int off, num, countersize; struct ip6t_entry *e; @@ -1106,12 +1104,12 @@ copy_entries_to_user(unsigned int total_size, static int get_entries(const struct ip6t_get_entries *entries, - struct ip6t_get_entries *uptr) + struct ip6t_get_entries __user *uptr) { int ret; struct ip6t_table *t; - t = find_table_lock(entries->name, &ret, &ip6t_mutex); + t = ip6t_find_table_lock(entries->name, &ret, &ip6t_mutex); if (t) { duprintf("t->private->number = %u\n", t->private->number); @@ -1133,7 +1131,7 @@ get_entries(const struct ip6t_get_entries *entries, } static int -do_replace(void *user, unsigned int len) +do_replace(void __user *user, unsigned int len) { int ret; struct ip6t_replace tmp; @@ -1174,7 +1172,7 @@ do_replace(void *user, unsigned int len) duprintf("ip_tables: Translated table\n"); - t = find_table_lock(tmp.name, &ret, &ip6t_mutex); + t = ip6t_find_table_lock(tmp.name, &ret, &ip6t_mutex); if (!t) goto free_newinfo_counters_untrans; @@ -1254,7 +1252,7 @@ add_counter_to_entry(struct ip6t_entry *e, } static int -do_add_counters(void *user, unsigned int len) +do_add_counters(void __user *user, unsigned int len) { unsigned int i; struct ip6t_counters_info tmp, *paddc; @@ -1276,7 +1274,7 @@ do_add_counters(void *user, unsigned int len) goto free; } - t = find_table_lock(tmp.name, &ret, &ip6t_mutex); + t = ip6t_find_table_lock(tmp.name, &ret, &ip6t_mutex); if (!t) goto free; @@ -1302,7 +1300,7 @@ do_add_counters(void *user, unsigned int len) } static int -do_ip6t_set_ctl(struct sock *sk, int cmd, void *user, unsigned int len) +do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) { int ret; @@ -1327,7 +1325,7 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void *user, unsigned int len) } static int -do_ip6t_get_ctl(struct sock *sk, int cmd, void *user, int *len) +do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) { int ret; @@ -1351,7 +1349,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void *user, int *len) break; } name[IP6T_TABLE_MAXNAMELEN-1] = '\0'; - t = find_table_lock(name, &ret, &ip6t_mutex); + t = ip6t_find_table_lock(name, &ret, &ip6t_mutex); if (t) { struct ip6t_getinfo info; @@ -1847,6 +1845,15 @@ static inline int print_name(const char *i, return 0; } +static inline int print_target(const struct ip6t_target *t, + off_t start_offset, char *buffer, int length, + off_t *pos, unsigned int *count) +{ + if (t == &ip6t_standard_target || t == &ip6t_error_target) + return 0; + return print_name((char *)t, start_offset, buffer, length, pos, count); +} + static int ip6t_get_tables(char *buffer, char **start, off_t offset, int length) { off_t pos = 0; @@ -1873,7 +1880,7 @@ static int ip6t_get_targets(char *buffer, char **start, off_t offset, int length if (down_interruptible(&ip6t_mutex) != 0) return 0; - LIST_FIND(&ip6t_target, print_name, char *, + LIST_FIND(&ip6t_target, print_target, struct ip6t_target *, offset, buffer, length, &pos, &count); up(&ip6t_mutex); @@ -1964,6 +1971,7 @@ static void __exit fini(void) EXPORT_SYMBOL(ip6t_register_table); EXPORT_SYMBOL(ip6t_unregister_table); EXPORT_SYMBOL(ip6t_do_table); +EXPORT_SYMBOL(ip6t_find_target_lock); EXPORT_SYMBOL(ip6t_register_match); EXPORT_SYMBOL(ip6t_unregister_match); EXPORT_SYMBOL(ip6t_register_target);