mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 01:05:15 +01:00
device: add ID to repeated routines
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
326aec10af
commit
7121927b87
@ -304,9 +304,9 @@ func NewDevice(tunDevice tun.Device, bind conn.Bind, logger *Logger) *Device {
|
|||||||
device.state.stopping.Wait()
|
device.state.stopping.Wait()
|
||||||
device.queue.encryption.wg.Add(cpus) // One for each RoutineHandshake
|
device.queue.encryption.wg.Add(cpus) // One for each RoutineHandshake
|
||||||
for i := 0; i < cpus; i++ {
|
for i := 0; i < cpus; i++ {
|
||||||
go device.RoutineEncryption()
|
go device.RoutineEncryption(i + 1)
|
||||||
go device.RoutineDecryption()
|
go device.RoutineDecryption(i + 1)
|
||||||
go device.RoutineHandshake()
|
go device.RoutineHandshake(i + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
device.state.stopping.Add(1) // RoutineReadFromTUN
|
device.state.stopping.Add(1) // RoutineReadFromTUN
|
||||||
|
@ -98,7 +98,7 @@ func (device *Device) RoutineReceiveIncoming(recv conn.ReceiveFunc) {
|
|||||||
if errors.Is(err, net.ErrClosed) {
|
if errors.Is(err, net.ErrClosed) {
|
||||||
return
|
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() {
|
if neterr, ok := err.(net.Error); ok && !neterr.Temporary() {
|
||||||
return
|
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
|
var nonce [chacha20poly1305.NonceSize]byte
|
||||||
|
|
||||||
defer device.log.Verbosef("Routine: decryption worker - stopped")
|
defer device.log.Verbosef("Routine: decryption worker %d - stopped", id)
|
||||||
device.log.Verbosef("Routine: decryption worker - started")
|
device.log.Verbosef("Routine: decryption worker %d - started", id)
|
||||||
|
|
||||||
for elem := range device.queue.decryption.c {
|
for elem := range device.queue.decryption.c {
|
||||||
// split message into fields
|
// split message into fields
|
||||||
@ -234,12 +234,12 @@ func (device *Device) RoutineDecryption() {
|
|||||||
|
|
||||||
/* Handles incoming packets related to handshake
|
/* Handles incoming packets related to handshake
|
||||||
*/
|
*/
|
||||||
func (device *Device) RoutineHandshake() {
|
func (device *Device) RoutineHandshake(id int) {
|
||||||
defer func() {
|
defer func() {
|
||||||
device.log.Verbosef("Routine: handshake worker - stopped")
|
device.log.Verbosef("Routine: handshake worker %d - stopped", id)
|
||||||
device.queue.encryption.wg.Done()
|
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 {
|
for elem := range device.queue.handshake.c {
|
||||||
|
|
||||||
|
@ -362,12 +362,12 @@ func calculatePaddingSize(packetSize, mtu int) int {
|
|||||||
*
|
*
|
||||||
* Obs. One instance per core
|
* Obs. One instance per core
|
||||||
*/
|
*/
|
||||||
func (device *Device) RoutineEncryption() {
|
func (device *Device) RoutineEncryption(id int) {
|
||||||
var paddingZeros [PaddingMultiple]byte
|
var paddingZeros [PaddingMultiple]byte
|
||||||
var nonce [chacha20poly1305.NonceSize]byte
|
var nonce [chacha20poly1305.NonceSize]byte
|
||||||
|
|
||||||
defer device.log.Verbosef("Routine: encryption worker - stopped")
|
defer device.log.Verbosef("Routine: encryption worker %d - stopped", id)
|
||||||
device.log.Verbosef("Routine: encryption worker - started")
|
device.log.Verbosef("Routine: encryption worker %d - started", id)
|
||||||
|
|
||||||
for elem := range device.queue.encryption.c {
|
for elem := range device.queue.encryption.c {
|
||||||
// populate header fields
|
// populate header fields
|
||||||
|
Loading…
Reference in New Issue
Block a user