diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2009-03-24 17:15:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-24 17:15:22 -0400 |
commit | 35c7f6de7339f40a591a8aeccacdc429b1953674 (patch) | |
tree | 0359631a2a13cb41daa545eee36450996f1a0c6b | |
parent | 8dd1d0471bcf634f2cd6a6cf4b6531bb61f0af47 (diff) |
arp_tables: ifname_compare() can assume 16bit alignment
Arches without efficient unaligned access can still perform a loop
assuming 16bit alignment in ifname_compare()
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/netfilter/arp_tables.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 64a7c6ce0b98..84b9c179df51 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c | |||
@@ -76,6 +76,7 @@ static inline int arp_devaddr_compare(const struct arpt_devaddr_info *ap, | |||
76 | /* | 76 | /* |
77 | * Unfortunatly, _b and _mask are not aligned to an int (or long int) | 77 | * Unfortunatly, _b and _mask are not aligned to an int (or long int) |
78 | * Some arches dont care, unrolling the loop is a win on them. | 78 | * Some arches dont care, unrolling the loop is a win on them. |
79 | * For other arches, we only have a 16bit alignement. | ||
79 | */ | 80 | */ |
80 | static unsigned long ifname_compare(const char *_a, const char *_b, const char *_mask) | 81 | static unsigned long ifname_compare(const char *_a, const char *_b, const char *_mask) |
81 | { | 82 | { |
@@ -95,10 +96,13 @@ static unsigned long ifname_compare(const char *_a, const char *_b, const char * | |||
95 | BUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long)); | 96 | BUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long)); |
96 | #else | 97 | #else |
97 | unsigned long ret = 0; | 98 | unsigned long ret = 0; |
99 | const u16 *a = (const u16 *)_a; | ||
100 | const u16 *b = (const u16 *)_b; | ||
101 | const u16 *mask = (const u16 *)_mask; | ||
98 | int i; | 102 | int i; |
99 | 103 | ||
100 | for (i = 0; i < IFNAMSIZ; i++) | 104 | for (i = 0; i < IFNAMSIZ/sizeof(u16); i++) |
101 | ret |= (_a[i] ^ _b[i]) & _mask[i]; | 105 | ret |= (a[i] ^ b[i]) & mask[i]; |
102 | #endif | 106 | #endif |
103 | return ret; | 107 | return ret; |
104 | } | 108 | } |