aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/send.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-07-10 03:58:40 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-07-10 20:24:26 +0200
commit214a66fa740604323be7a59511ec753406738779 (patch)
tree8701b1a96530e903ee9bc18e2cda0879ac1a7d36 /src/send.c
parenttimers: document conditions for calling (diff)
downloadwireguard-monolithic-historical-214a66fa740604323be7a59511ec753406738779.tar.xz
wireguard-monolithic-historical-214a66fa740604323be7a59511ec753406738779.zip
timers: move timer calls out of hot loop
We sacrifice a little bit of precision here, but this avoids jockeying around the timers for every packet, when we're sending in bundles anyway to minimize cache misses.
Diffstat (limited to 'src/send.c')
-rw-r--r--src/send.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/send.c b/src/send.c
index 6992fd4..b9a95ac 100644
--- a/src/send.c
+++ b/src/send.c
@@ -132,16 +132,19 @@ struct packet_bundle {
static inline void send_off_bundle(struct packet_bundle *bundle, struct wireguard_peer *peer)
{
struct sk_buff *skb, *next;
- bool is_keepalive;
+ bool is_keepalive, data_sent = false;
+ if (likely(bundle->first))
+ timers_any_authenticated_packet_traversal(peer);
for (skb = bundle->first; skb; skb = next) {
/* We store the next pointer locally because socket_send_skb_to_peer
* consumes the packet before the top of the loop comes again. */
next = skb->next;
is_keepalive = skb->len == message_data_len(0);
- timers_any_authenticated_packet_traversal(peer);
if (likely(!socket_send_skb_to_peer(peer, skb, 0 /* TODO: Should we copy the DSCP value from the enclosed packet? */) && !is_keepalive))
- timers_data_sent(peer);
+ data_sent = true;
}
+ if (likely(data_sent))
+ timers_data_sent(peer);
}
static void message_create_data_done(struct sk_buff *skb, struct wireguard_peer *peer)