Frédéric Lécaille | 1d96d6e | 2022-05-23 16:38:14 +0200 | [diff] [blame] | 1 | #include <string.h> |
| 2 | |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 3 | #include <haproxy/api.h> |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 4 | #include <haproxy/cfgparse.h> |
| 5 | #include <haproxy/global-t.h> |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 6 | #include <haproxy/listener.h> |
| 7 | #include <haproxy/proxy-t.h> |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 8 | #include <haproxy/tools.h> |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 9 | |
Amaury Denoyelle | b76ae69 | 2022-01-11 14:16:37 +0100 | [diff] [blame] | 10 | static int bind_parse_quic_force_retry(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
| 11 | { |
Willy Tarreau | 787e92a | 2022-05-20 16:06:01 +0200 | [diff] [blame] | 12 | conf->options |= BC_O_QUIC_FORCE_RETRY; |
Amaury Denoyelle | b76ae69 | 2022-01-11 14:16:37 +0100 | [diff] [blame] | 13 | return 0; |
| 14 | } |
| 15 | |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 16 | static struct bind_kw_list bind_kws = { "QUIC", { }, { |
Amaury Denoyelle | b76ae69 | 2022-01-11 14:16:37 +0100 | [diff] [blame] | 17 | { "quic-force-retry", bind_parse_quic_force_retry, 0 }, |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 18 | { NULL, NULL, 0 }, |
| 19 | }}; |
| 20 | |
| 21 | INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 22 | |
Frédéric Lécaille | 1d96d6e | 2022-05-23 16:38:14 +0200 | [diff] [blame] | 23 | /* Must be used to parse tune.quic.* setting which requires a time |
| 24 | * as value. |
| 25 | * Return -1 on alert, or 0 if succeeded. |
| 26 | */ |
| 27 | static int cfg_parse_quic_time(char **args, int section_type, |
| 28 | struct proxy *curpx, |
| 29 | const struct proxy *defpx, |
| 30 | const char *file, int line, char **err) |
| 31 | { |
| 32 | unsigned int time; |
| 33 | const char *res, *name, *value; |
| 34 | int prefix_len = strlen("tune.quic."); |
| 35 | |
| 36 | if (too_many_args(1, args, err, NULL)) |
| 37 | return -1; |
| 38 | |
| 39 | name = args[0]; |
| 40 | value = args[1]; |
| 41 | res = parse_time_err(value, &time, TIME_UNIT_MS); |
| 42 | if (res == PARSE_TIME_OVER) { |
| 43 | memprintf(err, "timer overflow in argument '%s' to '%s' " |
| 44 | "(maximum value is 2147483647 ms or ~24.8 days)", value, name); |
| 45 | return -1; |
| 46 | } |
| 47 | else if (res == PARSE_TIME_UNDER) { |
| 48 | memprintf(err, "timer underflow in argument '%s' to '%s' " |
| 49 | "(minimum non-null value is 1 ms)", value, name); |
| 50 | return -1; |
| 51 | } |
| 52 | else if (res) { |
| 53 | memprintf(err, "unexpected character '%c' in '%s'", *res, name); |
| 54 | return -1; |
| 55 | } |
| 56 | |
| 57 | if (strcmp(name + prefix_len, "frontend.max-idle-timeout") == 0) |
| 58 | global.tune.quic_frontend_max_idle_timeout = time; |
| 59 | else if (strcmp(name + prefix_len, "backend.max-idle-timeout") == 0) |
| 60 | global.tune.quic_backend_max_idle_timeout = time; |
| 61 | else { |
| 62 | memprintf(err, "'%s' keyword not unhandled (please report this bug).", args[0]); |
| 63 | return -1; |
| 64 | } |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 69 | /* Parse any tune.quic.* setting with strictly positive integer values. |
| 70 | * Return -1 on alert, or 0 if succeeded. |
| 71 | */ |
| 72 | static int cfg_parse_quic_tune_setting(char **args, int section_type, |
| 73 | struct proxy *curpx, |
| 74 | const struct proxy *defpx, |
| 75 | const char *file, int line, char **err) |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 76 | { |
| 77 | unsigned int arg = 0; |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 78 | int prefix_len = strlen("tune.quic."); |
Frédéric Lécaille | 2674098 | 2022-05-23 17:28:01 +0200 | [diff] [blame] | 79 | const char *suffix; |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 80 | |
| 81 | if (too_many_args(1, args, err, NULL)) |
| 82 | return -1; |
| 83 | |
| 84 | if (*(args[1]) != 0) |
| 85 | arg = atoi(args[1]); |
| 86 | |
| 87 | if (arg < 1) { |
| 88 | memprintf(err, "'%s' expects a positive integer.", args[0]); |
| 89 | return -1; |
| 90 | } |
| 91 | |
Frédéric Lécaille | 2674098 | 2022-05-23 17:28:01 +0200 | [diff] [blame] | 92 | suffix = args[0] + prefix_len; |
Frédéric Lécaille | 38dea05 | 2022-05-25 17:14:28 +0200 | [diff] [blame] | 93 | if (strcmp(suffix, "frontend.conn-tx-buffers.limit") == 0) |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 94 | global.tune.quic_streams_buf = arg; |
Frédéric Lécaille | 2674098 | 2022-05-23 17:28:01 +0200 | [diff] [blame] | 95 | else if (strcmp(suffix, "frontend.max-streams-bidi") == 0) |
| 96 | global.tune.quic_frontend_max_streams_bidi = arg; |
| 97 | else if (strcmp(suffix, "retry-threshold") == 0) |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 98 | global.tune.quic_retry_threshold = arg; |
| 99 | else { |
| 100 | memprintf(err, "'%s' keyword not unhandled (please report this bug).", args[0]); |
| 101 | return -1; |
| 102 | } |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static struct cfg_kw_list cfg_kws = {ILH, { |
Frédéric Lécaille | 1d96d6e | 2022-05-23 16:38:14 +0200 | [diff] [blame] | 108 | { CFG_GLOBAL, "tune.quic.backend.max-idle-timeou", cfg_parse_quic_time }, |
Frédéric Lécaille | 38dea05 | 2022-05-25 17:14:28 +0200 | [diff] [blame] | 109 | { CFG_GLOBAL, "tune.quic.frontend.conn-tx-buffers.limit", cfg_parse_quic_tune_setting }, |
Frédéric Lécaille | 2674098 | 2022-05-23 17:28:01 +0200 | [diff] [blame] | 110 | { CFG_GLOBAL, "tune.quic.frontend.max-streams-bidi", cfg_parse_quic_tune_setting }, |
Frédéric Lécaille | 1d96d6e | 2022-05-23 16:38:14 +0200 | [diff] [blame] | 111 | { CFG_GLOBAL, "tune.quic.frontend.max-idle-timeout", cfg_parse_quic_time }, |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 112 | { CFG_GLOBAL, "tune.quic.retry-threshold", cfg_parse_quic_tune_setting }, |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 113 | { 0, NULL, NULL } |
| 114 | }}; |
| 115 | |
| 116 | INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); |