netfilter: xtables: use memcmp in unconditional check
Instead of inspecting each u32/char open-coded, clean up and make use of memcmp. On some arches, memcmp is implemented as assembly or GCC's __builtin_memcmp which can possibly take advantages of known alignment. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
This commit is contained in:
@ -222,16 +222,11 @@ get_entry(void *base, unsigned int offset)
|
||||
|
||||
/* All zeroes == unconditional rule. */
|
||||
/* Mildly perf critical (only if packet tracing is on) */
|
||||
static inline int
|
||||
unconditional(const struct ip6t_ip6 *ipv6)
|
||||
static inline bool unconditional(const struct ip6t_ip6 *ipv6)
|
||||
{
|
||||
unsigned int i;
|
||||
static const struct ip6t_ip6 uncond;
|
||||
|
||||
for (i = 0; i < sizeof(*ipv6); i++)
|
||||
if (((char *)ipv6)[i])
|
||||
break;
|
||||
|
||||
return (i == sizeof(*ipv6));
|
||||
return memcmp(ipv6, &uncond, sizeof(uncond)) == 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
|
||||
|
Reference in New Issue
Block a user