diff options
author | Josh Bleecher Snyder <josh@tailscale.com> | 2020-12-14 13:34:03 -0800 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-12-15 18:08:24 +0100 |
commit | 6d9ecb7edbe74471d441ee2cce889612455b8354 (patch) | |
tree | eeb2983913169f87e129d1e7cd295bd0efde49c6 | |
parent | 5e92865404f56c6f7f2aaa784d2588f310d2d8a7 (diff) | |
download | wireguard-go-6d9ecb7edbe74471d441ee2cce889612455b8354.tar.gz wireguard-go-6d9ecb7edbe74471d441ee2cce889612455b8354.zip |
device: prevent spurious errors while closing a device
When closing a device, packets that are in flight
can make it to SendBuffer, which then returns an error.
Those errors add noise but no light;
they do not reflect an actual problem.
Adding the synchronization required to prevent
this from occurring is currently expensive and error-prone.
Instead, quietly drop such packets instead of
returning an error.
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
-rw-r--r-- | device/peer.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/device/peer.go b/device/peer.go index 02e145c..c2397cc 100644 --- a/device/peer.go +++ b/device/peer.go @@ -140,6 +140,11 @@ func (peer *Peer) SendBuffer(buffer []byte) error { defer peer.device.net.RUnlock() if peer.device.net.bind == nil { + // Packets can leak through to SendBuffer while the device is closing. + // When that happens, drop them silently to avoid spurious errors. + if peer.device.isClosed.Get() { + return nil + } return errors.New("no bind") } |