blob: 602749c4948d00957e495ef5e0b77ad182b67457 [file] [log] [blame]
Willy Tarreau39713102016-11-25 15:49:32 +01001/*
2 * "tcp" rules processing
3 *
4 * Copyright 2000-2016 Willy Tarreau <w@1wt.eu>
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#include <common/cfgparse.h>
13#include <common/compat.h>
14#include <common/config.h>
15#include <common/debug.h>
Willy Tarreau0108d902018-11-25 19:14:37 +010016#include <common/initcall.h>
Willy Tarreau39713102016-11-25 15:49:32 +010017#include <common/mini-clist.h>
18#include <common/standard.h>
19#include <common/ticks.h>
20#include <common/time.h>
21
22#include <types/arg.h>
23#include <types/capture.h>
24#include <types/connection.h>
25#include <types/global.h>
26
27#include <proto/acl.h>
28#include <proto/action.h>
29#include <proto/channel.h>
30#include <proto/connection.h>
31#include <proto/log.h>
32#include <proto/proxy.h>
33#include <proto/sample.h>
34#include <proto/stick_table.h>
35#include <proto/stream.h>
36#include <proto/stream_interface.h>
37#include <proto/tcp_rules.h>
38
39/* List head of all known action keywords for "tcp-request connection" */
40struct list tcp_req_conn_keywords = LIST_HEAD_INIT(tcp_req_conn_keywords);
41struct list tcp_req_sess_keywords = LIST_HEAD_INIT(tcp_req_sess_keywords);
42struct list tcp_req_cont_keywords = LIST_HEAD_INIT(tcp_req_cont_keywords);
43struct list tcp_res_cont_keywords = LIST_HEAD_INIT(tcp_res_cont_keywords);
44
45/*
46 * Register keywords.
47 */
48void tcp_req_conn_keywords_register(struct action_kw_list *kw_list)
49{
50 LIST_ADDQ(&tcp_req_conn_keywords, &kw_list->list);
51}
52
53void tcp_req_sess_keywords_register(struct action_kw_list *kw_list)
54{
55 LIST_ADDQ(&tcp_req_sess_keywords, &kw_list->list);
56}
57
58void tcp_req_cont_keywords_register(struct action_kw_list *kw_list)
59{
60 LIST_ADDQ(&tcp_req_cont_keywords, &kw_list->list);
61}
62
63void tcp_res_cont_keywords_register(struct action_kw_list *kw_list)
64{
65 LIST_ADDQ(&tcp_res_cont_keywords, &kw_list->list);
66}
67
68/*
69 * Return the struct tcp_req_action_kw associated to a keyword.
70 */
71static struct action_kw *tcp_req_conn_action(const char *kw)
72{
73 return action_lookup(&tcp_req_conn_keywords, kw);
74}
75
76static struct action_kw *tcp_req_sess_action(const char *kw)
77{
78 return action_lookup(&tcp_req_sess_keywords, kw);
79}
80
81static struct action_kw *tcp_req_cont_action(const char *kw)
82{
83 return action_lookup(&tcp_req_cont_keywords, kw);
84}
85
86static struct action_kw *tcp_res_cont_action(const char *kw)
87{
88 return action_lookup(&tcp_res_cont_keywords, kw);
89}
90
91/* This function performs the TCP request analysis on the current request. It
92 * returns 1 if the processing can continue on next analysers, or zero if it
93 * needs more data, encounters an error, or wants to immediately abort the
94 * request. It relies on buffers flags, and updates s->req->analysers. The
95 * function may be called for frontend rules and backend rules. It only relies
96 * on the backend pointer so this works for both cases.
97 */
98int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit)
99{
100 struct session *sess = s->sess;
101 struct act_rule *rule;
102 struct stksess *ts;
103 struct stktable *t;
104 int partial;
105 int act_flags = 0;
106
Christopher Faulet45073512018-07-20 10:16:29 +0200107 DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n",
Willy Tarreau39713102016-11-25 15:49:32 +0100108 now_ms, __FUNCTION__,
109 s,
110 req,
111 req->rex, req->wex,
112 req->flags,
Christopher Faulet45073512018-07-20 10:16:29 +0200113 ci_data(req),
Willy Tarreau39713102016-11-25 15:49:32 +0100114 req->analysers);
115
116 /* We don't know whether we have enough data, so must proceed
117 * this way :
118 * - iterate through all rules in their declaration order
119 * - if one rule returns MISS, it means the inspect delay is
120 * not over yet, then return immediately, otherwise consider
121 * it as a non-match.
122 * - if one rule returns OK, then return OK
123 * - if one rule returns KO, then return KO
124 */
125
Willy Tarreau23752332018-06-15 14:54:53 +0200126 if ((req->flags & CF_SHUTR) || channel_full(req, global.tune.maxrewrite) ||
Willy Tarreau39713102016-11-25 15:49:32 +0100127 !s->be->tcp_req.inspect_delay || tick_is_expired(req->analyse_exp, now_ms))
128 partial = SMP_OPT_FINAL;
129 else
130 partial = 0;
131
132 /* If "the current_rule_list" match the executed rule list, we are in
133 * resume condition. If a resume is needed it is always in the action
134 * and never in the ACL or converters. In this case, we initialise the
135 * current rule, and go to the action execution point.
136 */
137 if (s->current_rule) {
138 rule = s->current_rule;
139 s->current_rule = NULL;
140 if (s->current_rule_list == &s->be->tcp_req.inspect_rules)
141 goto resume_execution;
142 }
143 s->current_rule_list = &s->be->tcp_req.inspect_rules;
144
145 list_for_each_entry(rule, &s->be->tcp_req.inspect_rules, list) {
146 enum acl_test_res ret = ACL_TEST_PASS;
147
148 if (rule->cond) {
149 ret = acl_exec_cond(rule->cond, s->be, sess, s, SMP_OPT_DIR_REQ | partial);
150 if (ret == ACL_TEST_MISS)
151 goto missing_data;
152
153 ret = acl_pass(ret);
154 if (rule->cond->pol == ACL_COND_UNLESS)
155 ret = !ret;
156 }
157
158 if (ret) {
159 act_flags |= ACT_FLAG_FIRST;
160resume_execution:
161 /* we have a matching rule. */
162 if (rule->action == ACT_ACTION_ALLOW) {
163 break;
164 }
165 else if (rule->action == ACT_ACTION_DENY) {
166 channel_abort(req);
167 channel_abort(&s->res);
168 req->analysers = 0;
169
Christopher Fauletff8abcd2017-06-02 15:33:24 +0200170 HA_ATOMIC_ADD(&s->be->be_counters.denied_req, 1);
171 HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_req, 1);
Willy Tarreaua12dde02016-12-22 18:14:41 +0100172 if (sess->listener && sess->listener->counters)
Christopher Faulet8d8aa0d2017-05-30 15:36:50 +0200173 HA_ATOMIC_ADD(&sess->listener->counters->denied_req, 1);
Willy Tarreau39713102016-11-25 15:49:32 +0100174
175 if (!(s->flags & SF_ERR_MASK))
176 s->flags |= SF_ERR_PRXCOND;
177 if (!(s->flags & SF_FINST_MASK))
178 s->flags |= SF_FINST_R;
179 return 0;
180 }
181 else if (rule->action >= ACT_ACTION_TRK_SC0 && rule->action <= ACT_ACTION_TRK_SCMAX) {
182 /* Note: only the first valid tracking parameter of each
183 * applies.
184 */
185 struct stktable_key *key;
186 struct sample smp;
187
Christopher Faulet4fce0d82017-09-18 11:57:31 +0200188 if (stkctr_entry(&s->stkctr[trk_idx(rule->action)]))
Willy Tarreau39713102016-11-25 15:49:32 +0100189 continue;
190
191 t = rule->arg.trk_ctr.table.t;
192 key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->arg.trk_ctr.expr, &smp);
193
194 if ((smp.flags & SMP_F_MAY_CHANGE) && !(partial & SMP_OPT_FINAL))
195 goto missing_data; /* key might appear later */
196
197 if (key && (ts = stktable_get_entry(t, key))) {
Christopher Faulet4fce0d82017-09-18 11:57:31 +0200198 stream_track_stkctr(&s->stkctr[trk_idx(rule->action)], t, ts);
199 stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT);
Willy Tarreau39713102016-11-25 15:49:32 +0100200 if (sess->fe != s->be)
Christopher Faulet4fce0d82017-09-18 11:57:31 +0200201 stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_BACKEND);
Willy Tarreau39713102016-11-25 15:49:32 +0100202 }
203 }
204 else if (rule->action == ACT_TCP_CAPTURE) {
205 struct sample *key;
206 struct cap_hdr *h = rule->arg.cap.hdr;
207 char **cap = s->req_cap;
208 int len;
209
210 key = sample_fetch_as_type(s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->arg.cap.expr, SMP_T_STR);
211 if (!key)
212 continue;
213
214 if (key->flags & SMP_F_MAY_CHANGE)
215 goto missing_data;
216
217 if (cap[h->index] == NULL)
Willy Tarreaubafbe012017-11-24 17:34:44 +0100218 cap[h->index] = pool_alloc(h->pool);
Willy Tarreau39713102016-11-25 15:49:32 +0100219
220 if (cap[h->index] == NULL) /* no more capture memory */
221 continue;
222
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200223 len = key->data.u.str.data;
Willy Tarreau39713102016-11-25 15:49:32 +0100224 if (len > h->len)
225 len = h->len;
226
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200227 memcpy(cap[h->index], key->data.u.str.area,
228 len);
Willy Tarreau39713102016-11-25 15:49:32 +0100229 cap[h->index][len] = 0;
230 }
231 else {
232 /* Custom keywords. */
233 if (!rule->action_ptr)
234 continue;
235
236 if (partial & SMP_OPT_FINAL)
237 act_flags |= ACT_FLAG_FINAL;
238
239 switch (rule->action_ptr(rule, s->be, s->sess, s, act_flags)) {
240 case ACT_RET_ERR:
241 case ACT_RET_CONT:
242 continue;
243 case ACT_RET_STOP:
244 break;
245 case ACT_RET_YIELD:
246 s->current_rule = rule;
247 goto missing_data;
248 }
249 break; /* ACT_RET_STOP */
250 }
251 }
252 }
253
254 /* if we get there, it means we have no rule which matches, or
255 * we have an explicit accept, so we apply the default accept.
256 */
257 req->analysers &= ~an_bit;
258 req->analyse_exp = TICK_ETERNITY;
259 return 1;
260
261 missing_data:
262 channel_dont_connect(req);
263 /* just set the request timeout once at the beginning of the request */
264 if (!tick_isset(req->analyse_exp) && s->be->tcp_req.inspect_delay)
265 req->analyse_exp = tick_add(now_ms, s->be->tcp_req.inspect_delay);
266 return 0;
267
268}
269
270/* This function performs the TCP response analysis on the current response. It
271 * returns 1 if the processing can continue on next analysers, or zero if it
272 * needs more data, encounters an error, or wants to immediately abort the
273 * response. It relies on buffers flags, and updates s->rep->analysers. The
274 * function may be called for backend rules.
275 */
276int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit)
277{
278 struct session *sess = s->sess;
279 struct act_rule *rule;
280 int partial;
281 int act_flags = 0;
282
Christopher Faulet45073512018-07-20 10:16:29 +0200283 DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%lu analysers=%02x\n",
Willy Tarreau39713102016-11-25 15:49:32 +0100284 now_ms, __FUNCTION__,
285 s,
286 rep,
287 rep->rex, rep->wex,
288 rep->flags,
Christopher Faulet45073512018-07-20 10:16:29 +0200289 ci_data(rep),
Willy Tarreau39713102016-11-25 15:49:32 +0100290 rep->analysers);
291
292 /* We don't know whether we have enough data, so must proceed
293 * this way :
294 * - iterate through all rules in their declaration order
295 * - if one rule returns MISS, it means the inspect delay is
296 * not over yet, then return immediately, otherwise consider
297 * it as a non-match.
298 * - if one rule returns OK, then return OK
299 * - if one rule returns KO, then return KO
300 */
301
302 if (rep->flags & CF_SHUTR || tick_is_expired(rep->analyse_exp, now_ms))
303 partial = SMP_OPT_FINAL;
304 else
305 partial = 0;
306
307 /* If "the current_rule_list" match the executed rule list, we are in
308 * resume condition. If a resume is needed it is always in the action
309 * and never in the ACL or converters. In this case, we initialise the
310 * current rule, and go to the action execution point.
311 */
312 if (s->current_rule) {
313 rule = s->current_rule;
314 s->current_rule = NULL;
315 if (s->current_rule_list == &s->be->tcp_rep.inspect_rules)
316 goto resume_execution;
317 }
318 s->current_rule_list = &s->be->tcp_rep.inspect_rules;
319
320 list_for_each_entry(rule, &s->be->tcp_rep.inspect_rules, list) {
321 enum acl_test_res ret = ACL_TEST_PASS;
322
323 if (rule->cond) {
324 ret = acl_exec_cond(rule->cond, s->be, sess, s, SMP_OPT_DIR_RES | partial);
325 if (ret == ACL_TEST_MISS) {
326 /* just set the analyser timeout once at the beginning of the response */
327 if (!tick_isset(rep->analyse_exp) && s->be->tcp_rep.inspect_delay)
328 rep->analyse_exp = tick_add(now_ms, s->be->tcp_rep.inspect_delay);
329 return 0;
330 }
331
332 ret = acl_pass(ret);
333 if (rule->cond->pol == ACL_COND_UNLESS)
334 ret = !ret;
335 }
336
337 if (ret) {
338 act_flags |= ACT_FLAG_FIRST;
339resume_execution:
340 /* we have a matching rule. */
341 if (rule->action == ACT_ACTION_ALLOW) {
342 break;
343 }
344 else if (rule->action == ACT_ACTION_DENY) {
345 channel_abort(rep);
346 channel_abort(&s->req);
347 rep->analysers = 0;
348
Christopher Fauletff8abcd2017-06-02 15:33:24 +0200349 HA_ATOMIC_ADD(&s->be->be_counters.denied_resp, 1);
350 HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_resp, 1);
Willy Tarreaua12dde02016-12-22 18:14:41 +0100351 if (sess->listener && sess->listener->counters)
Christopher Faulet8d8aa0d2017-05-30 15:36:50 +0200352 HA_ATOMIC_ADD(&sess->listener->counters->denied_resp, 1);
Willy Tarreau39713102016-11-25 15:49:32 +0100353
354 if (!(s->flags & SF_ERR_MASK))
355 s->flags |= SF_ERR_PRXCOND;
356 if (!(s->flags & SF_FINST_MASK))
357 s->flags |= SF_FINST_D;
358 return 0;
359 }
360 else if (rule->action == ACT_TCP_CLOSE) {
361 chn_prod(rep)->flags |= SI_FL_NOLINGER | SI_FL_NOHALF;
362 si_shutr(chn_prod(rep));
363 si_shutw(chn_prod(rep));
364 break;
365 }
366 else {
367 /* Custom keywords. */
368 if (!rule->action_ptr)
369 continue;
370
371 if (partial & SMP_OPT_FINAL)
372 act_flags |= ACT_FLAG_FINAL;
373
374 switch (rule->action_ptr(rule, s->be, s->sess, s, act_flags)) {
375 case ACT_RET_ERR:
376 case ACT_RET_CONT:
377 continue;
378 case ACT_RET_STOP:
379 break;
380 case ACT_RET_YIELD:
381 channel_dont_close(rep);
382 s->current_rule = rule;
383 return 0;
384 }
385 break; /* ACT_RET_STOP */
386 }
387 }
388 }
389
390 /* if we get there, it means we have no rule which matches, or
391 * we have an explicit accept, so we apply the default accept.
392 */
393 rep->analysers &= ~an_bit;
394 rep->analyse_exp = TICK_ETERNITY;
395 return 1;
396}
397
398
399/* This function performs the TCP layer4 analysis on the current request. It
400 * returns 0 if a reject rule matches, otherwise 1 if either an accept rule
401 * matches or if no more rule matches. It can only use rules which don't need
402 * any data. This only works on connection-based client-facing stream interfaces.
403 */
404int tcp_exec_l4_rules(struct session *sess)
405{
406 struct act_rule *rule;
407 struct stksess *ts;
408 struct stktable *t = NULL;
409 struct connection *conn = objt_conn(sess->origin);
410 int result = 1;
411 enum acl_test_res ret;
412
413 if (!conn)
414 return result;
415
416 list_for_each_entry(rule, &sess->fe->tcp_req.l4_rules, list) {
417 ret = ACL_TEST_PASS;
418
419 if (rule->cond) {
420 ret = acl_exec_cond(rule->cond, sess->fe, sess, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
421 ret = acl_pass(ret);
422 if (rule->cond->pol == ACL_COND_UNLESS)
423 ret = !ret;
424 }
425
426 if (ret) {
427 /* we have a matching rule. */
428 if (rule->action == ACT_ACTION_ALLOW) {
429 break;
430 }
431 else if (rule->action == ACT_ACTION_DENY) {
Christopher Fauletff8abcd2017-06-02 15:33:24 +0200432 HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_conn, 1);
Willy Tarreaua12dde02016-12-22 18:14:41 +0100433 if (sess->listener && sess->listener->counters)
Christopher Faulet8d8aa0d2017-05-30 15:36:50 +0200434 HA_ATOMIC_ADD(&sess->listener->counters->denied_conn, 1);
Willy Tarreau39713102016-11-25 15:49:32 +0100435
436 result = 0;
437 break;
438 }
439 else if (rule->action >= ACT_ACTION_TRK_SC0 && rule->action <= ACT_ACTION_TRK_SCMAX) {
440 /* Note: only the first valid tracking parameter of each
441 * applies.
442 */
443 struct stktable_key *key;
444
Christopher Faulet4fce0d82017-09-18 11:57:31 +0200445 if (stkctr_entry(&sess->stkctr[trk_idx(rule->action)]))
Willy Tarreau39713102016-11-25 15:49:32 +0100446 continue;
447
448 t = rule->arg.trk_ctr.table.t;
449 key = stktable_fetch_key(t, sess->fe, sess, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->arg.trk_ctr.expr, NULL);
450
451 if (key && (ts = stktable_get_entry(t, key)))
Christopher Faulet4fce0d82017-09-18 11:57:31 +0200452 stream_track_stkctr(&sess->stkctr[trk_idx(rule->action)], t, ts);
Willy Tarreau39713102016-11-25 15:49:32 +0100453 }
454 else if (rule->action == ACT_TCP_EXPECT_PX) {
455 conn->flags |= CO_FL_ACCEPT_PROXY;
456 conn_sock_want_recv(conn);
457 }
458 else if (rule->action == ACT_TCP_EXPECT_CIP) {
459 conn->flags |= CO_FL_ACCEPT_CIP;
460 conn_sock_want_recv(conn);
461 }
462 else {
463 /* Custom keywords. */
464 if (!rule->action_ptr)
465 break;
466 switch (rule->action_ptr(rule, sess->fe, sess, NULL, ACT_FLAG_FINAL | ACT_FLAG_FIRST)) {
467 case ACT_RET_YIELD:
468 /* yield is not allowed at this point. If this return code is
469 * used it is a bug, so I prefer to abort the process.
470 */
471 send_log(sess->fe, LOG_WARNING,
472 "Internal error: yield not allowed with tcp-request connection actions.");
473 case ACT_RET_STOP:
474 break;
475 case ACT_RET_CONT:
476 continue;
477 case ACT_RET_ERR:
478 result = 0;
479 break;
480 }
481 break; /* ACT_RET_STOP */
482 }
483 }
484 }
485 return result;
486}
487
488/* This function performs the TCP layer5 analysis on the current request. It
489 * returns 0 if a reject rule matches, otherwise 1 if either an accept rule
490 * matches or if no more rule matches. It can only use rules which don't need
491 * any data. This only works on session-based client-facing stream interfaces.
492 * An example of valid use case is to track a stick-counter on the source
493 * address extracted from the proxy protocol.
494 */
495int tcp_exec_l5_rules(struct session *sess)
496{
497 struct act_rule *rule;
498 struct stksess *ts;
499 struct stktable *t = NULL;
500 int result = 1;
501 enum acl_test_res ret;
502
503 list_for_each_entry(rule, &sess->fe->tcp_req.l5_rules, list) {
504 ret = ACL_TEST_PASS;
505
506 if (rule->cond) {
507 ret = acl_exec_cond(rule->cond, sess->fe, sess, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
508 ret = acl_pass(ret);
509 if (rule->cond->pol == ACL_COND_UNLESS)
510 ret = !ret;
511 }
512
513 if (ret) {
514 /* we have a matching rule. */
515 if (rule->action == ACT_ACTION_ALLOW) {
516 break;
517 }
518 else if (rule->action == ACT_ACTION_DENY) {
Christopher Fauletff8abcd2017-06-02 15:33:24 +0200519 HA_ATOMIC_ADD(&sess->fe->fe_counters.denied_sess, 1);
Willy Tarreaua12dde02016-12-22 18:14:41 +0100520 if (sess->listener && sess->listener->counters)
Christopher Faulet8d8aa0d2017-05-30 15:36:50 +0200521 HA_ATOMIC_ADD(&sess->listener->counters->denied_sess, 1);
Willy Tarreau39713102016-11-25 15:49:32 +0100522
523 result = 0;
524 break;
525 }
526 else if (rule->action >= ACT_ACTION_TRK_SC0 && rule->action <= ACT_ACTION_TRK_SCMAX) {
527 /* Note: only the first valid tracking parameter of each
528 * applies.
529 */
530 struct stktable_key *key;
531
Christopher Faulet4fce0d82017-09-18 11:57:31 +0200532 if (stkctr_entry(&sess->stkctr[trk_idx(rule->action)]))
Willy Tarreau39713102016-11-25 15:49:32 +0100533 continue;
534
535 t = rule->arg.trk_ctr.table.t;
536 key = stktable_fetch_key(t, sess->fe, sess, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->arg.trk_ctr.expr, NULL);
537
538 if (key && (ts = stktable_get_entry(t, key)))
Christopher Faulet4fce0d82017-09-18 11:57:31 +0200539 stream_track_stkctr(&sess->stkctr[trk_idx(rule->action)], t, ts);
Willy Tarreau39713102016-11-25 15:49:32 +0100540 }
541 else {
542 /* Custom keywords. */
543 if (!rule->action_ptr)
544 break;
545 switch (rule->action_ptr(rule, sess->fe, sess, NULL, ACT_FLAG_FINAL | ACT_FLAG_FIRST)) {
546 case ACT_RET_YIELD:
547 /* yield is not allowed at this point. If this return code is
548 * used it is a bug, so I prefer to abort the process.
549 */
550 send_log(sess->fe, LOG_WARNING,
551 "Internal error: yield not allowed with tcp-request session actions.");
552 case ACT_RET_STOP:
553 break;
554 case ACT_RET_CONT:
555 continue;
556 case ACT_RET_ERR:
557 result = 0;
558 break;
559 }
560 break; /* ACT_RET_STOP */
561 }
562 }
563 }
564 return result;
565}
566
567/* Parse a tcp-response rule. Return a negative value in case of failure */
568static int tcp_parse_response_rule(char **args, int arg, int section_type,
569 struct proxy *curpx, struct proxy *defpx,
570 struct act_rule *rule, char **err,
571 unsigned int where,
572 const char *file, int line)
573{
574 if (curpx == defpx || !(curpx->cap & PR_CAP_BE)) {
575 memprintf(err, "%s %s is only allowed in 'backend' sections",
576 args[0], args[1]);
577 return -1;
578 }
579
580 if (strcmp(args[arg], "accept") == 0) {
581 arg++;
582 rule->action = ACT_ACTION_ALLOW;
583 }
584 else if (strcmp(args[arg], "reject") == 0) {
585 arg++;
586 rule->action = ACT_ACTION_DENY;
587 }
588 else if (strcmp(args[arg], "close") == 0) {
589 arg++;
590 rule->action = ACT_TCP_CLOSE;
591 }
592 else {
593 struct action_kw *kw;
594 kw = tcp_res_cont_action(args[arg]);
595 if (kw) {
596 arg++;
597 rule->from = ACT_F_TCP_RES_CNT;
598 rule->kw = kw;
599 if (kw->parse((const char **)args, &arg, curpx, rule, err) == ACT_RET_PRS_ERR)
600 return -1;
601 } else {
602 action_build_list(&tcp_res_cont_keywords, &trash);
603 memprintf(err,
604 "'%s %s' expects 'accept', 'close', 'reject', %s in %s '%s' (got '%s')",
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200605 args[0], args[1], trash.area,
606 proxy_type_str(curpx), curpx->id, args[arg]);
Willy Tarreau39713102016-11-25 15:49:32 +0100607 return -1;
608 }
609 }
610
611 if (strcmp(args[arg], "if") == 0 || strcmp(args[arg], "unless") == 0) {
Christopher Faulet1b421ea2017-09-22 14:38:56 +0200612 if ((rule->cond = build_acl_cond(file, line, &curpx->acl, curpx, (const char **)args+arg, err)) == NULL) {
Willy Tarreau39713102016-11-25 15:49:32 +0100613 memprintf(err,
614 "'%s %s %s' : error detected in %s '%s' while parsing '%s' condition : %s",
615 args[0], args[1], args[2], proxy_type_str(curpx), curpx->id, args[arg], *err);
616 return -1;
617 }
618 }
619 else if (*args[arg]) {
620 memprintf(err,
621 "'%s %s %s' only accepts 'if' or 'unless', in %s '%s' (got '%s')",
622 args[0], args[1], args[2], proxy_type_str(curpx), curpx->id, args[arg]);
623 return -1;
624 }
625 return 0;
626}
627
628
629
630/* Parse a tcp-request rule. Return a negative value in case of failure */
631static int tcp_parse_request_rule(char **args, int arg, int section_type,
632 struct proxy *curpx, struct proxy *defpx,
633 struct act_rule *rule, char **err,
634 unsigned int where, const char *file, int line)
635{
636 if (curpx == defpx) {
637 memprintf(err, "%s %s is not allowed in 'defaults' sections",
638 args[0], args[1]);
639 return -1;
640 }
641
642 if (!strcmp(args[arg], "accept")) {
643 arg++;
644 rule->action = ACT_ACTION_ALLOW;
645 }
646 else if (!strcmp(args[arg], "reject")) {
647 arg++;
648 rule->action = ACT_ACTION_DENY;
649 }
650 else if (strcmp(args[arg], "capture") == 0) {
651 struct sample_expr *expr;
652 struct cap_hdr *hdr;
653 int kw = arg;
654 int len = 0;
655
656 if (!(curpx->cap & PR_CAP_FE)) {
657 memprintf(err,
658 "'%s %s %s' : proxy '%s' has no frontend capability",
659 args[0], args[1], args[kw], curpx->id);
660 return -1;
661 }
662
663 if (!(where & SMP_VAL_FE_REQ_CNT)) {
664 memprintf(err,
665 "'%s %s' is not allowed in '%s %s' rules in %s '%s'",
666 args[arg], args[arg+1], args[0], args[1], proxy_type_str(curpx), curpx->id);
667 return -1;
668 }
669
670 arg++;
671
672 curpx->conf.args.ctx = ARGC_CAP;
673 expr = sample_parse_expr(args, &arg, file, line, err, &curpx->conf.args);
674 if (!expr) {
675 memprintf(err,
676 "'%s %s %s' : %s",
677 args[0], args[1], args[kw], *err);
678 return -1;
679 }
680
681 if (!(expr->fetch->val & where)) {
682 memprintf(err,
683 "'%s %s %s' : fetch method '%s' extracts information from '%s', none of which is available here",
684 args[0], args[1], args[kw], args[arg-1], sample_src_names(expr->fetch->use));
685 free(expr);
686 return -1;
687 }
688
689 if (strcmp(args[arg], "len") == 0) {
690 arg++;
691 if (!args[arg]) {
692 memprintf(err,
693 "'%s %s %s' : missing length value",
694 args[0], args[1], args[kw]);
695 free(expr);
696 return -1;
697 }
698 /* we copy the table name for now, it will be resolved later */
699 len = atoi(args[arg]);
700 if (len <= 0) {
701 memprintf(err,
702 "'%s %s %s' : length must be > 0",
703 args[0], args[1], args[kw]);
704 free(expr);
705 return -1;
706 }
707 arg++;
708 }
709
710 if (!len) {
711 memprintf(err,
712 "'%s %s %s' : a positive 'len' argument is mandatory",
713 args[0], args[1], args[kw]);
714 free(expr);
715 return -1;
716 }
717
718 hdr = calloc(1, sizeof(*hdr));
719 hdr->next = curpx->req_cap;
720 hdr->name = NULL; /* not a header capture */
721 hdr->namelen = 0;
722 hdr->len = len;
723 hdr->pool = create_pool("caphdr", hdr->len + 1, MEM_F_SHARED);
724 hdr->index = curpx->nb_req_cap++;
725
726 curpx->req_cap = hdr;
727 curpx->to_log |= LW_REQHDR;
728
729 /* check if we need to allocate an hdr_idx struct for HTTP parsing */
730 curpx->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
731
732 rule->arg.cap.expr = expr;
733 rule->arg.cap.hdr = hdr;
734 rule->action = ACT_TCP_CAPTURE;
735 }
Frédéric Lécaillea41d5312018-01-29 12:05:07 +0100736 else if (strncmp(args[arg], "track-sc", 8) == 0) {
Willy Tarreau39713102016-11-25 15:49:32 +0100737 struct sample_expr *expr;
738 int kw = arg;
Frédéric Lécaillea41d5312018-01-29 12:05:07 +0100739 unsigned int tsc_num;
740 const char *tsc_num_str;
Willy Tarreau39713102016-11-25 15:49:32 +0100741
742 arg++;
743
Frédéric Lécaillea41d5312018-01-29 12:05:07 +0100744 tsc_num_str = &args[kw][8];
745 if (cfg_parse_track_sc_num(&tsc_num, tsc_num_str, tsc_num_str + strlen(tsc_num_str), err) == -1) {
746 memprintf(err, "'%s %s %s' : %s", args[0], args[1], args[kw], *err);
747 return -1;
748 }
749
Willy Tarreau39713102016-11-25 15:49:32 +0100750 curpx->conf.args.ctx = ARGC_TRK;
751 expr = sample_parse_expr(args, &arg, file, line, err, &curpx->conf.args);
752 if (!expr) {
753 memprintf(err,
754 "'%s %s %s' : %s",
755 args[0], args[1], args[kw], *err);
756 return -1;
757 }
758
759 if (!(expr->fetch->val & where)) {
760 memprintf(err,
761 "'%s %s %s' : fetch method '%s' extracts information from '%s', none of which is available here",
762 args[0], args[1], args[kw], args[arg-1], sample_src_names(expr->fetch->use));
763 free(expr);
764 return -1;
765 }
766
767 /* check if we need to allocate an hdr_idx struct for HTTP parsing */
768 curpx->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
769
770 if (strcmp(args[arg], "table") == 0) {
771 arg++;
772 if (!args[arg]) {
773 memprintf(err,
774 "'%s %s %s' : missing table name",
775 args[0], args[1], args[kw]);
776 free(expr);
777 return -1;
778 }
779 /* we copy the table name for now, it will be resolved later */
780 rule->arg.trk_ctr.table.n = strdup(args[arg]);
781 arg++;
782 }
783 rule->arg.trk_ctr.expr = expr;
Frédéric Lécaillea41d5312018-01-29 12:05:07 +0100784 rule->action = ACT_ACTION_TRK_SC0 + tsc_num;
Christopher Faulet78880fb2017-09-18 14:43:55 +0200785 rule->check_ptr = check_trk_action;
Willy Tarreau39713102016-11-25 15:49:32 +0100786 }
787 else if (strcmp(args[arg], "expect-proxy") == 0) {
788 if (strcmp(args[arg+1], "layer4") != 0) {
789 memprintf(err,
790 "'%s %s %s' only supports 'layer4' in %s '%s' (got '%s')",
791 args[0], args[1], args[arg], proxy_type_str(curpx), curpx->id, args[arg+1]);
792 return -1;
793 }
794
795 if (!(where & SMP_VAL_FE_CON_ACC)) {
796 memprintf(err,
797 "'%s %s' is not allowed in '%s %s' rules in %s '%s'",
798 args[arg], args[arg+1], args[0], args[1], proxy_type_str(curpx), curpx->id);
799 return -1;
800 }
801
802 arg += 2;
803 rule->action = ACT_TCP_EXPECT_PX;
804 }
805 else if (strcmp(args[arg], "expect-netscaler-cip") == 0) {
806 if (strcmp(args[arg+1], "layer4") != 0) {
807 memprintf(err,
808 "'%s %s %s' only supports 'layer4' in %s '%s' (got '%s')",
809 args[0], args[1], args[arg], proxy_type_str(curpx), curpx->id, args[arg+1]);
810 return -1;
811 }
812
813 if (!(where & SMP_VAL_FE_CON_ACC)) {
814 memprintf(err,
815 "'%s %s' is not allowed in '%s %s' rules in %s '%s'",
816 args[arg], args[arg+1], args[0], args[1], proxy_type_str(curpx), curpx->id);
817 return -1;
818 }
819
820 arg += 2;
821 rule->action = ACT_TCP_EXPECT_CIP;
822 }
823 else {
824 struct action_kw *kw;
825 if (where & SMP_VAL_FE_CON_ACC) {
826 /* L4 */
827 kw = tcp_req_conn_action(args[arg]);
828 rule->kw = kw;
829 rule->from = ACT_F_TCP_REQ_CON;
830 } else if (where & SMP_VAL_FE_SES_ACC) {
831 /* L5 */
832 kw = tcp_req_sess_action(args[arg]);
833 rule->kw = kw;
834 rule->from = ACT_F_TCP_REQ_SES;
835 } else {
836 /* L6 */
837 kw = tcp_req_cont_action(args[arg]);
838 rule->kw = kw;
839 rule->from = ACT_F_TCP_REQ_CNT;
840 }
841 if (kw) {
842 arg++;
843 if (kw->parse((const char **)args, &arg, curpx, rule, err) == ACT_RET_PRS_ERR)
844 return -1;
845 } else {
846 if (where & SMP_VAL_FE_CON_ACC)
847 action_build_list(&tcp_req_conn_keywords, &trash);
848 else if (where & SMP_VAL_FE_SES_ACC)
849 action_build_list(&tcp_req_sess_keywords, &trash);
850 else
851 action_build_list(&tcp_req_cont_keywords, &trash);
852 memprintf(err,
853 "'%s %s' expects 'accept', 'reject', 'track-sc0' ... 'track-sc%d', %s "
854 "in %s '%s' (got '%s').\n",
Willy Tarreau843b7cb2018-07-13 10:54:26 +0200855 args[0], args[1], MAX_SESS_STKCTR-1,
856 trash.area, proxy_type_str(curpx),
Willy Tarreau39713102016-11-25 15:49:32 +0100857 curpx->id, args[arg]);
858 return -1;
859 }
860 }
861
862 if (strcmp(args[arg], "if") == 0 || strcmp(args[arg], "unless") == 0) {
Christopher Faulet1b421ea2017-09-22 14:38:56 +0200863 if ((rule->cond = build_acl_cond(file, line, &curpx->acl, curpx, (const char **)args+arg, err)) == NULL) {
Willy Tarreau39713102016-11-25 15:49:32 +0100864 memprintf(err,
865 "'%s %s %s' : error detected in %s '%s' while parsing '%s' condition : %s",
866 args[0], args[1], args[2], proxy_type_str(curpx), curpx->id, args[arg], *err);
867 return -1;
868 }
869 }
870 else if (*args[arg]) {
871 memprintf(err,
872 "'%s %s %s' only accepts 'if' or 'unless', in %s '%s' (got '%s')",
873 args[0], args[1], args[2], proxy_type_str(curpx), curpx->id, args[arg]);
874 return -1;
875 }
876 return 0;
877}
878
879/* This function should be called to parse a line starting with the "tcp-response"
880 * keyword.
881 */
882static int tcp_parse_tcp_rep(char **args, int section_type, struct proxy *curpx,
883 struct proxy *defpx, const char *file, int line,
884 char **err)
885{
886 const char *ptr = NULL;
887 unsigned int val;
888 int warn = 0;
889 int arg;
890 struct act_rule *rule;
891 unsigned int where;
892 const struct acl *acl;
893 const char *kw;
894
895 if (!*args[1]) {
896 memprintf(err, "missing argument for '%s' in %s '%s'",
897 args[0], proxy_type_str(curpx), curpx->id);
898 return -1;
899 }
900
901 if (strcmp(args[1], "inspect-delay") == 0) {
902 if (curpx == defpx || !(curpx->cap & PR_CAP_BE)) {
903 memprintf(err, "%s %s is only allowed in 'backend' sections",
904 args[0], args[1]);
905 return -1;
906 }
907
908 if (!*args[2] || (ptr = parse_time_err(args[2], &val, TIME_UNIT_MS))) {
909 memprintf(err,
910 "'%s %s' expects a positive delay in milliseconds, in %s '%s'",
911 args[0], args[1], proxy_type_str(curpx), curpx->id);
912 if (ptr)
913 memprintf(err, "%s (unexpected character '%c')", *err, *ptr);
914 return -1;
915 }
916
917 if (curpx->tcp_rep.inspect_delay) {
918 memprintf(err, "ignoring %s %s (was already defined) in %s '%s'",
919 args[0], args[1], proxy_type_str(curpx), curpx->id);
920 return 1;
921 }
922 curpx->tcp_rep.inspect_delay = val;
923 return 0;
924 }
925
926 rule = calloc(1, sizeof(*rule));
927 LIST_INIT(&rule->list);
928 arg = 1;
929 where = 0;
930
931 if (strcmp(args[1], "content") == 0) {
932 arg++;
933
934 if (curpx->cap & PR_CAP_FE)
935 where |= SMP_VAL_FE_RES_CNT;
936 if (curpx->cap & PR_CAP_BE)
937 where |= SMP_VAL_BE_RES_CNT;
938
939 if (tcp_parse_response_rule(args, arg, section_type, curpx, defpx, rule, err, where, file, line) < 0)
940 goto error;
941
942 acl = rule->cond ? acl_cond_conflicts(rule->cond, where) : NULL;
943 if (acl) {
944 if (acl->name && *acl->name)
945 memprintf(err,
946 "acl '%s' will never match in '%s %s' because it only involves keywords that are incompatible with '%s'",
947 acl->name, args[0], args[1], sample_ckp_names(where));
948 else
949 memprintf(err,
950 "anonymous acl will never match in '%s %s' because it uses keyword '%s' which is incompatible with '%s'",
951 args[0], args[1],
952 LIST_ELEM(acl->expr.n, struct acl_expr *, list)->kw,
953 sample_ckp_names(where));
954
955 warn++;
956 }
957 else if (rule->cond && acl_cond_kw_conflicts(rule->cond, where, &acl, &kw)) {
958 if (acl->name && *acl->name)
959 memprintf(err,
960 "acl '%s' involves keyword '%s' which is incompatible with '%s'",
961 acl->name, kw, sample_ckp_names(where));
962 else
963 memprintf(err,
964 "anonymous acl involves keyword '%s' which is incompatible with '%s'",
965 kw, sample_ckp_names(where));
966 warn++;
967 }
968
969 LIST_ADDQ(&curpx->tcp_rep.inspect_rules, &rule->list);
970 }
971 else {
972 memprintf(err,
973 "'%s' expects 'inspect-delay' or 'content' in %s '%s' (got '%s')",
974 args[0], proxy_type_str(curpx), curpx->id, args[1]);
975 goto error;
976 }
977
978 return warn;
979 error:
980 free(rule);
981 return -1;
982}
983
984
985/* This function should be called to parse a line starting with the "tcp-request"
986 * keyword.
987 */
988static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx,
989 struct proxy *defpx, const char *file, int line,
990 char **err)
991{
992 const char *ptr = NULL;
993 unsigned int val;
994 int warn = 0;
995 int arg;
996 struct act_rule *rule;
997 unsigned int where;
998 const struct acl *acl;
999 const char *kw;
1000
1001 if (!*args[1]) {
1002 if (curpx == defpx)
1003 memprintf(err, "missing argument for '%s' in defaults section", args[0]);
1004 else
1005 memprintf(err, "missing argument for '%s' in %s '%s'",
1006 args[0], proxy_type_str(curpx), curpx->id);
1007 return -1;
1008 }
1009
1010 if (!strcmp(args[1], "inspect-delay")) {
1011 if (curpx == defpx) {
1012 memprintf(err, "%s %s is not allowed in 'defaults' sections",
1013 args[0], args[1]);
1014 return -1;
1015 }
1016
1017 if (!*args[2] || (ptr = parse_time_err(args[2], &val, TIME_UNIT_MS))) {
1018 memprintf(err,
1019 "'%s %s' expects a positive delay in milliseconds, in %s '%s'",
1020 args[0], args[1], proxy_type_str(curpx), curpx->id);
1021 if (ptr)
1022 memprintf(err, "%s (unexpected character '%c')", *err, *ptr);
1023 return -1;
1024 }
1025
1026 if (curpx->tcp_req.inspect_delay) {
1027 memprintf(err, "ignoring %s %s (was already defined) in %s '%s'",
1028 args[0], args[1], proxy_type_str(curpx), curpx->id);
1029 return 1;
1030 }
1031 curpx->tcp_req.inspect_delay = val;
1032 return 0;
1033 }
1034
1035 rule = calloc(1, sizeof(*rule));
1036 LIST_INIT(&rule->list);
1037 arg = 1;
1038 where = 0;
1039
1040 if (strcmp(args[1], "content") == 0) {
1041 arg++;
1042
1043 if (curpx->cap & PR_CAP_FE)
1044 where |= SMP_VAL_FE_REQ_CNT;
1045 if (curpx->cap & PR_CAP_BE)
1046 where |= SMP_VAL_BE_REQ_CNT;
1047
1048 if (tcp_parse_request_rule(args, arg, section_type, curpx, defpx, rule, err, where, file, line) < 0)
1049 goto error;
1050
1051 acl = rule->cond ? acl_cond_conflicts(rule->cond, where) : NULL;
1052 if (acl) {
1053 if (acl->name && *acl->name)
1054 memprintf(err,
1055 "acl '%s' will never match in '%s %s' because it only involves keywords that are incompatible with '%s'",
1056 acl->name, args[0], args[1], sample_ckp_names(where));
1057 else
1058 memprintf(err,
1059 "anonymous acl will never match in '%s %s' because it uses keyword '%s' which is incompatible with '%s'",
1060 args[0], args[1],
1061 LIST_ELEM(acl->expr.n, struct acl_expr *, list)->kw,
1062 sample_ckp_names(where));
1063
1064 warn++;
1065 }
1066 else if (rule->cond && acl_cond_kw_conflicts(rule->cond, where, &acl, &kw)) {
1067 if (acl->name && *acl->name)
1068 memprintf(err,
1069 "acl '%s' involves keyword '%s' which is incompatible with '%s'",
1070 acl->name, kw, sample_ckp_names(where));
1071 else
1072 memprintf(err,
1073 "anonymous acl involves keyword '%s' which is incompatible with '%s'",
1074 kw, sample_ckp_names(where));
1075 warn++;
1076 }
1077
1078 /* the following function directly emits the warning */
1079 warnif_misplaced_tcp_cont(curpx, file, line, args[0]);
1080 LIST_ADDQ(&curpx->tcp_req.inspect_rules, &rule->list);
1081 }
1082 else if (strcmp(args[1], "connection") == 0) {
1083 arg++;
1084
1085 if (!(curpx->cap & PR_CAP_FE)) {
1086 memprintf(err, "%s %s is not allowed because %s %s is not a frontend",
1087 args[0], args[1], proxy_type_str(curpx), curpx->id);
1088 goto error;
1089 }
1090
1091 where |= SMP_VAL_FE_CON_ACC;
1092
1093 if (tcp_parse_request_rule(args, arg, section_type, curpx, defpx, rule, err, where, file, line) < 0)
1094 goto error;
1095
1096 acl = rule->cond ? acl_cond_conflicts(rule->cond, where) : NULL;
1097 if (acl) {
1098 if (acl->name && *acl->name)
1099 memprintf(err,
1100 "acl '%s' will never match in '%s %s' because it only involves keywords that are incompatible with '%s'",
1101 acl->name, args[0], args[1], sample_ckp_names(where));
1102 else
1103 memprintf(err,
1104 "anonymous acl will never match in '%s %s' because it uses keyword '%s' which is incompatible with '%s'",
1105 args[0], args[1],
1106 LIST_ELEM(acl->expr.n, struct acl_expr *, list)->kw,
1107 sample_ckp_names(where));
1108
1109 warn++;
1110 }
1111 else if (rule->cond && acl_cond_kw_conflicts(rule->cond, where, &acl, &kw)) {
1112 if (acl->name && *acl->name)
1113 memprintf(err,
1114 "acl '%s' involves keyword '%s' which is incompatible with '%s'",
1115 acl->name, kw, sample_ckp_names(where));
1116 else
1117 memprintf(err,
1118 "anonymous acl involves keyword '%s' which is incompatible with '%s'",
1119 kw, sample_ckp_names(where));
1120 warn++;
1121 }
1122
1123 /* the following function directly emits the warning */
1124 warnif_misplaced_tcp_conn(curpx, file, line, args[0]);
1125 LIST_ADDQ(&curpx->tcp_req.l4_rules, &rule->list);
1126 }
1127 else if (strcmp(args[1], "session") == 0) {
1128 arg++;
1129
1130 if (!(curpx->cap & PR_CAP_FE)) {
1131 memprintf(err, "%s %s is not allowed because %s %s is not a frontend",
1132 args[0], args[1], proxy_type_str(curpx), curpx->id);
1133 goto error;
1134 }
1135
1136 where |= SMP_VAL_FE_SES_ACC;
1137
1138 if (tcp_parse_request_rule(args, arg, section_type, curpx, defpx, rule, err, where, file, line) < 0)
1139 goto error;
1140
1141 acl = rule->cond ? acl_cond_conflicts(rule->cond, where) : NULL;
1142 if (acl) {
1143 if (acl->name && *acl->name)
1144 memprintf(err,
1145 "acl '%s' will never match in '%s %s' because it only involves keywords that are incompatible with '%s'",
1146 acl->name, args[0], args[1], sample_ckp_names(where));
1147 else
1148 memprintf(err,
1149 "anonymous acl will never match in '%s %s' because it uses keyword '%s' which is incompatible with '%s'",
1150 args[0], args[1],
1151 LIST_ELEM(acl->expr.n, struct acl_expr *, list)->kw,
1152 sample_ckp_names(where));
1153 warn++;
1154 }
1155 else if (rule->cond && acl_cond_kw_conflicts(rule->cond, where, &acl, &kw)) {
1156 if (acl->name && *acl->name)
1157 memprintf(err,
1158 "acl '%s' involves keyword '%s' which is incompatible with '%s'",
1159 acl->name, kw, sample_ckp_names(where));
1160 else
1161 memprintf(err,
1162 "anonymous acl involves keyword '%s' which is incompatible with '%s'",
1163 kw, sample_ckp_names(where));
1164 warn++;
1165 }
1166
1167 /* the following function directly emits the warning */
1168 warnif_misplaced_tcp_sess(curpx, file, line, args[0]);
1169 LIST_ADDQ(&curpx->tcp_req.l5_rules, &rule->list);
1170 }
1171 else {
1172 if (curpx == defpx)
1173 memprintf(err,
1174 "'%s' expects 'inspect-delay', 'connection', or 'content' in defaults section (got '%s')",
1175 args[0], args[1]);
1176 else
1177 memprintf(err,
1178 "'%s' expects 'inspect-delay', 'connection', or 'content' in %s '%s' (got '%s')",
1179 args[0], proxy_type_str(curpx), curpx->id, args[1]);
1180 goto error;
1181 }
1182
1183 return warn;
1184 error:
1185 free(rule);
1186 return -1;
1187}
1188
1189static struct cfg_kw_list cfg_kws = {ILH, {
1190 { CFG_LISTEN, "tcp-request", tcp_parse_tcp_req },
1191 { CFG_LISTEN, "tcp-response", tcp_parse_tcp_rep },
1192 { 0, NULL, NULL },
1193}};
1194
Willy Tarreau0108d902018-11-25 19:14:37 +01001195INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
Willy Tarreau39713102016-11-25 15:49:32 +01001196
1197/*
1198 * Local variables:
1199 * c-indent-level: 8
1200 * c-basic-offset: 8
1201 * End:
1202 */