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]
Date:	Fri, 25 Feb 2011 13:06:15 +0100
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Daniel Baluta <dbaluta@...acom.com>
Cc:	netdev@...r.kernel.org, davem@...emloft.net,
	Rohan Chitradurga <rohan@...acom.com>
Subject: Re: [PATCH] udp: avoid searching when no ports are available

Le vendredi 25 février 2011 à 13:35 +0200, Daniel Baluta a écrit :
> udp_lib_get_port uses a bitmap to mark used ports.
> 
> When no ports are available we spend a lot of time, searching
> for a port while holding hslot lock. Avoid this by checking if
> bitmap is full.
> 
> 
> Signed-off-by: Rohan Chitradurga <rohan@...acom.com>
> Signed-off-by: Daniel Baluta <dbaluta@...acom.com>
> ---
>  net/ipv4/udp.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index d37baaa..3e3592d 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
> @@ -225,6 +225,12 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
>  			udp_lib_lport_inuse(net, snum, hslot, bitmap, sk,
>  					    saddr_comp, udptable->log);
>  
> +			/* avoid searching when no ports are available */
> +			if (bitmap_full(bitmap, PORTS_PER_CHAIN)) {
> +				spin_unlock_bh(&hslot->lock);
> +				break;
> +			}
> +
>  			snum = first;
>  			/*
>  			 * Iterate on all possible values of snum for this hash.

Really ? I wonder how you got your performance numbers then.

First, PORTS_PER_CHAIN is wrong here, since its value is the max
possible value (256 bits)

#define UDP_HTABLE_SIZE_MIN              (CONFIG_BASE_SMALL ? 128 : 256)
#define MAX_UDP_PORTS 65536
#define PORTS_PER_CHAIN (MAX_UDP_PORTS / UDP_HTABLE_SIZE_MIN)   -> 256

As soon as your machine (and most current machines have) has enough
memory, UDP hash table size is not 256, but 1024 or 2048

dmesg | grep "UDP hash"
[    1.735203] UDP hash table entries: 2048 (order: 6, 327680 bytes)

So real bitmap size is 64 or 32 bits.

Your call to bitmap_full() always return false.


I dont like this patch. If you have special UDP needs on a small
machine, just add to kernel boot param "uhash_entries=8192", so that the
bitmap has 8 bits only.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ