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, 67607ca46eSDavid Howells }; 68607ca46eSDavid Howells 69607ca46eSDavid Howells #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE 70607ca46eSDavid Howells 71607ca46eSDavid Howells /* Bytecode is sequence of 4 byte commands followed by variable arguments. 72607ca46eSDavid Howells * All the commands identified by "code" are conditional jumps forward: 73607ca46eSDavid Howells * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be 74607ca46eSDavid Howells * length of the command and its arguments. 75607ca46eSDavid Howells */ 76607ca46eSDavid Howells 77607ca46eSDavid Howells struct inet_diag_bc_op { 78607ca46eSDavid Howells unsigned char code; 79607ca46eSDavid Howells unsigned char yes; 80607ca46eSDavid Howells unsigned short no; 81607ca46eSDavid Howells }; 82607ca46eSDavid Howells 83607ca46eSDavid Howells enum { 84607ca46eSDavid Howells INET_DIAG_BC_NOP, 85607ca46eSDavid Howells INET_DIAG_BC_JMP, 86607ca46eSDavid Howells INET_DIAG_BC_S_GE, 87607ca46eSDavid Howells INET_DIAG_BC_S_LE, 88607ca46eSDavid Howells INET_DIAG_BC_D_GE, 89607ca46eSDavid Howells INET_DIAG_BC_D_LE, 90607ca46eSDavid Howells INET_DIAG_BC_AUTO, 91607ca46eSDavid Howells INET_DIAG_BC_S_COND, 92607ca46eSDavid Howells INET_DIAG_BC_D_COND, 93637c841dSDavid Ahern INET_DIAG_BC_DEV_COND, /* u32 ifindex */ 94a52e95abSLorenzo Colitti INET_DIAG_BC_MARK_COND, 95bbb6189dSKristian Evensen INET_DIAG_BC_S_EQ, 96bbb6189dSKristian Evensen INET_DIAG_BC_D_EQ, 97607ca46eSDavid Howells }; 98607ca46eSDavid Howells 99607ca46eSDavid Howells struct inet_diag_hostcond { 100607ca46eSDavid Howells __u8 family; 101607ca46eSDavid Howells __u8 prefix_len; 102607ca46eSDavid Howells int port; 103607ca46eSDavid Howells __be32 addr[0]; 104607ca46eSDavid Howells }; 105607ca46eSDavid Howells 106a52e95abSLorenzo Colitti struct inet_diag_markcond { 107a52e95abSLorenzo Colitti __u32 mark; 108a52e95abSLorenzo Colitti __u32 mask; 109a52e95abSLorenzo Colitti }; 110a52e95abSLorenzo Colitti 111607ca46eSDavid Howells /* Base info structure. It contains socket identity (addrs/ports/cookie) 112607ca46eSDavid Howells * and, alas, the information shown by netstat. */ 113607ca46eSDavid Howells struct inet_diag_msg { 114607ca46eSDavid Howells __u8 idiag_family; 115607ca46eSDavid Howells __u8 idiag_state; 116607ca46eSDavid Howells __u8 idiag_timer; 117607ca46eSDavid Howells __u8 idiag_retrans; 118607ca46eSDavid Howells 119607ca46eSDavid Howells struct inet_diag_sockid id; 120607ca46eSDavid Howells 121607ca46eSDavid Howells __u32 idiag_expires; 122607ca46eSDavid Howells __u32 idiag_rqueue; 123607ca46eSDavid Howells __u32 idiag_wqueue; 124607ca46eSDavid Howells __u32 idiag_uid; 125607ca46eSDavid Howells __u32 idiag_inode; 126607ca46eSDavid Howells }; 127607ca46eSDavid Howells 128607ca46eSDavid Howells /* Extensions */ 129607ca46eSDavid Howells 130607ca46eSDavid Howells enum { 131607ca46eSDavid Howells INET_DIAG_NONE, 132607ca46eSDavid Howells INET_DIAG_MEMINFO, 133607ca46eSDavid Howells INET_DIAG_INFO, 134607ca46eSDavid Howells INET_DIAG_VEGASINFO, 135607ca46eSDavid Howells INET_DIAG_CONG, 136607ca46eSDavid Howells INET_DIAG_TOS, 137607ca46eSDavid Howells INET_DIAG_TCLASS, 138607ca46eSDavid Howells INET_DIAG_SKMEMINFO, 139e4e541a8SPavel Emelyanov INET_DIAG_SHUTDOWN, 140*1ec17dbdSKonstantin Khlebnikov 141*1ec17dbdSKonstantin Khlebnikov /* 142*1ec17dbdSKonstantin Khlebnikov * Next extenstions cannot be requested in struct inet_diag_req_v2: 143*1ec17dbdSKonstantin Khlebnikov * its field idiag_ext has only 8 bits. 144*1ec17dbdSKonstantin Khlebnikov */ 145*1ec17dbdSKonstantin Khlebnikov 146*1ec17dbdSKonstantin Khlebnikov INET_DIAG_DCTCPINFO, /* request as INET_DIAG_VEGASINFO */ 14735ac838aSCraig Gallek INET_DIAG_PROTOCOL, /* response attribute only */ 14820462155SPhil Sutter INET_DIAG_SKV6ONLY, 1498f840e47SXin Long INET_DIAG_LOCALS, 1508f840e47SXin Long INET_DIAG_PEERS, 1516ed46d12SNicolas Dichtel INET_DIAG_PAD, 152*1ec17dbdSKonstantin Khlebnikov INET_DIAG_MARK, /* only with CAP_NET_ADMIN */ 153*1ec17dbdSKonstantin Khlebnikov INET_DIAG_BBRINFO, /* request as INET_DIAG_VEGASINFO */ 154*1ec17dbdSKonstantin Khlebnikov INET_DIAG_CLASS_ID, /* request as INET_DIAG_TCLASS */ 155c03fa9bcSIvan Delalande INET_DIAG_MD5SIG, 1566ed46d12SNicolas Dichtel __INET_DIAG_MAX, 157607ca46eSDavid Howells }; 158607ca46eSDavid Howells 1596ed46d12SNicolas Dichtel #define INET_DIAG_MAX (__INET_DIAG_MAX - 1) 160607ca46eSDavid Howells 161607ca46eSDavid Howells /* INET_DIAG_MEM */ 162607ca46eSDavid Howells 163607ca46eSDavid Howells struct inet_diag_meminfo { 164607ca46eSDavid Howells __u32 idiag_rmem; 165607ca46eSDavid Howells __u32 idiag_wmem; 166607ca46eSDavid Howells __u32 idiag_fmem; 167607ca46eSDavid Howells __u32 idiag_tmem; 168607ca46eSDavid Howells }; 169607ca46eSDavid Howells 170607ca46eSDavid Howells /* INET_DIAG_VEGASINFO */ 171607ca46eSDavid Howells 172607ca46eSDavid Howells struct tcpvegas_info { 173607ca46eSDavid Howells __u32 tcpv_enabled; 174607ca46eSDavid Howells __u32 tcpv_rttcnt; 175607ca46eSDavid Howells __u32 tcpv_rtt; 176607ca46eSDavid Howells __u32 tcpv_minrtt; 177607ca46eSDavid Howells }; 178607ca46eSDavid Howells 179e3118e83SDaniel Borkmann /* INET_DIAG_DCTCPINFO */ 180e3118e83SDaniel Borkmann 181e3118e83SDaniel Borkmann struct tcp_dctcp_info { 182e3118e83SDaniel Borkmann __u16 dctcp_enabled; 183e3118e83SDaniel Borkmann __u16 dctcp_ce_state; 184e3118e83SDaniel Borkmann __u32 dctcp_alpha; 185e3118e83SDaniel Borkmann __u32 dctcp_ab_ecn; 186e3118e83SDaniel Borkmann __u32 dctcp_ab_tot; 187e3118e83SDaniel Borkmann }; 188607ca46eSDavid Howells 1890f8782eaSNeal Cardwell /* INET_DIAG_BBRINFO */ 1900f8782eaSNeal Cardwell 1910f8782eaSNeal Cardwell struct tcp_bbr_info { 1920f8782eaSNeal Cardwell /* u64 bw: max-filtered BW (app throughput) estimate in Byte per sec: */ 1930f8782eaSNeal Cardwell __u32 bbr_bw_lo; /* lower 32 bits of bw */ 1940f8782eaSNeal Cardwell __u32 bbr_bw_hi; /* upper 32 bits of bw */ 1950f8782eaSNeal Cardwell __u32 bbr_min_rtt; /* min-filtered RTT in uSec */ 1960f8782eaSNeal Cardwell __u32 bbr_pacing_gain; /* pacing gain shifted left 8 bits */ 1970f8782eaSNeal Cardwell __u32 bbr_cwnd_gain; /* cwnd gain shifted left 8 bits */ 1980f8782eaSNeal Cardwell }; 1990f8782eaSNeal Cardwell 20064f40ff5SEric Dumazet union tcp_cc_info { 20164f40ff5SEric Dumazet struct tcpvegas_info vegas; 20264f40ff5SEric Dumazet struct tcp_dctcp_info dctcp; 2030f8782eaSNeal Cardwell struct tcp_bbr_info bbr; 20464f40ff5SEric Dumazet }; 205607ca46eSDavid Howells #endif /* _UAPI_INET_DIAG_H_ */ 206