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:
@@ -0,0 +1,27 @@
|
||||
package amneziawg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
amneziatun "github.com/amnezia-vpn/amneziawg-go/tun"
|
||||
"github.com/qdm12/gluetun/internal/wireguard"
|
||||
)
|
||||
|
||||
// createTUN creates a TUN device. When gso is false, IFF_VNET_HDR is
|
||||
// omitted so amneziawg-go's initFromFlags sees no vnet header support and
|
||||
// keeps tun.vnetHdr=false, falling back to simple single-packet writes instead
|
||||
// of the GRO/GSO batch path that causes EINVAL on some vendor kernels.
|
||||
func createTUN(name string, mtu int, gso bool) (amneziatun.Device, error) { //nolint:ireturn
|
||||
if gso {
|
||||
return amneziatun.CreateTUN(name, mtu)
|
||||
}
|
||||
tunFile, err := wireguard.OpenTUNFile(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("creating tun fd file: %w", err)
|
||||
}
|
||||
tunDevice, err := amneziatun.CreateTUNFromFile(tunFile, mtu)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("creating TUN device from file: %w", err)
|
||||
}
|
||||
return tunDevice, nil
|
||||
}
|
||||
Reference in New Issue
Block a user