From db5e0dbea968a970de4cfd1acb98613ee31cf175 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 26 Mar 2021 15:29:35 +0100 Subject: [PATCH] MINOR: sample: add a new CLI_PARSER context for samples In order to prepare for supporting calling sample expressions from the CLI, let's create a new CLI_PARSER parsing context. This one supports constants and internal samples only. --- include/haproxy/sample-t.h | 2 ++ src/sample.c | 69 +++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/include/haproxy/sample-t.h b/include/haproxy/sample-t.h index 656e78ab50..7fb9f5e9b2 100644 --- a/include/haproxy/sample-t.h +++ b/include/haproxy/sample-t.h @@ -96,6 +96,7 @@ enum { SMP_CKP_FE_LOG_END, /* FE log at the end of the txn/stream */ SMP_CKP_BE_CHK_RUL, /* BE tcp-check rules */ SMP_CKP_CFG_PARSER, /* config parser (i.e. before boot) */ + SMP_CKP_CLI_PARSER, /* command line parser */ SMP_CKP_ENTRIES /* nothing after this */ }; @@ -164,6 +165,7 @@ enum { SMP_VAL_FE_LOG_END = 1 << SMP_CKP_FE_LOG_END, /* FE log at the end of the txn/stream */ SMP_VAL_BE_CHK_RUL = 1 << SMP_CKP_BE_CHK_RUL, /* BE tcp-check rule */ SMP_VAL_CFG_PARSER = 1 << SMP_CKP_CFG_PARSER, /* within config parser */ + SMP_VAL_CLI_PARSER = 1 << SMP_CKP_CLI_PARSER, /* within command line parser */ /* a few combinations to decide what direction to try to fetch (useful for logs) */ SMP_VAL_REQUEST = SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT | diff --git a/src/sample.c b/src/sample.c index 5b78125fc0..e7655a575f 100644 --- a/src/sample.c +++ b/src/sample.c @@ -76,7 +76,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL_CFG_PARSER), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL_CFG_PARSER | + SMP_VAL_CLI_PARSER ), [SMP_SRC_INTRN] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -84,7 +85,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL_CLI_PARSER ), [SMP_SRC_LISTN] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -92,7 +94,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_FTEND] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -100,7 +103,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_L4CLI] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -108,7 +112,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_L5CLI] = (SMP_VAL___________ | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -116,7 +121,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_TRACK] = (SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -124,7 +130,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_L6REQ] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -132,7 +139,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | - SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_HRQHV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -140,7 +148,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | - SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_HRQHP] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_FE_REQ_CNT | SMP_VAL_FE_HRQ_HDR | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -148,7 +157,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_HRQBO] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_FE_HRQ_BDY | SMP_VAL_FE_SET_BCK | @@ -156,7 +166,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | - SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_BKEND] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -164,7 +175,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL_BE_SET_SRV | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_SERVR] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -172,7 +184,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL_BE_SRV_CON | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_L4SRV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -180,7 +193,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_L5SRV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -188,7 +202,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_L6RES] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -196,7 +211,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL___________ | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL___________ | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_HRSHV] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -204,7 +220,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL___________ | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL___________ | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_HRSHP] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -212,7 +229,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_RES_CNT | SMP_VAL_BE_HRS_HDR | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_HRSBO] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -220,7 +238,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL_BE_HRS_BDY | SMP_VAL_BE_STO_RUL | SMP_VAL_FE_RES_CNT | SMP_VAL_FE_HRS_HDR | SMP_VAL_FE_HRS_BDY | - SMP_VAL___________ | SMP_VAL_BE_CHK_RUL | SMP_VAL___________), + SMP_VAL___________ | SMP_VAL_BE_CHK_RUL | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_RQFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -228,7 +247,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_RSFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -236,7 +256,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_TXFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -244,7 +265,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), [SMP_SRC_SSFIN] = (SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | @@ -252,7 +274,8 @@ const unsigned int fetch_cap[SMP_SRC_ENTRIES] = { SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | SMP_VAL___________ | - SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________), + SMP_VAL_FE_LOG_END | SMP_VAL___________ | SMP_VAL___________ | + SMP_VAL___________ ), }; static const char *fetch_src_names[SMP_SRC_ENTRIES] = { -- 2.39.5