aboutsummaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-05-07 12:21:21 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-05-07 12:21:21 +0200
commit7121927b8743a9177fda6ddbdfcf9ccd97989417 (patch)
tree1d8f1eff75d4dd3f8caa54f6c270a9918cc4e600 /device
parentdevice: remove unusual ... in messages (diff)
downloadwireguard-go-7121927b8743a9177fda6ddbdfcf9ccd97989417.tar.xz
wireguard-go-7121927b8743a9177fda6ddbdfcf9ccd97989417.zip
device: add ID to repeated routines
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device')
-rw-r--r--device/device.go6
-rw-r--r--device/receive.go14
-rw-r--r--device/send.go6
3 files changed, 13 insertions, 13 deletions
diff --git a/device/device.go b/device/device.go
index a635e68..86f519a 100644
--- a/device/device.go
+++ b/device/device.go
@@ -304,9 +304,9 @@ func NewDevice(tunDevice tun.Device, bind conn.Bind, logger *Logger) *Device {
device.state.stopping.Wait()
device.queue.encryption.wg.Add(cpus) // One for each RoutineHandshake
for i := 0; i < cpus; i++ {
- go device.RoutineEncryption()
- go device.RoutineDecryption()
- go device.RoutineHandshake()
+ go device.RoutineEncryption(i + 1)
+ go device.RoutineDecryption(i + 1)
+ go device.RoutineHandshake(i + 1)
}
device.state.stopping.Add(1) // RoutineReadFromTUN
diff --git a/device/receive.go b/device/receive.go
index 9f6b363..1182246 100644
--- a/device/receive.go
+++ b/device/receive.go
@@ -98,7 +98,7 @@ func (device *Device) RoutineReceiveIncoming(recv conn.ReceiveFunc) {
if errors.Is(err, net.ErrClosed) {
return
}
- device.log.Verbosef("Routine: receive incoming %s - failed to receive packet: %v", recvName, err)
+ device.log.Verbosef("Failed to receive %s packet: %v", recvName, err)
if neterr, ok := err.(net.Error); ok && !neterr.Temporary() {
return
}
@@ -203,11 +203,11 @@ func (device *Device) RoutineReceiveIncoming(recv conn.ReceiveFunc) {
}
}
-func (device *Device) RoutineDecryption() {
+func (device *Device) RoutineDecryption(id int) {
var nonce [chacha20poly1305.NonceSize]byte
- defer device.log.Verbosef("Routine: decryption worker - stopped")
- device.log.Verbosef("Routine: decryption worker - started")
+ defer device.log.Verbosef("Routine: decryption worker %d - stopped", id)
+ device.log.Verbosef("Routine: decryption worker %d - started", id)
for elem := range device.queue.decryption.c {
// split message into fields
@@ -234,12 +234,12 @@ func (device *Device) RoutineDecryption() {
/* Handles incoming packets related to handshake
*/
-func (device *Device) RoutineHandshake() {
+func (device *Device) RoutineHandshake(id int) {
defer func() {
- device.log.Verbosef("Routine: handshake worker - stopped")
+ device.log.Verbosef("Routine: handshake worker %d - stopped", id)
device.queue.encryption.wg.Done()
}()
- device.log.Verbosef("Routine: handshake worker - started")
+ device.log.Verbosef("Routine: handshake worker %d - started", id)
for elem := range device.queue.handshake.c {
diff --git a/device/send.go b/device/send.go
index a437cf1..e07df1b 100644
--- a/device/send.go
+++ b/device/send.go
@@ -362,12 +362,12 @@ func calculatePaddingSize(packetSize, mtu int) int {
*
* Obs. One instance per core
*/
-func (device *Device) RoutineEncryption() {
+func (device *Device) RoutineEncryption(id int) {
var paddingZeros [PaddingMultiple]byte
var nonce [chacha20poly1305.NonceSize]byte
- defer device.log.Verbosef("Routine: encryption worker - stopped")
- device.log.Verbosef("Routine: encryption worker - started")
+ defer device.log.Verbosef("Routine: encryption worker %d - stopped", id)
+ device.log.Verbosef("Routine: encryption worker %d - started", id)
for elem := range device.queue.encryption.c {
// populate header fields