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> |
Willy Tarreau | cb086c6 | 2022-05-27 09:47:12 +0200 | [diff] [blame] | 6 | #include <haproxy/stconn-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 |
Willy Tarreau | 79775fa | 2022-05-27 09:57:31 +0200 | [diff] [blame] | 15 | #define SHOW_AS_SC 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 |
Willy Tarreau | 2bacf4e | 2022-05-27 16:29:30 +0200 | [diff] [blame] | 20 | #define SHOW_AS_SD 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. |
Willy Tarreau | 2bacf4e | 2022-05-27 16:29:30 +0200 | [diff] [blame] | 24 | const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", }; |
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 | |
Willy Tarreau | 2bacf4e | 2022-05-27 16:29:30 +0200 | [diff] [blame] | 179 | void show_sd_flags(unsigned int f) |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 180 | { |
Willy Tarreau | 2bacf4e | 2022-05-27 16:29:30 +0200 | [diff] [blame] | 181 | printf("sd->flags = "); |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 182 | if (!f) { |
| 183 | printf("0\n"); |
| 184 | return; |
| 185 | } |
Christopher Faulet | a0bdec3 | 2022-04-04 07:51:21 +0200 | [diff] [blame] | 186 | |
Willy Tarreau | b23edc8 | 2022-05-24 16:49:03 +0200 | [diff] [blame] | 187 | SHOW_FLAG(f, SE_FL_APPLET_NEED_CONN); |
Willy Tarreau | 8c02f8d | 2022-05-25 16:01:38 +0200 | [diff] [blame] | 188 | SHOW_FLAG(f, SE_FL_HAVE_NO_DATA); |
Willy Tarreau | e4ebe26 | 2022-05-27 16:43:52 +0200 | [diff] [blame] | 189 | SHOW_FLAG(f, SE_FL_WONT_CONSUME); |
Willy Tarreau | b605c42 | 2022-05-17 17:04:55 +0200 | [diff] [blame] | 190 | SHOW_FLAG(f, SE_FL_WAIT_DATA); |
| 191 | SHOW_FLAG(f, SE_FL_KILL_CONN); |
| 192 | SHOW_FLAG(f, SE_FL_WAIT_FOR_HS); |
| 193 | SHOW_FLAG(f, SE_FL_WANT_ROOM); |
Willy Tarreau | a577bc2 | 2022-05-27 16:35:20 +0200 | [diff] [blame] | 194 | SHOW_FLAG(f, SE_FL_RCV_MORE); |
| 195 | SHOW_FLAG(f, SE_FL_MAY_SPLICE); |
Willy Tarreau | b605c42 | 2022-05-17 17:04:55 +0200 | [diff] [blame] | 196 | SHOW_FLAG(f, SE_FL_ERR_PENDING); |
Willy Tarreau | a577bc2 | 2022-05-27 16:35:20 +0200 | [diff] [blame] | 197 | SHOW_FLAG(f, SE_FL_ERROR); |
Willy Tarreau | b605c42 | 2022-05-17 17:04:55 +0200 | [diff] [blame] | 198 | SHOW_FLAG(f, SE_FL_EOS); |
| 199 | SHOW_FLAG(f, SE_FL_EOI); |
Willy Tarreau | b605c42 | 2022-05-17 17:04:55 +0200 | [diff] [blame] | 200 | SHOW_FLAG(f, SE_FL_WEBSOCKET); |
| 201 | SHOW_FLAG(f, SE_FL_NOT_FIRST); |
| 202 | SHOW_FLAG(f, SE_FL_SHWS); |
| 203 | SHOW_FLAG(f, SE_FL_SHWN); |
| 204 | SHOW_FLAG(f, SE_FL_SHRR); |
| 205 | SHOW_FLAG(f, SE_FL_SHRD); |
| 206 | SHOW_FLAG(f, SE_FL_ORPHAN); |
| 207 | SHOW_FLAG(f, SE_FL_DETACHED); |
| 208 | SHOW_FLAG(f, SE_FL_T_APPLET); |
| 209 | SHOW_FLAG(f, SE_FL_T_MUX); |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 210 | |
| 211 | if (f) { |
| 212 | printf("EXTRA(0x%08x)", f); |
| 213 | } |
| 214 | putchar('\n'); |
| 215 | } |
Willy Tarreau | 79775fa | 2022-05-27 09:57:31 +0200 | [diff] [blame] | 216 | void show_sc_flags(unsigned int f) |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 217 | { |
Willy Tarreau | 79775fa | 2022-05-27 09:57:31 +0200 | [diff] [blame] | 218 | printf("sc->flags = "); |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 219 | if (!f) { |
| 220 | printf("0\n"); |
| 221 | return; |
| 222 | } |
Willy Tarreau | 15252cd | 2022-05-25 16:36:21 +0200 | [diff] [blame] | 223 | SHOW_FLAG(f, SC_FL_NEED_ROOM); |
| 224 | SHOW_FLAG(f, SC_FL_NEED_BUFF); |
| 225 | SHOW_FLAG(f, SC_FL_WONT_READ); |
Willy Tarreau | cb04166 | 2022-05-17 19:44:42 +0200 | [diff] [blame] | 226 | SHOW_FLAG(f, SC_FL_INDEP_STR); |
| 227 | SHOW_FLAG(f, SC_FL_DONT_WAKE); |
Willy Tarreau | cb04166 | 2022-05-17 19:44:42 +0200 | [diff] [blame] | 228 | SHOW_FLAG(f, SC_FL_NOHALF); |
Willy Tarreau | a577bc2 | 2022-05-27 16:35:20 +0200 | [diff] [blame] | 229 | SHOW_FLAG(f, SC_FL_NOLINGER); |
Willy Tarreau | cb04166 | 2022-05-17 19:44:42 +0200 | [diff] [blame] | 230 | SHOW_FLAG(f, SC_FL_ISBACK); |
Christopher Faulet | 5f8ef13 | 2018-03-01 08:55:21 +0100 | [diff] [blame] | 231 | |
| 232 | if (f) { |
| 233 | printf("EXTRA(0x%08x)", f); |
| 234 | } |
| 235 | putchar('\n'); |
| 236 | } |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 237 | |
Christopher Faulet | 50264b4 | 2022-03-30 19:39:30 +0200 | [diff] [blame] | 238 | void show_strm_et(unsigned int f) |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 239 | { |
Christopher Faulet | 50264b4 | 2022-03-30 19:39:30 +0200 | [diff] [blame] | 240 | printf("strm->et = "); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 241 | if (!f) { |
Christopher Faulet | 50264b4 | 2022-03-30 19:39:30 +0200 | [diff] [blame] | 242 | printf("STRM_ET_NONE\n"); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 243 | return; |
| 244 | } |
| 245 | |
Christopher Faulet | 50264b4 | 2022-03-30 19:39:30 +0200 | [diff] [blame] | 246 | SHOW_FLAG(f, STRM_ET_QUEUE_TO); |
| 247 | SHOW_FLAG(f, STRM_ET_QUEUE_ERR); |
| 248 | SHOW_FLAG(f, STRM_ET_QUEUE_ABRT); |
| 249 | SHOW_FLAG(f, STRM_ET_CONN_TO); |
| 250 | SHOW_FLAG(f, STRM_ET_CONN_ERR); |
| 251 | SHOW_FLAG(f, STRM_ET_CONN_ABRT); |
| 252 | SHOW_FLAG(f, STRM_ET_CONN_RES); |
| 253 | SHOW_FLAG(f, STRM_ET_CONN_OTHER); |
| 254 | SHOW_FLAG(f, STRM_ET_DATA_TO); |
| 255 | SHOW_FLAG(f, STRM_ET_DATA_ERR); |
| 256 | SHOW_FLAG(f, STRM_ET_DATA_ABRT); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 257 | |
| 258 | if (f) { |
| 259 | printf("EXTRA(0x%08x)", f); |
| 260 | } |
| 261 | putchar('\n'); |
| 262 | } |
| 263 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 264 | void show_task_state(unsigned int f) |
| 265 | { |
| 266 | printf("task->state = "); |
| 267 | |
| 268 | if (!f) { |
| 269 | printf("TASK_SLEEPING\n"); |
| 270 | return; |
| 271 | } |
| 272 | |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 273 | SHOW_FLAG(f, TASK_F_USR1); |
| 274 | SHOW_FLAG(f, TASK_F_TASKLET); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 275 | SHOW_FLAG(f, TASK_WOKEN_OTHER); |
| 276 | SHOW_FLAG(f, TASK_WOKEN_RES); |
| 277 | SHOW_FLAG(f, TASK_WOKEN_MSG); |
| 278 | SHOW_FLAG(f, TASK_WOKEN_SIGNAL); |
| 279 | SHOW_FLAG(f, TASK_WOKEN_IO); |
| 280 | SHOW_FLAG(f, TASK_WOKEN_TIMER); |
| 281 | SHOW_FLAG(f, TASK_WOKEN_INIT); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 282 | SHOW_FLAG(f, TASK_HEAVY); |
| 283 | SHOW_FLAG(f, TASK_IN_LIST); |
| 284 | SHOW_FLAG(f, TASK_KILLED); |
| 285 | SHOW_FLAG(f, TASK_SELF_WAKING); |
| 286 | SHOW_FLAG(f, TASK_SHARED_WQ); |
| 287 | SHOW_FLAG(f, TASK_QUEUED); |
| 288 | SHOW_FLAG(f, TASK_GLOBAL); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 289 | SHOW_FLAG(f, TASK_RUNNING); |
| 290 | |
| 291 | if (f) { |
| 292 | printf("EXTRA(0x%08x)", f); |
| 293 | } |
| 294 | putchar('\n'); |
| 295 | } |
| 296 | |
| 297 | void show_txn_flags(unsigned int f) |
| 298 | { |
| 299 | printf("txn->flags = "); |
| 300 | |
| 301 | if (!f) { |
| 302 | printf("0\n"); |
| 303 | return; |
| 304 | } |
| 305 | |
Christopher Faulet | e05bf9e | 2022-03-29 15:23:40 +0200 | [diff] [blame] | 306 | SHOW_FLAG(f, TX_L7_RETRY); |
| 307 | SHOW_FLAG(f, TX_D_L7_RETRY); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 308 | SHOW_FLAG(f, TX_NOT_FIRST); |
| 309 | SHOW_FLAG(f, TX_USE_PX_CONN); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 310 | SHOW_FLAG(f, TX_CACHE_HAS_SEC_KEY); |
Christopher Faulet | c41547b | 2019-07-16 14:32:23 +0200 | [diff] [blame] | 311 | SHOW_FLAG(f, TX_CON_WANT_TUN); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 312 | |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 313 | SHOW_FLAG(f, TX_CACHE_IGNORE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 314 | SHOW_FLAG(f, TX_CACHE_COOK); |
| 315 | SHOW_FLAG(f, TX_CACHEABLE); |
| 316 | SHOW_FLAG(f, TX_SCK_PRESENT); |
| 317 | |
| 318 | //printf("%s", f ? "" : " | "); |
| 319 | switch (f & TX_SCK_MASK) { |
| 320 | case TX_SCK_NONE: f &= ~TX_SCK_MASK ; /*printf("TX_SCK_NONE%s", f ? " | " : "");*/ break; |
| 321 | case TX_SCK_FOUND: f &= ~TX_SCK_MASK ; printf("TX_SCK_FOUND%s", f ? " | " : ""); break; |
| 322 | case TX_SCK_DELETED: f &= ~TX_SCK_MASK ; printf("TX_SCK_DELETED%s", f ? " | " : ""); break; |
| 323 | case TX_SCK_INSERTED: f &= ~TX_SCK_MASK ; printf("TX_SCK_INSERTED%s", f ? " | " : ""); break; |
| 324 | case TX_SCK_REPLACED: f &= ~TX_SCK_MASK ; printf("TX_SCK_REPLACED%s", f ? " | " : ""); break; |
| 325 | case TX_SCK_UPDATED: f &= ~TX_SCK_MASK ; printf("TX_SCK_UPDATED%s", f ? " | " : ""); break; |
| 326 | default: printf("TX_SCK_MASK(%02x)", f); f &= ~TX_SCK_MASK ; printf("%s", f ? " | " : ""); break; |
| 327 | } |
| 328 | |
| 329 | //printf("%s", f ? "" : " | "); |
| 330 | switch (f & TX_CK_MASK) { |
| 331 | case TX_CK_NONE: f &= ~TX_CK_MASK ; /*printf("TX_CK_NONE%s", f ? " | " : "");*/ break; |
| 332 | case TX_CK_INVALID: f &= ~TX_CK_MASK ; printf("TX_CK_INVALID%s", f ? " | " : ""); break; |
| 333 | case TX_CK_DOWN: f &= ~TX_CK_MASK ; printf("TX_CK_DOWN%s", f ? " | " : ""); break; |
| 334 | case TX_CK_VALID: f &= ~TX_CK_MASK ; printf("TX_CK_VALID%s", f ? " | " : ""); break; |
| 335 | case TX_CK_EXPIRED: f &= ~TX_CK_MASK ; printf("TX_CK_EXPIRED%s", f ? " | " : ""); break; |
| 336 | case TX_CK_OLD: f &= ~TX_CK_MASK ; printf("TX_CK_OLD%s", f ? " | " : ""); break; |
| 337 | case TX_CK_UNUSED: f &= ~TX_CK_MASK ; printf("TX_CK_UNUSED%s", f ? " | " : ""); break; |
| 338 | default: printf("TX_CK_MASK(%02x)", f); f &= ~TX_CK_MASK ; printf("%s", f ? " | " : ""); break; |
| 339 | } |
| 340 | |
| 341 | SHOW_FLAG(f, TX_CLTARPIT); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 342 | SHOW_FLAG(f, TX_CONST_REPLY); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 343 | |
| 344 | if (f) { |
| 345 | printf("EXTRA(0x%08x)", f); |
| 346 | } |
| 347 | putchar('\n'); |
| 348 | } |
| 349 | |
| 350 | void show_strm_flags(unsigned int f) |
| 351 | { |
| 352 | printf("strm->flags = "); |
| 353 | |
| 354 | if (!f) { |
| 355 | printf("0\n"); |
| 356 | return; |
| 357 | } |
| 358 | |
Christopher Faulet | d139138 | 2022-03-30 16:26:39 +0200 | [diff] [blame] | 359 | SHOW_FLAG(f, SF_SRC_ADDR); |
Christopher Faulet | c2b7fa8 | 2022-01-18 10:46:10 +0100 | [diff] [blame] | 360 | SHOW_FLAG(f, SF_WEBSOCKET); |
| 361 | SHOW_FLAG(f, SF_SRV_REUSED_ANTICIPATED); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 362 | SHOW_FLAG(f, SF_SRV_REUSED); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 363 | SHOW_FLAG(f, SF_IGNORE_PRST); |
| 364 | |
| 365 | //printf("%s", f ? "" : " | "); |
| 366 | switch (f & SF_FINST_MASK) { |
| 367 | case SF_FINST_R: f &= ~SF_FINST_MASK ; printf("SF_FINST_R%s", f ? " | " : ""); break; |
| 368 | case SF_FINST_C: f &= ~SF_FINST_MASK ; printf("SF_FINST_C%s", f ? " | " : ""); break; |
| 369 | case SF_FINST_H: f &= ~SF_FINST_MASK ; printf("SF_FINST_H%s", f ? " | " : ""); break; |
| 370 | case SF_FINST_D: f &= ~SF_FINST_MASK ; printf("SF_FINST_D%s", f ? " | " : ""); break; |
| 371 | case SF_FINST_L: f &= ~SF_FINST_MASK ; printf("SF_FINST_L%s", f ? " | " : ""); break; |
| 372 | case SF_FINST_Q: f &= ~SF_FINST_MASK ; printf("SF_FINST_Q%s", f ? " | " : ""); break; |
| 373 | case SF_FINST_T: f &= ~SF_FINST_MASK ; printf("SF_FINST_T%s", f ? " | " : ""); break; |
| 374 | } |
| 375 | |
| 376 | switch (f & SF_ERR_MASK) { |
| 377 | case SF_ERR_LOCAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_LOCAL%s", f ? " | " : ""); break; |
| 378 | case SF_ERR_CLITO: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLITO%s", f ? " | " : ""); break; |
| 379 | case SF_ERR_CLICL: f &= ~SF_ERR_MASK ; printf("SF_ERR_CLICL%s", f ? " | " : ""); break; |
| 380 | case SF_ERR_SRVTO: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVTO%s", f ? " | " : ""); break; |
| 381 | case SF_ERR_SRVCL: f &= ~SF_ERR_MASK ; printf("SF_ERR_SRVCL%s", f ? " | " : ""); break; |
| 382 | case SF_ERR_PRXCOND: f &= ~SF_ERR_MASK ; printf("SF_ERR_PRXCOND%s", f ? " | " : ""); break; |
| 383 | case SF_ERR_RESOURCE: f &= ~SF_ERR_MASK ; printf("SF_ERR_RESOURCE%s", f ? " | " : ""); break; |
| 384 | case SF_ERR_INTERNAL: f &= ~SF_ERR_MASK ; printf("SF_ERR_INTERNAL%s", f ? " | " : ""); break; |
| 385 | case SF_ERR_DOWN: f &= ~SF_ERR_MASK ; printf("SF_ERR_DOWN%s", f ? " | " : ""); break; |
| 386 | case SF_ERR_KILLED: f &= ~SF_ERR_MASK ; printf("SF_ERR_KILLED%s", f ? " | " : ""); break; |
| 387 | 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] | 388 | 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] | 389 | } |
| 390 | |
Willy Tarreau | 8a0eabd | 2020-02-06 07:57:36 +0100 | [diff] [blame] | 391 | SHOW_FLAG(f, SF_HTX); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 392 | SHOW_FLAG(f, SF_REDIRECTABLE); |
Willy Tarreau | 8a0eabd | 2020-02-06 07:57:36 +0100 | [diff] [blame] | 393 | SHOW_FLAG(f, SF_IGNORE); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 394 | SHOW_FLAG(f, SF_REDISP); |
Christopher Faulet | ae024ce | 2022-03-29 19:02:31 +0200 | [diff] [blame] | 395 | SHOW_FLAG(f, SF_CONN_EXP); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 396 | SHOW_FLAG(f, SF_CURR_SESS); |
| 397 | SHOW_FLAG(f, SF_MONITOR); |
| 398 | SHOW_FLAG(f, SF_FORCE_PRST); |
| 399 | SHOW_FLAG(f, SF_BE_ASSIGNED); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 400 | SHOW_FLAG(f, SF_ASSIGNED); |
| 401 | SHOW_FLAG(f, SF_DIRECT); |
| 402 | |
| 403 | if (f) { |
| 404 | printf("EXTRA(0x%08x)", f); |
| 405 | } |
| 406 | putchar('\n'); |
| 407 | } |
| 408 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 409 | void usage_exit(const char *name) |
| 410 | { |
Willy Tarreau | 79775fa | 2022-05-27 09:57:31 +0200 | [diff] [blame] | 411 | fprintf(stderr, "Usage: %s [ana|chn|conn|sc|si|sierr|strm|task|txn]* { [+-][0x]value* | - }\n", name); |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 412 | exit(1); |
| 413 | } |
| 414 | |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 415 | int main(int argc, char **argv) |
| 416 | { |
| 417 | unsigned int flags; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 418 | unsigned int show_as = 0; |
| 419 | unsigned int f; |
| 420 | const char *name = argv[0]; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 421 | char line[20]; |
| 422 | char *value; |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 423 | int multi = 0; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 424 | int use_stdin = 0; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 425 | char *err; |
| 426 | |
| 427 | while (argc > 0) { |
| 428 | argv++; argc--; |
| 429 | if (argc < 1) |
| 430 | usage_exit(name); |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 431 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 432 | f = get_show_as(argv[0]); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 433 | if (!f) |
| 434 | break; |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 435 | show_as |= f; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 436 | } |
| 437 | |
Willy Tarreau | 354b6f5 | 2020-02-06 08:33:08 +0100 | [diff] [blame] | 438 | if (!show_as) |
| 439 | show_as = ~0U; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 440 | |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 441 | if (argc > 1) |
| 442 | multi = 1; |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 443 | |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 444 | if (strcmp(argv[0], "-") == 0) |
| 445 | use_stdin = 1; |
| 446 | |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 447 | while (argc > 0) { |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 448 | if (use_stdin) { |
| 449 | value = fgets(line, sizeof(line), stdin); |
| 450 | if (!value) |
| 451 | break; |
| 452 | |
Ilya Shipitsin | 6fb0f21 | 2020-04-02 15:25:26 +0500 | [diff] [blame] | 453 | /* skip common leading delimiters that slip from copy-paste */ |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 454 | while (*value == ' ' || *value == '\t' || *value == ':' || *value == '=') |
| 455 | value++; |
| 456 | |
| 457 | /* stop at the end of the number and trim any C suffix like "UL" */ |
| 458 | err = value; |
| 459 | while (*err == '-' || *err == '+' || |
Willy Tarreau | b00c00e | 2021-04-02 17:47:21 +0200 | [diff] [blame] | 460 | (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] | 461 | err++; |
Willy Tarreau | cd430b9 | 2021-04-03 15:26:56 +0200 | [diff] [blame] | 462 | *err = 0; |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 463 | } else { |
| 464 | value = argv[0]; |
| 465 | argv++; argc--; |
| 466 | } |
| 467 | |
| 468 | flags = strtoul(value, &err, 0); |
| 469 | if (!*value || *err) { |
| 470 | fprintf(stderr, "Unparsable value: <%s>\n", value); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 471 | usage_exit(name); |
| 472 | } |
| 473 | |
Willy Tarreau | e4f80a0 | 2020-02-06 18:17:50 +0100 | [diff] [blame] | 474 | if (multi || use_stdin) |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 475 | printf("### 0x%08x:\n", flags); |
| 476 | |
| 477 | if (show_as & SHOW_AS_ANA) show_chn_ana(flags); |
| 478 | if (show_as & SHOW_AS_CHN) show_chn_flags(flags); |
| 479 | if (show_as & SHOW_AS_CONN) show_conn_flags(flags); |
Willy Tarreau | 79775fa | 2022-05-27 09:57:31 +0200 | [diff] [blame] | 480 | if (show_as & SHOW_AS_SC) show_sc_flags(flags); |
Willy Tarreau | 2bacf4e | 2022-05-27 16:29:30 +0200 | [diff] [blame] | 481 | if (show_as & SHOW_AS_SD) show_sd_flags(flags); |
Christopher Faulet | 50264b4 | 2022-03-30 19:39:30 +0200 | [diff] [blame] | 482 | if (show_as & SHOW_AS_SET) show_strm_et(flags); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 483 | if (show_as & SHOW_AS_STRM) show_strm_flags(flags); |
| 484 | if (show_as & SHOW_AS_TASK) show_task_state(flags); |
| 485 | if (show_as & SHOW_AS_TXN) show_txn_flags(flags); |
Willy Tarreau | bde76f0 | 2020-02-06 08:48:16 +0100 | [diff] [blame] | 486 | } |
Willy Tarreau | 074d65b | 2015-12-20 23:21:57 +0100 | [diff] [blame] | 487 | return 0; |
| 488 | } |