Skip to content

Commit 63c6f81

Browse files
Eric Dumazetdavem330
authored andcommitted
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: 421b388 ("udp: ipv4: Add udp early demux") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: David Held <[email protected]> Cc: Shawn Bohrer <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2853af6 commit 63c6f81

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/ipv4/udp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,10 @@ static struct sock *__udp4_lib_mcast_demux_lookup(struct net *net,
18611861
unsigned int count, slot = udp_hashfn(net, hnum, udp_table.mask);
18621862
struct udp_hslot *hslot = &udp_table.hash[slot];
18631863

1864+
/* Do not bother scanning a too big list */
1865+
if (hslot->count > 10)
1866+
return NULL;
1867+
18641868
rcu_read_lock();
18651869
begin:
18661870
count = 0;

0 commit comments

Comments
 (0)