udp: ipv4: do not waste time in __udp4_lib_mcast_demux_lookup
authorEric Dumazet <edumazet@google.com>
Thu, 12 Jun 2014 23:13:06 +0000 (16:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Jun 2014 19:15:40 +0000 (15:15 -0400)
commit724d0d32fa2a6242a0f03c1baeb8310e7ddcf9a9
tree576f83ddd0feb5b215e35ef70bd9fa9294dab186
parentd5570b211c0e04553c2774c459852425eb8c7172
udp: ipv4: do not waste time in __udp4_lib_mcast_demux_lookup

[ Upstream commit 63c6f81cdde58c41da62a8d8a209592e42a0203e ]

Its too easy to add thousand of UDP sockets on a particular bucket,
and slow down an innocent multicast receiver.

Early demux is supposed to be an optimization, we should avoid spending
too much time in it.

It is interesting to note __udp4_lib_demux_lookup() only tries to
match first socket in the chain.

10 is the threshold we already have in __udp4_lib_lookup() to switch
to secondary hash.

Fixes: 421b3885bf6d5 ("udp: ipv4: Add udp early demux")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: David Held <drheld@google.com>
Cc: Shawn Bohrer <sbohrer@rgmadvisors.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/udp.c