diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-08 21:18:56 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-08 23:55:23 +0200 |
commit | 4a5231e2ba26f8567faffe2fac83fe8cabf52160 (patch) | |
tree | 18df5afce55fa1dfbfa9e0693a9ab5baab3a81df /src | |
parent | bcce73b296e6b8e439dd480f50518f6c08ad6910 (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.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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); } |