aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/netfilter/ip_tables.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2009-07-09 23:00:19 +0200
committerJan Engelhardt <jengelh@medozas.de>2009-08-10 13:35:27 +0200
commit47901dc2c4a3f1f9af453486a005d31fe9b393f0 (patch)
tree12bcbe4b7add3cc9beff300165ac4d962015ad15 /net/ipv4/netfilter/ip_tables.c
parente5afbba1869a5d9509c61f8962be9bdebf95f7d3 (diff)
downloadmrst-s0i3-test-47901dc2c4a3f1f9af453486a005d31fe9b393f0.tar.gz
mrst-s0i3-test-47901dc2c4a3f1f9af453486a005d31fe9b393f0.tar.xz
mrst-s0i3-test-47901dc2c4a3f1f9af453486a005d31fe9b393f0.zip
netfilter: xtables: use memcmp in unconditional check
Instead of inspecting each u32/char open-coded, clean up and make use of memcmp. On some arches, memcmp is implemented as assembly or GCC's __builtin_memcmp which can possibly take advantages of known alignment. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'net/ipv4/netfilter/ip_tables.c')
-rw-r--r--net/ipv4/netfilter/ip_tables.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 3856aa3f231..3431a771ff1 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -190,16 +190,11 @@ get_entry(void *base, unsigned int offset)
/* All zeroes == unconditional rule. */
/* Mildly perf critical (only if packet tracing is on) */
-static inline int
-unconditional(const struct ipt_ip *ip)
+static inline bool unconditional(const struct ipt_ip *ip)
{
- unsigned int i;
+ static const struct ipt_ip uncond;
- for (i = 0; i < sizeof(*ip)/sizeof(__u32); i++)
- if (((__u32 *)ip)[i])
- return 0;
-
- return 1;
+ return memcmp(ip, &uncond, sizeof(uncond)) == 0;
#undef FWINV
}