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