diff options
author | Harry Lin <mrregi24@gmail.com> | 2015-07-09 13:00:54 +1000 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-03-18 01:51:05 +0100 |
commit | 261dd7b3b8aaa18bc3f2d4d665c66a3ccb8f57f8 (patch) | |
tree | 8442bf33f40c71755993279f3dbe950c62e46da5 /net | |
parent | bf0a5dfef52ed642a596f44749b58bfd652cc65c (diff) | |
download | kernel_samsung_smdk4412-261dd7b3b8aaa18bc3f2d4d665c66a3ccb8f57f8.zip kernel_samsung_smdk4412-261dd7b3b8aaa18bc3f2d4d665c66a3ccb8f57f8.tar.gz kernel_samsung_smdk4412-261dd7b3b8aaa18bc3f2d4d665c66a3ccb8f57f8.tar.bz2 |
udp: fix behavior of wrong checksums
We have two problems in UDP stack related to bogus checksums :
1 ) We return -EGAIN to application even if receive queue is not empty.
This breaks applications using edge trigger epoll()
2 ) Under UDP flood, we can loop forever without yielding to other
processes, potentially hanging the host, especially on non SMP.
This patch is an attempt to make things better.
We might in the future add extra support for rt applications
wanting to better control time spent doing a recv() in a hostile
environment. For example we could validate checksums before queuing
packets in socket receive queue.
Change-Id: Ic25820228fd735e25a850951e059bf75ae39b653
Signed-off-by: Eruc Dumazet <edumazet@google.com>
Cc: Willem de Brujin <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/udp.c | 6 | ||||
-rw-r--r-- | net/ipv6/udp.c | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 966c3e1..2f00d32 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1249,10 +1249,8 @@ csum_copy_err: UDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite); unlock_sock_fast(sk, slow); - if (noblock) - return -EAGAIN; - - /* starting over for a new packet */ + /* starting over for a new packet, but check if we need to yield */ + cond_resched(); msg->msg_flags &= ~MSG_TRUNC; goto try_again; } diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 5c363cd..823d1ef 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -453,10 +453,8 @@ csum_copy_err: } unlock_sock_fast(sk, slow); - if (noblock) - return -EAGAIN; - - /* starting over for a new packet */ + /* starting over for a new packet, but check if we need to yield */ + cond_resched(); msg->msg_flags &= ~MSG_TRUNC; goto try_again; } |