aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2009-03-25 12:31:52 -0400
committerPatrick McHardy <kaber@trash.net>2009-03-25 12:31:52 -0400
commitb8dfe498775de912116f275680ddb57c8799d9ef (patch)
tree0472ffb18e0354deedc37bcab8c7d9bb4a2941bb /include
parent78f3648601fdc7a8166748bbd6d0555a88efa24a (diff)
netfilter: factorize ifname_compare()
We use same not trivial helper function in four places. We can factorize it. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/netfilter/x_tables.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index e8e08d036752..72918b7cbe85 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -435,6 +435,29 @@ extern void xt_free_table_info(struct xt_table_info *info);
435extern void xt_table_entry_swap_rcu(struct xt_table_info *old, 435extern void xt_table_entry_swap_rcu(struct xt_table_info *old,
436 struct xt_table_info *new); 436 struct xt_table_info *new);
437 437
438/*
439 * This helper is performance critical and must be inlined
440 */
441static inline unsigned long ifname_compare_aligned(const char *_a,
442 const char *_b,
443 const char *_mask)
444{
445 const unsigned long *a = (const unsigned long *)_a;
446 const unsigned long *b = (const unsigned long *)_b;
447 const unsigned long *mask = (const unsigned long *)_mask;
448 unsigned long ret;
449
450 ret = (a[0] ^ b[0]) & mask[0];
451 if (IFNAMSIZ > sizeof(unsigned long))
452 ret |= (a[1] ^ b[1]) & mask[1];
453 if (IFNAMSIZ > 2 * sizeof(unsigned long))
454 ret |= (a[2] ^ b[2]) & mask[2];
455 if (IFNAMSIZ > 3 * sizeof(unsigned long))
456 ret |= (a[3] ^ b[3]) & mask[3];
457 BUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long));
458 return ret;
459}
460
438#ifdef CONFIG_COMPAT 461#ifdef CONFIG_COMPAT
439#include <net/compat.h> 462#include <net/compat.h>
440 463