aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2014-06-12 19:13:06 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-13 18:39:24 -0400
commit63c6f81cdde58c41da62a8d8a209592e42a0203e (patch)
tree4cc5ca8299a5a4bc1b7ec09baaea25864159cdb7
parent2853af6a2ea1a8ed09b09dd4fb578e7f435e8d34 (diff)
udp: ipv4: do not waste time in __udp4_lib_mcast_demux_lookup
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>
-rw-r--r--net/ipv4/udp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 185ed3e59802..d92f94b7e402 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1861,6 +1861,10 @@ static struct sock *__udp4_lib_mcast_demux_lookup(struct net *net,
1861 unsigned int count, slot = udp_hashfn(net, hnum, udp_table.mask); 1861 unsigned int count, slot = udp_hashfn(net, hnum, udp_table.mask);
1862 struct udp_hslot *hslot = &udp_table.hash[slot]; 1862 struct udp_hslot *hslot = &udp_table.hash[slot];
1863 1863
1864 /* Do not bother scanning a too big list */
1865 if (hslot->count > 10)
1866 return NULL;
1867
1864 rcu_read_lock(); 1868 rcu_read_lock();
1865begin: 1869begin:
1866 count = 0; 1870 count = 0;