Re: [PATCH] netfilter: unfold two critical loops in ip_packet_match()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eric Dumazet <dada1@xxxxxxxxxxxxx> writes:

> While doing oprofile tests I noticed two loops are not properly unrolled by gcc

That's because nobody passed -funroll-loops. Did you try that for
that file? Likely will need -O2 too

> +static unsigned long ifname_compare(const void *_a, const void *_b, const void *_mask)
> +{
> +	const unsigned long *a = (const unsigned long *)_a;
> +	const unsigned long *b = (const unsigned long *)_b;
> +	const unsigned long *mask = (const unsigned long *)_mask;
> +	unsigned long ret;
> +
> +	ret = (a[0] ^ b[0]) & mask[0];
> +	ret |= (a[1] ^ b[1]) & mask[1];
> +	if (IFNAMSIZ > 2 * sizeof(unsigned long))
> +		ret |= (a[2] ^ b[2]) & mask[2];
> +	if (IFNAMSIZ > 3 * sizeof(unsigned long))
> +		ret |= (a[3] ^ b[3]) & mask[3];

That will silently break for IFNAMSIZ >= 4*sizeof(unsigned long)
You should add a dummy loop for that or at least a BUILD_BUG_ON

-Andi

-- 
ak@xxxxxxxxxxxxxxx -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux