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