]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stktable: check if a type should be used as-is
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 26 Oct 2023 15:46:02 +0000 (17:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Nov 2023 16:30:30 +0000 (17:30 +0100)
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.

include/haproxy/stick_table-t.h
src/stick_table.c

index c89c3ec8e717caf9eb24205c455016b1f54ca597..79fee4897ea6b10509d5d04e11861bcb6b903d40 100644 (file)
@@ -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 */
index 91d697b9ef7a28abc292f8bb3ca686a9ef2bbae8..4bf46ef385fac1e9edd4f63b97c43afc8b7ee850 100644 (file)
@@ -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 },
 };