summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-07-08 21:18:56 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-07-08 23:55:23 +0200
commit4a5231e2ba26f8567faffe2fac83fe8cabf52160 (patch)
tree18df5afce55fa1dfbfa9e0693a9ab5baab3a81df /src
parentbcce73b296e6b8e439dd480f50518f6c08ad6910 (diff)
keepalives: only queue keepalive when queue is empty
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/send.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/send.c b/src/send.c
index 1f63fd9..e1d8010 100644
--- a/src/send.c
+++ b/src/send.c
@@ -110,12 +110,15 @@ static inline void keep_key_fresh(struct wireguard_peer *peer)
void packet_send_keepalive(struct wireguard_peer *peer)
{
- struct sk_buff *skb = alloc_skb(DATA_PACKET_HEAD_ROOM + MESSAGE_MINIMUM_LENGTH, GFP_ATOMIC);
- if (unlikely(!skb))
- return;
- skb_reserve(skb, DATA_PACKET_HEAD_ROOM);
- skb->dev = netdev_pub(peer->device);
- skb_queue_tail(&peer->tx_packet_queue, skb);
+ struct sk_buff *skb;
+ if (!skb_queue_len(&peer->tx_packet_queue)) {
+ skb = alloc_skb(DATA_PACKET_HEAD_ROOM + MESSAGE_MINIMUM_LENGTH, GFP_ATOMIC);
+ if (unlikely(!skb))
+ return;
+ skb_reserve(skb, DATA_PACKET_HEAD_ROOM);
+ skb->dev = netdev_pub(peer->device);
+ skb_queue_tail(&peer->tx_packet_queue, skb);
+ }
packet_send_queue(peer);
}