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>
This commit is contained in:
committed by
David S. Miller
parent
8dd1d0471b
commit
35c7f6de73
@@ -76,6 +76,7 @@ static inline int arp_devaddr_compare(const struct arpt_devaddr_info *ap,
|
|||||||
/*
|
/*
|
||||||
* Unfortunatly, _b and _mask are not aligned to an int (or long int)
|
* Unfortunatly, _b and _mask are not aligned to an int (or long int)
|
||||||
* Some arches dont care, unrolling the loop is a win on them.
|
* Some arches dont care, unrolling the loop is a win on them.
|
||||||
|
* For other arches, we only have a 16bit alignement.
|
||||||
*/
|
*/
|
||||||
static unsigned long ifname_compare(const char *_a, const char *_b, const char *_mask)
|
static unsigned long ifname_compare(const char *_a, const char *_b, const char *_mask)
|
||||||
{
|
{
|
||||||
@@ -95,10 +96,13 @@ static unsigned long ifname_compare(const char *_a, const char *_b, const char *
|
|||||||
BUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long));
|
BUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long));
|
||||||
#else
|
#else
|
||||||
unsigned long ret = 0;
|
unsigned long ret = 0;
|
||||||
|
const u16 *a = (const u16 *)_a;
|
||||||
|
const u16 *b = (const u16 *)_b;
|
||||||
|
const u16 *mask = (const u16 *)_mask;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < IFNAMSIZ; i++)
|
for (i = 0; i < IFNAMSIZ/sizeof(u16); i++)
|
||||||
ret |= (_a[i] ^ _b[i]) & _mask[i];
|
ret |= (a[i] ^ b[i]) & mask[i];
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user