diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2010-02-24 12:32:59 -0500 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-02-24 12:32:59 -0500 |
commit | 72b2b1dd77e8feb0b7c0b26dee58f2a1e2c9828c (patch) | |
tree | 4289fef5441a1664f60a17cb473d657f77cf1112 /include | |
parent | 8ccb92ad41cb311e52ad1b1fe77992c7f47a3b63 (diff) |
netfilter: xtables: replace XT_ENTRY_ITERATE macro
The macro is replaced by a list.h-like foreach loop. This makes
the code much more inspectable.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netfilter/x_tables.h | 9 | ||||
-rw-r--r-- | include/linux/netfilter_arp/arp_tables.h | 10 | ||||
-rw-r--r-- | include/linux/netfilter_ipv4/ip_tables.h | 11 | ||||
-rw-r--r-- | include/linux/netfilter_ipv6/ip6_tables.h | 10 |
4 files changed, 15 insertions, 25 deletions
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index a18119fb88f0..9df3f5a8f9f7 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h | |||
@@ -139,6 +139,7 @@ struct xt_counters_info { | |||
139 | __ret; \ | 139 | __ret; \ |
140 | }) | 140 | }) |
141 | 141 | ||
142 | #ifndef __KERNEL__ | ||
142 | /* fn returns 0 to continue iteration */ | 143 | /* fn returns 0 to continue iteration */ |
143 | #define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \ | 144 | #define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \ |
144 | ({ \ | 145 | ({ \ |
@@ -163,6 +164,14 @@ struct xt_counters_info { | |||
163 | #define XT_ENTRY_ITERATE(type, entries, size, fn, args...) \ | 164 | #define XT_ENTRY_ITERATE(type, entries, size, fn, args...) \ |
164 | XT_ENTRY_ITERATE_CONTINUE(type, entries, size, 0, fn, args) | 165 | XT_ENTRY_ITERATE_CONTINUE(type, entries, size, 0, fn, args) |
165 | 166 | ||
167 | #endif /* !__KERNEL__ */ | ||
168 | |||
169 | /* pos is normally a struct ipt_entry/ip6t_entry/etc. */ | ||
170 | #define xt_entry_foreach(pos, ehead, esize) \ | ||
171 | for ((pos) = (typeof(pos))(ehead); \ | ||
172 | (pos) < (typeof(pos))((char *)(ehead) + (esize)); \ | ||
173 | (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset)) | ||
174 | |||
166 | #ifdef __KERNEL__ | 175 | #ifdef __KERNEL__ |
167 | 176 | ||
168 | #include <linux/netdevice.h> | 177 | #include <linux/netdevice.h> |
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h index 0b33980611b2..e9948c0560f6 100644 --- a/include/linux/netfilter_arp/arp_tables.h +++ b/include/linux/netfilter_arp/arp_tables.h | |||
@@ -211,9 +211,11 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e | |||
211 | return (void *)e + e->target_offset; | 211 | return (void *)e + e->target_offset; |
212 | } | 212 | } |
213 | 213 | ||
214 | #ifndef __KERNEL__ | ||
214 | /* fn returns 0 to continue iteration */ | 215 | /* fn returns 0 to continue iteration */ |
215 | #define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ | 216 | #define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ |
216 | XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args) | 217 | XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args) |
218 | #endif | ||
217 | 219 | ||
218 | /* | 220 | /* |
219 | * Main firewall chains definitions and global var's definitions. | 221 | * Main firewall chains definitions and global var's definitions. |
@@ -291,14 +293,6 @@ compat_arpt_get_target(struct compat_arpt_entry *e) | |||
291 | 293 | ||
292 | #define COMPAT_ARPT_ALIGN(s) COMPAT_XT_ALIGN(s) | 294 | #define COMPAT_ARPT_ALIGN(s) COMPAT_XT_ALIGN(s) |
293 | 295 | ||
294 | /* fn returns 0 to continue iteration */ | ||
295 | #define COMPAT_ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
296 | XT_ENTRY_ITERATE(struct compat_arpt_entry, entries, size, fn, ## args) | ||
297 | |||
298 | #define COMPAT_ARPT_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \ | ||
299 | XT_ENTRY_ITERATE_CONTINUE(struct compat_arpt_entry, entries, size, n, \ | ||
300 | fn, ## args) | ||
301 | |||
302 | #endif /* CONFIG_COMPAT */ | 296 | #endif /* CONFIG_COMPAT */ |
303 | #endif /*__KERNEL__*/ | 297 | #endif /*__KERNEL__*/ |
304 | #endif /* _ARPTABLES_H */ | 298 | #endif /* _ARPTABLES_H */ |
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h index 364973b42133..5b20ae724b41 100644 --- a/include/linux/netfilter_ipv4/ip_tables.h +++ b/include/linux/netfilter_ipv4/ip_tables.h | |||
@@ -227,9 +227,11 @@ ipt_get_target(struct ipt_entry *e) | |||
227 | #define IPT_MATCH_ITERATE(e, fn, args...) \ | 227 | #define IPT_MATCH_ITERATE(e, fn, args...) \ |
228 | XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args) | 228 | XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args) |
229 | 229 | ||
230 | #ifndef __KERNEL__ | ||
230 | /* fn returns 0 to continue iteration */ | 231 | /* fn returns 0 to continue iteration */ |
231 | #define IPT_ENTRY_ITERATE(entries, size, fn, args...) \ | 232 | #define IPT_ENTRY_ITERATE(entries, size, fn, args...) \ |
232 | XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args) | 233 | XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args) |
234 | #endif | ||
233 | 235 | ||
234 | /* | 236 | /* |
235 | * Main firewall chains definitions and global var's definitions. | 237 | * Main firewall chains definitions and global var's definitions. |
@@ -317,15 +319,6 @@ compat_ipt_get_target(struct compat_ipt_entry *e) | |||
317 | #define COMPAT_IPT_MATCH_ITERATE(e, fn, args...) \ | 319 | #define COMPAT_IPT_MATCH_ITERATE(e, fn, args...) \ |
318 | XT_MATCH_ITERATE(struct compat_ipt_entry, e, fn, ## args) | 320 | XT_MATCH_ITERATE(struct compat_ipt_entry, e, fn, ## args) |
319 | 321 | ||
320 | /* fn returns 0 to continue iteration */ | ||
321 | #define COMPAT_IPT_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
322 | XT_ENTRY_ITERATE(struct compat_ipt_entry, entries, size, fn, ## args) | ||
323 | |||
324 | /* fn returns 0 to continue iteration */ | ||
325 | #define COMPAT_IPT_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \ | ||
326 | XT_ENTRY_ITERATE_CONTINUE(struct compat_ipt_entry, entries, size, n, \ | ||
327 | fn, ## args) | ||
328 | |||
329 | #endif /* CONFIG_COMPAT */ | 322 | #endif /* CONFIG_COMPAT */ |
330 | #endif /*__KERNEL__*/ | 323 | #endif /*__KERNEL__*/ |
331 | #endif /* _IPTABLES_H */ | 324 | #endif /* _IPTABLES_H */ |
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h index 8031eb486a10..8bb3f5ba5ff2 100644 --- a/include/linux/netfilter_ipv6/ip6_tables.h +++ b/include/linux/netfilter_ipv6/ip6_tables.h | |||
@@ -284,9 +284,11 @@ ip6t_get_target(struct ip6t_entry *e) | |||
284 | #define IP6T_MATCH_ITERATE(e, fn, args...) \ | 284 | #define IP6T_MATCH_ITERATE(e, fn, args...) \ |
285 | XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args) | 285 | XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args) |
286 | 286 | ||
287 | #ifndef __KERNEL__ | ||
287 | /* fn returns 0 to continue iteration */ | 288 | /* fn returns 0 to continue iteration */ |
288 | #define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ | 289 | #define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ |
289 | XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args) | 290 | XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args) |
291 | #endif | ||
290 | 292 | ||
291 | /* | 293 | /* |
292 | * Main firewall chains definitions and global var's definitions. | 294 | * Main firewall chains definitions and global var's definitions. |
@@ -345,14 +347,6 @@ compat_ip6t_get_target(struct compat_ip6t_entry *e) | |||
345 | #define COMPAT_IP6T_MATCH_ITERATE(e, fn, args...) \ | 347 | #define COMPAT_IP6T_MATCH_ITERATE(e, fn, args...) \ |
346 | XT_MATCH_ITERATE(struct compat_ip6t_entry, e, fn, ## args) | 348 | XT_MATCH_ITERATE(struct compat_ip6t_entry, e, fn, ## args) |
347 | 349 | ||
348 | /* fn returns 0 to continue iteration */ | ||
349 | #define COMPAT_IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
350 | XT_ENTRY_ITERATE(struct compat_ip6t_entry, entries, size, fn, ## args) | ||
351 | |||
352 | #define COMPAT_IP6T_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \ | ||
353 | XT_ENTRY_ITERATE_CONTINUE(struct compat_ip6t_entry, entries, size, n, \ | ||
354 | fn, ## args) | ||
355 | |||
356 | #endif /* CONFIG_COMPAT */ | 350 | #endif /* CONFIG_COMPAT */ |
357 | #endif /*__KERNEL__*/ | 351 | #endif /*__KERNEL__*/ |
358 | #endif /* _IP6_TABLES_H */ | 352 | #endif /* _IP6_TABLES_H */ |