From: Antonio Quartulli <antonio@meshcoding.com>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Joe Perches <joe@perches.com>,
Antonio Quartulli <antonio@meshcoding.com>
Subject: [B.A.T.M.A.N.] [PATCH] batadv: Slight optimization of batadv_compare_eth
Date: Tue, 10 Dec 2013 08:44:14 +0100 [thread overview]
Message-ID: <1386661454-3036-1-git-send-email-antonio@meshcoding.com> (raw)
Use the newly added generic routine ether_addr_equal_unaligned
to test if possibly unaligned to u16 Ethernet addresses are equal.
This slightly improves comparison time for systems with
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.
Signed-off-by: Joe Perches <joe@perches.com>
[antonio@meshcoding.com: added compat code for linux <3.14]
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
compat.h | 6 ++++++
main.h | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/compat.h b/compat.h
index 8545b0a..a1c8396 100644
--- a/compat.h
+++ b/compat.h
@@ -382,4 +382,10 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
})
#endif /* < KERNEL_VERSION(3, 11, 0) */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+
+#define ether_addr_equal_unaligned(_a, _b) (memcmp(_a, _b, ETH_ALEN) == 0)
+
+#endif /* < KERNEL_VERSION(3, 14, 0) */
+
#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
diff --git a/main.h b/main.h
index 2f3ac06..d636449 100644
--- a/main.h
+++ b/main.h
@@ -273,7 +273,7 @@ static inline void batadv_dbg(int type __always_unused,
*/
static inline int batadv_compare_eth(const void *data1, const void *data2)
{
- return memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0;
+ return ether_addr_equal_unaligned(data1, data2);
}
/**
--
1.8.5.1
next reply other threads:[~2013-12-10 7:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 7:44 Antonio Quartulli [this message]
2013-12-10 7:45 ` [B.A.T.M.A.N.] [PATCH] batadv: Slight optimization of batadv_compare_eth Antonio Quartulli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386661454-3036-1-git-send-email-antonio@meshcoding.com \
--to=antonio@meshcoding.com \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=joe@perches.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.