aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2010-02-24 12:34:48 -0500
committerPatrick McHardy <kaber@trash.net>2010-02-24 12:34:48 -0500
commitdcea992aca82cb08b4674c4c783e325835408d1e (patch)
treeb3490bbbf49931f1405a7ebeb2f2f9d2b136cd9a /include
parent0559518b5b99c591226460c0bbf8e6a570c518a8 (diff)
netfilter: xtables: replace XT_MATCH_ITERATE macro
The macro is replaced by a list.h-like foreach loop. This makes the code 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.h10
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h6
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h6
3 files changed, 11 insertions, 11 deletions
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 9df3f5a8f9f7..84c7c928e9eb 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -120,6 +120,7 @@ struct xt_counters_info {
120 120
121#define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */ 121#define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */
122 122
123#ifndef __KERNEL__
123/* fn returns 0 to continue iteration */ 124/* fn returns 0 to continue iteration */
124#define XT_MATCH_ITERATE(type, e, fn, args...) \ 125#define XT_MATCH_ITERATE(type, e, fn, args...) \
125({ \ 126({ \
@@ -139,7 +140,6 @@ struct xt_counters_info {
139 __ret; \ 140 __ret; \
140}) 141})
141 142
142#ifndef __KERNEL__
143/* fn returns 0 to continue iteration */ 143/* fn returns 0 to continue iteration */
144#define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \ 144#define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \
145({ \ 145({ \
@@ -172,6 +172,14 @@ struct xt_counters_info {
172 (pos) < (typeof(pos))((char *)(ehead) + (esize)); \ 172 (pos) < (typeof(pos))((char *)(ehead) + (esize)); \
173 (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset)) 173 (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset))
174 174
175/* can only be xt_entry_match, so no use of typeof here */
176#define xt_ematch_foreach(pos, entry) \
177 for ((pos) = (struct xt_entry_match *)entry->elems; \
178 (pos) < (struct xt_entry_match *)((char *)(entry) + \
179 (entry)->target_offset); \
180 (pos) = (struct xt_entry_match *)((char *)(pos) + \
181 (pos)->u.match_size))
182
175#ifdef __KERNEL__ 183#ifdef __KERNEL__
176 184
177#include <linux/netdevice.h> 185#include <linux/netdevice.h>
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index 5b20ae724b41..704a7b6e8169 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -223,11 +223,11 @@ ipt_get_target(struct ipt_entry *e)
223 return (void *)e + e->target_offset; 223 return (void *)e + e->target_offset;
224} 224}
225 225
226#ifndef __KERNEL__
226/* fn returns 0 to continue iteration */ 227/* fn returns 0 to continue iteration */
227#define IPT_MATCH_ITERATE(e, fn, args...) \ 228#define IPT_MATCH_ITERATE(e, fn, args...) \
228 XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args) 229 XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args)
229 230
230#ifndef __KERNEL__
231/* fn returns 0 to continue iteration */ 231/* fn returns 0 to continue iteration */
232#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \ 232#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \
233 XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args) 233 XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args)
@@ -315,10 +315,6 @@ compat_ipt_get_target(struct compat_ipt_entry *e)
315 315
316#define COMPAT_IPT_ALIGN(s) COMPAT_XT_ALIGN(s) 316#define COMPAT_IPT_ALIGN(s) COMPAT_XT_ALIGN(s)
317 317
318/* fn returns 0 to continue iteration */
319#define COMPAT_IPT_MATCH_ITERATE(e, fn, args...) \
320 XT_MATCH_ITERATE(struct compat_ipt_entry, e, fn, ## args)
321
322#endif /* CONFIG_COMPAT */ 318#endif /* CONFIG_COMPAT */
323#endif /*__KERNEL__*/ 319#endif /*__KERNEL__*/
324#endif /* _IPTABLES_H */ 320#endif /* _IPTABLES_H */
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 8bb3f5ba5ff2..e5ba03d783c6 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -280,11 +280,11 @@ ip6t_get_target(struct ip6t_entry *e)
280 return (void *)e + e->target_offset; 280 return (void *)e + e->target_offset;
281} 281}
282 282
283#ifndef __KERNEL__
283/* fn returns 0 to continue iteration */ 284/* fn returns 0 to continue iteration */
284#define IP6T_MATCH_ITERATE(e, fn, args...) \ 285#define IP6T_MATCH_ITERATE(e, fn, args...) \
285 XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args) 286 XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args)
286 287
287#ifndef __KERNEL__
288/* fn returns 0 to continue iteration */ 288/* fn returns 0 to continue iteration */
289#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ 289#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \
290 XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args) 290 XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args)
@@ -343,10 +343,6 @@ compat_ip6t_get_target(struct compat_ip6t_entry *e)
343 343
344#define COMPAT_IP6T_ALIGN(s) COMPAT_XT_ALIGN(s) 344#define COMPAT_IP6T_ALIGN(s) COMPAT_XT_ALIGN(s)
345 345
346/* fn returns 0 to continue iteration */
347#define COMPAT_IP6T_MATCH_ITERATE(e, fn, args...) \
348 XT_MATCH_ITERATE(struct compat_ip6t_entry, e, fn, ## args)
349
350#endif /* CONFIG_COMPAT */ 346#endif /* CONFIG_COMPAT */
351#endif /*__KERNEL__*/ 347#endif /*__KERNEL__*/
352#endif /* _IP6_TABLES_H */ 348#endif /* _IP6_TABLES_H */