neterror_linux.go 768 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package neterror
  4. import (
  5. "errors"
  6. "os"
  7. "golang.org/x/sys/unix"
  8. )
  9. func init() {
  10. shouldDisableUDPGSO = func(err error) bool {
  11. var serr *os.SyscallError
  12. if errors.As(err, &serr) {
  13. // EIO is returned by udp_send_skb() if the device driver does not
  14. // have tx checksumming enabled, which is a hard requirement of
  15. // UDP_SEGMENT. See:
  16. // https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/man7/udp.7?id=806eabd74910447f21005160e90957bde4db0183#n228
  17. // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/udp.c?h=v6.2&id=c9c3395d5e3dcc6daee66c6908354d47bf98cb0c#n942
  18. return serr.Err == unix.EIO
  19. }
  20. return false
  21. }
  22. }