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, 683f935c75SPaolo Abeni INET_DIAG_REQ_PROTOCOL, 690df6d328SMartin KaFai Lau __INET_DIAG_REQ_MAX, 70607ca46eSDavid Howells }; 71607ca46eSDavid Howells 720df6d328SMartin KaFai Lau #define INET_DIAG_REQ_MAX (__INET_DIAG_REQ_MAX - 1) 73607ca46eSDavid Howells 74607ca46eSDavid Howells /* Bytecode is sequence of 4 byte commands followed by variable arguments. 75607ca46eSDavid Howells * All the commands identified by "code" are conditional jumps forward: 76607ca46eSDavid Howells * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be 77607ca46eSDavid Howells * length of the command and its arguments. 78607ca46eSDavid Howells */ 79607ca46eSDavid Howells 80607ca46eSDavid Howells struct inet_diag_bc_op { 81607ca46eSDavid Howells unsigned char code; 82607ca46eSDavid Howells unsigned char yes; 83607ca46eSDavid Howells unsigned short no; 84607ca46eSDavid Howells }; 85607ca46eSDavid Howells 86607ca46eSDavid Howells enum { 87607ca46eSDavid Howells INET_DIAG_BC_NOP, 88607ca46eSDavid Howells INET_DIAG_BC_JMP, 89607ca46eSDavid Howells INET_DIAG_BC_S_GE, 90607ca46eSDavid Howells INET_DIAG_BC_S_LE, 91607ca46eSDavid Howells INET_DIAG_BC_D_GE, 92607ca46eSDavid Howells INET_DIAG_BC_D_LE, 93607ca46eSDavid Howells INET_DIAG_BC_AUTO, 94607ca46eSDavid Howells INET_DIAG_BC_S_COND, 95607ca46eSDavid Howells INET_DIAG_BC_D_COND, 96637c841dSDavid Ahern INET_DIAG_BC_DEV_COND, /* u32 ifindex */ 97a52e95abSLorenzo Colitti INET_DIAG_BC_MARK_COND, 98bbb6189dSKristian Evensen INET_DIAG_BC_S_EQ, 99bbb6189dSKristian Evensen INET_DIAG_BC_D_EQ, 100b1f3e43dSDmitry Yakunin INET_DIAG_BC_CGROUP_COND, /* u64 cgroup v2 ID */ 101607ca46eSDavid Howells }; 102607ca46eSDavid Howells 103607ca46eSDavid Howells struct inet_diag_hostcond { 104607ca46eSDavid Howells __u8 family; 105607ca46eSDavid Howells __u8 prefix_len; 106607ca46eSDavid Howells int port; 107*94dfc73eSGustavo A. R. Silva __be32 addr[]; 108607ca46eSDavid Howells }; 109607ca46eSDavid Howells 110a52e95abSLorenzo Colitti struct inet_diag_markcond { 111a52e95abSLorenzo Colitti __u32 mark; 112a52e95abSLorenzo Colitti __u32 mask; 113a52e95abSLorenzo Colitti }; 114a52e95abSLorenzo Colitti 115607ca46eSDavid Howells /* Base info structure. It contains socket identity (addrs/ports/cookie) 116607ca46eSDavid Howells * and, alas, the information shown by netstat. */ 117607ca46eSDavid Howells struct inet_diag_msg { 118607ca46eSDavid Howells __u8 idiag_family; 119607ca46eSDavid Howells __u8 idiag_state; 120607ca46eSDavid Howells __u8 idiag_timer; 121607ca46eSDavid Howells __u8 idiag_retrans; 122607ca46eSDavid Howells 123607ca46eSDavid Howells struct inet_diag_sockid id; 124607ca46eSDavid Howells 125607ca46eSDavid Howells __u32 idiag_expires; 126607ca46eSDavid Howells __u32 idiag_rqueue; 127607ca46eSDavid Howells __u32 idiag_wqueue; 128607ca46eSDavid Howells __u32 idiag_uid; 129607ca46eSDavid Howells __u32 idiag_inode; 130607ca46eSDavid Howells }; 131607ca46eSDavid Howells 132607ca46eSDavid Howells /* Extensions */ 133607ca46eSDavid Howells 134607ca46eSDavid Howells enum { 135607ca46eSDavid Howells INET_DIAG_NONE, 136607ca46eSDavid Howells INET_DIAG_MEMINFO, 137607ca46eSDavid Howells INET_DIAG_INFO, 138607ca46eSDavid Howells INET_DIAG_VEGASINFO, 139607ca46eSDavid Howells INET_DIAG_CONG, 140607ca46eSDavid Howells INET_DIAG_TOS, 141607ca46eSDavid Howells INET_DIAG_TCLASS, 142607ca46eSDavid Howells INET_DIAG_SKMEMINFO, 143e4e541a8SPavel Emelyanov INET_DIAG_SHUTDOWN, 1441ec17dbdSKonstantin Khlebnikov 1451ec17dbdSKonstantin Khlebnikov /* 1461ec17dbdSKonstantin Khlebnikov * Next extenstions cannot be requested in struct inet_diag_req_v2: 1471ec17dbdSKonstantin Khlebnikov * its field idiag_ext has only 8 bits. 1481ec17dbdSKonstantin Khlebnikov */ 1491ec17dbdSKonstantin Khlebnikov 1501ec17dbdSKonstantin Khlebnikov INET_DIAG_DCTCPINFO, /* request as INET_DIAG_VEGASINFO */ 15135ac838aSCraig Gallek INET_DIAG_PROTOCOL, /* response attribute only */ 15220462155SPhil Sutter INET_DIAG_SKV6ONLY, 1538f840e47SXin Long INET_DIAG_LOCALS, 1548f840e47SXin Long INET_DIAG_PEERS, 1556ed46d12SNicolas Dichtel INET_DIAG_PAD, 1561ec17dbdSKonstantin Khlebnikov INET_DIAG_MARK, /* only with CAP_NET_ADMIN */ 1571ec17dbdSKonstantin Khlebnikov INET_DIAG_BBRINFO, /* request as INET_DIAG_VEGASINFO */ 1581ec17dbdSKonstantin Khlebnikov INET_DIAG_CLASS_ID, /* request as INET_DIAG_TCLASS */ 159c03fa9bcSIvan Delalande INET_DIAG_MD5SIG, 16061723b39SDavide Caratti INET_DIAG_ULP_INFO, 161085c20caSMartin KaFai Lau INET_DIAG_SK_BPF_STORAGES, 1626e3a401fSDmitry Yakunin INET_DIAG_CGROUP_ID, 163c1077616SWei Wang INET_DIAG_SOCKOPT, 1646ed46d12SNicolas Dichtel __INET_DIAG_MAX, 165607ca46eSDavid Howells }; 166607ca46eSDavid Howells 1676ed46d12SNicolas Dichtel #define INET_DIAG_MAX (__INET_DIAG_MAX - 1) 168607ca46eSDavid Howells 16961723b39SDavide Caratti enum { 17061723b39SDavide Caratti INET_ULP_INFO_UNSPEC, 17161723b39SDavide Caratti INET_ULP_INFO_NAME, 17226811cc9SDavide Caratti INET_ULP_INFO_TLS, 1735147dfb5SDavide Caratti INET_ULP_INFO_MPTCP, 17461723b39SDavide Caratti __INET_ULP_INFO_MAX, 17561723b39SDavide Caratti }; 17661723b39SDavide Caratti #define INET_ULP_INFO_MAX (__INET_ULP_INFO_MAX - 1) 17761723b39SDavide Caratti 178607ca46eSDavid Howells /* INET_DIAG_MEM */ 179607ca46eSDavid Howells 180607ca46eSDavid Howells struct inet_diag_meminfo { 181607ca46eSDavid Howells __u32 idiag_rmem; 182607ca46eSDavid Howells __u32 idiag_wmem; 183607ca46eSDavid Howells __u32 idiag_fmem; 184607ca46eSDavid Howells __u32 idiag_tmem; 185607ca46eSDavid Howells }; 186607ca46eSDavid Howells 187c1077616SWei Wang /* INET_DIAG_SOCKOPT */ 188c1077616SWei Wang 189c1077616SWei Wang struct inet_diag_sockopt { 190c1077616SWei Wang __u8 recverr:1, 191c1077616SWei Wang is_icsk:1, 192c1077616SWei Wang freebind:1, 193c1077616SWei Wang hdrincl:1, 194c1077616SWei Wang mc_loop:1, 195c1077616SWei Wang transparent:1, 196c1077616SWei Wang mc_all:1, 197c1077616SWei Wang nodefrag:1; 198c1077616SWei Wang __u8 bind_address_no_port:1, 199c1077616SWei Wang recverr_rfc4884:1, 200c1077616SWei Wang defer_connect:1, 201c1077616SWei Wang unused:5; 202c1077616SWei Wang }; 203c1077616SWei Wang 204607ca46eSDavid Howells /* INET_DIAG_VEGASINFO */ 205607ca46eSDavid Howells 206607ca46eSDavid Howells struct tcpvegas_info { 207607ca46eSDavid Howells __u32 tcpv_enabled; 208607ca46eSDavid Howells __u32 tcpv_rttcnt; 209607ca46eSDavid Howells __u32 tcpv_rtt; 210607ca46eSDavid Howells __u32 tcpv_minrtt; 211607ca46eSDavid Howells }; 212607ca46eSDavid Howells 213e3118e83SDaniel Borkmann /* INET_DIAG_DCTCPINFO */ 214e3118e83SDaniel Borkmann 215e3118e83SDaniel Borkmann struct tcp_dctcp_info { 216e3118e83SDaniel Borkmann __u16 dctcp_enabled; 217e3118e83SDaniel Borkmann __u16 dctcp_ce_state; 218e3118e83SDaniel Borkmann __u32 dctcp_alpha; 219e3118e83SDaniel Borkmann __u32 dctcp_ab_ecn; 220e3118e83SDaniel Borkmann __u32 dctcp_ab_tot; 221e3118e83SDaniel Borkmann }; 222607ca46eSDavid Howells 2230f8782eaSNeal Cardwell /* INET_DIAG_BBRINFO */ 2240f8782eaSNeal Cardwell 2250f8782eaSNeal Cardwell struct tcp_bbr_info { 2260f8782eaSNeal Cardwell /* u64 bw: max-filtered BW (app throughput) estimate in Byte per sec: */ 2270f8782eaSNeal Cardwell __u32 bbr_bw_lo; /* lower 32 bits of bw */ 2280f8782eaSNeal Cardwell __u32 bbr_bw_hi; /* upper 32 bits of bw */ 2290f8782eaSNeal Cardwell __u32 bbr_min_rtt; /* min-filtered RTT in uSec */ 2300f8782eaSNeal Cardwell __u32 bbr_pacing_gain; /* pacing gain shifted left 8 bits */ 2310f8782eaSNeal Cardwell __u32 bbr_cwnd_gain; /* cwnd gain shifted left 8 bits */ 2320f8782eaSNeal Cardwell }; 2330f8782eaSNeal Cardwell 23464f40ff5SEric Dumazet union tcp_cc_info { 23564f40ff5SEric Dumazet struct tcpvegas_info vegas; 23664f40ff5SEric Dumazet struct tcp_dctcp_info dctcp; 2370f8782eaSNeal Cardwell struct tcp_bbr_info bbr; 23864f40ff5SEric Dumazet }; 239607ca46eSDavid Howells #endif /* _UAPI_INET_DIAG_H_ */ 240