mirror of
https://github.com/qdm12/gluetun.git
synced 2026-08-05 03:43:24 +02:00
feat(wireguard): WIREGUARD_GSO option to disable TUN vnet hdr batching (#3424)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package wireguard
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"golang.zx2c4.com/wireguard/device"
|
||||
)
|
||||
|
||||
@@ -10,6 +14,7 @@ type Logger interface {
|
||||
Debug(s string)
|
||||
Debugf(format string, args ...interface{})
|
||||
Info(s string)
|
||||
Warn(s string)
|
||||
Error(s string)
|
||||
Erroer
|
||||
}
|
||||
@@ -18,9 +23,28 @@ type Erroer interface {
|
||||
Errorf(format string, args ...any)
|
||||
}
|
||||
|
||||
func makeDeviceLogger(logger Logger) (deviceLogger *device.Logger) {
|
||||
func makeDeviceLogger(logger Logger, gso bool) (deviceLogger *device.Logger) {
|
||||
errorf := logger.Errorf
|
||||
if gso {
|
||||
// Kernels advertising IFF_VNET_HDR support but rejecting
|
||||
// GRO-coalesced writes make wireguard-go log this error for
|
||||
// each failed write batch, see
|
||||
// https://github.com/tailscale/tailscale/issues/13041
|
||||
var suggestOnce sync.Once
|
||||
errorf = func(format string, args ...any) {
|
||||
logger.Errorf(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if strings.Contains(message, "Failed to write packets to TUN device") &&
|
||||
strings.Contains(message, "invalid argument") {
|
||||
suggestOnce.Do(func() {
|
||||
logger.Warn("The kernel seems to reject GRO-coalesced writes to " +
|
||||
"the TUN device; consider setting WIREGUARD_GSO=off")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return &device.Logger{
|
||||
Verbosef: logger.Debugf,
|
||||
Errorf: logger.Errorf,
|
||||
Errorf: errorf,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user