errors_linux.go 757 B

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