inet_diag.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI_INET_DIAG_H_
  3. #define _UAPI_INET_DIAG_H_
  4. #include <linux/types.h>
  5. /* Just some random number */
  6. #define TCPDIAG_GETSOCK 18
  7. #define DCCPDIAG_GETSOCK 19
  8. #define INET_DIAG_GETSOCK_MAX 24
  9. /* Socket identity */
  10. struct inet_diag_sockid {
  11. __be16 idiag_sport;
  12. __be16 idiag_dport;
  13. __be32 idiag_src[4];
  14. __be32 idiag_dst[4];
  15. __u32 idiag_if;
  16. __u32 idiag_cookie[2];
  17. #define INET_DIAG_NOCOOKIE (~0U)
  18. };
  19. /* Request structure */
  20. struct inet_diag_req {
  21. __u8 idiag_family; /* Family of addresses. */
  22. __u8 idiag_src_len;
  23. __u8 idiag_dst_len;
  24. __u8 idiag_ext; /* Query extended information */
  25. struct inet_diag_sockid id;
  26. __u32 idiag_states; /* States to dump */
  27. __u32 idiag_dbs; /* Tables to dump (NI) */
  28. };
  29. struct inet_diag_req_v2 {
  30. __u8 sdiag_family;
  31. __u8 sdiag_protocol;
  32. __u8 idiag_ext;
  33. __u8 pad;
  34. __u32 idiag_states;
  35. struct inet_diag_sockid id;
  36. };
  37. /*
  38. * SOCK_RAW sockets require the underlied protocol to be
  39. * additionally specified so we can use @pad member for
  40. * this, but we can't rename it because userspace programs
  41. * still may depend on this name. Instead lets use another
  42. * structure definition as an alias for struct
  43. * @inet_diag_req_v2.
  44. */
  45. struct inet_diag_req_raw {
  46. __u8 sdiag_family;
  47. __u8 sdiag_protocol;
  48. __u8 idiag_ext;
  49. __u8 sdiag_raw_protocol;
  50. __u32 idiag_states;
  51. struct inet_diag_sockid id;
  52. };
  53. enum {
  54. INET_DIAG_REQ_NONE,
  55. INET_DIAG_REQ_BYTECODE,
  56. };
  57. #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
  58. /* Bytecode is sequence of 4 byte commands followed by variable arguments.
  59. * All the commands identified by "code" are conditional jumps forward:
  60. * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
  61. * length of the command and its arguments.
  62. */
  63. struct inet_diag_bc_op {
  64. unsigned char code;
  65. unsigned char yes;
  66. unsigned short no;
  67. };
  68. enum {
  69. INET_DIAG_BC_NOP,
  70. INET_DIAG_BC_JMP,
  71. INET_DIAG_BC_S_GE,
  72. INET_DIAG_BC_S_LE,
  73. INET_DIAG_BC_D_GE,
  74. INET_DIAG_BC_D_LE,
  75. INET_DIAG_BC_AUTO,
  76. INET_DIAG_BC_S_COND,
  77. INET_DIAG_BC_D_COND,
  78. INET_DIAG_BC_DEV_COND, /* u32 ifindex */
  79. INET_DIAG_BC_MARK_COND,
  80. INET_DIAG_BC_S_EQ,
  81. INET_DIAG_BC_D_EQ,
  82. };
  83. struct inet_diag_hostcond {
  84. __u8 family;
  85. __u8 prefix_len;
  86. int port;
  87. __be32 addr[0];
  88. };
  89. struct inet_diag_markcond {
  90. __u32 mark;
  91. __u32 mask;
  92. };
  93. /* Base info structure. It contains socket identity (addrs/ports/cookie)
  94. * and, alas, the information shown by netstat. */
  95. struct inet_diag_msg {
  96. __u8 idiag_family;
  97. __u8 idiag_state;
  98. __u8 idiag_timer;
  99. __u8 idiag_retrans;
  100. struct inet_diag_sockid id;
  101. __u32 idiag_expires;
  102. __u32 idiag_rqueue;
  103. __u32 idiag_wqueue;
  104. __u32 idiag_uid;
  105. __u32 idiag_inode;
  106. };
  107. /* Extensions */
  108. enum {
  109. INET_DIAG_NONE,
  110. INET_DIAG_MEMINFO,
  111. INET_DIAG_INFO,
  112. INET_DIAG_VEGASINFO,
  113. INET_DIAG_CONG,
  114. INET_DIAG_TOS,
  115. INET_DIAG_TCLASS,
  116. INET_DIAG_SKMEMINFO,
  117. INET_DIAG_SHUTDOWN,
  118. /*
  119. * Next extenstions cannot be requested in struct inet_diag_req_v2:
  120. * its field idiag_ext has only 8 bits.
  121. */
  122. INET_DIAG_DCTCPINFO, /* request as INET_DIAG_VEGASINFO */
  123. INET_DIAG_PROTOCOL, /* response attribute only */
  124. INET_DIAG_SKV6ONLY,
  125. INET_DIAG_LOCALS,
  126. INET_DIAG_PEERS,
  127. INET_DIAG_PAD,
  128. INET_DIAG_MARK, /* only with CAP_NET_ADMIN */
  129. INET_DIAG_BBRINFO, /* request as INET_DIAG_VEGASINFO */
  130. INET_DIAG_CLASS_ID, /* request as INET_DIAG_TCLASS */
  131. INET_DIAG_MD5SIG,
  132. __INET_DIAG_MAX,
  133. };
  134. #define INET_DIAG_MAX (__INET_DIAG_MAX - 1)
  135. /* INET_DIAG_MEM */
  136. struct inet_diag_meminfo {
  137. __u32 idiag_rmem;
  138. __u32 idiag_wmem;
  139. __u32 idiag_fmem;
  140. __u32 idiag_tmem;
  141. };
  142. /* INET_DIAG_VEGASINFO */
  143. struct tcpvegas_info {
  144. __u32 tcpv_enabled;
  145. __u32 tcpv_rttcnt;
  146. __u32 tcpv_rtt;
  147. __u32 tcpv_minrtt;
  148. };
  149. /* INET_DIAG_DCTCPINFO */
  150. struct tcp_dctcp_info {
  151. __u16 dctcp_enabled;
  152. __u16 dctcp_ce_state;
  153. __u32 dctcp_alpha;
  154. __u32 dctcp_ab_ecn;
  155. __u32 dctcp_ab_tot;
  156. };
  157. /* INET_DIAG_BBRINFO */
  158. struct tcp_bbr_info {
  159. /* u64 bw: max-filtered BW (app throughput) estimate in Byte per sec: */
  160. __u32 bbr_bw_lo; /* lower 32 bits of bw */
  161. __u32 bbr_bw_hi; /* upper 32 bits of bw */
  162. __u32 bbr_min_rtt; /* min-filtered RTT in uSec */
  163. __u32 bbr_pacing_gain; /* pacing gain shifted left 8 bits */
  164. __u32 bbr_cwnd_gain; /* cwnd gain shifted left 8 bits */
  165. };
  166. union tcp_cc_info {
  167. struct tcpvegas_info vegas;
  168. struct tcp_dctcp_info dctcp;
  169. struct tcp_bbr_info bbr;
  170. };
  171. #endif /* _UAPI_INET_DIAG_H_ */