From 6dfb94eaa3bd0fcaa615f58e915f7214ce078beb Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Fri, 19 Apr 2024 17:00:11 +0200 Subject: [PATCH] unix: add types for SOCK_DIAG Change-Id: Ifcc90735b6e42b6c9971d4ba15c31b8169e005fe Reviewed-on: https://go-review.googlesource.com/c/sys/+/579996 Reviewed-by: Cherry Mui Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Tobias Klauser LUCI-TryBot-Result: Go LUCI --- unix/linux/types.go | 31 +++++++++++++++++++++++++++++++ unix/mkerrors.sh | 2 ++ unix/zerrors_linux.go | 4 ++++ unix/ztypes_linux.go | 31 +++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/unix/linux/types.go b/unix/linux/types.go index 2665d5e55..a6f44f4bb 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -143,6 +143,7 @@ struct termios2 { #include #undef kernel_sched_param #include +#include #include #include #include @@ -5917,3 +5918,33 @@ const SizeofSchedAttr = C.sizeof_struct_sched_attr type Cachestat_t C.struct_cachestat type CachestatRange C.struct_cachestat_range + +// generated by: +// $ perl -nlE '/^\s*((SK_|SKNLGRP_)\w+)/ && say "$1 = C.$1"' /usr/include/linux/sock_diag.h +const ( + SK_MEMINFO_RMEM_ALLOC = C.SK_MEMINFO_RMEM_ALLOC + SK_MEMINFO_RCVBUF = C.SK_MEMINFO_RCVBUF + SK_MEMINFO_WMEM_ALLOC = C.SK_MEMINFO_WMEM_ALLOC + SK_MEMINFO_SNDBUF = C.SK_MEMINFO_SNDBUF + SK_MEMINFO_FWD_ALLOC = C.SK_MEMINFO_FWD_ALLOC + SK_MEMINFO_WMEM_QUEUED = C.SK_MEMINFO_WMEM_QUEUED + SK_MEMINFO_OPTMEM = C.SK_MEMINFO_OPTMEM + SK_MEMINFO_BACKLOG = C.SK_MEMINFO_BACKLOG + SK_MEMINFO_DROPS = C.SK_MEMINFO_DROPS + SK_MEMINFO_VARS = C.SK_MEMINFO_VARS + SKNLGRP_NONE = C.SKNLGRP_NONE + SKNLGRP_INET_TCP_DESTROY = C.SKNLGRP_INET_TCP_DESTROY + SKNLGRP_INET_UDP_DESTROY = C.SKNLGRP_INET_UDP_DESTROY + SKNLGRP_INET6_TCP_DESTROY = C.SKNLGRP_INET6_TCP_DESTROY + SKNLGRP_INET6_UDP_DESTROY = C.SKNLGRP_INET6_UDP_DESTROY + SK_DIAG_BPF_STORAGE_REQ_NONE = C.SK_DIAG_BPF_STORAGE_REQ_NONE + SK_DIAG_BPF_STORAGE_REQ_MAP_FD = C.SK_DIAG_BPF_STORAGE_REQ_MAP_FD + SK_DIAG_BPF_STORAGE_REP_NONE = C.SK_DIAG_BPF_STORAGE_REP_NONE + SK_DIAG_BPF_STORAGE = C.SK_DIAG_BPF_STORAGE + SK_DIAG_BPF_STORAGE_NONE = C.SK_DIAG_BPF_STORAGE_NONE + SK_DIAG_BPF_STORAGE_PAD = C.SK_DIAG_BPF_STORAGE_PAD + SK_DIAG_BPF_STORAGE_MAP_ID = C.SK_DIAG_BPF_STORAGE_MAP_ID + SK_DIAG_BPF_STORAGE_MAP_VALUE = C.SK_DIAG_BPF_STORAGE_MAP_VALUE +) + +type SockDiagReq C.struct_sock_diag_req diff --git a/unix/mkerrors.sh b/unix/mkerrors.sh index fdcaa974d..4ed2e488b 100755 --- a/unix/mkerrors.sh +++ b/unix/mkerrors.sh @@ -263,6 +263,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -549,6 +550,7 @@ ccflags="$@" $2 !~ "NLA_TYPE_MASK" && $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ && $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ || + $2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ || $2 ~ /^FIORDCHK$/ || $2 ~ /^SIOC/ || $2 ~ /^TIOC/ || diff --git a/unix/zerrors_linux.go b/unix/zerrors_linux.go index 93a38a97d..f9dde70ef 100644 --- a/unix/zerrors_linux.go +++ b/unix/zerrors_linux.go @@ -3051,6 +3051,8 @@ const ( SIOCSMIIREG = 0x8949 SIOCSRARP = 0x8962 SIOCWANDEV = 0x894a + SK_DIAG_BPF_STORAGE_MAX = 0x3 + SK_DIAG_BPF_STORAGE_REQ_MAX = 0x1 SMACK_MAGIC = 0x43415d53 SMART_AUTOSAVE = 0xd2 SMART_AUTO_OFFLINE = 0xdb @@ -3071,6 +3073,8 @@ const ( SOCKFS_MAGIC = 0x534f434b SOCK_BUF_LOCK_MASK = 0x3 SOCK_DCCP = 0x6 + SOCK_DESTROY = 0x15 + SOCK_DIAG_BY_FAMILY = 0x14 SOCK_IOC_TYPE = 0x89 SOCK_PACKET = 0xa SOCK_RAW = 0x3 diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index 0036746ea..d4e476b7e 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -6001,3 +6001,34 @@ type CachestatRange struct { Off uint64 Len uint64 } + +const ( + SK_MEMINFO_RMEM_ALLOC = 0x0 + SK_MEMINFO_RCVBUF = 0x1 + SK_MEMINFO_WMEM_ALLOC = 0x2 + SK_MEMINFO_SNDBUF = 0x3 + SK_MEMINFO_FWD_ALLOC = 0x4 + SK_MEMINFO_WMEM_QUEUED = 0x5 + SK_MEMINFO_OPTMEM = 0x6 + SK_MEMINFO_BACKLOG = 0x7 + SK_MEMINFO_DROPS = 0x8 + SK_MEMINFO_VARS = 0x9 + SKNLGRP_NONE = 0x0 + SKNLGRP_INET_TCP_DESTROY = 0x1 + SKNLGRP_INET_UDP_DESTROY = 0x2 + SKNLGRP_INET6_TCP_DESTROY = 0x3 + SKNLGRP_INET6_UDP_DESTROY = 0x4 + SK_DIAG_BPF_STORAGE_REQ_NONE = 0x0 + SK_DIAG_BPF_STORAGE_REQ_MAP_FD = 0x1 + SK_DIAG_BPF_STORAGE_REP_NONE = 0x0 + SK_DIAG_BPF_STORAGE = 0x1 + SK_DIAG_BPF_STORAGE_NONE = 0x0 + SK_DIAG_BPF_STORAGE_PAD = 0x1 + SK_DIAG_BPF_STORAGE_MAP_ID = 0x2 + SK_DIAG_BPF_STORAGE_MAP_VALUE = 0x3 +) + +type SockDiagReq struct { + Family uint8 + Protocol uint8 +}