From: Aurelien DARRAGON Date: Wed, 8 Nov 2023 10:35:05 +0000 (+0100) Subject: MINOR: stktable/cli: support v6tov4 and v4tov6 conversions X-Git-Tag: v2.9-dev10~139 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8dae361f356890ac3e0e51df909d902c1f065d25;p=thirdparty%2Fhaproxy.git MINOR: stktable/cli: support v6tov4 and v4tov6 conversions Add a special treatment for the IPV4 and IPV6 cases in table_process_entry_per_key() function so that input string is parsed in best effort (STR to pseudo type ADDR): input format is first considered over table type and then let smp_to_stkey() do the type conversion for us when needed. This patch heavily depends on: - "MEDIUM: stktable/cli: simplify entry key handling" And optionally depends on: - 72514a44 ("MEDIUM: tools/ip: v4tov6() and v6tov4() rework") --- diff --git a/src/stick_table.c b/src/stick_table.c index 825c22cee3..b97114c304 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -4908,6 +4908,13 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args) switch (t->type) { case SMP_T_IPV4: case SMP_T_IPV6: + /* prefer input format over table type when parsing ip addresses, + * then let smp_to_stkey() do the conversion for us when needed + */ + BUG_ON(!sample_casts[key.data.type][SMP_T_ADDR]); + if (!sample_casts[key.data.type][SMP_T_ADDR](&key)) + return cli_err(appctx, "Invalid key\n"); + break; case SMP_T_SINT: case SMP_T_STR: break;