diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-11 17:15:49 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-07-11 17:16:31 +0200 |
commit | d9501f128f9f7b26474f6894111868fedc9e07ce (patch) | |
tree | 800ae1fffc709ac3b56a706525ca5cfa351bbe19 | |
parent | tools: only error on wg show if all interfaces fail (diff) | |
download | wireguard-monolithic-historical-d9501f128f9f7b26474f6894111868fedc9e07ce.tar.xz wireguard-monolithic-historical-d9501f128f9f7b26474f6894111868fedc9e07ce.zip |
receive: account for zero or negative budget
Suggested-by: Thomas Gschwantner <tharre3@gmail.com>
-rw-r--r-- | src/receive.c | 3 |
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); |