blob: c7522e942d11a7240701b6ff4cd9ffdc0b9c501e [file] [log] [blame]
Miroslav Zagorac70230c62020-12-09 16:54:31 +01001/***
2 * Copyright 2020 HAProxy Technologies
3 *
4 * This file is part of the HAProxy OpenTracing filter.
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 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#include "include.h"
21
22
23#ifdef DEBUG_OT
24struct flt_ot_debug flt_ot_debug;
25THREAD_LOCAL int dbg_indent_level = 0;
26#endif
27
28#ifdef OTC_DBG_MEM
29static struct otc_dbg_mem_data dbg_mem_data[1000000];
30static struct otc_dbg_mem dbg_mem;
31#endif
32
33static struct flt_ot_conf *flt_ot_current_config = NULL;
34static struct flt_ot_conf_tracer *flt_ot_current_tracer = NULL;
35static struct flt_ot_conf_group *flt_ot_current_group = NULL;
36static struct flt_ot_conf_scope *flt_ot_current_scope = NULL;
37static struct flt_ot_conf_span *flt_ot_current_span = NULL;
38
39
40/***
41 * NAME
42 * flt_ot_parse_strdup -
43 *
44 * ARGUMENTS
45 * ptr -
46 * str -
47 * err -
48 * err_msg -
49 *
50 * DESCRIPTION
51 * -
52 *
53 * RETURN VALUE
54 * Returns ERR_NONE (== 0) in case of success,
55 * or a combination of ERR_* flags if an error is encountered.
56 */
57static int flt_ot_parse_strdup(char **ptr, const char *str, char **err, const char *err_msg)
58{
59 int retval = ERR_NONE;
60
61 FLT_OT_FUNC("%p:%p, %p, %p:%p, \"%s\"", FLT_OT_DPTR_ARGS(ptr), str, FLT_OT_DPTR_ARGS(err), err_msg);
62
63 *ptr = FLT_OT_STRDUP(str);
64 if (*ptr == NULL) {
65 FLT_OT_PARSE_ERR(err, "'%s' : out of memory", err_msg);
66
67 retval |= ERR_ABORT | ERR_ALERT;
68 }
69
70 FLT_OT_RETURN(retval);
71}
72
73
74/***
75 * NAME
76 * flt_ot_parse_keyword -
77 *
78 * ARGUMENTS
79 * ptr -
80 * args -
81 * cur_arg -
82 * pos -
83 * err -
84 * err_msg -
85 *
86 * DESCRIPTION
87 * -
88 *
89 * RETURN VALUE
90 * Returns ERR_NONE (== 0) in case of success,
91 * or a combination of ERR_* flags if an error is encountered.
92 */
93static int flt_ot_parse_keyword(char **ptr, char **args, int cur_arg, int pos, char **err, const char *err_msg)
94{
95 int retval = ERR_NONE;
96
97 FLT_OT_FUNC("%p:%p, %p, %d, %d, %p:%p, \"%s\"", FLT_OT_DPTR_ARGS(ptr), args, cur_arg, pos, FLT_OT_DPTR_ARGS(err), err_msg);
98
99 if (*ptr != NULL) {
100 if (cur_arg == pos)
101 FLT_OT_PARSE_ERR(err, FLT_OT_FMT_TYPE "%s already set", err_msg);
102 else
103 FLT_OT_PARSE_ERR(err, "'%s' : %s already set", args[cur_arg], err_msg);
104 }
105 else if (!FLT_OT_ARG_ISVALID(pos + 1)) {
106 if (cur_arg == pos)
107 FLT_OT_PARSE_ERR(err, FLT_OT_FMT_TYPE "no %s set", err_msg);
108 else
109 FLT_OT_PARSE_ERR(err, "'%s' : no %s set", args[cur_arg], err_msg);
110 }
111 else {
112 retval = flt_ot_parse_strdup(ptr, args[pos + 1], err, args[cur_arg]);
113 }
114
115 FLT_OT_RETURN(retval);
116}
117
118
119/***
120 * NAME
121 * flt_ot_parse_invalid_char -
122 *
123 * ARGUMENTS
124 * name -
125 * type -
126 *
127 * DESCRIPTION
128 * -
129 *
130 * RETURN VALUE
131 * -
132 */
133static const char *flt_ot_parse_invalid_char(const char *name, int type)
134{
135 const char *retptr = NULL;
136
137 FLT_OT_FUNC("\"%s\", %d", name, type);
138
139 if (!FLT_OT_STR_ISVALID(name))
140 FLT_OT_RETURN(retptr);
141
142 if (type == 1) {
143 retptr = invalid_char(name);
144 }
145 else if (type == 2) {
146 retptr = invalid_domainchar(name);
147 }
148 else if (type == 3) {
149 retptr = invalid_prefix_char(name);
150 }
151 else if (type == 4) {
152 retptr = name;
153
154 /*
155 * Allowed characters are letters, numbers and '_', the first
156 * character in the string must not be a number.
157 */
158 if (!isdigit(*retptr))
159 for (++retptr; (*retptr == '_') || isalnum(*retptr); retptr++);
160
161 if (*retptr == '\0')
162 retptr = NULL;
163 }
164
165 FLT_OT_RETURN(retptr);
166}
167
168
169/***
170 * NAME
171 * flt_ot_parse_cfg_check -
172 *
173 * ARGUMENTS
174 * file -
175 * linenum -
176 * args -
177 * id -
178 * parse_data -
179 * parse_data_size -
180 * pdata -
181 * err -
182 *
183 * DESCRIPTION
184 * -
185 *
186 * RETURN VALUE
187 * Returns ERR_NONE (== 0) in case of success,
188 * or a combination of ERR_* flags if an error is encountered.
189 */
190static int flt_ot_parse_cfg_check(const char *file, int linenum, char **args, const void *id, const struct flt_ot_parse_data *parse_data, size_t parse_data_size, const struct flt_ot_parse_data **pdata, char **err)
191{
192 int i, retval = ERR_NONE;
193
194 FLT_OT_FUNC("\"%s\", %d, %p, %p, %p, %zu, %p:%p, %p:%p", file, linenum, args, id, parse_data, parse_data_size, FLT_OT_DPTR_ARGS(pdata), FLT_OT_DPTR_ARGS(err));
195
196 FLT_OT_ARGS_DUMP();
197
198 *pdata = NULL;
199
200 for (i = 0; (*pdata == NULL) && (i < parse_data_size); i++)
201 if (strcmp(parse_data[i].name, args[0]) == 0)
202 *pdata = parse_data + i;
203
204 if (*pdata == NULL)
205 FLT_OT_PARSE_ERR(err, "'%s' : unknown keyword", args[0]);
206
207 if ((retval & ERR_CODE) || (id == NULL))
208 /* Do nothing. */;
209 else if ((id != flt_ot_current_tracer) && (flt_ot_current_config->tracer == NULL))
210 FLT_OT_PARSE_ERR(err, "tracer not defined");
211
212 /*
213 * Checking that fewer arguments are specified in the configuration
214 * line than is required.
215 */
216 if (!(retval & ERR_CODE))
217 for (i = 1; i < (*pdata)->args_min; i++)
218 if (!FLT_OT_ARG_ISVALID(i))
219 FLT_OT_PARSE_ERR(err, "'%s' : too few arguments (use '%s%s')", args[0], (*pdata)->name, (*pdata)->usage);
220
221 /*
222 * Checking that more arguments are specified in the configuration
223 * line than the maximum allowed.
224 */
225 if (!(retval & ERR_CODE) && ((*pdata)->args_max > 0)) {
226 for ( ; (i <= (*pdata)->args_max) && FLT_OT_ARG_ISVALID(i); i++);
227
228 if (i > (*pdata)->args_max)
229 FLT_OT_PARSE_ERR(err, "'%s' : too many arguments (use '%s%s')", args[0], (*pdata)->name, (*pdata)->usage);
230 }
231
232 /* Checking that the first argument has only allowed characters. */
233 if (!(retval & ERR_CODE) && ((*pdata)->check_name > 0)) {
234 const char *ic;
235
236 ic = flt_ot_parse_invalid_char(args[1], (*pdata)->check_name);
237 if (ic != NULL)
238 FLT_OT_PARSE_ERR(err, "%s '%s' : invalid character '%c'", args[0], args[1], *ic);
239 }
240
241 /* Checking that the data group name is defined. */
242 if (!(retval & ERR_CODE) && (*pdata)->flag_check_id && (id == NULL))
243 FLT_OT_PARSE_ERR(err, "'%s' : %s ID not set (use '%s%s')", args[0], parse_data[1].name, parse_data[1].name, parse_data[1].usage);
244
245 FLT_OT_RETURN(retval);
246}
247
248
249/***
250 * NAME
251 * flt_ot_parse_cfg_sample_expr -
252 *
253 * ARGUMENTS
254 * file -
255 * linenum -
256 * args -
257 * idx -
258 * head -
259 * err -
260 *
261 * DESCRIPTION
262 * -
263 *
264 * RETURN VALUE
265 * Returns ERR_NONE (== 0) in case of success,
266 * or a combination of ERR_* flags if an error is encountered.
267 */
268static int flt_ot_parse_cfg_sample_expr(const char *file, int linenum, char **args, int *idx, struct list *head, char **err)
269{
270 struct flt_ot_conf_sample_expr *expr;
271 int retval = ERR_NONE;
272
273 FLT_OT_FUNC("\"%s\", %d, %p, %p, %p, %p:%p", file, linenum, args, idx, head, FLT_OT_DPTR_ARGS(err));
274
275 expr = flt_ot_conf_sample_expr_init(args[*idx], linenum, head, err);
276 if (expr != NULL) {
277 expr->expr = sample_parse_expr(args, idx, file, linenum, err, &(flt_ot_current_config->proxy->conf.args), NULL);
278 if (expr->expr != NULL)
279 FLT_OT_DBG(3, "sample expression '%s' added", expr->value);
280 else
281 retval |= ERR_ABORT | ERR_ALERT;
282 } else {
283 retval |= ERR_ABORT | ERR_ALERT;
284 }
285
286 if (retval & ERR_CODE)
287 flt_ot_conf_sample_expr_free(&expr);
288
289 FLT_OT_RETURN(retval);
290}
291
292
293/***
294 * NAME
295 * flt_ot_parse_cfg_sample -
296 *
297 * ARGUMENTS
298 * file -
299 * linenum -
300 * args -
301 * head -
302 * err -
303 *
304 * DESCRIPTION
305 * -
306 *
307 * RETURN VALUE
308 * Returns ERR_NONE (== 0) in case of success,
309 * or a combination of ERR_* flags if an error is encountered.
310 */
311static int flt_ot_parse_cfg_sample(const char *file, int linenum, char **args, struct list *head, char **err)
312{
313 struct flt_ot_conf_sample *sample;
314 int idx = 2, retval = ERR_NONE;
315
316 FLT_OT_FUNC("\"%s\", %d, %p, %p, %p:%p", file, linenum, args, head, FLT_OT_DPTR_ARGS(err));
317
318 sample = flt_ot_conf_sample_init(args, linenum, head, err);
319 if (sample == NULL)
320 FLT_OT_PARSE_ERR(err, "'%s' : out of memory", args[0]);
321
322 if (!(retval & ERR_CODE)) {
323 flt_ot_current_config->proxy->conf.args.ctx = ARGC_OT;
324 flt_ot_current_config->proxy->conf.args.file = file;
325 flt_ot_current_config->proxy->conf.args.line = linenum;
326
327 while (!(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(idx))
328 retval = flt_ot_parse_cfg_sample_expr(file, linenum, args, &idx, &(sample->exprs), err);
329
330 flt_ot_current_config->proxy->conf.args.file = NULL;
331 flt_ot_current_config->proxy->conf.args.line = 0;
332 }
333
334 if (retval & ERR_CODE)
335 flt_ot_conf_sample_free(&sample);
336 else
337 FLT_OT_DBG(3, "sample '%s' -> '%s' added", sample->key, sample->value);
338
339 FLT_OT_RETURN(retval);
340}
341
342
343/***
344 * NAME
345 * flt_ot_parse_cfg_str -
346 *
347 * ARGUMENTS
348 * file -
349 * linenum -
350 * args -
351 * head -
352 * err -
353 *
354 * DESCRIPTION
355 * -
356 *
357 * RETURN VALUE
358 * Returns ERR_NONE (== 0) in case of success,
359 * or a combination of ERR_* flags if an error is encountered.
360 */
361static int flt_ot_parse_cfg_str(const char *file, int linenum, char **args, struct list *head, char **err)
362{
363 struct flt_ot_conf_str *str = NULL;
364 int i, retval = ERR_NONE;
365
366 FLT_OT_FUNC("\"%s\", %d, %p, %p, %p:%p", file, linenum, args, head, FLT_OT_DPTR_ARGS(err));
367
368 for (i = 1; !(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(i); i++)
369 if (flt_ot_conf_str_init(args[i], linenum, head, err) == NULL)
370 retval |= ERR_ABORT | ERR_ALERT;
371
372 if (retval & ERR_CODE)
373 flt_ot_conf_str_free(&str);
374
375 FLT_OT_RETURN(retval);
376}
377
378
379/***
380 * NAME
381 * flt_ot_parse_cfg_file -
382 *
383 * ARGUMENTS
384 * ptr -
385 * file -
386 * linenum -
387 * args -
388 * err -
389 * err_msg -
390 *
391 * DESCRIPTION
392 * -
393 *
394 * RETURN VALUE
395 * Returns ERR_NONE (== 0) in case of success,
396 * or a combination of ERR_* flags if an error is encountered.
397 */
398static int flt_ot_parse_cfg_file(char **ptr, const char *file, int linenum, char **args, char **err, const char *err_msg)
399{
400 int retval = ERR_NONE;
401
402 FLT_OT_FUNC("%p:%p, \"%s\", %d, %p, %p:%p, \"%s\"", FLT_OT_DPTR_ARGS(ptr), file, linenum, args, FLT_OT_DPTR_ARGS(err), err_msg);
403
404 if (!FLT_OT_ARG_ISVALID(1))
405 FLT_OT_PARSE_ERR(err, "'%s' : no %s specified", flt_ot_current_tracer->id, err_msg);
406 else if (alertif_too_many_args(1, file, linenum, args, &retval))
407 retval |= ERR_ABORT | ERR_ALERT;
408 else if (access(args[1], R_OK) == -1)
409 FLT_OT_PARSE_ERR(err, "'%s' : %s", args[1], strerror(errno));
410 else
411 retval = flt_ot_parse_keyword(ptr, args, 0, 0, err, err_msg);
412
413 FLT_OT_RETURN(retval);
414}
415
416
417/***
418 * NAME
419 * flt_ot_parse_check_scope -
420 *
421 * ARGUMENTS
422 * This function takes no arguments.
423 *
424 * DESCRIPTION
425 * -
426 *
427 * RETURN VALUE
428 * Returns TRUE in case the configuration is not in the currently defined
429 * scope, FALSE otherwise.
430 */
431static bool flt_ot_parse_check_scope(void)
432{
433 bool retval = 0;
434
435 if ((cfg_scope != NULL) && (flt_ot_current_config->id != NULL) && (strcmp(flt_ot_current_config->id, cfg_scope) != 0)) {
436 FLT_OT_DBG(1, "cfg_scope: '%s', id: '%s'", cfg_scope, flt_ot_current_config->id);
437
438 retval = 1;
439 }
440
441 return retval;
442}
443
444
445/***
446 * NAME
447 * flt_ot_parse_cfg_tracer -
448 *
449 * ARGUMENTS
450 * file -
451 * linenum -
452 * args -
453 * kw_mod -
454 *
455 * DESCRIPTION
456 * -
457 *
458 * RETURN VALUE
459 * Returns ERR_NONE (== 0) in case of success,
460 * or a combination of ERR_* flags if an error is encountered.
461 */
462static int flt_ot_parse_cfg_tracer(const char *file, int linenum, char **args, int kw_mod)
463{
464#define FLT_OT_PARSE_TRACER_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_TRACER_##a, b, c, d, e, f, g },
465 static const struct flt_ot_parse_data parse_data[] = { FLT_OT_PARSE_TRACER_DEFINES };
466#undef FLT_OT_PARSE_TRACER_DEF
467 const struct flt_ot_parse_data *pdata = NULL;
468 char *err = NULL, *err_log = NULL;
469 int i, retval = ERR_NONE;
470
471 FLT_OT_FUNC("\"%s\", %d, %p, 0x%08x", file, linenum, args, kw_mod);
472
473 if (flt_ot_parse_check_scope())
474 FLT_OT_RETURN(retval);
475
476 retval = flt_ot_parse_cfg_check(file, linenum, args, flt_ot_current_tracer, parse_data, FLT_OT_TABLESIZE(parse_data), &pdata, &err);
477 if (retval & ERR_CODE) {
478 FLT_OT_PARSE_IFERR_ALERT();
479
480 FLT_OT_RETURN(retval);
481 }
482
483 if (pdata->keyword == FLT_OT_PARSE_TRACER_ID) {
484 if (flt_ot_current_config->tracer != NULL) {
485 FLT_OT_PARSE_ERR(&err, "'%s' : tracer can be defined only once", args[1]);
486 } else {
487 flt_ot_current_tracer = flt_ot_conf_tracer_init(args[1], linenum, &err);
488 if (flt_ot_current_tracer == NULL)
489 retval |= ERR_ABORT | ERR_ALERT;
490 }
491 }
492 else if (pdata->keyword == FLT_OT_PARSE_TRACER_LOG) {
Miroslav Zagorac98272252021-04-07 11:14:23 +0200493 if (parse_logsrv(args, &(flt_ot_current_tracer->proxy_log.logsrvs), kw_mod == KWM_NO, file, linenum, &err_log) == 0) {
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100494 FLT_OT_PARSE_ERR(&err, "'%s %s ...' : %s", args[0], args[1], err_log);
495 FLT_OT_FREE_CLEAR(err_log);
496
497 retval |= ERR_ABORT | ERR_ALERT;
498 } else {
499 flt_ot_current_tracer->logging |= FLT_OT_LOGGING_ON;
500 }
501 }
502 else if (pdata->keyword == FLT_OT_PARSE_TRACER_CONFIG) {
503 retval = flt_ot_parse_cfg_file(&(flt_ot_current_tracer->config), file, linenum, args, &err, "configuration file");
504 }
505 else if (pdata->keyword == FLT_OT_PARSE_TRACER_PLUGIN) {
506 retval = flt_ot_parse_cfg_file(&(flt_ot_current_tracer->plugin), file, linenum, args, &err, "plugin library");
507 }
508 else if (pdata->keyword == FLT_OT_PARSE_TRACER_GROUPS) {
509 for (i = 1; !(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(i); i++)
510 if (flt_ot_conf_ph_init(args[i], linenum, &(flt_ot_current_tracer->ph_groups), &err) == NULL)
511 retval |= ERR_ABORT | ERR_ALERT;
512 }
513 else if (pdata->keyword == FLT_OT_PARSE_TRACER_SCOPES) {
514 for (i = 1; !(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(i); i++)
515 if (flt_ot_conf_ph_init(args[i], linenum, &(flt_ot_current_tracer->ph_scopes), &err) == NULL)
516 retval |= ERR_ABORT | ERR_ALERT;
517 }
518 else if (pdata->keyword == FLT_OT_PARSE_TRACER_ACL) {
519 if (strcasecmp(args[1], "or") == 0)
520 FLT_OT_PARSE_ERR(&err, "'%s %s ...' : invalid ACL name", args[0], args[1]);
521 else if (parse_acl((const char **)args + 1, &(flt_ot_current_tracer->acls), &err, &(flt_ot_current_config->proxy->conf.args), file, linenum) == NULL)
522 retval |= ERR_ABORT | ERR_ALERT;
523 }
524 else if (pdata->keyword == FLT_OT_PARSE_TRACER_RATE_LIMIT) {
525 flt_ot_current_tracer->rate_limit = FLT_OT_FLOAT_U32(flt_ot_strtod(args[1], 0.0, FLT_OT_RATE_LIMIT_MAX, &err), FLT_OT_RATE_LIMIT_MAX);
526 }
527 else if (pdata->keyword == FLT_OT_PARSE_TRACER_OPTION) {
528 if (strcmp(args[1], FLT_OT_PARSE_OPTION_DISABLED) == 0) {
529 flt_ot_current_tracer->flag_disabled = (kw_mod == KWM_NO) ? 0 : 1;
530 }
531 else if (strcmp(args[1], FLT_OT_PARSE_OPTION_HARDERR) == 0) {
532 flt_ot_current_tracer->flag_harderr = (kw_mod == KWM_NO) ? 0 : 1;
533 }
534 else if (strcmp(args[1], FLT_OT_PARSE_OPTION_NOLOGNORM) == 0) {
535 if (kw_mod == KWM_NO)
536 flt_ot_current_tracer->logging &= ~FLT_OT_LOGGING_NOLOGNORM;
537 else
538 flt_ot_current_tracer->logging |= FLT_OT_LOGGING_NOLOGNORM;
539 }
540 else
541 FLT_OT_PARSE_ERR(&err, "'%s' : unknown option '%s'", args[0], args[1]);
542 }
543#ifdef DEBUG_OT
544 else if (pdata->keyword == FLT_OT_PARSE_TRACER_DEBUG_LEVEL) {
545 flt_ot_debug.level = flt_ot_strtoll(args[1], 0, 255, &err);
546 }
547#else
548 else {
549 FLT_OT_PARSE_WARNING("'%s' : keyword ignored", file, linenum, args[0]);
550 }
551#endif
552
553 FLT_OT_PARSE_IFERR_ALERT();
554
555 if ((retval & ERR_CODE) && (flt_ot_current_tracer != NULL))
556 flt_ot_conf_tracer_free(&flt_ot_current_tracer);
557
558 FLT_OT_RETURN(retval);
559}
560
561
562/***
563 * NAME
564 * flt_ot_post_parse_cfg_tracer -
565 *
566 * ARGUMENTS
567 * This function takes no arguments.
568 *
569 * DESCRIPTION
570 * -
571 *
572 * RETURN VALUE
573 * Returns ERR_NONE (== 0) in case of success,
574 * or a combination of ERR_* flags if an error is encountered.
575 */
576static int flt_ot_post_parse_cfg_tracer(void)
577{
578 int retval = ERR_NONE;
579
580 FLT_OT_FUNC("");
581
582 if (flt_ot_current_tracer == NULL)
583 FLT_OT_RETURN(retval);
584
585 flt_ot_current_config->tracer = flt_ot_current_tracer;
586
587 if (flt_ot_current_tracer->id == NULL)
588 FLT_OT_RETURN(retval);
589
590 if (flt_ot_current_tracer->config == NULL)
591 FLT_OT_POST_PARSE_ALERT("tracer '%s' has no configuration file specified", flt_ot_current_tracer->cfg_line, flt_ot_current_tracer->id);
592
593 if (flt_ot_current_tracer->plugin == NULL)
594 FLT_OT_POST_PARSE_ALERT("tracer '%s' has no plugin library specified", flt_ot_current_tracer->cfg_line, flt_ot_current_tracer->id);
595
596 flt_ot_current_tracer = NULL;
597
598 FLT_OT_RETURN(retval);
599}
600
601
602/***
603 * NAME
604 * flt_ot_parse_cfg_group -
605 *
606 * ARGUMENTS
607 * file -
608 * linenum -
609 * args -
610 * kw_mod -
611 *
612 * DESCRIPTION
613 * -
614 *
615 * RETURN VALUE
616 * Returns ERR_NONE (== 0) in case of success,
617 * or a combination of ERR_* flags if an error is encountered.
618 */
619static int flt_ot_parse_cfg_group(const char *file, int linenum, char **args, int kw_mod)
620{
621#define FLT_OT_PARSE_GROUP_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_GROUP_##a, b, c, d, e, f, g },
622 static const struct flt_ot_parse_data parse_data[] = { FLT_OT_PARSE_GROUP_DEFINES };
623#undef FLT_OT_PARSE_GROUP_DEF
624 const struct flt_ot_parse_data *pdata = NULL;
625 char *err = NULL;
626 int i, retval = ERR_NONE;
627
628 FLT_OT_FUNC("\"%s\", %d, %p, 0x%08x", file, linenum, args, kw_mod);
629
630 if (flt_ot_parse_check_scope())
631 FLT_OT_RETURN(retval);
632
633 retval = flt_ot_parse_cfg_check(file, linenum, args, flt_ot_current_group, parse_data, FLT_OT_TABLESIZE(parse_data), &pdata, &err);
634 if (retval & ERR_CODE) {
635 FLT_OT_PARSE_IFERR_ALERT();
636
637 FLT_OT_RETURN(retval);
638 }
639
640 if (pdata->keyword == FLT_OT_PARSE_GROUP_ID) {
641 flt_ot_current_group = flt_ot_conf_group_init(args[1], linenum, &(flt_ot_current_config->groups), &err);
642 if (flt_ot_current_config == NULL)
643 retval |= ERR_ABORT | ERR_ALERT;
644 }
645 else if (pdata->keyword == FLT_OT_PARSE_GROUP_SCOPES) {
646 for (i = 1; !(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(i); i++)
647 if (flt_ot_conf_ph_init(args[i], linenum, &(flt_ot_current_group->ph_scopes), &err) == NULL)
648 retval |= ERR_ABORT | ERR_ALERT;
649 }
650
651 FLT_OT_PARSE_IFERR_ALERT();
652
653 if ((retval & ERR_CODE) && (flt_ot_current_group != NULL))
654 flt_ot_conf_group_free(&flt_ot_current_group);
655
656 FLT_OT_RETURN(retval);
657}
658
659
660/***
661 * NAME
662 * flt_ot_post_parse_cfg_group -
663 *
664 * ARGUMENTS
665 * This function takes no arguments.
666 *
667 * DESCRIPTION
668 * -
669 *
670 * RETURN VALUE
671 * Returns ERR_NONE (== 0) in case of success,
672 * or a combination of ERR_* flags if an error is encountered.
673 */
674static int flt_ot_post_parse_cfg_group(void)
675{
676 int retval = ERR_NONE;
677
678 FLT_OT_FUNC("");
679
680 if (flt_ot_current_group == NULL)
681 FLT_OT_RETURN(retval);
682
683 /* Check that the group has at least one scope defined. */
684 if (LIST_ISEMPTY(&(flt_ot_current_group->ph_scopes)))
685 FLT_OT_POST_PARSE_ALERT("group '%s' has no defined scope(s)", flt_ot_current_group->cfg_line, flt_ot_current_group->id);
686
687 flt_ot_current_group = NULL;
688
689 FLT_OT_RETURN(retval);
690}
691
692
693/***
694 * NAME
695 * flt_ot_parse_cfg_scope_ctx -
696 *
697 * ARGUMENTS
698 * args -
699 * cur_arg -
700 * err -
701 *
702 * DESCRIPTION
703 * -
704 *
705 * RETURN VALUE
706 * Returns ERR_NONE (== 0) in case of success,
707 * or a combination of ERR_* flags if an error is encountered.
708 */
709static int flt_ot_parse_cfg_scope_ctx(char **args, int cur_arg, char **err)
710{
711 uint8_t flags = 0;
712 int retval = ERR_NONE;
713
714 FLT_OT_FUNC("%p, %d, %p:%p", args, cur_arg, FLT_OT_DPTR_ARGS(err));
715
716 if (strcmp(args[cur_arg], FLT_OT_PARSE_CTX_USE_HEADERS) == 0)
717 flags = FLT_OT_CTX_USE_HEADERS;
718 else if (strcmp(args[cur_arg], FLT_OT_PARSE_CTX_USE_VARS) == 0)
719 flags = FLT_OT_CTX_USE_VARS;
720 else
721 FLT_OT_PARSE_ERR(err, "'%s' : invalid context storage type", args[0]);
722
723 if (flags == 0)
724 /* Do nothing. */;
725 else if (flt_ot_current_span->ctx_flags & flags)
726 FLT_OT_PARSE_ERR(err, "'%s' : %s already used", args[0], args[cur_arg]);
727 else
728 flt_ot_current_span->ctx_flags |= flags;
729
730 FLT_OT_DBG(2, "ctx_flags: 0x%02hhx (0x%02hhx)", flt_ot_current_span->ctx_flags, flags);
731
732 FLT_OT_RETURN(retval);
733}
734
735
736/***
737 * NAME
738 * flt_ot_parse_acl -
739 *
740 * ARGUMENTS
741 * file -
742 * linenum -
743 * px -
744 * args -
745 * err -
746 * head -
747 *
748 * DESCRIPTION
749 * -
750 *
751 * RETURN VALUE
752 * -
753 */
754static struct acl_cond *flt_ot_parse_acl(const char *file, int linenum, struct proxy *px, const char **args, char **err, struct list *head, ...)
755{
756 va_list ap;
757 int n = 0;
758 struct acl_cond *retptr = NULL;
759
760 FLT_OT_FUNC("\"%s\", %d, %p, %p, %p:%p, %p, ...", file, linenum, px, args, FLT_OT_DPTR_ARGS(err), head);
761
762 for (va_start(ap, head); (retptr == NULL) && (head != NULL); head = va_arg(ap, typeof(head)), n++) {
763 retptr = build_acl_cond(file, linenum, head, px, args, (n == 0) ? err : NULL);
764 if (retptr != NULL)
765 FLT_OT_DBG(2, "ACL build done, using list %p %d", head, n);
766 }
767 va_end(ap);
768
769 if ((retptr != NULL) && (err != NULL))
770 FLT_OT_FREE_CLEAR(*err);
771
772 FLT_OT_RETURN(retptr);
773}
774
775
776/***
777 * NAME
778 * flt_ot_parse_cfg_scope -
779 *
780 * ARGUMENTS
781 * file -
782 * linenum -
783 * args -
784 * kw_mod -
785 *
786 * DESCRIPTION
787 * Function used to load the scope block configuration.
788 *
789 * RETURN VALUE
790 * Returns ERR_NONE (== 0) in case of success,
791 * or a combination of ERR_* flags if an error is encountered.
792 */
793static int flt_ot_parse_cfg_scope(const char *file, int linenum, char **args, int kw_mod)
794{
795#define FLT_OT_PARSE_SCOPE_DEF(a,b,c,d,e,f,g) { FLT_OT_PARSE_SCOPE_##a, b, c, d, e, f, g },
796 static const struct flt_ot_parse_data parse_data[] = { FLT_OT_PARSE_SCOPE_DEFINES };
797#undef FLT_OT_PARSE_SCOPE_DEF
798 const struct flt_ot_parse_data *pdata = NULL;
799 char *err = NULL;
800 int i, retval = ERR_NONE;
801
802 FLT_OT_FUNC("\"%s\", %d, %p, 0x%08x", file, linenum, args, kw_mod);
803
804 if (flt_ot_parse_check_scope())
805 FLT_OT_RETURN(retval);
806
807 retval = flt_ot_parse_cfg_check(file, linenum, args, flt_ot_current_span, parse_data, FLT_OT_TABLESIZE(parse_data), &pdata, &err);
808 if (retval & ERR_CODE) {
809 FLT_OT_PARSE_IFERR_ALERT();
810
811 FLT_OT_RETURN(retval);
812 }
813
814 if (pdata->keyword == FLT_OT_PARSE_SCOPE_ID) {
815 /* Initialization of a new scope. */
816 flt_ot_current_scope = flt_ot_conf_scope_init(args[1], linenum, &(flt_ot_current_config->scopes), &err);
817 if (flt_ot_current_scope == NULL)
818 retval |= ERR_ABORT | ERR_ALERT;
819 }
820 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_SPAN) {
821 /*
822 * Checking if this is the beginning of the definition of
823 * a new span.
824 */
825 if (flt_ot_current_span != NULL) {
826 FLT_OT_DBG(3, "span '%s' (done)", flt_ot_current_span->id);
827
828 flt_ot_current_span = NULL;
829 }
830
831 /* Initialization of a new span. */
832 flt_ot_current_span = flt_ot_conf_span_init(args[1], linenum, &(flt_ot_current_scope->spans), &err);
833
834 /*
835 * In case the span has a defined reference,
836 * the correctness of the arguments is checked here.
837 */
838 if (flt_ot_current_span == NULL) {
839 retval |= ERR_ABORT | ERR_ALERT;
840 }
841 else if (FLT_OT_ARG_ISVALID(2)) {
842 for (i = 2; (i < pdata->args_max) && FLT_OT_ARG_ISVALID(i); i++)
843 if (strcmp(args[i], FLT_OT_PARSE_SPAN_ROOT) == 0) {
844 if (flt_ot_current_span->flag_root)
845 FLT_OT_PARSE_ERR(&err, "'%s' : already set (use '%s%s')", args[i], pdata->name, pdata->usage);
846 else
847 flt_ot_current_span->flag_root = 1;
848 }
849 else if ((strcmp(args[i], FLT_OT_PARSE_SPAN_REF_CHILD) == 0) || (strcmp(args[i], FLT_OT_PARSE_SPAN_REF_FOLLOWS) == 0)) {
850 if (!FLT_OT_ARG_ISVALID(i + 1)) {
851 FLT_OT_PARSE_ERR(&err, "'%s' : too few arguments (use '%s%s')", args[i], pdata->name, pdata->usage);
852 }
853 else if (strcmp(args[i++], FLT_OT_PARSE_SPAN_REF_CHILD) == 0) {
854 flt_ot_current_span->ref_type = otc_span_reference_child_of;
855 flt_ot_current_span->ref_id_len = strlen(args[i]);
856
857 retval = flt_ot_parse_strdup(&(flt_ot_current_span->ref_id), args[i], &err, args[1]);
858 }
859 else {
860 flt_ot_current_span->ref_type = otc_span_reference_follows_from;
861 flt_ot_current_span->ref_id_len = strlen(args[i]);
862
863 retval = flt_ot_parse_strdup(&(flt_ot_current_span->ref_id), args[i], &err, args[1]);
864 }
865 }
866 else {
867 FLT_OT_PARSE_ERR(&err, "'%s' : invalid argument (use '%s%s')", args[i], pdata->name, pdata->usage);
868 }
869 }
870 else {
871 /*
872 * This is not a faulty configuration, only such a case
873 * will be logged.
874 */
875 FLT_OT_DBG(3, "new span '%s' without reference", flt_ot_current_span->id);
876 }
877 }
878 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_TAG) {
879 retval = flt_ot_parse_cfg_sample(file, linenum, args, &(flt_ot_current_span->tags), &err);
880 }
881 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_LOG) {
882 retval = flt_ot_parse_cfg_sample(file, linenum, args, &(flt_ot_current_span->logs), &err);
883 }
884 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_BAGGAGE) {
885 retval = flt_ot_parse_cfg_sample(file, linenum, args, &(flt_ot_current_span->baggages), &err);
886 }
887 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_INJECT) {
888 /*
889 * Automatic context name generation can be specified here
890 * if the contents of the FLT_OT_PARSE_CTX_AUTONAME macro
891 * are used as the name. In that case, if the context is
892 * after a particular event, it gets its name; otherwise
893 * it gets the name of the current span.
894 */
895 if (flt_ot_current_span->ctx_id != NULL)
896 FLT_OT_PARSE_ERR(&err, "'%s' : only one context per span is allowed", args[1]);
897 else if (strcmp(args[1], FLT_OT_PARSE_CTX_AUTONAME) != 0)
898 retval = flt_ot_parse_strdup(&(flt_ot_current_span->ctx_id), args[1], &err, args[0]);
899 else if (flt_ot_current_scope->event != FLT_OT_EVENT_REQ_NONE)
900 retval = flt_ot_parse_strdup(&(flt_ot_current_span->ctx_id), flt_ot_event_data[flt_ot_current_scope->event].name, &err, args[0]);
901 else
902 retval = flt_ot_parse_strdup(&(flt_ot_current_span->ctx_id), flt_ot_current_span->id, &err, args[0]);
903
904 if (flt_ot_current_span->ctx_id != NULL) {
905 flt_ot_current_span->ctx_id_len = strlen(flt_ot_current_span->ctx_id);
906
907 /*
908 * Here is checked the context storage type; which, if
909 * not explicitly specified, is set to HTTP headers.
910 *
911 * It is possible to use both types of context storage
912 * at the same time.
913 */
914 if (FLT_OT_ARG_ISVALID(2)) {
915 retval = flt_ot_parse_cfg_scope_ctx(args, 2, &err);
916 if (!(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(3))
917 retval = flt_ot_parse_cfg_scope_ctx(args, 3, &err);
918 } else {
919 flt_ot_current_span->ctx_flags = FLT_OT_CTX_USE_HEADERS;
920 }
921 }
922 }
923 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_EXTRACT) {
924 struct flt_ot_conf_context *conf_ctx;
925
926 /*
927 * Here is checked the context storage type; which, if
928 * not explicitly specified, is set to HTTP headers.
929 */
930 conf_ctx = flt_ot_conf_context_init(args[1], linenum, &(flt_ot_current_scope->contexts), &err);
931 if (conf_ctx == NULL)
932 retval |= ERR_ABORT | ERR_ALERT;
933 else if (!FLT_OT_ARG_ISVALID(2))
934 conf_ctx->flags = FLT_OT_CTX_USE_HEADERS;
935 else if (strcmp(args[2], FLT_OT_PARSE_CTX_USE_HEADERS) == 0)
936 conf_ctx->flags = FLT_OT_CTX_USE_HEADERS;
937 else if (strcmp(args[2], FLT_OT_PARSE_CTX_USE_VARS) == 0)
938 conf_ctx->flags = FLT_OT_CTX_USE_VARS;
939 else
940 FLT_OT_PARSE_ERR(&err, "'%s' : invalid context storage type", args[2]);
941 }
942 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_FINISH) {
943 retval = flt_ot_parse_cfg_str(file, linenum, args, &(flt_ot_current_scope->finish), &err);
944 }
945 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_ACL) {
946 if (strcasecmp(args[1], "or") == 0)
947 FLT_OT_PARSE_ERR(&err, "'%s %s ...' : invalid ACL name", args[0], args[1]);
948 else if (parse_acl((const char **)args + 1, &(flt_ot_current_scope->acls), &err, &(flt_ot_current_config->proxy->conf.args), file, linenum) == NULL)
949 retval |= ERR_ABORT | ERR_ALERT;
950 }
951 else if (pdata->keyword == FLT_OT_PARSE_SCOPE_EVENT) {
952 /* Scope can only have one event defined. */
953 if (flt_ot_current_scope->event != FLT_OT_EVENT_REQ_NONE) {
954 FLT_OT_PARSE_ERR(&err, "'%s' : event already set", flt_ot_current_scope->id);
955 } else {
956 /* Check the event name. */
957 for (i = 0; i < FLT_OT_TABLESIZE(flt_ot_event_data); i++)
958 if (strcmp(flt_ot_event_data[i].name, args[1]) == 0) {
959 flt_ot_current_scope->event = i;
960
961 break;
962 }
963
964 /*
965 * The event can have some condition defined and this
966 * is checked here.
967 */
968 if (flt_ot_current_scope->event == FLT_OT_EVENT_REQ_NONE) {
969 FLT_OT_PARSE_ERR(&err, "'%s' : unknown event", args[1]);
970 }
971 else if (!FLT_OT_ARG_ISVALID(2)) {
972 /* Do nothing. */
973 }
974 else if ((strcmp(args[2], FLT_OT_CONDITION_IF) == 0) || (strcmp(args[2], FLT_OT_CONDITION_UNLESS) == 0)) {
975 /*
976 * We will first try to build ACL condition using
977 * local settings and then if that fails, using
978 * global settings (from tracer block). If it
979 * also fails, then try to use ACL defined in
980 * the HAProxy configuration.
981 */
982 flt_ot_current_scope->cond = flt_ot_parse_acl(file, linenum, flt_ot_current_config->proxy, (const char **)args + 2, &err, &(flt_ot_current_scope->acls), &(flt_ot_current_config->tracer->acls), &(flt_ot_current_config->proxy->acl), NULL);
983 if (flt_ot_current_scope->cond == NULL)
984 retval |= ERR_ABORT | ERR_ALERT;
985 }
986 else {
987 FLT_OT_PARSE_ERR(&err, "'%s' : expects either 'if' or 'unless' followed by a condition but found '%s'", args[1], args[2]);
988 }
989
990 if (!(retval & ERR_CODE))
991 FLT_OT_DBG(3, "event '%s'", args[1]);
992 }
993 }
994
995 FLT_OT_PARSE_IFERR_ALERT();
996
997 if ((retval & ERR_CODE) && (flt_ot_current_scope != NULL)) {
998 flt_ot_conf_scope_free(&flt_ot_current_scope);
999
1000 flt_ot_current_span = NULL;
1001 }
1002
1003 FLT_OT_RETURN(retval);
1004}
1005
1006
1007/***
1008 * NAME
1009 * flt_ot_post_parse_cfg_scope -
1010 *
1011 * ARGUMENTS
1012 * This function takes no arguments.
1013 *
1014 * DESCRIPTION
1015 * In this function the correctness of the complete scope block is examined.
1016 * This does not mean that all elements are checked here, but only those for
1017 * which it has not been possible to establish their complete correctness in
1018 * the function flt_ot_parse_cfg_scope().
1019 *
1020 * RETURN VALUE
1021 * Returns ERR_NONE (== 0) in case of success,
1022 * or a combination of ERR_* flags if an error is encountered.
1023 */
1024static int flt_ot_post_parse_cfg_scope(void)
1025{
1026 struct flt_ot_conf_span *conf_span;
1027 int retval = ERR_NONE;
1028
1029 FLT_OT_FUNC("");
1030
1031 if (flt_ot_current_scope == NULL)
1032 FLT_OT_RETURN(retval);
1033
1034 /* If span context inject is used, check that this is possible. */
1035 list_for_each_entry(conf_span, &(flt_ot_current_scope->spans), list)
1036 if ((conf_span->ctx_id != NULL) && (conf_span->ctx_flags & FLT_OT_CTX_USE_HEADERS))
1037 if (!flt_ot_event_data[flt_ot_current_scope->event].flag_http_inject)
1038 FLT_OT_POST_PARSE_ALERT("inject '%s' : cannot use on this event", conf_span->cfg_line, conf_span->ctx_id);
1039
1040 if (retval & ERR_CODE)
1041 flt_ot_conf_scope_free(&flt_ot_current_scope);
1042
1043 flt_ot_current_scope = NULL;
1044 flt_ot_current_span = NULL;
1045
1046 FLT_OT_RETURN(retval);
1047}
1048
1049
1050/***
1051 * NAME
1052 * flt_ot_parse_cfg -
1053 *
1054 * ARGUMENTS
1055 * conf -
1056 * flt_name -
1057 * err -
1058 *
1059 * DESCRIPTION
1060 * -
1061 *
1062 * RETURN VALUE
1063 * Returns ERR_NONE (== 0) in case of success,
1064 * or a combination of ERR_* flags if an error is encountered.
1065 */
1066static int flt_ot_parse_cfg(struct flt_ot_conf *conf, const char *flt_name, char **err)
1067{
1068 struct list backup_sections;
1069 int retval = ERR_ABORT | ERR_ALERT;
1070
1071 FLT_OT_FUNC("%p, \"%s\", %p:%p", conf, flt_name, FLT_OT_DPTR_ARGS(err));
1072
1073 flt_ot_current_config = conf;
1074
1075 /* Backup sections. */
1076 LIST_INIT(&backup_sections);
1077 cfg_backup_sections(&backup_sections);
1078
1079 /* Register new OT sections and parse the OT filter configuration file. */
1080 if (!cfg_register_section(FLT_OT_PARSE_SECTION_TRACER_ID, flt_ot_parse_cfg_tracer, flt_ot_post_parse_cfg_tracer))
1081 /* Do nothing. */;
1082 else if (!cfg_register_section(FLT_OT_PARSE_SECTION_GROUP_ID, flt_ot_parse_cfg_group, flt_ot_post_parse_cfg_group))
1083 /* Do nothing. */;
1084 else if (!cfg_register_section(FLT_OT_PARSE_SECTION_SCOPE_ID, flt_ot_parse_cfg_scope, flt_ot_post_parse_cfg_scope))
1085 /* Do nothing. */;
1086 else if (access(conf->cfg_file, R_OK) == -1)
1087 FLT_OT_PARSE_ERR(err, "'%s' : %s", conf->cfg_file, strerror(errno));
1088 else
1089 retval = readcfgfile(conf->cfg_file);
1090
1091 /* Unregister OT sections and restore previous sections. */
1092 cfg_unregister_sections();
1093 cfg_restore_sections(&backup_sections);
1094
1095 flt_ot_current_config = NULL;
1096
1097 FLT_OT_RETURN(retval);
1098}
1099
1100
1101/***
1102 * NAME
1103 * flt_ot_parse -
1104 *
1105 * ARGUMENTS
1106 * args -
1107 * cur_arg -
1108 * px -
1109 * fconf -
1110 * err -
1111 * private -
1112 *
1113 * DESCRIPTION
1114 * -
1115 *
1116 * RETURN VALUE
1117 * Returns ERR_NONE (== 0) in case of success,
1118 * or a combination of ERR_* flags if an error is encountered.
1119 */
1120static int flt_ot_parse(char **args, int *cur_arg, struct proxy *px, struct flt_conf *fconf, char **err, void *private)
1121{
1122 struct flt_ot_conf *conf = NULL;
1123 int pos, retval = ERR_NONE;
1124
1125#ifdef DEBUG_OT
1126 FLT_OT_RUN_ONCE(
1127# ifndef DEBUG_OT_SYSTIME
1128 (void)memcpy(&(flt_ot_debug.start), &now, sizeof(flt_ot_debug.start));
1129# endif
1130
1131 flt_ot_debug.level = FLT_OT_DEBUG_LEVEL;
1132 );
1133#endif
1134
1135 FLT_OT_FUNC("%p, %p, %p, %p, %p:%p, %p", args, cur_arg, px, fconf, FLT_OT_DPTR_ARGS(err), private);
1136
1137#ifdef OTC_DBG_MEM
1138 FLT_OT_RUN_ONCE(
1139 if (otc_dbg_mem_init(&dbg_mem, dbg_mem_data, FLT_OT_TABLESIZE(dbg_mem_data), 0xff) == -1) {
1140 FLT_OT_PARSE_ERR(err, "cannot initialize memory debugger");
1141
1142 FLT_OT_RETURN(retval);
1143 }
1144 );
1145#endif
1146
1147 FLT_OT_ARGS_DUMP();
1148
1149 conf = flt_ot_conf_init(px);
1150 if (conf == NULL) {
1151 FLT_OT_PARSE_ERR(err, "'%s' : out of memory", args[*cur_arg]);
1152
1153 FLT_OT_RETURN(retval);
1154 }
1155
1156 for (pos = *cur_arg + 1; !(retval & ERR_CODE) && FLT_OT_ARG_ISVALID(pos); pos++) {
1157 FLT_OT_DBG(3, "args[%d:2] : { '%s' '%s' }", pos, args[pos], args[pos + 1]);
1158
1159 if (strcmp(args[pos], FLT_OT_OPT_FILTER_ID) == 0) {
1160 retval = flt_ot_parse_keyword(&(conf->id), args, *cur_arg, pos, err, "name");
1161 pos++;
1162 }
1163 else if (strcmp(args[pos], FLT_OT_OPT_CONFIG) == 0) {
1164 retval = flt_ot_parse_keyword(&(conf->cfg_file), args, *cur_arg, pos, err, "configuration file");
1165 if (!(retval & ERR_CODE))
1166 retval = flt_ot_parse_cfg(conf, args[*cur_arg], err);
1167 pos++;
1168 }
1169 else {
1170 FLT_OT_PARSE_ERR(err, "'%s' : unknown keyword '%s'", args[*cur_arg], args[pos]);
1171 }
1172 }
1173
1174 /* If the OpenTracing filter ID is not set, use default name. */
1175 if (!(retval & ERR_CODE) && (conf->id == NULL)) {
1176 ha_warning("parsing : " FLT_OT_FMT_TYPE FLT_OT_FMT_NAME "'no filter id set, using default id '%s'\n", FLT_OT_OPT_FILTER_ID_DEFAULT);
1177
1178 retval = flt_ot_parse_strdup(&(conf->id), FLT_OT_OPT_FILTER_ID_DEFAULT, err, args[*cur_arg]);
1179 }
1180
1181 if (!(retval & ERR_CODE) && (conf->cfg_file == NULL))
1182 FLT_OT_PARSE_ERR(err, "'%s' : no configuration file specified", args[*cur_arg]);
1183
1184 if (retval & ERR_CODE) {
1185 flt_ot_conf_free(&conf);
1186 } else {
1187 fconf->id = ot_flt_id;
1188 fconf->ops = &flt_ot_ops;
1189 fconf->conf = conf;
1190
1191 *cur_arg = pos;
1192
1193 FLT_OT_DBG(3, "filter set: id '%s', config '%s'", conf->id, conf->cfg_file);
1194 }
1195
1196 FLT_OT_RETURN(retval);
1197}
1198
1199
1200/* Declare the filter parser for FLT_OT_OPT_NAME keyword. */
1201static struct flt_kw_list flt_kws = { FLT_OT_SCOPE, { }, {
1202 { FLT_OT_OPT_NAME, flt_ot_parse, NULL },
1203 { NULL, NULL, NULL },
1204 }
1205};
1206
1207INITCALL1(STG_REGISTER, flt_register_keywords, &flt_kws);
1208
1209/*
1210 * Local variables:
1211 * c-indent-level: 8
1212 * c-basic-offset: 8
1213 * End:
1214 *
1215 * vi: noexpandtab shiftwidth=8 tabstop=8
1216 */