Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 1 | #include <haproxy/api.h> |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 2 | #include <haproxy/cfgparse.h> |
| 3 | #include <haproxy/global-t.h> |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 4 | #include <haproxy/listener.h> |
| 5 | #include <haproxy/proxy-t.h> |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 6 | #include <haproxy/tools.h> |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 7 | |
Amaury Denoyelle | b76ae69 | 2022-01-11 14:16:37 +0100 | [diff] [blame] | 8 | static int bind_parse_quic_force_retry(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
| 9 | { |
Willy Tarreau | 787e92a | 2022-05-20 16:06:01 +0200 | [diff] [blame] | 10 | conf->options |= BC_O_QUIC_FORCE_RETRY; |
Amaury Denoyelle | b76ae69 | 2022-01-11 14:16:37 +0100 | [diff] [blame] | 11 | return 0; |
| 12 | } |
| 13 | |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 14 | static struct bind_kw_list bind_kws = { "QUIC", { }, { |
Amaury Denoyelle | b76ae69 | 2022-01-11 14:16:37 +0100 | [diff] [blame] | 15 | { "quic-force-retry", bind_parse_quic_force_retry, 0 }, |
Amaury Denoyelle | c8b4ce4 | 2022-01-11 11:54:59 +0100 | [diff] [blame] | 16 | { NULL, NULL, 0 }, |
| 17 | }}; |
| 18 | |
| 19 | INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 20 | |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 21 | /* Parse any tune.quic.* setting with strictly positive integer values. |
| 22 | * Return -1 on alert, or 0 if succeeded. |
| 23 | */ |
| 24 | static int cfg_parse_quic_tune_setting(char **args, int section_type, |
| 25 | struct proxy *curpx, |
| 26 | const struct proxy *defpx, |
| 27 | const char *file, int line, char **err) |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 28 | { |
| 29 | unsigned int arg = 0; |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 30 | int prefix_len = strlen("tune.quic."); |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 31 | |
| 32 | if (too_many_args(1, args, err, NULL)) |
| 33 | return -1; |
| 34 | |
| 35 | if (*(args[1]) != 0) |
| 36 | arg = atoi(args[1]); |
| 37 | |
| 38 | if (arg < 1) { |
| 39 | memprintf(err, "'%s' expects a positive integer.", args[0]); |
| 40 | return -1; |
| 41 | } |
| 42 | |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 43 | if (strcmp(args[0] + prefix_len, "conn-buf-limit") == 0) |
| 44 | global.tune.quic_streams_buf = arg; |
| 45 | else if (strcmp(args[0] + prefix_len, "retry-threshold") == 0) |
| 46 | global.tune.quic_retry_threshold = arg; |
| 47 | else { |
| 48 | memprintf(err, "'%s' keyword not unhandled (please report this bug).", args[0]); |
| 49 | return -1; |
| 50 | } |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static struct cfg_kw_list cfg_kws = {ILH, { |
Frédéric Lécaille | 9286210 | 2022-05-20 16:29:10 +0200 | [diff] [blame] | 56 | { CFG_GLOBAL, "tune.quic.conn-buf-limit", cfg_parse_quic_tune_setting }, |
| 57 | { CFG_GLOBAL, "tune.quic.retry-threshold", cfg_parse_quic_tune_setting }, |
Amaury Denoyelle | 97e84c6 | 2022-04-19 18:26:55 +0200 | [diff] [blame] | 58 | { 0, NULL, NULL } |
| 59 | }}; |
| 60 | |
| 61 | INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); |