summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-05-31 04:25:55 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-05-31 05:36:21 +0200
commitc0ad0d970830ac680bed6f143743096be82cef51 (patch)
tree0a5e2ec73552781e8c0a263c822e99bbe4095c14 /src
parentbf4c1698b732ef22266f608db1286149e20bd6e2 (diff)
debug: print interface name in dmesg
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/compat/compat.h4
-rw-r--r--src/cookie.c2
-rw-r--r--src/data.c2
-rw-r--r--src/device.c10
-rw-r--r--src/main.c2
-rw-r--r--src/noise.c4
-rw-r--r--src/peer.c4
-rw-r--r--src/receive.c46
-rw-r--r--src/send.c8
-rw-r--r--src/socket.c12
-rw-r--r--src/timers.c8
11 files changed, 52 insertions, 50 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h
index e504a0b..6a5f33c 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -238,10 +238,10 @@ static inline struct net_device *netdev_pub(void *dev)
#endif
#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
-#define net_dbg_skb_ratelimited(fmt, skb, ...) do { \
+#define net_dbg_skb_ratelimited(fmt, dev, skb, ...) do { \
struct endpoint __endpoint; \
socket_endpoint_from_skb(&__endpoint, skb); \
- net_dbg_ratelimited(fmt, &__endpoint.addr, ##__VA_ARGS__); \
+ net_dbg_ratelimited(fmt, dev, &__endpoint.addr, ##__VA_ARGS__); \
} while(0)
#else
#define net_dbg_skb_ratelimited(fmt, skb, ...)
diff --git a/src/cookie.c b/src/cookie.c
index 2046493..21b7c7b 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -193,7 +193,7 @@ void cookie_message_consume(struct message_handshake_cookie *src, struct wiregua
entry->peer->latest_cookie.have_sent_mac1 = false;
up_write(&entry->peer->latest_cookie.lock);
} else
- net_dbg_ratelimited("Could not decrypt invalid cookie response\n");
+ net_dbg_ratelimited("%s: Could not decrypt invalid cookie response\n", netdev_pub(wg)->name);
out:
peer_put(entry->peer);
diff --git a/src/data.c b/src/data.c
index 943d6e8..9210304 100644
--- a/src/data.c
+++ b/src/data.c
@@ -351,7 +351,7 @@ static void finish_decrypt_packet(struct decryption_ctx *ctx)
return;
if (unlikely(!counter_validate(&ctx->keypair->receiving.counter, PACKET_CB(ctx->skb)->nonce))) {
- net_dbg_ratelimited("Packet has invalid nonce %Lu (max %Lu)\n", PACKET_CB(ctx->skb)->nonce, ctx->keypair->receiving.counter.receive.counter);
+ net_dbg_ratelimited("%s: Packet has invalid nonce %Lu (max %Lu)\n", netdev_pub(ctx->keypair->entry.peer->device)->name, PACKET_CB(ctx->skb)->nonce, ctx->keypair->receiving.counter.receive.counter);
peer_put(ctx->keypair->entry.peer);
noise_keypair_put(ctx->keypair);
dev_kfree_skb(ctx->skb);
diff --git a/src/device.c b/src/device.c
index f0c172f..802e90d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -136,7 +136,7 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
if (unlikely(dev_recursion_level() > 4)) {
ret = -ELOOP;
- net_dbg_ratelimited("Routing loop detected\n");
+ net_dbg_ratelimited("%s: Routing loop detected\n", dev->name);
skb_unsendable(skb, dev);
goto err;
}
@@ -144,7 +144,7 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
peer = routing_table_lookup_dst(&wg->peer_routing_table, skb);
if (unlikely(!peer)) {
ret = -ENOKEY;
- net_dbg_skb_ratelimited("No peer is configured for %pISc\n", skb);
+ net_dbg_skb_ratelimited("%s: No peer is configured for %pISc\n", dev->name, skb);
goto err;
}
@@ -153,7 +153,7 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
read_unlock_bh(&peer->endpoint_lock);
if (unlikely(ret)) {
ret = -EHOSTUNREACH;
- net_dbg_ratelimited("No valid endpoint has been configured or discovered for peer %Lu\n", peer->internal_id);
+ net_dbg_ratelimited("%s: No valid endpoint has been configured or discovered for peer %Lu\n", dev->name, peer->internal_id);
goto err_peer;
}
@@ -251,7 +251,7 @@ static void destruct(struct net_device *dev)
free_percpu(wg->incoming_handshakes_worker);
put_net(wg->creating_net);
- pr_debug("Device %s has been deleted\n", dev->name);
+ pr_debug("%s: Interface deleted\n", dev->name);
free_netdev(dev);
}
@@ -352,7 +352,7 @@ static int newlink(struct net *src_net, struct net_device *dev, struct nlattr *t
if (ret < 0)
goto error_10;
- pr_debug("Device %s has been created\n", dev->name);
+ pr_debug("%s: Interface created\n", dev->name);
return 0;
diff --git a/src/main.c b/src/main.c
index 2c2cc6f..f6b36e1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -61,7 +61,7 @@ static void __exit mod_exit(void)
packet_deinit_data_caches();
#endif
ratelimiter_module_deinit();
- pr_debug("WireGuard has been unloaded\n");
+ pr_debug("WireGuard unloaded\n");
}
module_init(mod_init);
diff --git a/src/noise.c b/src/noise.c
index c9d8148..7ca2a67 100644
--- a/src/noise.c
+++ b/src/noise.c
@@ -88,7 +88,7 @@ static struct noise_keypair *keypair_create(struct wireguard_peer *peer)
static void keypair_free_rcu(struct rcu_head *rcu)
{
struct noise_keypair *keypair = container_of(rcu, struct noise_keypair, rcu);
- net_dbg_ratelimited("Keypair %Lu destroyed for peer %Lu\n", keypair->internal_id, keypair->entry.peer->internal_id);
+ net_dbg_ratelimited("%s: Keypair %Lu destroyed for peer %Lu\n", netdev_pub(keypair->entry.peer->device)->name, keypair->internal_id, keypair->entry.peer->internal_id);
kzfree(keypair);
}
@@ -592,7 +592,7 @@ bool noise_handshake_begin_session(struct noise_handshake *handshake, struct noi
add_new_keypair(keypairs, new_keypair);
index_hashtable_replace(&handshake->entry.peer->device->index_hashtable, &handshake->entry, &new_keypair->entry);
noise_handshake_clear(handshake);
- net_dbg_ratelimited("Keypair %Lu created for peer %Lu\n", new_keypair->internal_id, new_keypair->entry.peer->internal_id);
+ net_dbg_ratelimited("%s: Keypair %Lu created for peer %Lu\n", netdev_pub(new_keypair->entry.peer->device)->name, new_keypair->internal_id, new_keypair->entry.peer->internal_id);
return true;
diff --git a/src/peer.c b/src/peer.c
index 168083b..a73ec7d 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -46,7 +46,7 @@ struct wireguard_peer *peer_create(struct wireguard_device *wg, const u8 public_
kref_init(&peer->refcount);
pubkey_hashtable_add(&wg->peer_hashtable, peer);
list_add_tail(&peer->peer_list, &wg->peer_list);
- pr_debug("Peer %Lu created\n", peer->internal_id);
+ pr_debug("%s: Peer %Lu created\n", netdev_pub(wg)->name, peer->internal_id);
return peer;
}
@@ -89,7 +89,7 @@ void peer_remove(struct wireguard_peer *peer)
static void rcu_release(struct rcu_head *rcu)
{
struct wireguard_peer *peer = container_of(rcu, struct wireguard_peer, rcu);
- pr_debug("Peer %Lu (%pISpfsc) destroyed\n", peer->internal_id, &peer->endpoint.addr);
+ pr_debug("%s: Peer %Lu (%pISpfsc) destroyed\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
skb_queue_purge(&peer->tx_packet_queue);
dst_cache_destroy(&peer->endpoint_cache);
kzfree(peer);
diff --git a/src/receive.c b/src/receive.c
index c5d0b12..fb057aa 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -30,7 +30,7 @@ static inline void update_latest_addr(struct wireguard_peer *peer, struct sk_buf
socket_set_peer_endpoint(peer, &endpoint);
}
-static inline int skb_prepare_header(struct sk_buff *skb)
+static inline int skb_prepare_header(struct sk_buff *skb, struct wireguard_device *wg)
{
struct udphdr *udp;
size_t data_offset, data_len;
@@ -46,41 +46,41 @@ static inline int skb_prepare_header(struct sk_buff *skb)
udp = udp_hdr(skb);
data_offset = (u8 *)udp - skb->data;
if (unlikely(data_offset > U16_MAX)) {
- net_dbg_skb_ratelimited("Packet has offset at impossible location from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Packet has offset at impossible location from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
if (unlikely(data_offset + sizeof(struct udphdr) > skb->len)) {
- net_dbg_skb_ratelimited("Packet isn't big enough to have UDP fields from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Packet isn't big enough to have UDP fields from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
data_len = ntohs(udp->len);
if (unlikely(data_len < sizeof(struct udphdr))) {
- net_dbg_skb_ratelimited("UDP packet is reporting too small of a size from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: UDP packet is reporting too small of a size from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
if (unlikely(data_len > skb->len - data_offset)) {
- net_dbg_skb_ratelimited("UDP packet is lying about its size from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: UDP packet is lying about its size from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
data_len -= sizeof(struct udphdr);
data_offset = (u8 *)udp + sizeof(struct udphdr) - skb->data;
if (unlikely(!pskb_may_pull(skb, data_offset + sizeof(struct message_header)))) {
- net_dbg_skb_ratelimited("Could not pull header into data section from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Could not pull header into data section from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
if (pskb_trim(skb, data_len + data_offset) < 0) {
- net_dbg_skb_ratelimited("Could not trim packet from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Could not trim packet from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
skb_pull(skb, data_offset);
if (unlikely(skb->len != data_len)) {
- net_dbg_skb_ratelimited("Final len does not agree with calculated len from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Final len does not agree with calculated len from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
message_type = message_determine_type(skb);
__skb_push(skb, data_offset);
if (unlikely(!pskb_may_pull(skb, data_offset + message_header_sizes[message_type]))) {
- net_dbg_skb_ratelimited("Could not pull full header into data section from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Could not pull full header into data section from %pISpfsc\n", netdev_pub(wg)->name, skb);
return -EINVAL;
}
__skb_pull(skb, data_offset);
@@ -98,7 +98,7 @@ static void receive_handshake_packet(struct wireguard_device *wg, struct sk_buff
message_type = message_determine_type(skb);
if (message_type == MESSAGE_HANDSHAKE_COOKIE) {
- net_dbg_skb_ratelimited("Receiving cookie response from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Receiving cookie response from %pISpfsc\n", netdev_pub(wg)->name, skb);
cookie_message_consume((struct message_handshake_cookie *)skb->data, wg);
return;
}
@@ -110,7 +110,7 @@ static void receive_handshake_packet(struct wireguard_device *wg, struct sk_buff
else if (under_load && mac_state == VALID_MAC_BUT_NO_COOKIE)
packet_needs_cookie = true;
else {
- net_dbg_skb_ratelimited("Invalid MAC of handshake, dropping packet from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Invalid MAC of handshake, dropping packet from %pISpfsc\n", netdev_pub(wg)->name, skb);
return;
}
@@ -123,11 +123,11 @@ static void receive_handshake_packet(struct wireguard_device *wg, struct sk_buff
}
peer = noise_handshake_consume_initiation(message, wg);
if (unlikely(!peer)) {
- net_dbg_skb_ratelimited("Invalid handshake initiation from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Invalid handshake initiation from %pISpfsc\n", netdev_pub(wg)->name, skb);
return;
}
update_latest_addr(peer, skb);
- net_dbg_ratelimited("Receiving handshake initiation from peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Receiving handshake initiation from peer %Lu (%pISpfsc)\n", netdev_pub(wg)->name, peer->internal_id, &peer->endpoint.addr);
packet_send_handshake_response(peer);
break;
}
@@ -139,11 +139,11 @@ static void receive_handshake_packet(struct wireguard_device *wg, struct sk_buff
}
peer = noise_handshake_consume_response(message, wg);
if (unlikely(!peer)) {
- net_dbg_skb_ratelimited("Invalid handshake response from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Invalid handshake response from %pISpfsc\n", netdev_pub(wg)->name, skb);
return;
}
update_latest_addr(peer, skb);
- net_dbg_ratelimited("Receiving handshake response from peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Receiving handshake response from peer %Lu (%pISpfsc)\n", netdev_pub(wg)->name, peer->internal_id, &peer->endpoint.addr);
if (noise_handshake_begin_session(&peer->handshake, &peer->keypairs, true)) {
timers_ephemeral_key_created(peer);
timers_handshake_complete(peer);
@@ -222,14 +222,14 @@ void packet_consume_data_done(struct sk_buff *skb, struct wireguard_peer *peer,
/* A packet with length 0 is a keepalive packet */
if (unlikely(!skb->len)) {
- net_dbg_ratelimited("Receiving keepalive packet from peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Receiving keepalive packet from peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
goto packet_processed;
}
if (!pskb_may_pull(skb, 1 /* For checking the ip version below */)) {
++dev->stats.rx_errors;
++dev->stats.rx_length_errors;
- net_dbg_ratelimited("Packet missing IP version from peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Packet missing IP version from peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
goto packet_processed;
}
@@ -246,7 +246,7 @@ void packet_consume_data_done(struct sk_buff *skb, struct wireguard_peer *peer,
} else {
++dev->stats.rx_errors;
++dev->stats.rx_length_errors;
- net_dbg_ratelimited("Packet neither ipv4 nor ipv6 from peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Packet neither ipv4 nor ipv6 from peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
goto packet_processed;
}
@@ -258,7 +258,7 @@ void packet_consume_data_done(struct sk_buff *skb, struct wireguard_peer *peer,
if (unlikely(routed_peer != peer)) {
++dev->stats.rx_errors;
++dev->stats.rx_frame_errors;
- net_dbg_skb_ratelimited("Packet has unallowed src IP (%pISc) from peer %Lu (%pISpfsc)\n", skb, peer->internal_id, &peer->endpoint.addr);
+ net_dbg_skb_ratelimited("%s: Packet has unallowed src IP (%pISc) from peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, skb, peer->internal_id, &peer->endpoint.addr);
goto packet_processed;
}
@@ -267,7 +267,7 @@ void packet_consume_data_done(struct sk_buff *skb, struct wireguard_peer *peer,
rx_stats(peer, len);
else {
++dev->stats.rx_dropped;
- net_dbg_ratelimited("Failed to give packet to userspace from peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Failed to give packet to userspace from peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
}
goto continue_processing;
@@ -281,7 +281,7 @@ continue_processing:
void packet_receive(struct wireguard_device *wg, struct sk_buff *skb)
{
- int message_type = skb_prepare_header(skb);
+ int message_type = skb_prepare_header(skb, wg);
if (unlikely(message_type < 0))
goto err;
switch (message_type) {
@@ -290,7 +290,7 @@ void packet_receive(struct wireguard_device *wg, struct sk_buff *skb)
case MESSAGE_HANDSHAKE_COOKIE: {
int cpu_index, cpu, target_cpu;
if (skb_queue_len(&wg->incoming_handshakes) > MAX_QUEUED_INCOMING_HANDSHAKES) {
- net_dbg_skb_ratelimited("Too many handshakes queued, dropping packet from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Too many handshakes queued, dropping packet from %pISpfsc\n", netdev_pub(wg)->name, skb);
goto err;
}
skb_queue_tail(&wg->incoming_handshakes, skb);
@@ -308,7 +308,7 @@ void packet_receive(struct wireguard_device *wg, struct sk_buff *skb)
packet_consume_data(skb, wg);
break;
default:
- net_dbg_skb_ratelimited("Invalid packet from %pISpfsc\n", skb);
+ net_dbg_skb_ratelimited("%s: Invalid packet from %pISpfsc\n", netdev_pub(wg)->name, skb);
goto err;
}
return;
diff --git a/src/send.c b/src/send.c
index f83918a..b45f221 100644
--- a/src/send.c
+++ b/src/send.c
@@ -27,7 +27,7 @@ static void packet_send_handshake_initiation(struct wireguard_peer *peer)
peer->last_sent_handshake = get_jiffies_64();
up_write(&peer->handshake.lock);
- net_dbg_ratelimited("Sending handshake initiation to peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Sending handshake initiation to peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
if (noise_handshake_create_initiation(&packet, &peer->handshake)) {
cookie_add_mac_to_packet(&packet, sizeof(packet), peer);
@@ -64,7 +64,7 @@ void packet_send_handshake_response(struct wireguard_peer *peer)
{
struct message_handshake_response packet;
- net_dbg_ratelimited("Sending handshake response to peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Sending handshake response to peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
peer->last_sent_handshake = get_jiffies_64();
if (noise_handshake_create_response(&packet, &peer->handshake)) {
@@ -81,7 +81,7 @@ void packet_send_handshake_cookie(struct wireguard_device *wg, struct sk_buff *i
{
struct message_handshake_cookie packet;
- net_dbg_skb_ratelimited("Sending cookie response for denied handshake message for %pISpfsc\n", initiating_skb);
+ net_dbg_skb_ratelimited("%s: Sending cookie response for denied handshake message for %pISpfsc\n", netdev_pub(wg)->name, initiating_skb);
cookie_message_create(&packet, initiating_skb, sender_index, &wg->cookie_checker);
socket_send_buffer_as_reply_to_skb(wg, initiating_skb, &packet, sizeof(packet));
}
@@ -113,7 +113,7 @@ void packet_send_keepalive(struct wireguard_peer *peer)
skb_reserve(skb, DATA_PACKET_HEAD_ROOM);
skb->dev = netdev_pub(peer->device);
skb_queue_tail(&peer->tx_packet_queue, skb);
- net_dbg_ratelimited("Sending keepalive packet to peer %Lu (%pISpfsc)\n", peer->internal_id, &peer->endpoint.addr);
+ net_dbg_ratelimited("%s: Sending keepalive packet to peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr);
}
packet_send_queue(peer);
}
diff --git a/src/socket.c b/src/socket.c
index 54b1ba2..acf3b4a 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -52,12 +52,12 @@ static inline int send4(struct wireguard_device *wg, struct sk_buff *skb, struct
}
if (unlikely(IS_ERR(rt))) {
ret = PTR_ERR(rt);
- net_dbg_ratelimited("No route to %pISpfsc, error %d\n", &endpoint->addr, ret);
+ net_dbg_ratelimited("%s: No route to %pISpfsc, error %d\n", netdev_pub(wg)->name, &endpoint->addr, ret);
goto err;
} else if (unlikely(rt->dst.dev == skb->dev)) {
dst_release(&rt->dst);
ret = -ELOOP;
- net_dbg_ratelimited("Avoiding routing loop to %pISpfsc\n", &endpoint->addr);
+ net_dbg_ratelimited("%s: Avoiding routing loop to %pISpfsc\n", netdev_pub(wg)->name, &endpoint->addr);
goto err;
}
if (cache)
@@ -117,12 +117,12 @@ static inline int send6(struct wireguard_device *wg, struct sk_buff *skb, struct
}
ret = ipv6_stub->ipv6_dst_lookup(sock_net(sock), sock, &dst, &fl);
if (unlikely(ret)) {
- net_dbg_ratelimited("No route to %pISpfsc, error %d\n", &endpoint->addr, ret);
+ net_dbg_ratelimited("%s: No route to %pISpfsc, error %d\n", netdev_pub(wg)->name, &endpoint->addr, ret);
goto err;
} else if (unlikely(dst->dev == skb->dev)) {
dst_release(dst);
ret = -ELOOP;
- net_dbg_ratelimited("Avoiding routing loop to %pISpfsc\n", &endpoint->addr);
+ net_dbg_ratelimited("%s: Avoiding routing loop to %pISpfsc\n", netdev_pub(wg)->name, &endpoint->addr);
goto err;
}
if (cache)
@@ -335,7 +335,7 @@ retry:
ret = udp_sock_create(wg->creating_net, &port4, &new4);
if (ret < 0) {
- pr_err("Could not create IPv4 socket\n");
+ pr_err("%s: Could not create IPv4 socket\n", netdev_pub(wg)->name);
goto out;
}
wg->incoming_port = ntohs(inet_sk(new4->sk)->inet_sport);
@@ -355,7 +355,7 @@ retry:
goto retry;
if (!port4.local_udp_port)
wg->incoming_port = 0;
- pr_err("Could not create IPv6 socket\n");
+ pr_err("%s: Could not create IPv6 socket\n", netdev_pub(wg)->name);
goto out;
}
set_sock_opts(new6);
diff --git a/src/timers.c b/src/timers.c
index 9d80bf9..ff422b1 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -27,8 +27,9 @@ static inline unsigned long slack_time(unsigned long time)
static void expired_retransmit_handshake(unsigned long ptr)
{
peer_get_from_ptr(ptr);
- pr_debug("Handshake for peer %Lu (%pISpfsc) did not complete after %d seconds, retrying\n", peer->internal_id, &peer->endpoint.addr, REKEY_TIMEOUT / HZ);
if (peer->timer_handshake_attempts > MAX_TIMER_HANDSHAKES) {
+ pr_debug("%s: Handshake for peer %Lu (%pISpfsc) did not complete after %d attempts, giving up\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, MAX_TIMER_HANDSHAKES);
+
del_timer(&peer->timer_send_keepalive);
/* We remove all existing packets and don't try again,
* if we try unsuccessfully for too long to make a handshake. */
@@ -39,6 +40,7 @@ static void expired_retransmit_handshake(unsigned long ptr)
mod_timer(&peer->timer_kill_ephemerals, jiffies + (REJECT_AFTER_TIME * 3));
goto out;
}
+ pr_debug("%s: Handshake for peer %Lu (%pISpfsc) did not complete after %d seconds, retrying\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, REKEY_TIMEOUT / HZ);
/* We clear the endpoint address src address, in case this is the cause of trouble. */
socket_clear_peer_endpoint_src(peer);
@@ -64,7 +66,7 @@ static void expired_send_keepalive(unsigned long ptr)
static void expired_new_handshake(unsigned long ptr)
{
peer_get_from_ptr(ptr);
- pr_debug("Retrying handshake with peer %Lu (%pISpfsc) because we stopped hearing back after %d seconds\n", peer->internal_id, &peer->endpoint.addr, (KEEPALIVE_TIMEOUT + REKEY_TIMEOUT) / HZ);
+ pr_debug("%s: Retrying handshake with peer %Lu (%pISpfsc) because we stopped hearing back after %d seconds\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, (KEEPALIVE_TIMEOUT + REKEY_TIMEOUT) / HZ);
/* We clear the endpoint address src address, in case this is the cause of trouble. */
socket_clear_peer_endpoint_src(peer);
packet_queue_handshake_initiation(peer);
@@ -80,7 +82,7 @@ static void expired_kill_ephemerals(unsigned long ptr)
static void queued_expired_kill_ephemerals(struct work_struct *work)
{
struct wireguard_peer *peer = container_of(work, struct wireguard_peer, clear_peer_work);
- pr_debug("Zeroing out all keys for peer %Lu (%pISpfsc), since we haven't received a new one in %d seconds\n", peer->internal_id, &peer->endpoint.addr, (REJECT_AFTER_TIME * 3) / HZ);
+ pr_debug("%s: Zeroing out all keys for peer %Lu (%pISpfsc), since we haven't received a new one in %d seconds\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr, (REJECT_AFTER_TIME * 3) / HZ);
noise_handshake_clear(&peer->handshake);
noise_keypairs_clear(&peer->keypairs);
peer_put(peer);