mirror of
https://github.com/haproxy/haproxy.git
synced 2026-02-03 20:39:41 -05:00
MINOR: ha-inject: Move some mux h2 parsing functions to cfgparse-mux_h2.c
Add cfgparse-mux_h2.c new C file to avoid compiling such code for ha-inject. Move mux_h2.c parsing functions to this new file.
This commit is contained in:
parent
2b7e9ffa34
commit
7b801abb65
4 changed files with 220 additions and 201 deletions
4
Makefile
4
Makefile
|
|
@ -1005,8 +1005,8 @@ OBJS_COMMON += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o \
|
|||
src/version.o src/ncbmbuf.o src/ech.o \
|
||||
|
||||
OBJS += $(OBJS_COMMON) src/acl.o src/cfgdiag.o src/cfgparse.o \
|
||||
src/cfgparse-global.o src/cfgparse-listen.o src/cfgparse-tcp.o \
|
||||
src/cfgparse-thread.o \
|
||||
src/cfgparse-global.o src/cfgparse-listen.o src/cfgparse-mux_h2.o \
|
||||
src/cfgparse-tcp.o src/cfgparse-thread.o \
|
||||
src/cfgparse-unix.o src/check.o src/dns.o src/dns_ring.o src/event_hdl.o \
|
||||
src/extcheck.o src/filters.o src/flt_bwlim.o src/flt_http_comp.o \
|
||||
src/flt_spoe.o src/flt_trace.o src/haproxy.o src/http_acl.o \
|
||||
|
|
|
|||
|
|
@ -225,4 +225,18 @@ static inline const char *h2s_st_to_str(enum h2_ss st)
|
|||
}
|
||||
}
|
||||
|
||||
extern int h2_settings_header_table_size;
|
||||
extern int h2_settings_initial_window_size;
|
||||
extern int h2_be_settings_initial_window_size;
|
||||
extern int h2_fe_settings_initial_window_size;
|
||||
extern int h2_be_glitches_threshold;
|
||||
extern int h2_fe_glitches_threshold;
|
||||
extern uint h2_be_rxbuf;
|
||||
extern uint h2_fe_rxbuf;
|
||||
extern unsigned int h2_settings_max_concurrent_streams;
|
||||
extern unsigned int h2_be_settings_max_concurrent_streams;
|
||||
extern unsigned int h2_fe_settings_max_concurrent_streams;
|
||||
extern int h2_settings_max_frame_size;
|
||||
extern unsigned int h2_fe_max_total_streams;
|
||||
|
||||
#endif /* _HAPROXY_MUX_H2_T_H */
|
||||
|
|
|
|||
191
src/cfgparse-mux_h2.c
Normal file
191
src/cfgparse-mux_h2.c
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
#include <haproxy/api.h>
|
||||
#include <haproxy/cfgparse.h>
|
||||
#include <haproxy/mux_h2-t.h>
|
||||
#include <haproxy/proxy-t.h>
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
/*******************************************************/
|
||||
/* functions below are dedicated to the config parsers */
|
||||
/*******************************************************/
|
||||
|
||||
/* config parser for global "tune.h2.{fe,be}.glitches-threshold" */
|
||||
static int h2_parse_glitches_threshold(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
int *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_glitches_threshold : &h2_fe_glitches_threshold;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if (*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.header-table-size" */
|
||||
static int h2_parse_header_table_size(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
h2_settings_header_table_size = atoi(args[1]);
|
||||
if (h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) {
|
||||
memprintf(err, "'%s' expects a numeric value between 4096 and 65536.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.{be.,fe.,}initial-window-size" */
|
||||
static int h2_parse_initial_window_size(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
int *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend/default */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_settings_initial_window_size :
|
||||
(args[0][8] == 'f') ? &h2_fe_settings_initial_window_size :
|
||||
&h2_settings_initial_window_size;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if (*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.{be.,fe.,}max-concurrent-streams" */
|
||||
static int h2_parse_max_concurrent_streams(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
uint *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend/default */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_settings_max_concurrent_streams :
|
||||
(args[0][8] == 'f') ? &h2_fe_settings_max_concurrent_streams :
|
||||
&h2_settings_max_concurrent_streams;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if ((int)*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.fe.max-total-streams" */
|
||||
static int h2_parse_max_total_streams(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
uint *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* frontend only for now */
|
||||
vptr = &h2_fe_max_total_streams;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if ((int)*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.max-frame-size" */
|
||||
static int h2_parse_max_frame_size(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
h2_settings_max_frame_size = atoi(args[1]);
|
||||
if (h2_settings_max_frame_size < 16384 || h2_settings_max_frame_size > 16777215) {
|
||||
memprintf(err, "'%s' expects a numeric value between 16384 and 16777215.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.{be.,fe.}rxbuf" */
|
||||
static int h2_parse_rxbuf(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
const char *errptr;
|
||||
uint *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_rxbuf : &h2_fe_rxbuf;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if ((errptr = parse_size_err(args[1], vptr)) != NULL) {
|
||||
memprintf(err, "'%s': unexpected character '%c' in size argument '%s'.", args[0], *errptr, args[1]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.zero-copy-fwd-send" */
|
||||
static int h2_parse_zero_copy_fwd_snd(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
if (strcmp(args[1], "on") == 0)
|
||||
global.tune.no_zero_copy_fwd &= ~NO_ZERO_COPY_FWD_H2_SND;
|
||||
else if (strcmp(args[1], "off") == 0)
|
||||
global.tune.no_zero_copy_fwd |= NO_ZERO_COPY_FWD_H2_SND;
|
||||
else {
|
||||
memprintf(err, "'%s' expects 'on' or 'off'.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config keyword parsers */
|
||||
static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_GLOBAL, "tune.h2.be.glitches-threshold", h2_parse_glitches_threshold },
|
||||
{ CFG_GLOBAL, "tune.h2.be.initial-window-size", h2_parse_initial_window_size },
|
||||
{ CFG_GLOBAL, "tune.h2.be.max-concurrent-streams", h2_parse_max_concurrent_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.be.rxbuf", h2_parse_rxbuf },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.glitches-threshold", h2_parse_glitches_threshold },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.initial-window-size", h2_parse_initial_window_size },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.max-concurrent-streams", h2_parse_max_concurrent_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.max-total-streams", h2_parse_max_total_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.rxbuf", h2_parse_rxbuf },
|
||||
{ CFG_GLOBAL, "tune.h2.header-table-size", h2_parse_header_table_size },
|
||||
{ CFG_GLOBAL, "tune.h2.initial-window-size", h2_parse_initial_window_size },
|
||||
{ CFG_GLOBAL, "tune.h2.max-concurrent-streams", h2_parse_max_concurrent_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.max-frame-size", h2_parse_max_frame_size },
|
||||
{ CFG_GLOBAL, "tune.h2.zero-copy-fwd-send", h2_parse_zero_copy_fwd_snd },
|
||||
{ 0, NULL, NULL }
|
||||
}};
|
||||
|
||||
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
|
||||
212
src/mux_h2.c
212
src/mux_h2.c
|
|
@ -467,21 +467,21 @@ struct pool_head *pool_head_h2_rx_bufs __read_mostly = NULL;
|
|||
#define MAX_DATA_REALIGN 1024
|
||||
|
||||
/* a few settings from the global section */
|
||||
static int h2_settings_header_table_size = 4096; /* initial value */
|
||||
static int h2_settings_initial_window_size = 0; /* default initial value: bufsize */
|
||||
static int h2_be_settings_initial_window_size = 0; /* backend's default initial value */
|
||||
static int h2_fe_settings_initial_window_size = 0; /* frontend's default initial value */
|
||||
static int h2_be_glitches_threshold = 0; /* backend's max glitches: unlimited */
|
||||
static int h2_fe_glitches_threshold = 0; /* frontend's max glitches: unlimited */
|
||||
static uint h2_be_rxbuf = 0; /* backend's default total rxbuf (bytes) */
|
||||
static uint h2_fe_rxbuf = 0; /* frontend's default total rxbuf (bytes) */
|
||||
static unsigned int h2_settings_max_concurrent_streams = 100; /* default value */
|
||||
static unsigned int h2_be_settings_max_concurrent_streams = 0; /* backend value */
|
||||
static unsigned int h2_fe_settings_max_concurrent_streams = 0; /* frontend value */
|
||||
static int h2_settings_max_frame_size = 0; /* unset */
|
||||
int h2_settings_header_table_size = 4096; /* initial value */
|
||||
int h2_settings_initial_window_size = 0; /* default initial value: bufsize */
|
||||
int h2_be_settings_initial_window_size = 0; /* backend's default initial value */
|
||||
int h2_fe_settings_initial_window_size = 0; /* frontend's default initial value */
|
||||
int h2_be_glitches_threshold = 0; /* backend's max glitches: unlimited */
|
||||
int h2_fe_glitches_threshold = 0; /* frontend's max glitches: unlimited */
|
||||
uint h2_be_rxbuf = 0; /* backend's default total rxbuf (bytes) */
|
||||
uint h2_fe_rxbuf = 0; /* frontend's default total rxbuf (bytes) */
|
||||
unsigned int h2_settings_max_concurrent_streams = 100; /* default value */
|
||||
unsigned int h2_be_settings_max_concurrent_streams = 0; /* backend value */
|
||||
unsigned int h2_fe_settings_max_concurrent_streams = 0; /* frontend value */
|
||||
int h2_settings_max_frame_size = 0; /* unset */
|
||||
|
||||
/* other non-protocol settings */
|
||||
static unsigned int h2_fe_max_total_streams = 0; /* frontend value */
|
||||
unsigned int h2_fe_max_total_streams = 0; /* frontend value */
|
||||
|
||||
/* a dummy closed endpoint */
|
||||
static const struct sedesc closed_ep = {
|
||||
|
|
@ -8529,171 +8529,6 @@ static int h2_takeover(struct connection *conn, int orig_tid, int release)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
/* functions below are dedicated to the config parsers */
|
||||
/*******************************************************/
|
||||
|
||||
/* config parser for global "tune.h2.{fe,be}.glitches-threshold" */
|
||||
static int h2_parse_glitches_threshold(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
int *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_glitches_threshold : &h2_fe_glitches_threshold;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if (*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.header-table-size" */
|
||||
static int h2_parse_header_table_size(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
h2_settings_header_table_size = atoi(args[1]);
|
||||
if (h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) {
|
||||
memprintf(err, "'%s' expects a numeric value between 4096 and 65536.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.{be.,fe.,}initial-window-size" */
|
||||
static int h2_parse_initial_window_size(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
int *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend/default */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_settings_initial_window_size :
|
||||
(args[0][8] == 'f') ? &h2_fe_settings_initial_window_size :
|
||||
&h2_settings_initial_window_size;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if (*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.{be.,fe.,}max-concurrent-streams" */
|
||||
static int h2_parse_max_concurrent_streams(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
uint *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend/default */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_settings_max_concurrent_streams :
|
||||
(args[0][8] == 'f') ? &h2_fe_settings_max_concurrent_streams :
|
||||
&h2_settings_max_concurrent_streams;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if ((int)*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.fe.max-total-streams" */
|
||||
static int h2_parse_max_total_streams(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
uint *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* frontend only for now */
|
||||
vptr = &h2_fe_max_total_streams;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if ((int)*vptr < 0) {
|
||||
memprintf(err, "'%s' expects a positive numeric value.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.max-frame-size" */
|
||||
static int h2_parse_max_frame_size(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
h2_settings_max_frame_size = atoi(args[1]);
|
||||
if (h2_settings_max_frame_size < 16384 || h2_settings_max_frame_size > 16777215) {
|
||||
memprintf(err, "'%s' expects a numeric value between 16384 and 16777215.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.{be.,fe.}rxbuf" */
|
||||
static int h2_parse_rxbuf(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
const char *errptr;
|
||||
uint *vptr;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
/* backend/frontend */
|
||||
vptr = (args[0][8] == 'b') ? &h2_be_rxbuf : &h2_fe_rxbuf;
|
||||
|
||||
*vptr = atoi(args[1]);
|
||||
if ((errptr = parse_size_err(args[1], vptr)) != NULL) {
|
||||
memprintf(err, "'%s': unexpected character '%c' in size argument '%s'.", args[0], *errptr, args[1]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.h2.zero-copy-fwd-send" */
|
||||
static int h2_parse_zero_copy_fwd_snd(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
if (strcmp(args[1], "on") == 0)
|
||||
global.tune.no_zero_copy_fwd &= ~NO_ZERO_COPY_FWD_H2_SND;
|
||||
else if (strcmp(args[1], "off") == 0)
|
||||
global.tune.no_zero_copy_fwd |= NO_ZERO_COPY_FWD_H2_SND;
|
||||
else {
|
||||
memprintf(err, "'%s' expects 'on' or 'off'.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/* MUX initialization and instantiation */
|
||||
/***************************************/
|
||||
|
|
@ -8730,27 +8565,6 @@ static struct mux_proto_list mux_proto_h2 =
|
|||
|
||||
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_h2);
|
||||
|
||||
/* config keyword parsers */
|
||||
static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_GLOBAL, "tune.h2.be.glitches-threshold", h2_parse_glitches_threshold },
|
||||
{ CFG_GLOBAL, "tune.h2.be.initial-window-size", h2_parse_initial_window_size },
|
||||
{ CFG_GLOBAL, "tune.h2.be.max-concurrent-streams", h2_parse_max_concurrent_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.be.rxbuf", h2_parse_rxbuf },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.glitches-threshold", h2_parse_glitches_threshold },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.initial-window-size", h2_parse_initial_window_size },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.max-concurrent-streams", h2_parse_max_concurrent_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.max-total-streams", h2_parse_max_total_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.fe.rxbuf", h2_parse_rxbuf },
|
||||
{ CFG_GLOBAL, "tune.h2.header-table-size", h2_parse_header_table_size },
|
||||
{ CFG_GLOBAL, "tune.h2.initial-window-size", h2_parse_initial_window_size },
|
||||
{ CFG_GLOBAL, "tune.h2.max-concurrent-streams", h2_parse_max_concurrent_streams },
|
||||
{ CFG_GLOBAL, "tune.h2.max-frame-size", h2_parse_max_frame_size },
|
||||
{ CFG_GLOBAL, "tune.h2.zero-copy-fwd-send", h2_parse_zero_copy_fwd_snd },
|
||||
{ 0, NULL, NULL }
|
||||
}};
|
||||
|
||||
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
|
||||
|
||||
/* initialize internal structs after the config is parsed.
|
||||
* Returns zero on success, non-zero on error.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue