Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | |
Willy Tarreau | f1d32c4 | 2020-06-04 21:07:02 +0200 | [diff] [blame] | 4 | #include <haproxy/channel-t.h> |
Willy Tarreau | 7ea393d | 2020-06-04 18:02:10 +0200 | [diff] [blame] | 5 | #include <haproxy/connection-t.h> |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 6 | #include <haproxy/conn_stream-t.h> |
Willy Tarreau | c2b1ff0 | 2020-06-04 21:21:03 +0200 | [diff] [blame] | 7 | #include <haproxy/http_ana-t.h> |
Willy Tarreau | dfd3de8 | 2020-06-04 23:46:14 +0200 | [diff] [blame] | 8 | #include <haproxy/stream-t.h> |
Willy Tarreau | 5e539c9 | 2020-06-04 20:45:39 +0200 | [diff] [blame] | 9 | #include <haproxy/stream_interface-t.h> |
Willy Tarreau | cea0e1b | 2020-06-04 17:25:40 +0200 | [diff] [blame] | 10 | #include <haproxy/task-t.h> |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 11 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 12 | // 1 bit per flag, no hole permitted here |
| 13 | #define SHOW_AS_ANA 0x00000001 |
| 14 | #define SHOW_AS_CHN 0x00000002 |
| 15 | #define SHOW_AS_CONN 0x00000004 |
| 16 | #define SHOW_AS_CS 0x00000008 |
| 17 | #define SHOW_AS_SI 0x00000010 |
| 18 | #define SHOW_AS_SIET 0x00000020 |
| 19 | #define SHOW_AS_STRM 0x00000040 |
| 20 | #define SHOW_AS_TASK 0x00000080 |
| 21 | #define SHOW_AS_TXN 0x00000100 |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 22 | #define SHOW_AS_ENDP 0x00000200 |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 23 | |
| 24 | // command line names, must be in exact same order as the SHOW_AS_* flags above |
| 25 | // so that show_as_words[i] matches flag 1U<<i. |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 26 | const char *show_as_words[] = { "ana", "chn", "conn", "cs", "si", "siet", "strm", "task", "txn", "endp", }; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 27 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 28 | #define SHOW_FLAG(f,n) \ |
| 29 | do { \ |
| 30 | if (!((f) & (n))) break; \ |
| 31 | (f) &= ~(n); \ |
| 32 | printf(#n"%s", (f) ? " | " : ""); \ |
| 33 | } while (0) |
| 34 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 35 | unsigned int get_show_as(const char *word) |
| 36 | { |
| 37 | int w = 0; |
| 38 | |
| 39 | while (1) { |
| 40 | if (w == sizeof(show_as_words) / sizeof(*show_as_words)) |
| 41 | return 0; |
| 42 | if (strcmp(word, show_as_words[w]) == 0) |
| 43 | return 1U << w; |
| 44 | w++; |
| 45 | } |
| 46 | } |
| 47 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 48 | void show_chn_ana(unsigned int f) |
| 49 | { |
| 50 | printf("chn->ana = "); |
| 51 | |
| 52 | if (!f) { |
| 53 | printf("0\n"); |
| 54 | return; |
| 55 | } |
| 56 | |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 57 | SHOW_FLAG(f, AN_REQ_FLT_START_FE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 58 | SHOW_FLAG(f, AN_REQ_INSPECT_FE); |
| 59 | SHOW_FLAG(f, AN_REQ_WAIT_HTTP); |
| 60 | SHOW_FLAG(f, AN_REQ_HTTP_BODY); |
| 61 | SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_FE); |
| 62 | SHOW_FLAG(f, AN_REQ_SWITCHING_RULES); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 63 | SHOW_FLAG(f, AN_REQ_FLT_START_BE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 64 | SHOW_FLAG(f, AN_REQ_INSPECT_BE); |
| 65 | SHOW_FLAG(f, AN_REQ_HTTP_PROCESS_BE); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 66 | SHOW_FLAG(f, AN_REQ_HTTP_TARPIT); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 67 | SHOW_FLAG(f, AN_REQ_SRV_RULES); |
| 68 | SHOW_FLAG(f, AN_REQ_HTTP_INNER); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 69 | SHOW_FLAG(f, AN_REQ_PRST_RDP_COOKIE); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 70 | SHOW_FLAG(f, AN_REQ_STICKING_RULES); |
| 71 | SHOW_FLAG(f, AN_REQ_FLT_HTTP_HDRS); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 72 | SHOW_FLAG(f, AN_REQ_HTTP_XFER_BODY); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 73 | SHOW_FLAG(f, AN_REQ_WAIT_CLI); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 74 | SHOW_FLAG(f, AN_REQ_FLT_XFER_DATA); |
| 75 | SHOW_FLAG(f, AN_REQ_FLT_END); |
| 76 | |
Willy Tarreau | 260bf5c | 2018-01-15 18:59:16 +0100 | [diff] [blame] | 77 | SHOW_FLAG(f, AN_RES_FLT_START_FE); |
| 78 | SHOW_FLAG(f, AN_RES_FLT_START_BE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 79 | SHOW_FLAG(f, AN_RES_INSPECT); |
| 80 | SHOW_FLAG(f, AN_RES_WAIT_HTTP); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 81 | SHOW_FLAG(f, AN_RES_STORE_RULES); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 82 | SHOW_FLAG(f, AN_RES_HTTP_PROCESS_FE); |
| 83 | SHOW_FLAG(f, AN_RES_HTTP_PROCESS_BE); |
| 84 | SHOW_FLAG(f, AN_RES_FLT_HTTP_HDRS); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 85 | SHOW_FLAG(f, AN_RES_HTTP_XFER_BODY); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 86 | SHOW_FLAG(f, AN_RES_WAIT_CLI); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 87 | SHOW_FLAG(f, AN_RES_FLT_XFER_DATA); |
| 88 | SHOW_FLAG(f, AN_RES_FLT_END); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 89 | |
| 90 | if (f) { |
| 91 | printf("EXTRA(0x%08x)", f); |
| 92 | } |
| 93 | putchar('\n'); |
| 94 | } |
| 95 | |
| 96 | void show_chn_flags(unsigned int f) |
| 97 | { |
| 98 | printf("chn->flags = "); |
| 99 | |
| 100 | if (!f) { |
| 101 | printf("0\n"); |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | SHOW_FLAG(f, CF_ISRESP); |
Willy Tarreau | f882a85 | 2019-03-25 18:34:28 +0100 | [diff] [blame] | 106 | SHOW_FLAG(f, CF_EOI); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 107 | SHOW_FLAG(f, CF_FLT_ANALYZE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 108 | SHOW_FLAG(f, CF_WAKE_ONCE); |
| 109 | SHOW_FLAG(f, CF_NEVER_WAIT); |
| 110 | SHOW_FLAG(f, CF_SEND_DONTWAIT); |
| 111 | SHOW_FLAG(f, CF_EXPECT_MORE); |
| 112 | SHOW_FLAG(f, CF_DONT_READ); |
| 113 | SHOW_FLAG(f, CF_AUTO_CONNECT); |
| 114 | SHOW_FLAG(f, CF_READ_DONTWAIT); |
| 115 | SHOW_FLAG(f, CF_KERN_SPLICING); |
| 116 | SHOW_FLAG(f, CF_READ_ATTACHED); |
| 117 | SHOW_FLAG(f, CF_ANA_TIMEOUT); |
| 118 | SHOW_FLAG(f, CF_WROTE_DATA); |
| 119 | SHOW_FLAG(f, CF_STREAMER_FAST); |
| 120 | SHOW_FLAG(f, CF_STREAMER); |
| 121 | SHOW_FLAG(f, CF_AUTO_CLOSE); |
| 122 | SHOW_FLAG(f, CF_SHUTW_NOW); |
| 123 | SHOW_FLAG(f, CF_SHUTW); |
| 124 | SHOW_FLAG(f, CF_WAKE_WRITE); |
| 125 | SHOW_FLAG(f, CF_WRITE_ERROR); |
| 126 | SHOW_FLAG(f, CF_WRITE_TIMEOUT); |
| 127 | SHOW_FLAG(f, CF_WRITE_PARTIAL); |
| 128 | SHOW_FLAG(f, CF_WRITE_NULL); |
| 129 | SHOW_FLAG(f, CF_READ_NOEXP); |
| 130 | SHOW_FLAG(f, CF_SHUTR_NOW); |
| 131 | SHOW_FLAG(f, CF_SHUTR); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 132 | SHOW_FLAG(f, CF_READ_ERROR); |
| 133 | SHOW_FLAG(f, CF_READ_TIMEOUT); |
| 134 | SHOW_FLAG(f, CF_READ_PARTIAL); |
| 135 | SHOW_FLAG(f, CF_READ_NULL); |
| 136 | |
| 137 | if (f) { |
| 138 | printf("EXTRA(0x%08x)", f); |
| 139 | } |
| 140 | putchar('\n'); |
| 141 | } |
| 142 | |
| 143 | void show_conn_flags(unsigned int f) |
| 144 | { |
| 145 | printf("conn->flags = "); |
| 146 | if (!f) { |
| 147 | printf("0\n"); |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | SHOW_FLAG(f, CO_FL_XPRT_TRACKED); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 152 | SHOW_FLAG(f, CO_FL_SESS_IDLE); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 153 | SHOW_FLAG(f, CO_FL_RCVD_PROXY); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 154 | SHOW_FLAG(f, CO_FL_PRIVATE); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 155 | SHOW_FLAG(f, CO_FL_SSL_WAIT_HS); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 156 | SHOW_FLAG(f, CO_FL_ACCEPT_CIP); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 157 | SHOW_FLAG(f, CO_FL_ACCEPT_PROXY); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 158 | SHOW_FLAG(f, CO_FL_SEND_PROXY); |
| 159 | SHOW_FLAG(f, CO_FL_WAIT_L6_CONN); |
| 160 | SHOW_FLAG(f, CO_FL_WAIT_L4_CONN); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 161 | SHOW_FLAG(f, CO_FL_ERROR); |
| 162 | SHOW_FLAG(f, CO_FL_SOCK_WR_SH); |
| 163 | SHOW_FLAG(f, CO_FL_SOCK_RD_SH); |
Willy Tarreau | db20750 | 2019-06-03 14:26:54 +0200 | [diff] [blame] | 164 | SHOW_FLAG(f, CO_FL_SOCKS4_RECV); |
| 165 | SHOW_FLAG(f, CO_FL_SOCKS4_SEND); |
Christopher Faulet | f4cfcf9 | 2017-11-10 14:10:35 +0100 | [diff] [blame] | 166 | SHOW_FLAG(f, CO_FL_EARLY_DATA); |
| 167 | SHOW_FLAG(f, CO_FL_EARLY_SSL_HS); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 168 | SHOW_FLAG(f, CO_FL_ADDR_TO_SET); |
| 169 | SHOW_FLAG(f, CO_FL_ADDR_FROM_SET); |
| 170 | SHOW_FLAG(f, CO_FL_WAIT_ROOM); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 171 | SHOW_FLAG(f, CO_FL_WANT_DRAIN); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 172 | SHOW_FLAG(f, CO_FL_XPRT_READY); |
| 173 | SHOW_FLAG(f, CO_FL_CTRL_READY); |
Willy Tarreau | 54067e9 | 2020-06-19 08:47:30 +0200 | [diff] [blame] | 174 | SHOW_FLAG(f, CO_FL_IDLE_LIST); |
| 175 | SHOW_FLAG(f, CO_FL_SAFE_LIST); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 176 | |
| 177 | if (f) { |
| 178 | printf("EXTRA(0x%08x)", f); |
| 179 | } |
| 180 | putchar('\n'); |
| 181 | } |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 182 | |
| 183 | void show_endp_flags(unsigned int f) |
| 184 | { |
| 185 | printf("endp->flags = "); |
| 186 | if (!f) { |
| 187 | printf("0\n"); |
| 188 | return; |
| 189 | } |
Christopher Faulet | e9e4820 | 2022-03-22 18:13:29 +0100 | [diff] [blame] | 190 | SHOW_FLAG(f, CS_EP_KILL_CONN); |
| 191 | SHOW_FLAG(f, CS_EP_WAIT_FOR_HS); |
Christopher Faulet | b041b23 | 2022-03-24 10:27:02 +0100 | [diff] [blame] | 192 | SHOW_FLAG(f, CS_EP_WANT_ROOM); |
| 193 | SHOW_FLAG(f, CS_EP_ERROR); |
| 194 | SHOW_FLAG(f, CS_EP_ERR_PENDING); |
| 195 | SHOW_FLAG(f, CS_EP_EOS); |
| 196 | SHOW_FLAG(f, CS_EP_EOI); |
| 197 | SHOW_FLAG(f, CS_EP_RCV_MORE); |
Christopher Faulet | e9e4820 | 2022-03-22 18:13:29 +0100 | [diff] [blame] | 198 | SHOW_FLAG(f, CS_EP_MAY_SPLICE); |
| 199 | SHOW_FLAG(f, CS_EP_WEBSOCKET); |
| 200 | SHOW_FLAG(f, CS_EP_NOT_FIRST); |
| 201 | SHOW_FLAG(f, CS_EP_SHWS); |
| 202 | SHOW_FLAG(f, CS_EP_SHWN); |
| 203 | SHOW_FLAG(f, CS_EP_SHRR); |
| 204 | SHOW_FLAG(f, CS_EP_SHRD); |
Christopher Faulet | 9ec2f4d | 2022-03-23 15:15:29 +0100 | [diff] [blame] | 205 | SHOW_FLAG(f, CS_EP_ORPHAN); |
| 206 | SHOW_FLAG(f, CS_EP_DETACHED); |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 207 | SHOW_FLAG(f, CS_EP_T_APPLET); |
| 208 | SHOW_FLAG(f, CS_EP_T_MUX); |
| 209 | |
| 210 | if (f) { |
| 211 | printf("EXTRA(0x%08x)", f); |
| 212 | } |
| 213 | putchar('\n'); |
| 214 | } |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 215 | void show_cs_flags(unsigned int f) |
| 216 | { |
| 217 | printf("cs->flags = "); |
| 218 | if (!f) { |
| 219 | printf("0\n"); |
| 220 | return; |
| 221 | } |
Christopher Faulet | a728518 | 2022-03-30 15:43:23 +0200 | [diff] [blame^] | 222 | SHOW_FLAG(f, CS_FL_INDEP_STR); |
Christopher Faulet | 974da9f | 2022-03-30 15:30:03 +0200 | [diff] [blame] | 223 | SHOW_FLAG(f, CS_FL_DONT_WAKE); |
Christopher Faulet | 8abe712 | 2022-03-30 15:10:18 +0200 | [diff] [blame] | 224 | SHOW_FLAG(f, CS_FL_NOLINGER); |
| 225 | SHOW_FLAG(f, CS_FL_NOHALF); |
Christopher Faulet | 8da67aa | 2022-03-29 17:53:09 +0200 | [diff] [blame] | 226 | SHOW_FLAG(f, CS_FL_ADDR_FROM_SET); |
| 227 | SHOW_FLAG(f, CS_FL_ADDR_TO_SET); |
Christopher Faulet | 3099511 | 2022-03-25 15:32:38 +0100 | [diff] [blame] | 228 | SHOW_FLAG(f, CS_FL_ISBACK); |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 229 | |
| 230 | if (f) { |
| 231 | printf("EXTRA(0x%08x)", f); |
| 232 | } |
| 233 | putchar('\n'); |
| 234 | } |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 235 | |
| 236 | void show_si_et(unsigned int f) |
| 237 | { |
| 238 | printf("si->et = "); |
| 239 | if (!f) { |
| 240 | printf("SI_ET_NONE\n"); |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | SHOW_FLAG(f, SI_ET_QUEUE_TO); |
| 245 | SHOW_FLAG(f, SI_ET_QUEUE_ERR); |
| 246 | SHOW_FLAG(f, SI_ET_QUEUE_ABRT); |
| 247 | SHOW_FLAG(f, SI_ET_CONN_TO); |
| 248 | SHOW_FLAG(f, SI_ET_CONN_ERR); |
| 249 | SHOW_FLAG(f, SI_ET_CONN_ABRT); |
| 250 | SHOW_FLAG(f, SI_ET_CONN_RES); |
| 251 | SHOW_FLAG(f, SI_ET_CONN_OTHER); |
| 252 | SHOW_FLAG(f, SI_ET_DATA_TO); |
| 253 | SHOW_FLAG(f, SI_ET_DATA_ERR); |
| 254 | SHOW_FLAG(f, SI_ET_DATA_ABRT); |
| 255 | |
| 256 | if (f) { |
| 257 | printf("EXTRA(0x%08x)", f); |
| 258 | } |
| 259 | putchar('\n'); |
| 260 | } |
| 261 | |
| 262 | void show_si_flags(unsigned int f) |
| 263 | { |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 264 | printf("si->flags = "); |
| 265 | if (!f) { |
| 266 | printf("SI_FL_NONE\n"); |
| 267 | return; |
| 268 | } |
| 269 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 270 | SHOW_FLAG(f, SI_FL_WAIT_DATA); |
| 271 | SHOW_FLAG(f, SI_FL_ISBACK); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 272 | SHOW_FLAG(f, SI_FL_SRC_ADDR); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 273 | SHOW_FLAG(f, SI_FL_WANT_GET); |
Willy Tarreau | f2ddd87 | 2018-12-18 09:54:22 +0100 | [diff] [blame] | 274 | SHOW_FLAG(f, SI_FL_CLEAN_ABRT); |
Willy Tarreau | 94f7907 | 2018-11-14 11:24:08 +0100 | [diff] [blame] | 275 | SHOW_FLAG(f, SI_FL_RXBLK_CHAN); |
| 276 | SHOW_FLAG(f, SI_FL_RXBLK_BUFF); |
| 277 | SHOW_FLAG(f, SI_FL_RXBLK_ROOM); |
| 278 | SHOW_FLAG(f, SI_FL_RXBLK_SHUT); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 279 | SHOW_FLAG(f, SI_FL_RXBLK_CONN); |
Willy Tarreau | 94f7907 | 2018-11-14 11:24:08 +0100 | [diff] [blame] | 280 | SHOW_FLAG(f, SI_FL_RX_WAIT_EP); |
| 281 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 282 | if (f) { |
Willy Tarreau | 94f7907 | 2018-11-14 11:24:08 +0100 | [diff] [blame] | 283 | printf("EXTRA(0x%08x)", f); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 284 | } |
| 285 | putchar('\n'); |
| 286 | } |
| 287 | |
| 288 | void show_task_state(unsigned int f) |
| 289 | { |
| 290 | printf("task->state = "); |
| 291 | |
| 292 | if (!f) { |
| 293 | printf("TASK_SLEEPING\n"); |
| 294 | return; |
| 295 | } |
| 296 | |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 297 | SHOW_FLAG(f, TASK_F_USR1); |
| 298 | SHOW_FLAG(f, TASK_F_TASKLET); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 299 | SHOW_FLAG(f, TASK_WOKEN_OTHER); |
| 300 | SHOW_FLAG(f, TASK_WOKEN_RES); |
| 301 | SHOW_FLAG(f, TASK_WOKEN_MSG); |
| 302 | SHOW_FLAG(f, TASK_WOKEN_SIGNAL); |
| 303 | SHOW_FLAG(f, TASK_WOKEN_IO); |
| 304 | SHOW_FLAG(f, TASK_WOKEN_TIMER); |
| 305 | SHOW_FLAG(f, TASK_WOKEN_INIT); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 306 | SHOW_FLAG(f, TASK_HEAVY); |
| 307 | SHOW_FLAG(f, TASK_IN_LIST); |
| 308 | SHOW_FLAG(f, TASK_KILLED); |
| 309 | SHOW_FLAG(f, TASK_SELF_WAKING); |
| 310 | SHOW_FLAG(f, TASK_SHARED_WQ); |
| 311 | SHOW_FLAG(f, TASK_QUEUED); |
| 312 | SHOW_FLAG(f, TASK_GLOBAL); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 313 | SHOW_FLAG(f, TASK_RUNNING); |
| 314 | |
| 315 | if (f) { |
| 316 | printf("EXTRA(0x%08x)", f); |
| 317 | } |
| 318 | putchar('\n'); |
| 319 | } |
| 320 | |
| 321 | void show_txn_flags(unsigned int f) |
| 322 | { |
| 323 | printf("txn->flags = "); |
| 324 | |
| 325 | if (!f) { |
| 326 | printf("0\n"); |
| 327 | return; |
| 328 | } |
| 329 | |
Christopher Faulet | e05bf9e | 2022-03-29 15:23:40 +0200 | [diff] [blame] | 330 | SHOW_FLAG(f, TX_L7_RETRY); |
| 331 | SHOW_FLAG(f, TX_D_L7_RETRY); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 332 | SHOW_FLAG(f, TX_NOT_FIRST); |
| 333 | SHOW_FLAG(f, TX_USE_PX_CONN); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 334 | SHOW_FLAG(f, TX_CACHE_HAS_SEC_KEY); |
Christopher Faulet | c41547b | 2019-07-16 14:32:23 +0200 | [diff] [blame] | 335 | SHOW_FLAG(f, TX_CON_WANT_TUN); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 336 | |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 337 | SHOW_FLAG(f, TX_CACHE_IGNORE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 338 | SHOW_FLAG(f, TX_CACHE_COOK); |
| 339 | SHOW_FLAG(f, TX_CACHEABLE); |
| 340 | SHOW_FLAG(f, TX_SCK_PRESENT); |
| 341 | |
| 342 | //printf("%s", f ? "" : " | "); |
| 343 | switch (f & TX_SCK_MASK) { |
| 344 | case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break; |
| 345 | case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break; |
| 346 | case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break; |
| 347 | case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break; |
| 348 | case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break; |
| 349 | case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break; |
| 350 | default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break; |
| 351 | } |
| 352 | |
| 353 | //printf("%s", f ? "" : " | "); |
| 354 | switch (f & TX_CK_MASK) { |
| 355 | case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break; |
| 356 | case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break; |
| 357 | case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break; |
| 358 | case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break; |
| 359 | case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break; |
| 360 | case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break; |
| 361 | case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break; |
| 362 | default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break; |
| 363 | } |
| 364 | |
| 365 | SHOW_FLAG(f, TX_CLTARPIT); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 366 | SHOW_FLAG(f, TX_CONST_REPLY); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 367 | |
| 368 | if (f) { |
| 369 | printf("EXTRA(0x%08x)", f); |
| 370 | } |
| 371 | putchar('\n'); |
| 372 | } |
| 373 | |
| 374 | void show_strm_flags(unsigned int f) |
| 375 | { |
| 376 | printf("strm->flags = "); |
| 377 | |
| 378 | if (!f) { |
| 379 | printf("0\n"); |
| 380 | return; |
| 381 | } |
| 382 | |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 383 | SHOW_FLAG(f, SF_WEBSOCKET); |
| 384 | SHOW_FLAG(f, SF_SRV_REUSED_ANTICIPATED); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 385 | SHOW_FLAG(f, SF_SRV_REUSED); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 386 | SHOW_FLAG(f, SF_IGNORE_PRST); |
| 387 | |
| 388 | //printf("%s", f ? "" : " | "); |
| 389 | switch (f & SF_FINST_MASK) { |
| 390 | case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break; |
| 391 | case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break; |
| 392 | case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break; |
| 393 | case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break; |
| 394 | case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break; |
| 395 | case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break; |
| 396 | case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break; |
| 397 | } |
| 398 | |
| 399 | switch (f & SF_ERR_MASK) { |
| 400 | case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break; |
| 401 | case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break; |
| 402 | case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break; |
| 403 | case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break; |
| 404 | case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break; |
| 405 | case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break; |
| 406 | case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break; |
| 407 | case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break; |
| 408 | case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break; |
| 409 | case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break; |
| 410 | case SF_ERR_UP: f &= ~SF_ERR_MASK ; printf("SF_ERR_UP%s", f ? " | " : ""); break; |
Willy Tarreau | a7da4d2 | 2016-11-11 08:05:34 +0100 | [diff] [blame] | 411 | case SF_ERR_CHK_PORT: f &= ~SF_ERR_MASK ; printf("SF_ERR_CHK_PORT%s", f ? " | " : ""); break; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 412 | } |
| 413 | |
Willy Tarreau | 8a0eabd | 2020-02-06 07:57:36 +0100 | [diff] [blame] | 414 | SHOW_FLAG(f, SF_HTX); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 415 | SHOW_FLAG(f, SF_REDIRECTABLE); |
Willy Tarreau | 8a0eabd | 2020-02-06 07:57:36 +0100 | [diff] [blame] | 416 | SHOW_FLAG(f, SF_IGNORE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 417 | SHOW_FLAG(f, SF_REDISP); |
Christopher Faulet | ae024ce | 2022-03-29 19:02:31 +0200 | [diff] [blame] | 418 | SHOW_FLAG(f, SF_CONN_EXP); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 419 | SHOW_FLAG(f, SF_CURR_SESS); |
| 420 | SHOW_FLAG(f, SF_MONITOR); |
| 421 | SHOW_FLAG(f, SF_FORCE_PRST); |
| 422 | SHOW_FLAG(f, SF_BE_ASSIGNED); |
| 423 | SHOW_FLAG(f, SF_ADDR_SET); |
| 424 | SHOW_FLAG(f, SF_ASSIGNED); |
| 425 | SHOW_FLAG(f, SF_DIRECT); |
| 426 | |
| 427 | if (f) { |
| 428 | printf("EXTRA(0x%08x)", f); |
| 429 | } |
| 430 | putchar('\n'); |
| 431 | } |
| 432 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 433 | void usage_exit(const char *name) |
| 434 | { |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 435 | fprintf(stderr, "Usage: %s [ana|chn|conn|cs|si|sierr|strm|task|txn]* { [+-][0x]value* | - }\n", name); |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 436 | exit(1); |
| 437 | } |
| 438 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 439 | int main(int argc, char **argv) |
| 440 | { |
| 441 | unsigned int flags; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 442 | unsigned int show_as = 0; |
| 443 | unsigned int f; |
| 444 | const char *name = argv[0]; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 445 | char line[20]; |
| 446 | char *value; |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 447 | int multi = 0; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 448 | int use_stdin = 0; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 449 | char *err; |
| 450 | |
| 451 | while (argc > 0) { |
| 452 | argv++; argc--; |
| 453 | if (argc < 1) |
| 454 | usage_exit(name); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 455 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 456 | f = get_show_as(argv[0]); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 457 | if (!f) |
| 458 | break; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 459 | show_as |= f; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 460 | } |
| 461 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 462 | if (!show_as) |
| 463 | show_as = ~0U; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 464 | |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 465 | if (argc > 1) |
| 466 | multi = 1; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 467 | |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 468 | if (strcmp(argv[0], "-") == 0) |
| 469 | use_stdin = 1; |
| 470 | |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 471 | while (argc > 0) { |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 472 | if (use_stdin) { |
| 473 | value = fgets(line, sizeof(line), stdin); |
| 474 | if (!value) |
| 475 | break; |
| 476 | |
Ilya Shipitsin | 6fb0f21 | 2020-04-02 15:25:26 +0500 | [diff] [blame] | 477 | /* skip common leading delimiters that slip from copy-paste */ |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 478 | while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=') |
| 479 | value++; |
| 480 | |
| 481 | /* stop at the end of the number and trim any C suffix like "UL" */ |
| 482 | err = value; |
| 483 | while (*err == '-' || *err == '+' || |
Willy Tarreau | b00c00e | 2021-04-02 17:47:21 +0200 | [diff] [blame] | 484 | (isalnum((unsigned char)*err) && toupper((unsigned char)*err) != 'U' && toupper((unsigned char)*err) != 'L')) |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 485 | err++; |
Willy Tarreau | cd430b9 | 2021-04-03 15:26:56 +0200 | [diff] [blame] | 486 | *err = 0; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 487 | } else { |
| 488 | value = argv[0]; |
| 489 | argv++; argc--; |
| 490 | } |
| 491 | |
| 492 | flags = strtoul(value, &err, 0); |
| 493 | if (!*value || *err) { |
| 494 | fprintf(stderr, "Unparsable value: <%s>\n", value); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 495 | usage_exit(name); |
| 496 | } |
| 497 | |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 498 | if (multi || use_stdin) |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 499 | printf("### 0x%08x:\n", flags); |
| 500 | |
| 501 | if (show_as & SHOW_AS_ANA) show_chn_ana(flags); |
| 502 | if (show_as & SHOW_AS_CHN) show_chn_flags(flags); |
| 503 | if (show_as & SHOW_AS_CONN) show_conn_flags(flags); |
| 504 | if (show_as & SHOW_AS_CS) show_cs_flags(flags); |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 505 | if (show_as & SHOW_AS_ENDP) show_endp_flags(flags); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 506 | if (show_as & SHOW_AS_SI) show_si_flags(flags); |
| 507 | if (show_as & SHOW_AS_SIET) show_si_et(flags); |
| 508 | if (show_as & SHOW_AS_STRM) show_strm_flags(flags); |
| 509 | if (show_as & SHOW_AS_TASK) show_task_state(flags); |
| 510 | if (show_as & SHOW_AS_TXN) show_txn_flags(flags); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 511 | } |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 512 | return 0; |
| 513 | } |