summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-07-11 17:15:49 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-07-11 17:16:31 +0200
commit88f864e839acad65e48652f37cc7b6b8f984c49e (patch)
tree39ea9935b291e7ed2748f61544fd17db49e7d961
parentee8e78b96cc2c52bfe4eed14ad9d30698551739b (diff)
receive: account for zero or negative budget
Suggested-by: Thomas Gschwantner <tharre3@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/receive.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/receive.c b/src/receive.c
index 1e8a242..f9d8228 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -379,6 +379,9 @@ int packet_rx_poll(struct napi_struct *napi, int budget)
int work_done = 0;
bool free;
+ if (unlikely(budget <= 0))
+ return 0;
+
while ((skb = __ptr_ring_peek(&queue->ring)) != NULL && (state = atomic_read(&PACKET_CB(skb)->state)) != PACKET_STATE_UNCRYPTED) {
__ptr_ring_discard_one(&queue->ring);
peer = PACKET_PEER(skb);