]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: handle broader range of errors in RoutineReceiveIncoming
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 30 Mar 2021 19:36:59 +0000 (12:36 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 30 Mar 2021 19:41:43 +0000 (12:41 -0700)
RoutineReceiveIncoming exits immediately on net.ErrClosed,
but not on other errors. However, for errors that are known
to be permanent, such as syscall.EAFNOSUPPORT,
we may as well exit immediately instead of retrying.

This considerably speeds up the package device tests right now,
because the Bind sometimes (incorrectly) returns syscall.EAFNOSUPPORT
instead of net.ErrClosed.

Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
device/receive.go

index b1959c69ebcc2b1083e9c4594c79b20554d694fd..5ddb66c015f1ae2aabb174ea786d11d80a1cd1f0 100644 (file)
@@ -104,6 +104,9 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind conn.Bind) {
                        if errors.Is(err, net.ErrClosed) {
                                return
                        }
+                       if neterr, ok := err.(net.Error); ok && !neterr.Temporary() {
+                               return
+                       }
                        device.log.Errorf("Failed to receive packet: %v", err)
                        if deathSpiral < 10 {
                                deathSpiral++