diff options
author | Patrick McHardy <kaber@trash.net> | 2006-09-20 15:05:37 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 18:20:01 -0400 |
commit | 9fa492cdc160cd27ce1046cb36f47d3b2b1efa21 (patch) | |
tree | 6ecb2a92a87523af2a1f7236f0bca456ca0677f3 /include/linux | |
parent | 79030ed07de673e8451a03aecb9ada9f4d75d491 (diff) |
[NETFILTER]: x_tables: simplify compat API
Split the xt_compat_match/xt_compat_target into smaller type-safe functions
performing just one operation. Handle all alignment and size-related
conversions centrally in these function instead of requiring each module to
implement a full-blown conversion function. Replace ->compat callback by
->compat_from_user and ->compat_to_user callbacks, responsible for
converting just a single private structure.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/netfilter/x_tables.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index c832295dbf61..739a98eebe2c 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h | |||
@@ -138,12 +138,6 @@ struct xt_counters_info | |||
138 | 138 | ||
139 | #include <linux/netdevice.h> | 139 | #include <linux/netdevice.h> |
140 | 140 | ||
141 | #ifdef CONFIG_COMPAT | ||
142 | #define COMPAT_TO_USER 1 | ||
143 | #define COMPAT_FROM_USER -1 | ||
144 | #define COMPAT_CALC_SIZE 0 | ||
145 | #endif | ||
146 | |||
147 | struct xt_match | 141 | struct xt_match |
148 | { | 142 | { |
149 | struct list_head list; | 143 | struct list_head list; |
@@ -176,7 +170,8 @@ struct xt_match | |||
176 | void (*destroy)(const struct xt_match *match, void *matchinfo); | 170 | void (*destroy)(const struct xt_match *match, void *matchinfo); |
177 | 171 | ||
178 | /* Called when userspace align differs from kernel space one */ | 172 | /* Called when userspace align differs from kernel space one */ |
179 | int (*compat)(void *match, void **dstptr, int *size, int convert); | 173 | void (*compat_from_user)(void *dst, void *src); |
174 | int (*compat_to_user)(void __user *dst, void *src); | ||
180 | 175 | ||
181 | /* Set this to THIS_MODULE if you are a module, otherwise NULL */ | 176 | /* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
182 | struct module *me; | 177 | struct module *me; |
@@ -186,6 +181,7 @@ struct xt_match | |||
186 | 181 | ||
187 | char *table; | 182 | char *table; |
188 | unsigned int matchsize; | 183 | unsigned int matchsize; |
184 | unsigned int compatsize; | ||
189 | unsigned int hooks; | 185 | unsigned int hooks; |
190 | unsigned short proto; | 186 | unsigned short proto; |
191 | 187 | ||
@@ -224,13 +220,15 @@ struct xt_target | |||
224 | void (*destroy)(const struct xt_target *target, void *targinfo); | 220 | void (*destroy)(const struct xt_target *target, void *targinfo); |
225 | 221 | ||
226 | /* Called when userspace align differs from kernel space one */ | 222 | /* Called when userspace align differs from kernel space one */ |
227 | int (*compat)(void *target, void **dstptr, int *size, int convert); | 223 | void (*compat_from_user)(void *dst, void *src); |
224 | int (*compat_to_user)(void __user *dst, void *src); | ||
228 | 225 | ||
229 | /* Set this to THIS_MODULE if you are a module, otherwise NULL */ | 226 | /* Set this to THIS_MODULE if you are a module, otherwise NULL */ |
230 | struct module *me; | 227 | struct module *me; |
231 | 228 | ||
232 | char *table; | 229 | char *table; |
233 | unsigned int targetsize; | 230 | unsigned int targetsize; |
231 | unsigned int compatsize; | ||
234 | unsigned int hooks; | 232 | unsigned int hooks; |
235 | unsigned short proto; | 233 | unsigned short proto; |
236 | 234 | ||
@@ -387,9 +385,18 @@ struct compat_xt_counters_info | |||
387 | 385 | ||
388 | extern void xt_compat_lock(int af); | 386 | extern void xt_compat_lock(int af); |
389 | extern void xt_compat_unlock(int af); | 387 | extern void xt_compat_unlock(int af); |
390 | extern int xt_compat_match(void *match, void **dstptr, int *size, int convert); | 388 | |
391 | extern int xt_compat_target(void *target, void **dstptr, int *size, | 389 | extern int xt_compat_match_offset(struct xt_match *match); |
392 | int convert); | 390 | extern void xt_compat_match_from_user(struct xt_entry_match *m, |
391 | void **dstptr, int *size); | ||
392 | extern int xt_compat_match_to_user(struct xt_entry_match *m, | ||
393 | void * __user *dstptr, int *size); | ||
394 | |||
395 | extern int xt_compat_target_offset(struct xt_target *target); | ||
396 | extern void xt_compat_target_from_user(struct xt_entry_target *t, | ||
397 | void **dstptr, int *size); | ||
398 | extern int xt_compat_target_to_user(struct xt_entry_target *t, | ||
399 | void * __user *dstptr, int *size); | ||
393 | 400 | ||
394 | #endif /* CONFIG_COMPAT */ | 401 | #endif /* CONFIG_COMPAT */ |
395 | #endif /* __KERNEL__ */ | 402 | #endif /* __KERNEL__ */ |