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:
@@ -46,6 +46,13 @@ type Wireguard struct {
|
||||
// It defaults to "auto" and cannot be the empty string
|
||||
// in the internal state.
|
||||
Implementation string `json:"implementation"`
|
||||
// GSO enables wireguard-go's GRO/GSO batched TUN I/O by creating
|
||||
// the WireGuard TUN device with IFF_VNET_HDR. It should be disabled
|
||||
// on kernels (e.g. certain NAS devices) that claim IFF_VNET_HDR
|
||||
// support but return EINVAL when wireguard-go writes GRO-coalesced
|
||||
// packets with virtio_net_hdr structs under load.
|
||||
// It defaults to true and cannot be nil in the internal state.
|
||||
GSO *bool `json:"gso"`
|
||||
}
|
||||
|
||||
var regexpInterfaceName = regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
|
||||
@@ -136,6 +143,7 @@ func (w *Wireguard) copy() (copied Wireguard) {
|
||||
Interface: w.Interface,
|
||||
MTU: w.MTU,
|
||||
Implementation: w.Implementation,
|
||||
GSO: gosettings.CopyPointer(w.GSO),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +157,7 @@ func (w *Wireguard) overrideWith(other Wireguard) {
|
||||
w.Interface = gosettings.OverrideWithComparable(w.Interface, other.Interface)
|
||||
w.MTU = gosettings.OverrideWithComparable(w.MTU, other.MTU)
|
||||
w.Implementation = gosettings.OverrideWithComparable(w.Implementation, other.Implementation)
|
||||
w.GSO = gosettings.OverrideWithPointer(w.GSO, other.GSO)
|
||||
}
|
||||
|
||||
func (w *Wireguard) setDefaults(vpnProvider string) {
|
||||
@@ -173,6 +182,7 @@ func (w *Wireguard) setDefaults(vpnProvider string) {
|
||||
w.Interface = gosettings.DefaultComparable(w.Interface, "wg0")
|
||||
w.MTU = gosettings.DefaultPointer(w.MTU, 0)
|
||||
w.Implementation = gosettings.DefaultComparable(w.Implementation, "auto")
|
||||
w.GSO = gosettings.DefaultPointer(w.GSO, true)
|
||||
}
|
||||
|
||||
func (w Wireguard) String() string {
|
||||
@@ -217,6 +227,10 @@ func (w Wireguard) toLinesNode() (node *gotree.Node) {
|
||||
node.Appendf("Implementation: %s", w.Implementation)
|
||||
}
|
||||
|
||||
if !*w.GSO {
|
||||
node.Append("GSO disabled")
|
||||
}
|
||||
|
||||
return node
|
||||
}
|
||||
|
||||
@@ -265,5 +279,11 @@ func (w *Wireguard) read(r *reader.Reader, amneziaWG bool) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
w.GSO, err = r.BoolPtr("WIREGUARD_GSO")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user