summaryrefslogtreecommitdiffstats
path: root/net/ipv4/netfilter/arp_tables.c
diff options
context:
space:
mode:
authorJan Engelhardt2009-07-09 23:00:19 +0200
committerJan Engelhardt2009-08-10 13:35:27 +0200
commit47901dc2c4a3f1f9af453486a005d31fe9b393f0 (patch)
tree12bcbe4b7add3cc9beff300165ac4d962015ad15 /net/ipv4/netfilter/arp_tables.c
parentnetfilter: iptables: remove unused datalen variable (diff)
downloadkernel-qcow2-linux-47901dc2c4a3f1f9af453486a005d31fe9b393f0.tar.gz
kernel-qcow2-linux-47901dc2c4a3f1f9af453486a005d31fe9b393f0.tar.xz
kernel-qcow2-linux-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/arp_tables.c')
-rw-r--r--net/ipv4/netfilter/arp_tables.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 7505dff4ffdf..b9f7243f4220 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -341,15 +341,11 @@ unsigned int arpt_do_table(struct sk_buff *skb,
}
/* All zeroes == unconditional rule. */
-static inline int unconditional(const struct arpt_arp *arp)
+static inline bool unconditional(const struct arpt_arp *arp)
{
- unsigned int i;
-
- for (i = 0; i < sizeof(*arp)/sizeof(__u32); i++)
- if (((__u32 *)arp)[i])
- return 0;
+ static const struct arpt_arp uncond;
- return 1;
+ return memcmp(arp, &uncond, sizeof(uncond)) == 0;
}
/* Figures out from what hook each rule can be called: returns 0 if