unix: add types for SOCK_DIAG
Change-Id: Ifcc90735b6e42b6c9971d4ba15c31b8169e005fe
Reviewed-on: https://go-review.googlesource.com/c/sys/+/579996
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/unix/linux/types.go b/unix/linux/types.go
index 2665d5e..a6f44f4 100644
--- a/unix/linux/types.go
+++ b/unix/linux/types.go
@@ -143,6 +143,7 @@
#include <linux/sched/types.h>
#undef kernel_sched_param
#include <linux/shm.h>
+#include <linux/sock_diag.h>
#include <linux/socket.h>
#include <linux/stat.h>
#include <linux/taskstats.h>
@@ -5917,3 +5918,33 @@
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 fdcaa97..4ed2e48 100755
--- a/unix/mkerrors.sh
+++ b/unix/mkerrors.sh
@@ -263,6 +263,7 @@
#include <linux/sched.h>
#include <linux/seccomp.h>
#include <linux/serial.h>
+#include <linux/sock_diag.h>
#include <linux/sockios.h>
#include <linux/taskstats.h>
#include <linux/tipc.h>
@@ -549,6 +550,7 @@
$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 93a38a9..f9dde70 100644
--- a/unix/zerrors_linux.go
+++ b/unix/zerrors_linux.go
@@ -3051,6 +3051,8 @@
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 @@
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 0036746..d4e476b 100644
--- a/unix/ztypes_linux.go
+++ b/unix/ztypes_linux.go
@@ -6001,3 +6001,34 @@
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
+}