xref: /linux/include/uapi/linux/inet_diag.h (revision b1f3e43dbfacfcd95296b0f80f84b186add9ef54)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells #ifndef _UAPI_INET_DIAG_H_
3607ca46eSDavid Howells #define _UAPI_INET_DIAG_H_
4607ca46eSDavid Howells 
5607ca46eSDavid Howells #include <linux/types.h>
6607ca46eSDavid Howells 
7607ca46eSDavid Howells /* Just some random number */
8607ca46eSDavid Howells #define TCPDIAG_GETSOCK 18
9607ca46eSDavid Howells #define DCCPDIAG_GETSOCK 19
10607ca46eSDavid Howells 
11607ca46eSDavid Howells #define INET_DIAG_GETSOCK_MAX 24
12607ca46eSDavid Howells 
13607ca46eSDavid Howells /* Socket identity */
14607ca46eSDavid Howells struct inet_diag_sockid {
15607ca46eSDavid Howells 	__be16	idiag_sport;
16607ca46eSDavid Howells 	__be16	idiag_dport;
17607ca46eSDavid Howells 	__be32	idiag_src[4];
18607ca46eSDavid Howells 	__be32	idiag_dst[4];
19607ca46eSDavid Howells 	__u32	idiag_if;
20607ca46eSDavid Howells 	__u32	idiag_cookie[2];
21607ca46eSDavid Howells #define INET_DIAG_NOCOOKIE (~0U)
22607ca46eSDavid Howells };
23607ca46eSDavid Howells 
24607ca46eSDavid Howells /* Request structure */
25607ca46eSDavid Howells 
26607ca46eSDavid Howells struct inet_diag_req {
27607ca46eSDavid Howells 	__u8	idiag_family;		/* Family of addresses. */
28607ca46eSDavid Howells 	__u8	idiag_src_len;
29607ca46eSDavid Howells 	__u8	idiag_dst_len;
30607ca46eSDavid Howells 	__u8	idiag_ext;		/* Query extended information */
31607ca46eSDavid Howells 
32607ca46eSDavid Howells 	struct inet_diag_sockid id;
33607ca46eSDavid Howells 
34607ca46eSDavid Howells 	__u32	idiag_states;		/* States to dump */
35607ca46eSDavid Howells 	__u32	idiag_dbs;		/* Tables to dump (NI) */
36607ca46eSDavid Howells };
37607ca46eSDavid Howells 
38607ca46eSDavid Howells struct inet_diag_req_v2 {
39607ca46eSDavid Howells 	__u8	sdiag_family;
40607ca46eSDavid Howells 	__u8	sdiag_protocol;
41607ca46eSDavid Howells 	__u8	idiag_ext;
42607ca46eSDavid Howells 	__u8	pad;
43607ca46eSDavid Howells 	__u32	idiag_states;
44607ca46eSDavid Howells 	struct inet_diag_sockid id;
45607ca46eSDavid Howells };
46607ca46eSDavid Howells 
47432490f9SCyrill Gorcunov /*
48432490f9SCyrill Gorcunov  * SOCK_RAW sockets require the underlied protocol to be
49432490f9SCyrill Gorcunov  * additionally specified so we can use @pad member for
50432490f9SCyrill Gorcunov  * this, but we can't rename it because userspace programs
51432490f9SCyrill Gorcunov  * still may depend on this name. Instead lets use another
52432490f9SCyrill Gorcunov  * structure definition as an alias for struct
53432490f9SCyrill Gorcunov  * @inet_diag_req_v2.
54432490f9SCyrill Gorcunov  */
55432490f9SCyrill Gorcunov struct inet_diag_req_raw {
56432490f9SCyrill Gorcunov 	__u8	sdiag_family;
57432490f9SCyrill Gorcunov 	__u8	sdiag_protocol;
58432490f9SCyrill Gorcunov 	__u8	idiag_ext;
59432490f9SCyrill Gorcunov 	__u8	sdiag_raw_protocol;
60432490f9SCyrill Gorcunov 	__u32	idiag_states;
61432490f9SCyrill Gorcunov 	struct inet_diag_sockid id;
62432490f9SCyrill Gorcunov };
63432490f9SCyrill Gorcunov 
64607ca46eSDavid Howells enum {
65607ca46eSDavid Howells 	INET_DIAG_REQ_NONE,
66607ca46eSDavid Howells 	INET_DIAG_REQ_BYTECODE,
67085c20caSMartin KaFai Lau 	INET_DIAG_REQ_SK_BPF_STORAGES,
680df6d328SMartin KaFai Lau 	__INET_DIAG_REQ_MAX,
69607ca46eSDavid Howells };
70607ca46eSDavid Howells 
710df6d328SMartin KaFai Lau #define INET_DIAG_REQ_MAX (__INET_DIAG_REQ_MAX - 1)
72607ca46eSDavid Howells 
73607ca46eSDavid Howells /* Bytecode is sequence of 4 byte commands followed by variable arguments.
74607ca46eSDavid Howells  * All the commands identified by "code" are conditional jumps forward:
75607ca46eSDavid Howells  * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
76607ca46eSDavid Howells  * length of the command and its arguments.
77607ca46eSDavid Howells  */
78607ca46eSDavid Howells 
79607ca46eSDavid Howells struct inet_diag_bc_op {
80607ca46eSDavid Howells 	unsigned char	code;
81607ca46eSDavid Howells 	unsigned char	yes;
82607ca46eSDavid Howells 	unsigned short	no;
83607ca46eSDavid Howells };
84607ca46eSDavid Howells 
85607ca46eSDavid Howells enum {
86607ca46eSDavid Howells 	INET_DIAG_BC_NOP,
87607ca46eSDavid Howells 	INET_DIAG_BC_JMP,
88607ca46eSDavid Howells 	INET_DIAG_BC_S_GE,
89607ca46eSDavid Howells 	INET_DIAG_BC_S_LE,
90607ca46eSDavid Howells 	INET_DIAG_BC_D_GE,
91607ca46eSDavid Howells 	INET_DIAG_BC_D_LE,
92607ca46eSDavid Howells 	INET_DIAG_BC_AUTO,
93607ca46eSDavid Howells 	INET_DIAG_BC_S_COND,
94607ca46eSDavid Howells 	INET_DIAG_BC_D_COND,
95637c841dSDavid Ahern 	INET_DIAG_BC_DEV_COND,   /* u32 ifindex */
96a52e95abSLorenzo Colitti 	INET_DIAG_BC_MARK_COND,
97bbb6189dSKristian Evensen 	INET_DIAG_BC_S_EQ,
98bbb6189dSKristian Evensen 	INET_DIAG_BC_D_EQ,
99*b1f3e43dSDmitry Yakunin 	INET_DIAG_BC_CGROUP_COND,   /* u64 cgroup v2 ID */
100607ca46eSDavid Howells };
101607ca46eSDavid Howells 
102607ca46eSDavid Howells struct inet_diag_hostcond {
103607ca46eSDavid Howells 	__u8	family;
104607ca46eSDavid Howells 	__u8	prefix_len;
105607ca46eSDavid Howells 	int	port;
106607ca46eSDavid Howells 	__be32	addr[0];
107607ca46eSDavid Howells };
108607ca46eSDavid Howells 
109a52e95abSLorenzo Colitti struct inet_diag_markcond {
110a52e95abSLorenzo Colitti 	__u32 mark;
111a52e95abSLorenzo Colitti 	__u32 mask;
112a52e95abSLorenzo Colitti };
113a52e95abSLorenzo Colitti 
114607ca46eSDavid Howells /* Base info structure. It contains socket identity (addrs/ports/cookie)
115607ca46eSDavid Howells  * and, alas, the information shown by netstat. */
116607ca46eSDavid Howells struct inet_diag_msg {
117607ca46eSDavid Howells 	__u8	idiag_family;
118607ca46eSDavid Howells 	__u8	idiag_state;
119607ca46eSDavid Howells 	__u8	idiag_timer;
120607ca46eSDavid Howells 	__u8	idiag_retrans;
121607ca46eSDavid Howells 
122607ca46eSDavid Howells 	struct inet_diag_sockid id;
123607ca46eSDavid Howells 
124607ca46eSDavid Howells 	__u32	idiag_expires;
125607ca46eSDavid Howells 	__u32	idiag_rqueue;
126607ca46eSDavid Howells 	__u32	idiag_wqueue;
127607ca46eSDavid Howells 	__u32	idiag_uid;
128607ca46eSDavid Howells 	__u32	idiag_inode;
129607ca46eSDavid Howells };
130607ca46eSDavid Howells 
131607ca46eSDavid Howells /* Extensions */
132607ca46eSDavid Howells 
133607ca46eSDavid Howells enum {
134607ca46eSDavid Howells 	INET_DIAG_NONE,
135607ca46eSDavid Howells 	INET_DIAG_MEMINFO,
136607ca46eSDavid Howells 	INET_DIAG_INFO,
137607ca46eSDavid Howells 	INET_DIAG_VEGASINFO,
138607ca46eSDavid Howells 	INET_DIAG_CONG,
139607ca46eSDavid Howells 	INET_DIAG_TOS,
140607ca46eSDavid Howells 	INET_DIAG_TCLASS,
141607ca46eSDavid Howells 	INET_DIAG_SKMEMINFO,
142e4e541a8SPavel Emelyanov 	INET_DIAG_SHUTDOWN,
1431ec17dbdSKonstantin Khlebnikov 
1441ec17dbdSKonstantin Khlebnikov 	/*
1451ec17dbdSKonstantin Khlebnikov 	 * Next extenstions cannot be requested in struct inet_diag_req_v2:
1461ec17dbdSKonstantin Khlebnikov 	 * its field idiag_ext has only 8 bits.
1471ec17dbdSKonstantin Khlebnikov 	 */
1481ec17dbdSKonstantin Khlebnikov 
1491ec17dbdSKonstantin Khlebnikov 	INET_DIAG_DCTCPINFO,	/* request as INET_DIAG_VEGASINFO */
15035ac838aSCraig Gallek 	INET_DIAG_PROTOCOL,	/* response attribute only */
15120462155SPhil Sutter 	INET_DIAG_SKV6ONLY,
1528f840e47SXin Long 	INET_DIAG_LOCALS,
1538f840e47SXin Long 	INET_DIAG_PEERS,
1546ed46d12SNicolas Dichtel 	INET_DIAG_PAD,
1551ec17dbdSKonstantin Khlebnikov 	INET_DIAG_MARK,		/* only with CAP_NET_ADMIN */
1561ec17dbdSKonstantin Khlebnikov 	INET_DIAG_BBRINFO,	/* request as INET_DIAG_VEGASINFO */
1571ec17dbdSKonstantin Khlebnikov 	INET_DIAG_CLASS_ID,	/* request as INET_DIAG_TCLASS */
158c03fa9bcSIvan Delalande 	INET_DIAG_MD5SIG,
15961723b39SDavide Caratti 	INET_DIAG_ULP_INFO,
160085c20caSMartin KaFai Lau 	INET_DIAG_SK_BPF_STORAGES,
1616e3a401fSDmitry Yakunin 	INET_DIAG_CGROUP_ID,
1626ed46d12SNicolas Dichtel 	__INET_DIAG_MAX,
163607ca46eSDavid Howells };
164607ca46eSDavid Howells 
1656ed46d12SNicolas Dichtel #define INET_DIAG_MAX (__INET_DIAG_MAX - 1)
166607ca46eSDavid Howells 
16761723b39SDavide Caratti enum {
16861723b39SDavide Caratti 	INET_ULP_INFO_UNSPEC,
16961723b39SDavide Caratti 	INET_ULP_INFO_NAME,
17026811cc9SDavide Caratti 	INET_ULP_INFO_TLS,
1715147dfb5SDavide Caratti 	INET_ULP_INFO_MPTCP,
17261723b39SDavide Caratti 	__INET_ULP_INFO_MAX,
17361723b39SDavide Caratti };
17461723b39SDavide Caratti #define INET_ULP_INFO_MAX (__INET_ULP_INFO_MAX - 1)
17561723b39SDavide Caratti 
176607ca46eSDavid Howells /* INET_DIAG_MEM */
177607ca46eSDavid Howells 
178607ca46eSDavid Howells struct inet_diag_meminfo {
179607ca46eSDavid Howells 	__u32	idiag_rmem;
180607ca46eSDavid Howells 	__u32	idiag_wmem;
181607ca46eSDavid Howells 	__u32	idiag_fmem;
182607ca46eSDavid Howells 	__u32	idiag_tmem;
183607ca46eSDavid Howells };
184607ca46eSDavid Howells 
185607ca46eSDavid Howells /* INET_DIAG_VEGASINFO */
186607ca46eSDavid Howells 
187607ca46eSDavid Howells struct tcpvegas_info {
188607ca46eSDavid Howells 	__u32	tcpv_enabled;
189607ca46eSDavid Howells 	__u32	tcpv_rttcnt;
190607ca46eSDavid Howells 	__u32	tcpv_rtt;
191607ca46eSDavid Howells 	__u32	tcpv_minrtt;
192607ca46eSDavid Howells };
193607ca46eSDavid Howells 
194e3118e83SDaniel Borkmann /* INET_DIAG_DCTCPINFO */
195e3118e83SDaniel Borkmann 
196e3118e83SDaniel Borkmann struct tcp_dctcp_info {
197e3118e83SDaniel Borkmann 	__u16	dctcp_enabled;
198e3118e83SDaniel Borkmann 	__u16	dctcp_ce_state;
199e3118e83SDaniel Borkmann 	__u32	dctcp_alpha;
200e3118e83SDaniel Borkmann 	__u32	dctcp_ab_ecn;
201e3118e83SDaniel Borkmann 	__u32	dctcp_ab_tot;
202e3118e83SDaniel Borkmann };
203607ca46eSDavid Howells 
2040f8782eaSNeal Cardwell /* INET_DIAG_BBRINFO */
2050f8782eaSNeal Cardwell 
2060f8782eaSNeal Cardwell struct tcp_bbr_info {
2070f8782eaSNeal Cardwell 	/* u64 bw: max-filtered BW (app throughput) estimate in Byte per sec: */
2080f8782eaSNeal Cardwell 	__u32	bbr_bw_lo;		/* lower 32 bits of bw */
2090f8782eaSNeal Cardwell 	__u32	bbr_bw_hi;		/* upper 32 bits of bw */
2100f8782eaSNeal Cardwell 	__u32	bbr_min_rtt;		/* min-filtered RTT in uSec */
2110f8782eaSNeal Cardwell 	__u32	bbr_pacing_gain;	/* pacing gain shifted left 8 bits */
2120f8782eaSNeal Cardwell 	__u32	bbr_cwnd_gain;		/* cwnd gain shifted left 8 bits */
2130f8782eaSNeal Cardwell };
2140f8782eaSNeal Cardwell 
21564f40ff5SEric Dumazet union tcp_cc_info {
21664f40ff5SEric Dumazet 	struct tcpvegas_info	vegas;
21764f40ff5SEric Dumazet 	struct tcp_dctcp_info	dctcp;
2180f8782eaSNeal Cardwell 	struct tcp_bbr_info	bbr;
21964f40ff5SEric Dumazet };
220607ca46eSDavid Howells #endif /* _UAPI_INET_DIAG_H_ */
221