lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240613073441.781919-1-dqfext@gmail.com>
Date: Thu, 13 Jun 2024 15:34:41 +0800
From: Qingfang Deng <dqfext@...il.com>
To: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Joe Perches <joe@...ches.com>,
	Qingfang Deng <qingfang.deng@...lower.com.cn>
Subject: [PATCH net-next] etherdevice: Optimize is_broadcast_ether_addr

From: Qingfang Deng <qingfang.deng@...lower.com.cn>

Like is_zero_ether_addr, is_broadcast_ether_addr can also be optimized
by using a 32-bit load if CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set.
Sign extension is used to populate the upper 16-bit of the 16-bit load.

Signed-off-by: Qingfang Deng <qingfang.deng@...lower.com.cn>
---
 include/linux/etherdevice.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 2ad1ffa4ccb9..23b9cc5e299d 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -174,9 +174,14 @@ static inline bool is_local_ether_addr(const u8 *addr)
  */
 static inline bool is_broadcast_ether_addr(const u8 *addr)
 {
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+	return (*(const s32 *)(addr + 0) &
+		*(const s16 *)(addr + 4)) == (s32)0xffffffff;
+#else
 	return (*(const u16 *)(addr + 0) &
 		*(const u16 *)(addr + 2) &
 		*(const u16 *)(addr + 4)) == 0xffff;
+#endif
 }
 
 /**
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ