udp_openbsd.go 783 B

1234567891011121314151617181920212223
  1. //go:build openbsd && !e2e_testing
  2. // +build openbsd,!e2e_testing
  3. package udp
  4. import (
  5. "golang.org/x/sys/unix"
  6. )
  7. // EnablePathMTUDiscovery sets the don't-fragment bit on outbound packets.
  8. // OpenBSD exposes IPV6_DONTFRAG via golang.org/x/sys/unix but the kernel does
  9. // not provide a socket-level knob for setting DF on v4 UDP. The only IP-layer
  10. // constant exposed is IP_DF, which is the wire header flag, not a sockopt.
  11. // quic-go skips OpenBSD for the same reason. So v4 sockets stay at nebula's
  12. // historical behavior (kernel may fragment); v6 gets DF.
  13. func (u *GenericConn) EnablePathMTUDiscovery() error {
  14. if u.isV4Socket() {
  15. return nil
  16. }
  17. return u.controlFD(func(fd uintptr) error {
  18. return unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_DONTFRAG, 1)
  19. })
  20. }