diff --git a/cpu/cpu_linux_mips64x.go b/cpu/cpu_linux_mips64x.go index eb24e507..5a418900 100644 --- a/cpu/cpu_linux_mips64x.go +++ b/cpu/cpu_linux_mips64x.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build linux // +build mips64 mips64le package cpu diff --git a/unix/linux/types.go b/unix/linux/types.go index b1daba7f..1f9176bd 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -105,6 +105,7 @@ struct termios2 { #include #include #include +#include #include #include #include @@ -1076,6 +1077,13 @@ const ( PERF_SAMPLE_STREAM_ID = C.PERF_SAMPLE_STREAM_ID PERF_SAMPLE_RAW = C.PERF_SAMPLE_RAW PERF_SAMPLE_BRANCH_STACK = C.PERF_SAMPLE_BRANCH_STACK + PERF_SAMPLE_REGS_USER = C.PERF_SAMPLE_REGS_USER + PERF_SAMPLE_STACK_USER = C.PERF_SAMPLE_STACK_USER + PERF_SAMPLE_WEIGHT = C.PERF_SAMPLE_WEIGHT + PERF_SAMPLE_DATA_SRC = C.PERF_SAMPLE_DATA_SRC + PERF_SAMPLE_IDENTIFIER = C.PERF_SAMPLE_IDENTIFIER + PERF_SAMPLE_TRANSACTION = C.PERF_SAMPLE_TRANSACTION + PERF_SAMPLE_REGS_INTR = C.PERF_SAMPLE_REGS_INTR PERF_SAMPLE_BRANCH_USER = C.PERF_SAMPLE_BRANCH_USER PERF_SAMPLE_BRANCH_KERNEL = C.PERF_SAMPLE_BRANCH_KERNEL @@ -1735,6 +1743,24 @@ const ( NFT_NG_RANDOM = C.NFT_NG_RANDOM ) +// netfilter nf_tables_compat +// generated using: +// perl -nlE '/^\s*(NFT\w+)/ && say "$1 = C.$1"' /usr/include/linux/netfilter/nf_tables_compat.h +const ( + NFTA_TARGET_UNSPEC = C.NFTA_TARGET_UNSPEC + NFTA_TARGET_NAME = C.NFTA_TARGET_NAME + NFTA_TARGET_REV = C.NFTA_TARGET_REV + NFTA_TARGET_INFO = C.NFTA_TARGET_INFO + NFTA_MATCH_UNSPEC = C.NFTA_MATCH_UNSPEC + NFTA_MATCH_NAME = C.NFTA_MATCH_NAME + NFTA_MATCH_REV = C.NFTA_MATCH_REV + NFTA_MATCH_INFO = C.NFTA_MATCH_INFO + NFTA_COMPAT_UNSPEC = C.NFTA_COMPAT_UNSPEC + NFTA_COMPAT_NAME = C.NFTA_COMPAT_NAME + NFTA_COMPAT_REV = C.NFTA_COMPAT_REV + NFTA_COMPAT_TYPE = C.NFTA_COMPAT_TYPE +) + type RTCTime C.struct_rtc_time type RTCWkAlrm C.struct_rtc_wkalrm diff --git a/unix/mksysctl_openbsd.go b/unix/mksysctl_openbsd.go index b6b40990..28b27364 100644 --- a/unix/mksysctl_openbsd.go +++ b/unix/mksysctl_openbsd.go @@ -163,12 +163,10 @@ func main() { `netinet/ip_gre.h`, `netinet/ip_ipcomp.h`, `netinet/ip_ipip.h`, - `netinet/pim_var.h`, `netinet/tcp_var.h`, `netinet/udp_var.h`, `netinet6/in6.h`, `netinet6/ip6_divert.h`, - `netinet6/pim6_var.h`, `netinet/icmp6.h`, `netmpls/mpls.h`, } @@ -211,14 +209,12 @@ func main() { `net.inet.ipip`, `net.inet.mobileip`, `net.inet.pfsync`, - `net.inet.pim`, `net.inet.tcp`, `net.inet.udp`, `net.inet6`, `net.inet6.divert`, `net.inet6.ip6`, `net.inet6.icmp6`, - `net.inet6.pim6`, `net.inet6.tcp6`, `net.inet6.udp6`, `net.mpls`, diff --git a/unix/syscall_internal_linux_test.go b/unix/syscall_internal_linux_test.go index 40d3aca8..8af671ef 100644 --- a/unix/syscall_internal_linux_test.go +++ b/unix/syscall_internal_linux_test.go @@ -168,6 +168,24 @@ func Test_anyToSockaddr(t *testing.T) { Name: " ", }, }, + { + name: "AF_CAN", + rsa: sockaddrCANToAny(RawSockaddrCAN{ + Family: AF_CAN, + Ifindex: 12345678, + Addr: [16]byte{ + 0x89, 0x67, 0x45, 0x23, + 0x90, 0x78, 0x56, 0x34, + 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, + }, + }), + sa: &SockaddrCAN{ + Ifindex: 12345678, + RxID: 0x23456789, + TxID: 0x34567890, + }, + }, { name: "AF_MAX EAFNOSUPPORT", rsa: &RawSockaddrAny{ @@ -544,6 +562,62 @@ func TestSockaddrIUCV_sockaddr(t *testing.T) { } } +func TestSockaddrCAN_sockaddr(t *testing.T) { + tests := []struct { + name string + sa *SockaddrCAN + raw *RawSockaddrCAN + err error + }{ + { + name: "with ids", + sa: &SockaddrCAN{ + Ifindex: 12345678, + RxID: 0x23456789, + TxID: 0x34567890, + }, + raw: &RawSockaddrCAN{ + Family: AF_CAN, + Ifindex: 12345678, + Addr: [16]byte{ + 0x89, 0x67, 0x45, 0x23, + 0x90, 0x78, 0x56, 0x34, + 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, + }, + }, + }, + { + name: "negative ifindex", + sa: &SockaddrCAN{ + Ifindex: -1, + }, + err: EINVAL, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + out, l, err := tt.sa.sockaddr() + if err != tt.err { + t.Fatalf("unexpected error: %v, want: %v", err, tt.err) + } + + // Must be 0 on error or a fixed size otherwise. + if (tt.err != nil && l != 0) || (tt.raw != nil && l != SizeofSockaddrCAN) { + t.Fatalf("unexpected Socklen: %d", l) + } + + if out != nil { + raw := (*RawSockaddrCAN)(out) + if !reflect.DeepEqual(raw, tt.raw) { + t.Fatalf("unexpected RawSockaddrCAN:\n got: %#v\nwant: %#v", raw, tt.raw) + } + } + }) + } +} + // These helpers explicitly copy the contents of in into out to produce // the correct sockaddr structure, without relying on unsafe casting to // a type of a larger size. @@ -591,3 +665,12 @@ func sockaddrIUCVToAny(in RawSockaddrIUCV) *RawSockaddrAny { ) return &out } + +func sockaddrCANToAny(in RawSockaddrCAN) *RawSockaddrAny { + var out RawSockaddrAny + copy( + (*(*[SizeofSockaddrAny]byte)(unsafe.Pointer(&out)))[:], + (*(*[SizeofSockaddrCAN]byte)(unsafe.Pointer(&in)))[:], + ) + return &out +} diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index c48f5dda..3e20fcf5 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -1111,6 +1111,21 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { } return sa, nil + case AF_CAN: + pp := (*RawSockaddrCAN)(unsafe.Pointer(rsa)) + sa := &SockaddrCAN{ + Ifindex: int(pp.Ifindex), + } + rx := (*[4]byte)(unsafe.Pointer(&sa.RxID)) + for i := 0; i < 4; i++ { + rx[i] = pp.Addr[i] + } + tx := (*[4]byte)(unsafe.Pointer(&sa.TxID)) + for i := 0; i < 4; i++ { + tx[i] = pp.Addr[i+4] + } + return sa, nil + } return nil, EAFNOSUPPORT } diff --git a/unix/syscall_linux_arm.go b/unix/syscall_linux_arm.go index e1913e2c..496837b1 100644 --- a/unix/syscall_linux_arm.go +++ b/unix/syscall_linux_arm.go @@ -7,7 +7,6 @@ package unix import ( - "syscall" "unsafe" ) @@ -49,10 +48,6 @@ func Pipe2(p []int, flags int) (err error) { return } -// Underlying system call writes to newoffset via pointer. -// Implemented in assembly to avoid allocation. -func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) - func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { newoffset, errno := seek(fd, offset, whence) if errno != 0 { diff --git a/unix/syscall_linux_gc_arm.go b/unix/syscall_linux_gc_arm.go new file mode 100644 index 00000000..8c514c95 --- /dev/null +++ b/unix/syscall_linux_gc_arm.go @@ -0,0 +1,13 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build arm,!gccgo,linux + +package unix + +import "syscall" + +// Underlying system call writes to newoffset via pointer. +// Implemented in assembly to avoid allocation. +func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index 77449a9e..953166c7 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -1016,6 +1016,13 @@ const ( PERF_SAMPLE_STREAM_ID = 0x200 PERF_SAMPLE_RAW = 0x400 PERF_SAMPLE_BRANCH_STACK = 0x800 + PERF_SAMPLE_REGS_USER = 0x1000 + PERF_SAMPLE_STACK_USER = 0x2000 + PERF_SAMPLE_WEIGHT = 0x4000 + PERF_SAMPLE_DATA_SRC = 0x8000 + PERF_SAMPLE_IDENTIFIER = 0x10000 + PERF_SAMPLE_TRANSACTION = 0x20000 + PERF_SAMPLE_REGS_INTR = 0x40000 PERF_SAMPLE_BRANCH_USER = 0x1 PERF_SAMPLE_BRANCH_KERNEL = 0x2 @@ -1745,6 +1752,21 @@ const ( NFT_NG_RANDOM = 0x1 ) +const ( + NFTA_TARGET_UNSPEC = 0x0 + NFTA_TARGET_NAME = 0x1 + NFTA_TARGET_REV = 0x2 + NFTA_TARGET_INFO = 0x3 + NFTA_MATCH_UNSPEC = 0x0 + NFTA_MATCH_NAME = 0x1 + NFTA_MATCH_REV = 0x2 + NFTA_MATCH_INFO = 0x3 + NFTA_COMPAT_UNSPEC = 0x0 + NFTA_COMPAT_NAME = 0x1 + NFTA_COMPAT_REV = 0x2 + NFTA_COMPAT_TYPE = 0x3 +) + type RTCTime struct { Sec int32 Min int32