Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Stream filters related variables and functions. |
| 3 | * |
| 4 | * Copyright (C) 2015 Qualys Inc., Christopher Faulet <cfaulet@qualys.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <common/buffer.h> |
| 14 | #include <common/debug.h> |
| 15 | #include <common/cfgparse.h> |
| 16 | #include <common/compat.h> |
| 17 | #include <common/config.h> |
| 18 | #include <common/errors.h> |
Willy Tarreau | b96b77e | 2018-12-11 10:22:41 +0100 | [diff] [blame] | 19 | #include <common/htx.h> |
Willy Tarreau | 0108d90 | 2018-11-25 19:14:37 +0100 | [diff] [blame] | 20 | #include <common/initcall.h> |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 21 | #include <common/namespace.h> |
| 22 | #include <common/standard.h> |
Christopher Faulet | 71a6a8e | 2017-07-27 16:33:28 +0200 | [diff] [blame] | 23 | #include <common/hathreads.h> |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 24 | |
| 25 | #include <types/filters.h> |
Christopher Faulet | fc9cfe4 | 2019-07-16 14:54:53 +0200 | [diff] [blame] | 26 | #include <types/http_ana.h> |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 27 | |
| 28 | #include <proto/compression.h> |
| 29 | #include <proto/filters.h> |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 30 | #include <proto/flt_http_comp.h> |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 31 | #include <proto/http_htx.h> |
Christopher Faulet | fc9cfe4 | 2019-07-16 14:54:53 +0200 | [diff] [blame] | 32 | #include <proto/http_ana.h> |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 33 | #include <proto/stream.h> |
| 34 | #include <proto/stream_interface.h> |
| 35 | |
| 36 | /* Pool used to allocate filters */ |
Willy Tarreau | 8ceae72 | 2018-11-26 11:58:30 +0100 | [diff] [blame] | 37 | DECLARE_STATIC_POOL(pool_head_filter, "filter", sizeof(struct filter)); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 38 | |
| 39 | static int handle_analyzer_result(struct stream *s, struct channel *chn, unsigned int an_bit, int ret); |
| 40 | |
| 41 | /* - RESUME_FILTER_LOOP and RESUME_FILTER_END must always be used together. |
| 42 | * The first one begins a loop and the seconds one ends it. |
| 43 | * |
| 44 | * - BREAK_EXECUTION must be used to break the loop and set the filter from |
| 45 | * which to resume the next time. |
| 46 | * |
Bertrand Jacquin | 874a35c | 2018-09-10 21:26:07 +0100 | [diff] [blame] | 47 | * Here is an example: |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 48 | * |
| 49 | * RESUME_FILTER_LOOP(stream, channel) { |
| 50 | * ... |
| 51 | * if (cond) |
| 52 | * BREAK_EXECUTION(stream, channel, label); |
| 53 | * ... |
| 54 | * } RESUME_FILTER_END; |
| 55 | * ... |
| 56 | * label: |
| 57 | * ... |
| 58 | * |
| 59 | */ |
| 60 | #define RESUME_FILTER_LOOP(strm, chn) \ |
| 61 | do { \ |
| 62 | struct filter *filter; \ |
| 63 | \ |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 64 | if (strm_flt(strm)->current[CHN_IDX(chn)]) { \ |
| 65 | filter = strm_flt(strm)->current[CHN_IDX(chn)]; \ |
| 66 | strm_flt(strm)->current[CHN_IDX(chn)] = NULL; \ |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 67 | goto resume_execution; \ |
| 68 | } \ |
| 69 | \ |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 70 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { \ |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 71 | resume_execution: |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 72 | |
| 73 | #define RESUME_FILTER_END \ |
| 74 | } \ |
| 75 | } while(0) |
| 76 | |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 77 | #define BREAK_EXECUTION(strm, chn, label) \ |
| 78 | do { \ |
| 79 | strm_flt(strm)->current[CHN_IDX(chn)] = filter; \ |
| 80 | goto label; \ |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 81 | } while (0) |
| 82 | |
| 83 | |
| 84 | /* List head of all known filter keywords */ |
| 85 | static struct flt_kw_list flt_keywords = { |
| 86 | .list = LIST_HEAD_INIT(flt_keywords.list) |
| 87 | }; |
| 88 | |
| 89 | /* |
| 90 | * Registers the filter keyword list <kwl> as a list of valid keywords for next |
| 91 | * parsing sessions. |
| 92 | */ |
| 93 | void |
| 94 | flt_register_keywords(struct flt_kw_list *kwl) |
| 95 | { |
| 96 | LIST_ADDQ(&flt_keywords.list, &kwl->list); |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | * Returns a pointer to the filter keyword <kw>, or NULL if not found. If the |
| 101 | * keyword is found with a NULL ->parse() function, then an attempt is made to |
| 102 | * find one with a valid ->parse() function. This way it is possible to declare |
| 103 | * platform-dependant, known keywords as NULL, then only declare them as valid |
| 104 | * if some options are met. Note that if the requested keyword contains an |
| 105 | * opening parenthesis, everything from this point is ignored. |
| 106 | */ |
| 107 | struct flt_kw * |
| 108 | flt_find_kw(const char *kw) |
| 109 | { |
| 110 | int index; |
| 111 | const char *kwend; |
| 112 | struct flt_kw_list *kwl; |
| 113 | struct flt_kw *ret = NULL; |
| 114 | |
| 115 | kwend = strchr(kw, '('); |
| 116 | if (!kwend) |
| 117 | kwend = kw + strlen(kw); |
| 118 | |
| 119 | list_for_each_entry(kwl, &flt_keywords.list, list) { |
| 120 | for (index = 0; kwl->kw[index].kw != NULL; index++) { |
| 121 | if ((strncmp(kwl->kw[index].kw, kw, kwend - kw) == 0) && |
| 122 | kwl->kw[index].kw[kwend-kw] == 0) { |
| 123 | if (kwl->kw[index].parse) |
| 124 | return &kwl->kw[index]; /* found it !*/ |
| 125 | else |
| 126 | ret = &kwl->kw[index]; /* may be OK */ |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | return ret; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | * Dumps all registered "filter" keywords to the <out> string pointer. The |
| 135 | * unsupported keywords are only dumped if their supported form was not found. |
| 136 | */ |
| 137 | void |
| 138 | flt_dump_kws(char **out) |
| 139 | { |
| 140 | struct flt_kw_list *kwl; |
| 141 | int index; |
| 142 | |
| 143 | *out = NULL; |
| 144 | list_for_each_entry(kwl, &flt_keywords.list, list) { |
| 145 | for (index = 0; kwl->kw[index].kw != NULL; index++) { |
| 146 | if (kwl->kw[index].parse || |
| 147 | flt_find_kw(kwl->kw[index].kw) == &kwl->kw[index]) { |
| 148 | memprintf(out, "%s[%4s] %s%s\n", *out ? *out : "", |
| 149 | kwl->scope, |
| 150 | kwl->kw[index].kw, |
| 151 | kwl->kw[index].parse ? "" : " (not supported)"); |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | /* |
Christopher Faulet | b3f4e14 | 2016-03-07 12:46:38 +0100 | [diff] [blame] | 158 | * Lists the known filters on <out> |
| 159 | */ |
| 160 | void |
| 161 | list_filters(FILE *out) |
| 162 | { |
| 163 | char *filters, *p, *f; |
| 164 | |
| 165 | fprintf(out, "Available filters :\n"); |
| 166 | flt_dump_kws(&filters); |
| 167 | for (p = filters; (f = strtok_r(p,"\n",&p));) |
| 168 | fprintf(out, "\t%s\n", f); |
| 169 | free(filters); |
| 170 | } |
| 171 | |
| 172 | /* |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 173 | * Parses the "filter" keyword. All keywords must be handled by filters |
| 174 | * themselves |
| 175 | */ |
| 176 | static int |
| 177 | parse_filter(char **args, int section_type, struct proxy *curpx, |
| 178 | struct proxy *defpx, const char *file, int line, char **err) |
| 179 | { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 180 | struct flt_conf *fconf = NULL; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 181 | |
| 182 | /* Filter cannot be defined on a default proxy */ |
| 183 | if (curpx == defpx) { |
Christopher Faulet | cc7317d | 2016-04-04 10:51:17 +0200 | [diff] [blame] | 184 | memprintf(err, "parsing [%s:%d] : %s is not allowed in a 'default' section.", |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 185 | file, line, args[0]); |
| 186 | return -1; |
| 187 | } |
| 188 | if (!strcmp(args[0], "filter")) { |
| 189 | struct flt_kw *kw; |
| 190 | int cur_arg; |
| 191 | |
| 192 | if (!*args[1]) { |
| 193 | memprintf(err, |
| 194 | "parsing [%s:%d] : missing argument for '%s' in %s '%s'.", |
| 195 | file, line, args[0], proxy_type_str(curpx), curpx->id); |
| 196 | goto error; |
| 197 | } |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 198 | fconf = calloc(1, sizeof(*fconf)); |
| 199 | if (!fconf) { |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 200 | memprintf(err, "'%s' : out of memory", args[0]); |
| 201 | goto error; |
| 202 | } |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 203 | |
| 204 | cur_arg = 1; |
| 205 | kw = flt_find_kw(args[cur_arg]); |
| 206 | if (kw) { |
| 207 | if (!kw->parse) { |
| 208 | memprintf(err, "parsing [%s:%d] : '%s' : " |
| 209 | "'%s' option is not implemented in this version (check build options).", |
| 210 | file, line, args[0], args[cur_arg]); |
| 211 | goto error; |
| 212 | } |
Thierry Fournier | 3610c39 | 2016-04-13 18:27:51 +0200 | [diff] [blame] | 213 | if (kw->parse(args, &cur_arg, curpx, fconf, err, kw->private) != 0) { |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 214 | if (err && *err) |
| 215 | memprintf(err, "'%s' : '%s'", |
| 216 | args[0], *err); |
| 217 | else |
| 218 | memprintf(err, "'%s' : error encountered while processing '%s'", |
| 219 | args[0], args[cur_arg]); |
| 220 | goto error; |
| 221 | } |
| 222 | } |
| 223 | else { |
| 224 | flt_dump_kws(err); |
| 225 | indent_msg(err, 4); |
| 226 | memprintf(err, "'%s' : unknown keyword '%s'.%s%s", |
| 227 | args[0], args[cur_arg], |
| 228 | err && *err ? " Registered keywords :" : "", err && *err ? *err : ""); |
| 229 | goto error; |
| 230 | } |
| 231 | if (*args[cur_arg]) { |
| 232 | memprintf(err, "'%s %s' : unknown keyword '%s'.", |
| 233 | args[0], args[1], args[cur_arg]); |
| 234 | goto error; |
| 235 | } |
Christopher Faulet | 00e818a | 2016-04-19 17:00:44 +0200 | [diff] [blame] | 236 | if (fconf->ops == NULL) { |
| 237 | memprintf(err, "'%s %s' : no callbacks defined.", |
| 238 | args[0], args[1]); |
| 239 | goto error; |
| 240 | } |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 241 | |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 242 | LIST_ADDQ(&curpx->filter_configs, &fconf->list); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 243 | } |
| 244 | return 0; |
| 245 | |
| 246 | error: |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 247 | free(fconf); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 248 | return -1; |
| 249 | |
| 250 | |
| 251 | } |
| 252 | |
| 253 | /* |
| 254 | * Calls 'init' callback for all filters attached to a proxy. This happens after |
| 255 | * the configuration parsing. Filters can finish to fill their config. Returns |
| 256 | * (ERR_ALERT|ERR_FATAL) if an error occurs, 0 otherwise. |
| 257 | */ |
Willy Tarreau | 64bca59 | 2016-12-21 20:13:11 +0100 | [diff] [blame] | 258 | static int |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 259 | flt_init(struct proxy *proxy) |
| 260 | { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 261 | struct flt_conf *fconf; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 262 | |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 263 | list_for_each_entry(fconf, &proxy->filter_configs, list) { |
| 264 | if (fconf->ops->init && fconf->ops->init(proxy, fconf) < 0) |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 265 | return ERR_ALERT|ERR_FATAL; |
| 266 | } |
| 267 | return 0; |
| 268 | } |
| 269 | |
Christopher Faulet | 71a6a8e | 2017-07-27 16:33:28 +0200 | [diff] [blame] | 270 | /* |
| 271 | * Calls 'init_per_thread' callback for all filters attached to a proxy for each |
| 272 | * threads. This happens after the thread creation. Filters can finish to fill |
| 273 | * their config. Returns (ERR_ALERT|ERR_FATAL) if an error occurs, 0 otherwise. |
| 274 | */ |
| 275 | static int |
| 276 | flt_init_per_thread(struct proxy *proxy) |
| 277 | { |
| 278 | struct flt_conf *fconf; |
| 279 | |
| 280 | list_for_each_entry(fconf, &proxy->filter_configs, list) { |
| 281 | if (fconf->ops->init_per_thread && fconf->ops->init_per_thread(proxy, fconf) < 0) |
| 282 | return ERR_ALERT|ERR_FATAL; |
| 283 | } |
| 284 | return 0; |
| 285 | } |
| 286 | |
Willy Tarreau | 64bca59 | 2016-12-21 20:13:11 +0100 | [diff] [blame] | 287 | /* Calls flt_init() for all proxies, see above */ |
| 288 | static int |
| 289 | flt_init_all() |
| 290 | { |
| 291 | struct proxy *px; |
| 292 | int err_code = 0; |
| 293 | |
Olivier Houchard | fbc74e8 | 2017-11-24 16:54:05 +0100 | [diff] [blame] | 294 | for (px = proxies_list; px; px = px->next) { |
Willy Tarreau | 64bca59 | 2016-12-21 20:13:11 +0100 | [diff] [blame] | 295 | err_code |= flt_init(px); |
| 296 | if (err_code & (ERR_ABORT|ERR_FATAL)) { |
Christopher Faulet | 767a84b | 2017-11-24 16:50:31 +0100 | [diff] [blame] | 297 | ha_alert("Failed to initialize filters for proxy '%s'.\n", |
| 298 | px->id); |
Willy Tarreau | 64bca59 | 2016-12-21 20:13:11 +0100 | [diff] [blame] | 299 | return err_code; |
| 300 | } |
| 301 | } |
| 302 | return 0; |
| 303 | } |
| 304 | |
Joseph Herlant | b35ea68 | 2018-11-15 12:24:23 -0800 | [diff] [blame] | 305 | /* Calls flt_init_per_thread() for all proxies, see above. Be careful here, it |
| 306 | * returns 0 if an error occurred. This is the opposite of flt_init_all. */ |
Christopher Faulet | 71a6a8e | 2017-07-27 16:33:28 +0200 | [diff] [blame] | 307 | static int |
| 308 | flt_init_all_per_thread() |
| 309 | { |
| 310 | struct proxy *px; |
| 311 | int err_code = 0; |
| 312 | |
Olivier Houchard | fbc74e8 | 2017-11-24 16:54:05 +0100 | [diff] [blame] | 313 | for (px = proxies_list; px; px = px->next) { |
Christopher Faulet | 71a6a8e | 2017-07-27 16:33:28 +0200 | [diff] [blame] | 314 | err_code = flt_init_per_thread(px); |
| 315 | if (err_code & (ERR_ABORT|ERR_FATAL)) { |
Christopher Faulet | 767a84b | 2017-11-24 16:50:31 +0100 | [diff] [blame] | 316 | ha_alert("Failed to initialize filters for proxy '%s' for thread %u.\n", |
| 317 | px->id, tid); |
Christopher Faulet | 71a6a8e | 2017-07-27 16:33:28 +0200 | [diff] [blame] | 318 | return 0; |
| 319 | } |
| 320 | } |
| 321 | return 1; |
| 322 | } |
| 323 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 324 | /* |
| 325 | * Calls 'check' callback for all filters attached to a proxy. This happens |
| 326 | * after the configuration parsing but before filters initialization. Returns |
| 327 | * the number of encountered errors. |
| 328 | */ |
| 329 | int |
| 330 | flt_check(struct proxy *proxy) |
| 331 | { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 332 | struct flt_conf *fconf; |
| 333 | int err = 0; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 334 | |
Christopher Faulet | ff17b18 | 2019-01-07 15:03:22 +0100 | [diff] [blame] | 335 | err += check_implicit_http_comp_flt(proxy); |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 336 | list_for_each_entry(fconf, &proxy->filter_configs, list) { |
| 337 | if (fconf->ops->check) |
| 338 | err += fconf->ops->check(proxy, fconf); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 339 | } |
| 340 | return err; |
| 341 | } |
| 342 | |
| 343 | /* |
| 344 | * Calls 'denit' callback for all filters attached to a proxy. This happens when |
| 345 | * HAProxy is stopped. |
| 346 | */ |
| 347 | void |
| 348 | flt_deinit(struct proxy *proxy) |
| 349 | { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 350 | struct flt_conf *fconf, *back; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 351 | |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 352 | list_for_each_entry_safe(fconf, back, &proxy->filter_configs, list) { |
| 353 | if (fconf->ops->deinit) |
| 354 | fconf->ops->deinit(proxy, fconf); |
| 355 | LIST_DEL(&fconf->list); |
| 356 | free(fconf); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
Christopher Faulet | 71a6a8e | 2017-07-27 16:33:28 +0200 | [diff] [blame] | 360 | /* |
| 361 | * Calls 'denit_per_thread' callback for all filters attached to a proxy for |
| 362 | * each threads. This happens before exiting a thread. |
| 363 | */ |
| 364 | void |
| 365 | flt_deinit_per_thread(struct proxy *proxy) |
| 366 | { |
| 367 | struct flt_conf *fconf, *back; |
| 368 | |
| 369 | list_for_each_entry_safe(fconf, back, &proxy->filter_configs, list) { |
| 370 | if (fconf->ops->deinit_per_thread) |
| 371 | fconf->ops->deinit_per_thread(proxy, fconf); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | |
| 376 | /* Calls flt_deinit_per_thread() for all proxies, see above */ |
| 377 | static void |
| 378 | flt_deinit_all_per_thread() |
| 379 | { |
| 380 | struct proxy *px; |
| 381 | |
Olivier Houchard | fbc74e8 | 2017-11-24 16:54:05 +0100 | [diff] [blame] | 382 | for (px = proxies_list; px; px = px->next) |
Christopher Faulet | 71a6a8e | 2017-07-27 16:33:28 +0200 | [diff] [blame] | 383 | flt_deinit_per_thread(px); |
| 384 | } |
| 385 | |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 386 | /* Attaches a filter to a stream. Returns -1 if an error occurs, 0 otherwise. */ |
| 387 | static int |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 388 | flt_stream_add_filter(struct stream *s, struct flt_conf *fconf, unsigned int flags) |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 389 | { |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 390 | struct filter *f; |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 391 | |
Christopher Faulet | 0f17a9b | 2019-04-05 10:11:38 +0200 | [diff] [blame] | 392 | if (IS_HTX_STRM(s) && !(fconf->flags & FLT_CFG_FL_HTX)) |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 393 | return 0; |
| 394 | |
| 395 | f = pool_alloc(pool_head_filter); |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 396 | if (!f) /* not enough memory */ |
| 397 | return -1; |
| 398 | memset(f, 0, sizeof(*f)); |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 399 | f->config = fconf; |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 400 | f->flags |= flags; |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 401 | |
| 402 | if (FLT_OPS(f)->attach) { |
| 403 | int ret = FLT_OPS(f)->attach(s, f); |
| 404 | if (ret <= 0) { |
Willy Tarreau | bafbe01 | 2017-11-24 17:34:44 +0100 | [diff] [blame] | 405 | pool_free(pool_head_filter, f); |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 406 | return ret; |
| 407 | } |
| 408 | } |
| 409 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 410 | LIST_ADDQ(&strm_flt(s)->filters, &f->list); |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 411 | strm_flt(s)->flags |= STRM_FLT_FL_HAS_FILTERS; |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | /* |
| 416 | * Called when a stream is created. It attaches all frontend filters to the |
| 417 | * stream. Returns -1 if an error occurs, 0 otherwise. |
| 418 | */ |
| 419 | int |
| 420 | flt_stream_init(struct stream *s) |
| 421 | { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 422 | struct flt_conf *fconf; |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 423 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 424 | memset(strm_flt(s), 0, sizeof(*strm_flt(s))); |
| 425 | LIST_INIT(&strm_flt(s)->filters); |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 426 | list_for_each_entry(fconf, &strm_fe(s)->filter_configs, list) { |
| 427 | if (flt_stream_add_filter(s, fconf, 0) < 0) |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 428 | return -1; |
| 429 | } |
| 430 | return 0; |
| 431 | } |
| 432 | |
| 433 | /* |
| 434 | * Called when a stream is closed or when analyze ends (For an HTTP stream, this |
| 435 | * happens after each request/response exchange). When analyze ends, backend |
| 436 | * filters are removed. When the stream is closed, all filters attached to the |
| 437 | * stream are removed. |
| 438 | */ |
| 439 | void |
| 440 | flt_stream_release(struct stream *s, int only_backend) |
| 441 | { |
| 442 | struct filter *filter, *back; |
| 443 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 444 | list_for_each_entry_safe(filter, back, &strm_flt(s)->filters, list) { |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 445 | if (!only_backend || (filter->flags & FLT_FL_IS_BACKEND_FILTER)) { |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 446 | if (FLT_OPS(filter)->detach) |
| 447 | FLT_OPS(filter)->detach(s, filter); |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 448 | LIST_DEL(&filter->list); |
Willy Tarreau | bafbe01 | 2017-11-24 17:34:44 +0100 | [diff] [blame] | 449 | pool_free(pool_head_filter, filter); |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 450 | } |
| 451 | } |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 452 | if (LIST_ISEMPTY(&strm_flt(s)->filters)) |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 453 | strm_flt(s)->flags &= ~STRM_FLT_FL_HAS_FILTERS; |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 454 | } |
| 455 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 456 | /* |
| 457 | * Calls 'stream_start' for all filters attached to a stream. This happens when |
| 458 | * the stream is created, just after calling flt_stream_init |
| 459 | * function. Returns -1 if an error occurs, 0 otherwise. |
| 460 | */ |
| 461 | int |
| 462 | flt_stream_start(struct stream *s) |
| 463 | { |
| 464 | struct filter *filter; |
| 465 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 466 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 467 | if (FLT_OPS(filter)->stream_start && FLT_OPS(filter)->stream_start(s, filter) < 0) |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 468 | return -1; |
| 469 | } |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | /* |
| 474 | * Calls 'stream_stop' for all filters attached to a stream. This happens when |
| 475 | * the stream is stopped, just before calling flt_stream_release function. |
| 476 | */ |
| 477 | void |
| 478 | flt_stream_stop(struct stream *s) |
| 479 | { |
| 480 | struct filter *filter; |
| 481 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 482 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 483 | if (FLT_OPS(filter)->stream_stop) |
| 484 | FLT_OPS(filter)->stream_stop(s, filter); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 485 | } |
| 486 | } |
| 487 | |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 488 | /* |
Christopher Faulet | a00d817 | 2016-11-10 14:58:05 +0100 | [diff] [blame] | 489 | * Calls 'check_timeouts' for all filters attached to a stream. This happens when |
| 490 | * the stream is woken up because of expired timer. |
| 491 | */ |
| 492 | void |
| 493 | flt_stream_check_timeouts(struct stream *s) |
| 494 | { |
| 495 | struct filter *filter; |
| 496 | |
| 497 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
| 498 | if (FLT_OPS(filter)->check_timeouts) |
| 499 | FLT_OPS(filter)->check_timeouts(s, filter); |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | /* |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 504 | * Called when a backend is set for a stream. If the frontend and the backend |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 505 | * are not the same, this function attaches all backend filters to the |
| 506 | * stream. Returns -1 if an error occurs, 0 otherwise. |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 507 | */ |
| 508 | int |
| 509 | flt_set_stream_backend(struct stream *s, struct proxy *be) |
| 510 | { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 511 | struct flt_conf *fconf; |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 512 | struct filter *filter; |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 513 | |
| 514 | if (strm_fe(s) == be) |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 515 | goto end; |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 516 | |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 517 | list_for_each_entry(fconf, &be->filter_configs, list) { |
| 518 | if (flt_stream_add_filter(s, fconf, FLT_FL_IS_BACKEND_FILTER) < 0) |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 519 | return -1; |
| 520 | } |
Christopher Faulet | 31ed32d | 2016-06-21 11:42:37 +0200 | [diff] [blame] | 521 | |
| 522 | end: |
| 523 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
| 524 | if (FLT_OPS(filter)->stream_set_backend && |
| 525 | FLT_OPS(filter)->stream_set_backend(s, filter, be) < 0) |
| 526 | return -1; |
| 527 | } |
| 528 | |
Christopher Faulet | 92d3638 | 2015-11-05 13:35:03 +0100 | [diff] [blame] | 529 | return 0; |
| 530 | } |
| 531 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 532 | |
| 533 | /* |
| 534 | * Calls 'http_end' callback for all filters attached to a stream. All filters |
| 535 | * are called here, but only if there is at least one "data" filter. This |
| 536 | * functions is called when all data were parsed and forwarded. 'http_end' |
| 537 | * callback is resumable, so this function returns a negative value if an error |
| 538 | * occurs, 0 if it needs to wait for some reason, any other value otherwise. |
| 539 | */ |
| 540 | int |
| 541 | flt_http_end(struct stream *s, struct http_msg *msg) |
| 542 | { |
| 543 | int ret = 1; |
| 544 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 545 | RESUME_FILTER_LOOP(s, msg->chn) { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 546 | if (FLT_OPS(filter)->http_end) { |
| 547 | ret = FLT_OPS(filter)->http_end(s, filter, msg); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 548 | if (ret <= 0) |
| 549 | BREAK_EXECUTION(s, msg->chn, end); |
| 550 | } |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 551 | } RESUME_FILTER_END; |
| 552 | end: |
| 553 | return ret; |
| 554 | } |
| 555 | |
| 556 | /* |
| 557 | * Calls 'http_reset' callback for all filters attached to a stream. This |
| 558 | * happens when a 100-continue response is received. |
| 559 | */ |
| 560 | void |
| 561 | flt_http_reset(struct stream *s, struct http_msg *msg) |
| 562 | { |
| 563 | struct filter *filter; |
| 564 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 565 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 566 | if (FLT_OPS(filter)->http_reset) |
| 567 | FLT_OPS(filter)->http_reset(s, filter, msg); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 568 | } |
| 569 | } |
| 570 | |
| 571 | /* |
| 572 | * Calls 'http_reply' callback for all filters attached to a stream when HA |
| 573 | * decides to stop the HTTP message processing. |
| 574 | */ |
| 575 | void |
Willy Tarreau | 83061a8 | 2018-07-13 11:56:34 +0200 | [diff] [blame] | 576 | flt_http_reply(struct stream *s, short status, const struct buffer *msg) |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 577 | { |
| 578 | struct filter *filter; |
| 579 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 580 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 581 | if (FLT_OPS(filter)->http_reply) |
| 582 | FLT_OPS(filter)->http_reply(s, filter, status, msg); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 583 | } |
| 584 | } |
| 585 | |
| 586 | /* |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 587 | * Calls 'http_payload' callback for all "data" filters attached to a |
| 588 | * stream. This function is called when some data can be forwarded in the |
| 589 | * AN_REQ_HTTP_XFER_BODY and AN_RES_HTTP_XFER_BODY analyzers. It takes care to |
| 590 | * update the filters and the stream offset to be sure that a filter cannot |
| 591 | * forward more data than its predecessors. A filter can choose to not forward |
| 592 | * all data. Returns a negative value if an error occurs, else the number of |
| 593 | * forwarded bytes. |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 594 | */ |
| 595 | int |
| 596 | flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len) |
| 597 | { |
| 598 | struct filter *filter; |
| 599 | unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn); |
Christopher Faulet | 421e769 | 2019-06-13 11:16:45 +0200 | [diff] [blame] | 600 | unsigned int out = co_data(msg->chn); |
| 601 | int ret = len - out; |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 602 | |
| 603 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
| 604 | /* Call "data" filters only */ |
| 605 | if (!IS_DATA_FILTER(filter, msg->chn)) |
| 606 | continue; |
| 607 | if (FLT_OPS(filter)->http_payload) { |
| 608 | unsigned long long *flt_off = &FLT_OFF(filter, msg->chn); |
| 609 | unsigned int offset = *flt_off - *strm_off; |
| 610 | |
Christopher Faulet | 421e769 | 2019-06-13 11:16:45 +0200 | [diff] [blame] | 611 | ret = FLT_OPS(filter)->http_payload(s, filter, msg, out + offset, ret - offset); |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 612 | if (ret < 0) |
| 613 | goto end; |
| 614 | *flt_off += ret; |
| 615 | ret += offset; |
| 616 | } |
| 617 | } |
| 618 | *strm_off += ret; |
Christopher Faulet | 75bc913 | 2018-11-30 15:18:09 +0100 | [diff] [blame] | 619 | end: |
| 620 | return ret; |
| 621 | } |
| 622 | |
| 623 | /* |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 624 | * Calls 'channel_start_analyze' callback for all filters attached to a |
| 625 | * stream. This function is called when we start to analyze a request or a |
| 626 | * response. For frontend filters, it is called before all other analyzers. For |
| 627 | * backend ones, it is called before all backend |
| 628 | * analyzers. 'channel_start_analyze' callback is resumable, so this function |
| 629 | * returns 0 if an error occurs or if it needs to wait, any other value |
| 630 | * otherwise. |
| 631 | */ |
| 632 | int |
| 633 | flt_start_analyze(struct stream *s, struct channel *chn, unsigned int an_bit) |
| 634 | { |
| 635 | int ret = 1; |
| 636 | |
| 637 | /* If this function is called, this means there is at least one filter, |
| 638 | * so we do not need to check the filter list's emptiness. */ |
| 639 | |
Christopher Faulet | e600624 | 2017-03-10 11:52:44 +0100 | [diff] [blame] | 640 | /* Set flag on channel to tell that the channel is filtered */ |
| 641 | chn->flags |= CF_FLT_ANALYZE; |
| 642 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 643 | RESUME_FILTER_LOOP(s, chn) { |
Christopher Faulet | 0184ea7 | 2017-01-05 14:06:34 +0100 | [diff] [blame] | 644 | if (!(chn->flags & CF_ISRESP)) { |
| 645 | if (an_bit == AN_REQ_FLT_START_BE && |
| 646 | !(filter->flags & FLT_FL_IS_BACKEND_FILTER)) |
| 647 | continue; |
| 648 | } |
| 649 | else { |
| 650 | if (an_bit == AN_RES_FLT_START_BE && |
| 651 | !(filter->flags & FLT_FL_IS_BACKEND_FILTER)) |
| 652 | continue; |
| 653 | } |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 654 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 655 | FLT_NXT(filter, chn) = 0; |
| 656 | FLT_FWD(filter, chn) = 0; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 657 | |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 658 | if (FLT_OPS(filter)->channel_start_analyze) { |
| 659 | ret = FLT_OPS(filter)->channel_start_analyze(s, filter, chn); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 660 | if (ret <= 0) |
| 661 | BREAK_EXECUTION(s, chn, end); |
| 662 | } |
| 663 | } RESUME_FILTER_END; |
| 664 | |
| 665 | end: |
| 666 | return handle_analyzer_result(s, chn, an_bit, ret); |
| 667 | } |
| 668 | |
| 669 | /* |
Christopher Faulet | 3a394fa | 2016-05-11 17:13:39 +0200 | [diff] [blame] | 670 | * Calls 'channel_pre_analyze' callback for all filters attached to a |
| 671 | * stream. This function is called BEFORE each analyzer attached to a channel, |
| 672 | * expects analyzers responsible for data sending. 'channel_pre_analyze' |
| 673 | * callback is resumable, so this function returns 0 if an error occurs or if it |
| 674 | * needs to wait, any other value otherwise. |
| 675 | * |
| 676 | * Note this function can be called many times for the same analyzer. In fact, |
| 677 | * it is called until the analyzer finishes its processing. |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 678 | */ |
| 679 | int |
Christopher Faulet | 3a394fa | 2016-05-11 17:13:39 +0200 | [diff] [blame] | 680 | flt_pre_analyze(struct stream *s, struct channel *chn, unsigned int an_bit) |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 681 | { |
| 682 | int ret = 1; |
| 683 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 684 | RESUME_FILTER_LOOP(s, chn) { |
Christopher Faulet | 3a394fa | 2016-05-11 17:13:39 +0200 | [diff] [blame] | 685 | if (FLT_OPS(filter)->channel_pre_analyze && (filter->pre_analyzers & an_bit)) { |
| 686 | ret = FLT_OPS(filter)->channel_pre_analyze(s, filter, chn, an_bit); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 687 | if (ret <= 0) |
| 688 | BREAK_EXECUTION(s, chn, check_result); |
| 689 | } |
| 690 | } RESUME_FILTER_END; |
| 691 | |
| 692 | check_result: |
Christopher Faulet | 309c641 | 2015-12-02 09:57:32 +0100 | [diff] [blame] | 693 | return handle_analyzer_result(s, chn, 0, ret); |
| 694 | } |
| 695 | |
| 696 | /* |
Christopher Faulet | 3a394fa | 2016-05-11 17:13:39 +0200 | [diff] [blame] | 697 | * Calls 'channel_post_analyze' callback for all filters attached to a |
| 698 | * stream. This function is called AFTER each analyzer attached to a channel, |
| 699 | * expects analyzers responsible for data sending. 'channel_post_analyze' |
| 700 | * callback is NOT resumable, so this function returns a 0 if an error occurs, |
| 701 | * any other value otherwise. |
| 702 | * |
| 703 | * Here, AFTER means when the analyzer finishes its processing. |
| 704 | */ |
| 705 | int |
| 706 | flt_post_analyze(struct stream *s, struct channel *chn, unsigned int an_bit) |
| 707 | { |
| 708 | struct filter *filter; |
| 709 | int ret = 1; |
| 710 | |
| 711 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
| 712 | if (FLT_OPS(filter)->channel_post_analyze && (filter->post_analyzers & an_bit)) { |
| 713 | ret = FLT_OPS(filter)->channel_post_analyze(s, filter, chn, an_bit); |
| 714 | if (ret < 0) |
| 715 | break; |
| 716 | } |
| 717 | } |
| 718 | return handle_analyzer_result(s, chn, 0, ret); |
| 719 | } |
| 720 | |
| 721 | /* |
Christopher Faulet | 0184ea7 | 2017-01-05 14:06:34 +0100 | [diff] [blame] | 722 | * This function is the AN_REQ/RES_FLT_HTTP_HDRS analyzer, used to filter HTTP |
| 723 | * headers or a request or a response. Returns 0 if an error occurs or if it |
| 724 | * needs to wait, any other value otherwise. |
Christopher Faulet | 309c641 | 2015-12-02 09:57:32 +0100 | [diff] [blame] | 725 | */ |
| 726 | int |
| 727 | flt_analyze_http_headers(struct stream *s, struct channel *chn, unsigned int an_bit) |
| 728 | { |
Christopher Faulet | 1339d74 | 2016-05-11 16:48:33 +0200 | [diff] [blame] | 729 | struct http_msg *msg; |
| 730 | int ret = 1; |
Christopher Faulet | 309c641 | 2015-12-02 09:57:32 +0100 | [diff] [blame] | 731 | |
Christopher Faulet | 1339d74 | 2016-05-11 16:48:33 +0200 | [diff] [blame] | 732 | msg = ((chn->flags & CF_ISRESP) ? &s->txn->rsp : &s->txn->req); |
Christopher Faulet | 309c641 | 2015-12-02 09:57:32 +0100 | [diff] [blame] | 733 | RESUME_FILTER_LOOP(s, chn) { |
Christopher Faulet | 1339d74 | 2016-05-11 16:48:33 +0200 | [diff] [blame] | 734 | if (FLT_OPS(filter)->http_headers) { |
| 735 | ret = FLT_OPS(filter)->http_headers(s, filter, msg); |
Christopher Faulet | 309c641 | 2015-12-02 09:57:32 +0100 | [diff] [blame] | 736 | if (ret <= 0) |
| 737 | BREAK_EXECUTION(s, chn, check_result); |
| 738 | } |
| 739 | } RESUME_FILTER_END; |
Christopher Faulet | 3d11969 | 2019-07-15 22:04:51 +0200 | [diff] [blame] | 740 | channel_htx_fwd_headers(chn, htxbuf(&chn->buf)); |
Christopher Faulet | 309c641 | 2015-12-02 09:57:32 +0100 | [diff] [blame] | 741 | |
| 742 | check_result: |
| 743 | return handle_analyzer_result(s, chn, an_bit, ret); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | /* |
| 747 | * Calls 'channel_end_analyze' callback for all filters attached to a |
| 748 | * stream. This function is called when we stop to analyze a request or a |
| 749 | * response. It is called after all other analyzers. 'channel_end_analyze' |
| 750 | * callback is resumable, so this function returns 0 if an error occurs or if it |
| 751 | * needs to wait, any other value otherwise. |
| 752 | */ |
| 753 | int |
| 754 | flt_end_analyze(struct stream *s, struct channel *chn, unsigned int an_bit) |
| 755 | { |
| 756 | int ret = 1; |
| 757 | |
Christopher Faulet | e600624 | 2017-03-10 11:52:44 +0100 | [diff] [blame] | 758 | /* Check if all filters attached on the stream have finished their |
| 759 | * processing on this channel. */ |
| 760 | if (!(chn->flags & CF_FLT_ANALYZE)) |
| 761 | goto sync; |
| 762 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 763 | RESUME_FILTER_LOOP(s, chn) { |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 764 | FLT_NXT(filter, chn) = 0; |
| 765 | FLT_FWD(filter, chn) = 0; |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 766 | unregister_data_filter(s, chn, filter); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 767 | |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 768 | if (FLT_OPS(filter)->channel_end_analyze) { |
| 769 | ret = FLT_OPS(filter)->channel_end_analyze(s, filter, chn); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 770 | if (ret <= 0) |
| 771 | BREAK_EXECUTION(s, chn, end); |
| 772 | } |
| 773 | } RESUME_FILTER_END; |
| 774 | |
Christopher Faulet | e600624 | 2017-03-10 11:52:44 +0100 | [diff] [blame] | 775 | end: |
| 776 | /* We don't remove yet this analyzer because we need to synchronize the |
| 777 | * both channels. So here, we just remove the flag CF_FLT_ANALYZE. */ |
| 778 | ret = handle_analyzer_result(s, chn, 0, ret); |
Christopher Faulet | 570f799 | 2017-07-06 15:53:02 +0200 | [diff] [blame] | 779 | if (ret) { |
Christopher Faulet | e600624 | 2017-03-10 11:52:44 +0100 | [diff] [blame] | 780 | chn->flags &= ~CF_FLT_ANALYZE; |
Christopher Faulet | 02c7b22 | 2015-12-22 12:01:29 +0100 | [diff] [blame] | 781 | |
Christopher Faulet | 570f799 | 2017-07-06 15:53:02 +0200 | [diff] [blame] | 782 | /* Pretend there is an activity on both channels. Flag on the |
| 783 | * current one will be automatically removed, so only the other |
| 784 | * one will remain. This is a way to be sure that |
| 785 | * 'channel_end_analyze' callback will have a chance to be |
| 786 | * called at least once for the other side to finish the current |
Joseph Herlant | b35ea68 | 2018-11-15 12:24:23 -0800 | [diff] [blame] | 787 | * processing. Of course, this is the filter responsibility to |
Christopher Faulet | 570f799 | 2017-07-06 15:53:02 +0200 | [diff] [blame] | 788 | * wakeup the stream if it choose to loop on this callback. */ |
| 789 | s->req.flags |= CF_WAKE_ONCE; |
| 790 | s->res.flags |= CF_WAKE_ONCE; |
| 791 | } |
| 792 | |
| 793 | |
Christopher Faulet | e600624 | 2017-03-10 11:52:44 +0100 | [diff] [blame] | 794 | sync: |
| 795 | /* Now we can check if filters have finished their work on the both |
| 796 | * channels */ |
| 797 | if (!(s->req.flags & CF_FLT_ANALYZE) && !(s->res.flags & CF_FLT_ANALYZE)) { |
| 798 | /* Sync channels by removing this analyzer for the both channels */ |
| 799 | s->req.analysers &= ~AN_REQ_FLT_END; |
| 800 | s->res.analysers &= ~AN_RES_FLT_END; |
Christopher Faulet | c6062be | 2016-10-31 11:22:37 +0100 | [diff] [blame] | 801 | |
Christopher Faulet | e600624 | 2017-03-10 11:52:44 +0100 | [diff] [blame] | 802 | /* Remove backend filters from the list */ |
| 803 | flt_stream_release(s, 1); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 804 | } |
Christopher Faulet | 2b553de | 2017-03-30 11:13:22 +0200 | [diff] [blame] | 805 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 806 | return ret; |
| 807 | } |
| 808 | |
| 809 | |
| 810 | /* |
| 811 | * Calls 'tcp_data' callback for all "data" filters attached to a stream. This |
| 812 | * function is called when incoming data are available. It takes care to update |
| 813 | * the next offset of filters and adjusts available data to be sure that a |
| 814 | * filter cannot parse more data than its predecessors. A filter can choose to |
| 815 | * not consume all available data. Returns -1 if an error occurs, the number of |
| 816 | * consumed bytes otherwise. |
| 817 | */ |
| 818 | static int |
| 819 | flt_data(struct stream *s, struct channel *chn) |
| 820 | { |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 821 | struct filter *filter; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 822 | unsigned int buf_i; |
Christopher Faulet | 55048a4 | 2016-06-21 10:44:32 +0200 | [diff] [blame] | 823 | int delta = 0, ret = 0; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 824 | |
| 825 | /* Save buffer state */ |
Willy Tarreau | 44a41a8 | 2018-06-19 07:16:31 +0200 | [diff] [blame] | 826 | buf_i = ci_data(chn); |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 827 | |
| 828 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 829 | unsigned int *nxt; |
| 830 | |
| 831 | /* Call "data" filters only */ |
| 832 | if (!IS_DATA_FILTER(filter, chn)) |
| 833 | continue; |
| 834 | |
| 835 | nxt = &FLT_NXT(filter, chn); |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 836 | if (FLT_OPS(filter)->tcp_data) { |
Willy Tarreau | 44a41a8 | 2018-06-19 07:16:31 +0200 | [diff] [blame] | 837 | unsigned int i = ci_data(chn); |
Christopher Faulet | 55048a4 | 2016-06-21 10:44:32 +0200 | [diff] [blame] | 838 | |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 839 | ret = FLT_OPS(filter)->tcp_data(s, filter, chn); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 840 | if (ret < 0) |
| 841 | break; |
Willy Tarreau | 44a41a8 | 2018-06-19 07:16:31 +0200 | [diff] [blame] | 842 | delta += (int)(ci_data(chn) - i); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 843 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 844 | /* Increase next offset of the current filter */ |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 845 | *nxt += ret; |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 846 | |
| 847 | /* And set this value as the bound for the next |
| 848 | * filter. It will not able to parse more data than the |
| 849 | * current one. */ |
Willy Tarreau | c9fa048 | 2018-07-10 17:43:27 +0200 | [diff] [blame] | 850 | b_set_data(&chn->buf, co_data(chn) + *nxt); |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 851 | } |
| 852 | else { |
| 853 | /* Consume all available data */ |
Willy Tarreau | 44a41a8 | 2018-06-19 07:16:31 +0200 | [diff] [blame] | 854 | *nxt = ci_data(chn); |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 855 | } |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 856 | |
| 857 | /* Update <ret> value to be sure to have the last one when we |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 858 | * exit from the loop. This value will be used to know how much |
| 859 | * data are "forwardable" */ |
| 860 | ret = *nxt; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 861 | } |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 862 | |
| 863 | /* Restore the original buffer state */ |
Willy Tarreau | c9fa048 | 2018-07-10 17:43:27 +0200 | [diff] [blame] | 864 | b_set_data(&chn->buf, co_data(chn) + buf_i + delta); |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 865 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 866 | return ret; |
| 867 | } |
| 868 | |
| 869 | /* |
| 870 | * Calls 'tcp_forward_data' callback for all "data" filters attached to a |
| 871 | * stream. This function is called when some data can be forwarded. It takes |
| 872 | * care to update the forward offset of filters and adjusts "forwardable" data |
| 873 | * to be sure that a filter cannot forward more data than its predecessors. A |
| 874 | * filter can choose to not forward all parsed data. Returns a negative value if |
| 875 | * an error occurs, else the number of forwarded bytes. |
| 876 | */ |
| 877 | static int |
| 878 | flt_forward_data(struct stream *s, struct channel *chn, unsigned int len) |
| 879 | { |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 880 | struct filter *filter; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 881 | int ret = len; |
| 882 | |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 883 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 884 | unsigned int *fwd; |
| 885 | |
| 886 | /* Call "data" filters only */ |
| 887 | if (!IS_DATA_FILTER(filter, chn)) |
| 888 | continue; |
| 889 | |
| 890 | fwd = &FLT_FWD(filter, chn); |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 891 | if (FLT_OPS(filter)->tcp_forward_data) { |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 892 | /* Remove bytes that the current filter considered as |
| 893 | * forwarded */ |
Christopher Faulet | 443ea1a | 2016-02-04 13:40:26 +0100 | [diff] [blame] | 894 | ret = FLT_OPS(filter)->tcp_forward_data(s, filter, chn, ret - *fwd); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 895 | if (ret < 0) |
| 896 | goto end; |
| 897 | } |
| 898 | |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 899 | /* Adjust bytes that the current filter considers as |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 900 | * forwarded */ |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 901 | *fwd += ret; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 902 | |
| 903 | /* And set this value as the bound for the next filter. It will |
| 904 | * not able to forward more data than the current one. */ |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 905 | ret = *fwd; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | if (!ret) |
| 909 | goto end; |
| 910 | |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 911 | /* Finally, adjust filters offsets by removing data that HAProxy will |
| 912 | * forward. */ |
Christopher Faulet | fcf035c | 2015-12-03 11:48:03 +0100 | [diff] [blame] | 913 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 914 | if (!IS_DATA_FILTER(filter, chn)) |
| 915 | continue; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 916 | FLT_NXT(filter, chn) -= ret; |
| 917 | FLT_FWD(filter, chn) -= ret; |
| 918 | } |
| 919 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 920 | end: |
| 921 | return ret; |
| 922 | } |
| 923 | |
| 924 | /* |
| 925 | * Called when TCP data must be filtered on a channel. This function is the |
Christopher Faulet | 0184ea7 | 2017-01-05 14:06:34 +0100 | [diff] [blame] | 926 | * AN_REQ/RES_FLT_XFER_DATA analyzer. When called, it is responsible to forward |
| 927 | * data when the proxy is not in http mode. Behind the scene, it calls |
| 928 | * consecutively 'tcp_data' and 'tcp_forward_data' callbacks for all "data" |
| 929 | * filters attached to a stream. Returns 0 if an error occurs or if it needs to |
| 930 | * wait, any other value otherwise. |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 931 | */ |
| 932 | int |
| 933 | flt_xfer_data(struct stream *s, struct channel *chn, unsigned int an_bit) |
| 934 | { |
| 935 | int ret = 1; |
| 936 | |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 937 | /* If there is no "data" filters, we do nothing */ |
| 938 | if (!HAS_DATA_FILTERS(s, chn)) |
| 939 | goto end; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 940 | |
| 941 | /* Be sure that the output is still opened. Else we stop the data |
| 942 | * filtering. */ |
| 943 | if ((chn->flags & (CF_READ_ERROR|CF_READ_TIMEOUT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) || |
Willy Tarreau | 44a41a8 | 2018-06-19 07:16:31 +0200 | [diff] [blame] | 944 | ((chn->flags & CF_SHUTW) && (chn->to_forward || co_data(chn)))) |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 945 | goto end; |
| 946 | |
| 947 | /* Let all "data" filters parsing incoming data */ |
| 948 | ret = flt_data(s, chn); |
| 949 | if (ret < 0) |
| 950 | goto end; |
| 951 | |
| 952 | /* And forward them */ |
| 953 | ret = flt_forward_data(s, chn, ret); |
| 954 | if (ret < 0) |
| 955 | goto end; |
| 956 | |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 957 | /* Consume data that all filters consider as forwarded. */ |
Willy Tarreau | bcbd393 | 2018-06-06 07:13:22 +0200 | [diff] [blame] | 958 | c_adv(chn, ret); |
Christopher Faulet | da02e17 | 2015-12-04 09:25:05 +0100 | [diff] [blame] | 959 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 960 | /* Stop waiting data if the input in closed and no data is pending or if |
| 961 | * the output is closed. */ |
| 962 | if ((chn->flags & CF_SHUTW) || |
Willy Tarreau | 5ba6552 | 2018-06-15 15:14:53 +0200 | [diff] [blame] | 963 | ((chn->flags & CF_SHUTR) && !ci_data(chn))) { |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 964 | ret = 1; |
| 965 | goto end; |
| 966 | } |
| 967 | |
| 968 | /* Wait for data */ |
| 969 | return 0; |
| 970 | end: |
| 971 | /* Terminate the data filtering. If <ret> is negative, an error was |
| 972 | * encountered during the filtering. */ |
| 973 | return handle_analyzer_result(s, chn, an_bit, ret); |
| 974 | } |
| 975 | |
| 976 | /* |
| 977 | * Handles result of filter's analyzers. It returns 0 if an error occurs or if |
| 978 | * it needs to wait, any other value otherwise. |
| 979 | */ |
| 980 | static int |
| 981 | handle_analyzer_result(struct stream *s, struct channel *chn, |
| 982 | unsigned int an_bit, int ret) |
| 983 | { |
| 984 | int finst; |
Christopher Faulet | e058f73 | 2019-09-06 15:24:55 +0200 | [diff] [blame] | 985 | int status = 0; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 986 | |
| 987 | if (ret < 0) |
| 988 | goto return_bad_req; |
| 989 | else if (!ret) |
| 990 | goto wait; |
| 991 | |
| 992 | /* End of job, return OK */ |
| 993 | if (an_bit) { |
| 994 | chn->analysers &= ~an_bit; |
| 995 | chn->analyse_exp = TICK_ETERNITY; |
| 996 | } |
| 997 | return 1; |
| 998 | |
| 999 | return_bad_req: |
| 1000 | /* An error occurs */ |
| 1001 | channel_abort(&s->req); |
| 1002 | channel_abort(&s->res); |
| 1003 | |
| 1004 | if (!(chn->flags & CF_ISRESP)) { |
Christopher Faulet | 0184ea7 | 2017-01-05 14:06:34 +0100 | [diff] [blame] | 1005 | s->req.analysers &= AN_REQ_FLT_END; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1006 | finst = SF_FINST_R; |
Christopher Faulet | e058f73 | 2019-09-06 15:24:55 +0200 | [diff] [blame] | 1007 | status = 400; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1008 | /* FIXME: incr counters */ |
| 1009 | } |
| 1010 | else { |
Christopher Faulet | 0184ea7 | 2017-01-05 14:06:34 +0100 | [diff] [blame] | 1011 | s->res.analysers &= AN_RES_FLT_END; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1012 | finst = SF_FINST_H; |
Christopher Faulet | e058f73 | 2019-09-06 15:24:55 +0200 | [diff] [blame] | 1013 | status = 502; |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1014 | /* FIXME: incr counters */ |
| 1015 | } |
| 1016 | |
Christopher Faulet | 3d11969 | 2019-07-15 22:04:51 +0200 | [diff] [blame] | 1017 | if (IS_HTX_STRM(s)) { |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1018 | /* Do not do that when we are waiting for the next request */ |
Christopher Faulet | e058f73 | 2019-09-06 15:24:55 +0200 | [diff] [blame] | 1019 | if (s->txn->status > 0) |
Christopher Faulet | fc9cfe4 | 2019-07-16 14:54:53 +0200 | [diff] [blame] | 1020 | http_reply_and_close(s, s->txn->status, NULL); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1021 | else { |
Christopher Faulet | e058f73 | 2019-09-06 15:24:55 +0200 | [diff] [blame] | 1022 | s->txn->status = status; |
| 1023 | http_reply_and_close(s, status, http_error_message(s)); |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | if (!(s->flags & SF_ERR_MASK)) |
| 1028 | s->flags |= SF_ERR_PRXCOND; |
| 1029 | if (!(s->flags & SF_FINST_MASK)) |
| 1030 | s->flags |= finst; |
| 1031 | return 0; |
| 1032 | |
| 1033 | wait: |
| 1034 | if (!(chn->flags & CF_ISRESP)) |
| 1035 | channel_dont_connect(chn); |
| 1036 | return 0; |
| 1037 | } |
| 1038 | |
| 1039 | |
| 1040 | /* Note: must not be declared <const> as its list will be overwritten. |
| 1041 | * Please take care of keeping this list alphabetically sorted, doing so helps |
| 1042 | * all code contributors. |
| 1043 | * Optional keywords are also declared with a NULL ->parse() function so that |
| 1044 | * the config parser can report an appropriate error when a known keyword was |
| 1045 | * not enabled. */ |
| 1046 | static struct cfg_kw_list cfg_kws = {ILH, { |
| 1047 | { CFG_LISTEN, "filter", parse_filter }, |
| 1048 | { 0, NULL, NULL }, |
| 1049 | } |
| 1050 | }; |
| 1051 | |
Willy Tarreau | 0108d90 | 2018-11-25 19:14:37 +0100 | [diff] [blame] | 1052 | INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); |
| 1053 | |
Willy Tarreau | 172f5ce | 2018-11-26 11:21:50 +0100 | [diff] [blame] | 1054 | REGISTER_POST_CHECK(flt_init_all); |
| 1055 | REGISTER_PER_THREAD_INIT(flt_init_all_per_thread); |
| 1056 | REGISTER_PER_THREAD_DEINIT(flt_deinit_all_per_thread); |
| 1057 | |
Christopher Faulet | d7c9196 | 2015-04-30 11:48:27 +0200 | [diff] [blame] | 1058 | /* |
| 1059 | * Local variables: |
| 1060 | * c-indent-level: 8 |
| 1061 | * c-basic-offset: 8 |
| 1062 | * End: |
| 1063 | */ |