From: Aurelien DARRAGON Date: Thu, 26 Oct 2023 15:46:02 +0000 (+0200) Subject: MINOR: stktable: check if a type should be used as-is X-Git-Tag: v2.9-dev9~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db0cb54f8129ae6977e3947b211796f6d7a35f8c;p=thirdparty%2Fhaproxy.git MINOR: stktable: check if a type should be used as-is stick table types now have an extra bit named 'as_is' that allows us to check if such type should be used as-is or if it may be involved in arithmetic operations such as counters. This can be useful since those types are not common and may require specific handling. e.g.: stktable_data_types[data_type].as_is will be set to 1 if the type cannot be used in arithmetic operations. --- diff --git a/include/haproxy/stick_table-t.h b/include/haproxy/stick_table-t.h index c89c3ec8e7..79fee4897e 100644 --- a/include/haproxy/stick_table-t.h +++ b/include/haproxy/stick_table-t.h @@ -127,6 +127,7 @@ struct stktable_data_type { int arg_type; /* type of optional argument, ARG_T_* */ uint is_array:1; /* this is an array of gpc/gpt */ uint is_local:1; /* this is local only and never learned */ + uint as_is:1; /* cannot be processed / used with arithmetic operations */ }; /* stick table keyword type */ diff --git a/src/stick_table.c b/src/stick_table.c index 91d697b9ef..4bf46ef385 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -1316,8 +1316,8 @@ int stktable_compatible_sample(struct sample_expr *expr, unsigned long table_typ * at run time. */ struct stktable_data_type stktable_data_types[STKTABLE_DATA_TYPES] = { - [STKTABLE_DT_SERVER_ID] = { .name = "server_id", .std_type = STD_T_SINT }, - [STKTABLE_DT_GPT0] = { .name = "gpt0", .std_type = STD_T_UINT }, + [STKTABLE_DT_SERVER_ID] = { .name = "server_id", .std_type = STD_T_SINT, .as_is = 1 }, + [STKTABLE_DT_GPT0] = { .name = "gpt0", .std_type = STD_T_UINT, .as_is = 1 }, [STKTABLE_DT_GPC0] = { .name = "gpc0", .std_type = STD_T_UINT }, [STKTABLE_DT_GPC0_RATE] = { .name = "gpc0_rate", .std_type = STD_T_FRQP, .arg_type = ARG_T_DELAY }, [STKTABLE_DT_CONN_CNT] = { .name = "conn_cnt", .std_type = STD_T_UINT }, @@ -1335,10 +1335,10 @@ struct stktable_data_type stktable_data_types[STKTABLE_DATA_TYPES] = { [STKTABLE_DT_BYTES_OUT_RATE]= { .name = "bytes_out_rate", .std_type = STD_T_FRQP, .arg_type = ARG_T_DELAY }, [STKTABLE_DT_GPC1] = { .name = "gpc1", .std_type = STD_T_UINT }, [STKTABLE_DT_GPC1_RATE] = { .name = "gpc1_rate", .std_type = STD_T_FRQP, .arg_type = ARG_T_DELAY }, - [STKTABLE_DT_SERVER_KEY] = { .name = "server_key", .std_type = STD_T_DICT }, + [STKTABLE_DT_SERVER_KEY] = { .name = "server_key", .std_type = STD_T_DICT, .as_is = 1 }, [STKTABLE_DT_HTTP_FAIL_CNT] = { .name = "http_fail_cnt", .std_type = STD_T_UINT }, [STKTABLE_DT_HTTP_FAIL_RATE]= { .name = "http_fail_rate", .std_type = STD_T_FRQP, .arg_type = ARG_T_DELAY }, - [STKTABLE_DT_GPT] = { .name = "gpt", .std_type = STD_T_UINT, .is_array = 1 }, + [STKTABLE_DT_GPT] = { .name = "gpt", .std_type = STD_T_UINT, .is_array = 1, .as_is = 1 }, [STKTABLE_DT_GPC] = { .name = "gpc", .std_type = STD_T_UINT, .is_array = 1 }, [STKTABLE_DT_GPC_RATE] = { .name = "gpc_rate", .std_type = STD_T_FRQP, .is_array = 1, .arg_type = ARG_T_DELAY }, };