aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-07-10 02:46:37 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-07-10 03:46:56 +0200
commit1b5c30a6b55372539c2b935745e07ffb2f43cc99 (patch)
tree8698a664444b483c9ab4e90ece8e0162e403ce39 /src
parentpersistent keepalive: use authenticated keepalives (diff)
downloadwireguard-monolithic-historical-1b5c30a6b55372539c2b935745e07ffb2f43cc99.tar.xz
wireguard-monolithic-historical-1b5c30a6b55372539c2b935745e07ffb2f43cc99.zip
persistent keepalive: use unsigned long to avoid multiplication in hotpath
Diffstat (limited to 'src')
-rw-r--r--src/config.c4
-rw-r--r--src/peer.h2
-rw-r--r--src/timers.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/config.c b/src/config.c
index 9cf75b1..3ca23f3 100644
--- a/src/config.c
+++ b/src/config.c
@@ -109,7 +109,7 @@ static int set_peer(struct wireguard_device *wg, void __user *user_peer, size_t
else {
if (!peer->persistent_keepalive_interval && in_peer.persistent_keepalive_interval && netdev_pub(wg)->flags & IFF_UP)
packet_send_keepalive(peer);
- peer->persistent_keepalive_interval = in_peer.persistent_keepalive_interval;
+ peer->persistent_keepalive_interval = (unsigned long)in_peer.persistent_keepalive_interval * HZ;
}
}
@@ -251,7 +251,7 @@ static int populate_peer(struct wireguard_peer *peer, void *ctx)
out_peer.last_handshake_time = peer->walltime_last_handshake;
out_peer.tx_bytes = peer->tx_bytes;
out_peer.rx_bytes = peer->rx_bytes;
- out_peer.persistent_keepalive_interval = peer->persistent_keepalive_interval;
+ out_peer.persistent_keepalive_interval = (uint16_t)(peer->persistent_keepalive_interval / HZ);
ipmasks_data.out_len = data->out_len;
ipmasks_data.data = data->data;
diff --git a/src/peer.h b/src/peer.h
index 6d74385..47534a2 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -29,7 +29,7 @@ struct wireguard_peer {
uint64_t rx_bytes, tx_bytes;
struct timer_list timer_retransmit_handshake, timer_send_keepalive, timer_new_handshake, timer_kill_ephemerals, timer_persistent_keepalive;
unsigned int timer_handshake_attempts;
- uint16_t persistent_keepalive_interval;
+ unsigned long persistent_keepalive_interval;
bool timer_need_another_keepalive;
struct timeval walltime_last_handshake;
struct sk_buff_head tx_packet_queue;
diff --git a/src/timers.c b/src/timers.c
index 8ef1469..58b6e64 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -82,7 +82,7 @@ static void expired_send_persistent_keepalive(unsigned long ptr)
if (unlikely(!peer->persistent_keepalive_interval))
return;
- pr_debug("Sending keep alive packet to peer %Lu (%pISpfsc), since we haven't sent or received authenticated data for %u seconds\n", peer->internal_id, &peer->endpoint_addr, peer->persistent_keepalive_interval);
+ pr_debug("Sending keep alive packet to peer %Lu (%pISpfsc), since we haven't sent or received authenticated data for %lu seconds\n", peer->internal_id, &peer->endpoint_addr, peer->persistent_keepalive_interval / HZ);
packet_send_keepalive(peer);
}
@@ -134,7 +134,7 @@ void timers_ephemeral_key_created(struct wireguard_peer *peer)
void timers_any_authenticated_packet_traversal(struct wireguard_peer *peer)
{
if (peer->persistent_keepalive_interval && likely(peer->timer_persistent_keepalive.data))
- mod_timer(&peer->timer_persistent_keepalive, jiffies + HZ * peer->persistent_keepalive_interval);
+ mod_timer(&peer->timer_persistent_keepalive, jiffies + peer->persistent_keepalive_interval);
}
void timers_init_peer(struct wireguard_peer *peer)