forked from WireGuard/wireguard-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'WireGuard:master' into main
- Loading branch information
Showing
32 changed files
with
1,242 additions
and
499 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build !windows && !linux && !js | ||
//go:build !windows && !linux && !wasm | ||
|
||
/* SPDX-License-Identifier: MIT | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build !linux | ||
|
||
/* SPDX-License-Identifier: MIT | ||
* | ||
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. | ||
*/ | ||
|
||
package conn | ||
|
||
func errShouldDisableUDPGSO(err error) bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* SPDX-License-Identifier: MIT | ||
* | ||
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. | ||
*/ | ||
|
||
package conn | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
func errShouldDisableUDPGSO(err error) bool { | ||
var serr *os.SyscallError | ||
if errors.As(err, &serr) { | ||
// EIO is returned by udp_send_skb() if the device driver does not have | ||
// tx checksumming enabled, which is a hard requirement of UDP_SEGMENT. | ||
// See: | ||
// https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/man7/udp.7?id=806eabd74910447f21005160e90957bde4db0183#n228 | ||
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/udp.c?h=v6.2&id=c9c3395d5e3dcc6daee66c6908354d47bf98cb0c#n942 | ||
return serr.Err == unix.EIO | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//go:build !linux | ||
// +build !linux | ||
|
||
/* SPDX-License-Identifier: MIT | ||
* | ||
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. | ||
*/ | ||
|
||
package conn | ||
|
||
import "net" | ||
|
||
func supportsUDPOffload(conn *net.UDPConn) (txOffload, rxOffload bool) { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* SPDX-License-Identifier: MIT | ||
* | ||
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. | ||
*/ | ||
|
||
package conn | ||
|
||
import ( | ||
"net" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
func supportsUDPOffload(conn *net.UDPConn) (txOffload, rxOffload bool) { | ||
rc, err := conn.SyscallConn() | ||
if err != nil { | ||
return | ||
} | ||
err = rc.Control(func(fd uintptr) { | ||
_, errSyscall := unix.GetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_SEGMENT) | ||
txOffload = errSyscall == nil | ||
opt, errSyscall := unix.GetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_GRO) | ||
rxOffload = errSyscall == nil && opt == 1 | ||
}) | ||
if err != nil { | ||
return false, false | ||
} | ||
return txOffload, rxOffload | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build !linux | ||
|
||
/* SPDX-License-Identifier: MIT | ||
* | ||
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. | ||
*/ | ||
|
||
package conn | ||
|
||
// getGSOSize parses control for UDP_GRO and if found returns its GSO size data. | ||
func getGSOSize(control []byte) (int, error) { | ||
return 0, nil | ||
} | ||
|
||
// setGSOSize sets a UDP_SEGMENT in control based on gsoSize. | ||
func setGSOSize(control *[]byte, gsoSize uint16) { | ||
} | ||
|
||
// gsoControlSize returns the recommended buffer size for pooling sticky and UDP | ||
// offloading control data. | ||
const gsoControlSize = 0 |
Oops, something went wrong.