Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit a268817

Browse files
edumazetdmbaturin
authored andcommitted
udp: fix behavior of wrong checksums
We have two problems in UDP stack related to bogus checksums : 1) We return -EAGAIN 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. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3d4cff5 commit a268817

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

net/ipv4/udp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,10 +1317,8 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
13171317
}
13181318
unlock_sock_fast(sk, slow);
13191319

1320-
if (noblock)
1321-
return -EAGAIN;
1322-
1323-
/* starting over for a new packet */
1320+
/* starting over for a new packet, but check if we need to yield */
1321+
cond_resched();
13241322
msg->msg_flags &= ~MSG_TRUNC;
13251323
goto try_again;
13261324
}

net/ipv6/udp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,8 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
513513
}
514514
unlock_sock_fast(sk, slow);
515515

516-
if (noblock)
517-
return -EAGAIN;
518-
519-
/* starting over for a new packet */
516+
/* starting over for a new packet, but check if we need to yield */
517+
cond_resched();
520518
msg->msg_flags &= ~MSG_TRUNC;
521519
goto try_again;
522520
}

0 commit comments

Comments
 (0)