aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2023-03-02 16:17:12 +0100
committerGopher Robot <gobot@golang.org>2023-03-02 17:30:46 +0000
commit147085206c054f6dff27a858c8cff1f289ec5339 (patch)
tree5b8b54d415eb6b4d277e24d2a6d5f7ceaad5cb73
parenta6bfb89d2fda1be39bf24b33d59fee29d65bf76f (diff)
downloadgolang-x-sys-147085206c054f6dff27a858c8cff1f289ec5339.tar.gz
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 <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
-rw-r--r--unix/mkpost.go9
-rw-r--r--unix/syscall_linux.go4
-rw-r--r--unix/ztypes_linux_386.go2
-rw-r--r--unix/ztypes_linux_amd64.go2
-rw-r--r--unix/ztypes_linux_arm.go2
-rw-r--r--unix/ztypes_linux_arm64.go2
-rw-r--r--unix/ztypes_linux_loong64.go2
-rw-r--r--unix/ztypes_linux_mips.go2
-rw-r--r--unix/ztypes_linux_mips64.go2
-rw-r--r--unix/ztypes_linux_mips64le.go2
-rw-r--r--unix/ztypes_linux_mipsle.go2
-rw-r--r--unix/ztypes_linux_ppc.go2
-rw-r--r--unix/ztypes_linux_ppc64.go2
-rw-r--r--unix/ztypes_linux_ppc64le.go2
-rw-r--r--unix/ztypes_linux_riscv64.go2
-rw-r--r--unix/ztypes_linux_s390x.go2
-rw-r--r--unix/ztypes_linux_sparc64.go2
17 files changed, 28 insertions, 15 deletions
diff --git a/unix/mkpost.go b/unix/mkpost.go
index 783f11d..ec31df2 100644
--- a/unix/mkpost.go
+++ b/unix/mkpost.go
@@ -110,6 +110,15 @@ func main() {
icmpV6Regex := regexp.MustCompile(`type (ICMPv6Filter) struct {(\s+)X__icmp6_filt(\s+\S+\s+)}`)
b = icmpV6Regex.ReplaceAll(b, []byte("type $1 struct {${2}Filt$3}"))
+ // Intentionally export address storage field in SockaddrStorage convert it to [N]byte.
+ convertSockaddrStorageData := regexp.MustCompile(`(X__ss_padding)\s+\[(\d+)\]u?int8`)
+ sockaddrStorageType := regexp.MustCompile(`type SockaddrStorage struct {[^}]*}`)
+ sockaddrStorageStructs := sockaddrStorageType.FindAll(b, -1)
+ for _, s := range sockaddrStorageStructs {
+ newNames := convertSockaddrStorageData.ReplaceAll(s, []byte("Data [$2]byte"))
+ b = bytes.Replace(b, s, newNames, 1)
+ }
+
// If we have empty Ptrace structs, we should delete them. Only s390x emits
// nonempty Ptrace structs.
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go
index bbcad67..9735331 100644
--- a/unix/syscall_linux.go
+++ b/unix/syscall_linux.go
@@ -1364,6 +1364,10 @@ func SetsockoptTCPRepairOpt(fd, level, opt int, o []TCPRepairOpt) (err error) {
return setsockopt(fd, level, opt, unsafe.Pointer(&o[0]), uintptr(SizeofTCPRepairOpt*len(o)))
}
+func SetsockoptTCPMD5Sig(fd, level, opt int, s *TCPMD5Sig) error {
+ return setsockopt(fd, level, opt, unsafe.Pointer(s), unsafe.Sizeof(*s))
+}
+
// Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html)
// KeyctlInt calls keyctl commands in which each argument is an int.
diff --git a/unix/ztypes_linux_386.go b/unix/ztypes_linux_386.go
index 89c516a..4ecc149 100644
--- a/unix/ztypes_linux_386.go
+++ b/unix/ztypes_linux_386.go
@@ -414,7 +414,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [122]int8
+ Data [122]byte
_ uint32
}
diff --git a/unix/ztypes_linux_amd64.go b/unix/ztypes_linux_amd64.go
index 62b4fb2..34fddff 100644
--- a/unix/ztypes_linux_amd64.go
+++ b/unix/ztypes_linux_amd64.go
@@ -427,7 +427,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]int8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_arm.go b/unix/ztypes_linux_arm.go
index e86b358..3b14a60 100644
--- a/unix/ztypes_linux_arm.go
+++ b/unix/ztypes_linux_arm.go
@@ -405,7 +405,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [122]uint8
+ Data [122]byte
_ uint32
}
diff --git a/unix/ztypes_linux_arm64.go b/unix/ztypes_linux_arm64.go
index 6c6be4c..0517651 100644
--- a/unix/ztypes_linux_arm64.go
+++ b/unix/ztypes_linux_arm64.go
@@ -406,7 +406,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]int8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_loong64.go b/unix/ztypes_linux_loong64.go
index 4982ea3..3b0c518 100644
--- a/unix/ztypes_linux_loong64.go
+++ b/unix/ztypes_linux_loong64.go
@@ -407,7 +407,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]int8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_mips.go b/unix/ztypes_linux_mips.go
index 173141a..fccdf4d 100644
--- a/unix/ztypes_linux_mips.go
+++ b/unix/ztypes_linux_mips.go
@@ -410,7 +410,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [122]int8
+ Data [122]byte
_ uint32
}
diff --git a/unix/ztypes_linux_mips64.go b/unix/ztypes_linux_mips64.go
index 93ae4c5..500de8f 100644
--- a/unix/ztypes_linux_mips64.go
+++ b/unix/ztypes_linux_mips64.go
@@ -409,7 +409,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]int8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_mips64le.go b/unix/ztypes_linux_mips64le.go
index 4e4e510..d0434cd 100644
--- a/unix/ztypes_linux_mips64le.go
+++ b/unix/ztypes_linux_mips64le.go
@@ -409,7 +409,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]int8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_mipsle.go b/unix/ztypes_linux_mipsle.go
index 3f5ba01..84206ba 100644
--- a/unix/ztypes_linux_mipsle.go
+++ b/unix/ztypes_linux_mipsle.go
@@ -410,7 +410,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [122]int8
+ Data [122]byte
_ uint32
}
diff --git a/unix/ztypes_linux_ppc.go b/unix/ztypes_linux_ppc.go
index 71dfe7c..ab078cf 100644
--- a/unix/ztypes_linux_ppc.go
+++ b/unix/ztypes_linux_ppc.go
@@ -417,7 +417,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [122]uint8
+ Data [122]byte
_ uint32
}
diff --git a/unix/ztypes_linux_ppc64.go b/unix/ztypes_linux_ppc64.go
index 3a2b7f0..42eb2c4 100644
--- a/unix/ztypes_linux_ppc64.go
+++ b/unix/ztypes_linux_ppc64.go
@@ -416,7 +416,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]uint8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_ppc64le.go b/unix/ztypes_linux_ppc64le.go
index a52d627..31304a4 100644
--- a/unix/ztypes_linux_ppc64le.go
+++ b/unix/ztypes_linux_ppc64le.go
@@ -416,7 +416,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]uint8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_riscv64.go b/unix/ztypes_linux_riscv64.go
index dfc007d..c311f96 100644
--- a/unix/ztypes_linux_riscv64.go
+++ b/unix/ztypes_linux_riscv64.go
@@ -434,7 +434,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]uint8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_s390x.go b/unix/ztypes_linux_s390x.go
index b53cb91..bba3cef 100644
--- a/unix/ztypes_linux_s390x.go
+++ b/unix/ztypes_linux_s390x.go
@@ -429,7 +429,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]int8
+ Data [118]byte
_ uint64
}
diff --git a/unix/ztypes_linux_sparc64.go b/unix/ztypes_linux_sparc64.go
index fe0aa35..ad8a013 100644
--- a/unix/ztypes_linux_sparc64.go
+++ b/unix/ztypes_linux_sparc64.go
@@ -411,7 +411,7 @@ const (
type SockaddrStorage struct {
Family uint16
- _ [118]int8
+ Data [118]byte
_ uint64
}