Skip to content

Commit 1470852

Browse files
tklausergopherbot
authored andcommitted
unix: add SetsockoptTCPMD5Sig on linux
This allows to set the TCP MD5 signature (see https://www.rfc-editor.org/rfc/rfc2385) using TCPMD5Sig introduced in CL 106656. Also export the storage data field in SockaddrStorage and convert it to a byte array so the address in TCPMD5Sig.Addr can be set from an net.IP without conversion. Change-Id: I6bccfab57c188fcef857a6a3c514c943ca00b670 Reviewed-on: https://go-review.googlesource.com/c/sys/+/472835 Auto-Submit: Tobias Klauser <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Run-TryBot: Tobias Klauser <[email protected]>
1 parent a6bfb89 commit 1470852

17 files changed

+28
-15
lines changed

unix/mkpost.go

+9
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ func main() {
110110
icmpV6Regex := regexp.MustCompile(`type (ICMPv6Filter) struct {(\s+)X__icmp6_filt(\s+\S+\s+)}`)
111111
b = icmpV6Regex.ReplaceAll(b, []byte("type $1 struct {${2}Filt$3}"))
112112

113+
// Intentionally export address storage field in SockaddrStorage convert it to [N]byte.
114+
convertSockaddrStorageData := regexp.MustCompile(`(X__ss_padding)\s+\[(\d+)\]u?int8`)
115+
sockaddrStorageType := regexp.MustCompile(`type SockaddrStorage struct {[^}]*}`)
116+
sockaddrStorageStructs := sockaddrStorageType.FindAll(b, -1)
117+
for _, s := range sockaddrStorageStructs {
118+
newNames := convertSockaddrStorageData.ReplaceAll(s, []byte("Data [$2]byte"))
119+
b = bytes.Replace(b, s, newNames, 1)
120+
}
121+
113122
// If we have empty Ptrace structs, we should delete them. Only s390x emits
114123
// nonempty Ptrace structs.
115124
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)

unix/syscall_linux.go

+4
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,10 @@ func SetsockoptTCPRepairOpt(fd, level, opt int, o []TCPRepairOpt) (err error) {
13641364
return setsockopt(fd, level, opt, unsafe.Pointer(&o[0]), uintptr(SizeofTCPRepairOpt*len(o)))
13651365
}
13661366

1367+
func SetsockoptTCPMD5Sig(fd, level, opt int, s *TCPMD5Sig) error {
1368+
return setsockopt(fd, level, opt, unsafe.Pointer(s), unsafe.Sizeof(*s))
1369+
}
1370+
13671371
// Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html)
13681372

13691373
// KeyctlInt calls keyctl commands in which each argument is an int.

unix/ztypes_linux_386.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_amd64.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_arm.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_arm64.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_loong64.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_mips.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_mips64.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_mips64le.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_mipsle.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_ppc.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_ppc64.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_ppc64le.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_riscv64.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_s390x.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/ztypes_linux_sparc64.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)