diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-10 03:58:40 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-10 20:24:26 +0200 |
commit | 45092f8fb277fc45d7dcfa49bd549fbed10d44e7 (patch) | |
tree | bf6e7bc753cf6c8dafb69508b4f2345e669bc461 /src | |
parent | c60e34aa2cb6f372c331184fb20eba3108c6f97b (diff) |
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.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/send.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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) |