mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-25 04:17:42 +00:00
MINOR: config: Enable tracking of up to MAX_SESS_STKCTR stick counters.
This patch really adds support for up to MAX_SESS_STKCTR stick counters.
This commit is contained in:
parent
1478aa795e
commit
a41d531e4e
@ -66,6 +66,8 @@ extern char *cfg_scope;
|
|||||||
|
|
||||||
int cfg_parse_global(const char *file, int linenum, char **args, int inv);
|
int cfg_parse_global(const char *file, int linenum, char **args, int inv);
|
||||||
int cfg_parse_listen(const char *file, int linenum, char **args, int inv);
|
int cfg_parse_listen(const char *file, int linenum, char **args, int inv);
|
||||||
|
int cfg_parse_track_sc_num(unsigned int *track_sc_num,
|
||||||
|
const char *arg, const char *end, char **err);
|
||||||
int readcfgfile(const char *file);
|
int readcfgfile(const char *file);
|
||||||
void cfg_register_keywords(struct cfg_kw_list *kwl);
|
void cfg_register_keywords(struct cfg_kw_list *kwl);
|
||||||
void cfg_unregister_keywords(struct cfg_kw_list *kwl);
|
void cfg_unregister_keywords(struct cfg_kw_list *kwl);
|
||||||
|
@ -7120,6 +7120,31 @@ cfg_parse_scope(const char *file, int linenum, char *line)
|
|||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cfg_parse_track_sc_num(unsigned int *track_sc_num,
|
||||||
|
const char *arg, const char *end, char **errmsg)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
unsigned int num;
|
||||||
|
|
||||||
|
p = arg;
|
||||||
|
num = read_uint64(&arg, end);
|
||||||
|
|
||||||
|
if (arg != end) {
|
||||||
|
memprintf(errmsg, "Wrong track-sc number '%s'", p);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num >= MAX_SESS_STKCTR) {
|
||||||
|
memprintf(errmsg, "%u track-sc number exceeding "
|
||||||
|
"%d (MAX_SESS_STKCTR-1) value", num, MAX_SESS_STKCTR - 1);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*track_sc_num = num;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function reads and parses the configuration file given in the argument.
|
* This function reads and parses the configuration file given in the argument.
|
||||||
* Returns the error code, 0 if OK, or any combination of :
|
* Returns the error code, 0 if OK, or any combination of :
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
#include <common/base64.h>
|
#include <common/base64.h>
|
||||||
|
#include <common/cfgparse.h>
|
||||||
#include <common/chunk.h>
|
#include <common/chunk.h>
|
||||||
#include <common/compat.h>
|
#include <common/compat.h>
|
||||||
#include <common/config.h>
|
#include <common/config.h>
|
||||||
@ -8543,16 +8544,24 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li
|
|||||||
proxy->conf.lfs_file = strdup(proxy->conf.args.file);
|
proxy->conf.lfs_file = strdup(proxy->conf.args.file);
|
||||||
proxy->conf.lfs_line = proxy->conf.args.line;
|
proxy->conf.lfs_line = proxy->conf.args.line;
|
||||||
cur_arg += 1;
|
cur_arg += 1;
|
||||||
} else if (strncmp(args[0], "track-sc", 8) == 0 &&
|
} else if (strncmp(args[0], "track-sc", 8) == 0) {
|
||||||
args[0][9] == '\0' && args[0][8] >= '0' &&
|
|
||||||
args[0][8] < '0' + MAX_SESS_STKCTR) { /* track-sc 0..9 */
|
|
||||||
struct sample_expr *expr;
|
struct sample_expr *expr;
|
||||||
unsigned int where;
|
unsigned int where;
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
|
unsigned int tsc_num;
|
||||||
|
const char *tsc_num_str;
|
||||||
|
|
||||||
cur_arg = 1;
|
cur_arg = 1;
|
||||||
proxy->conf.args.ctx = ARGC_TRK;
|
proxy->conf.args.ctx = ARGC_TRK;
|
||||||
|
|
||||||
|
tsc_num_str = &args[0][8];
|
||||||
|
if (cfg_parse_track_sc_num(&tsc_num, tsc_num_str, tsc_num_str + strlen(tsc_num_str), &err) == -1) {
|
||||||
|
ha_alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-request %s' rule : %s.\n",
|
||||||
|
file, linenum, proxy_type_str(proxy), proxy->id, args[0], err);
|
||||||
|
free(err);
|
||||||
|
goto out_err;
|
||||||
|
}
|
||||||
|
|
||||||
expr = sample_parse_expr((char **)args, &cur_arg, file, linenum, &err, &proxy->conf.args);
|
expr = sample_parse_expr((char **)args, &cur_arg, file, linenum, &err, &proxy->conf.args);
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
ha_alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-request %s' rule : %s.\n",
|
ha_alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-request %s' rule : %s.\n",
|
||||||
@ -8589,7 +8598,7 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li
|
|||||||
cur_arg++;
|
cur_arg++;
|
||||||
}
|
}
|
||||||
rule->arg.trk_ctr.expr = expr;
|
rule->arg.trk_ctr.expr = expr;
|
||||||
rule->action = ACT_ACTION_TRK_SC0 + args[0][8] - '0';
|
rule->action = ACT_ACTION_TRK_SC0 + tsc_num;
|
||||||
rule->check_ptr = check_trk_action;
|
rule->check_ptr = check_trk_action;
|
||||||
} else if (strcmp(args[0], "redirect") == 0) {
|
} else if (strcmp(args[0], "redirect") == 0) {
|
||||||
struct redirect_rule *redir;
|
struct redirect_rule *redir;
|
||||||
@ -9148,16 +9157,24 @@ struct act_rule *parse_http_res_cond(const char **args, const char *file, int li
|
|||||||
redir->cond = NULL;
|
redir->cond = NULL;
|
||||||
cur_arg = 2;
|
cur_arg = 2;
|
||||||
return rule;
|
return rule;
|
||||||
} else if (strncmp(args[0], "track-sc", 8) == 0 &&
|
} else if (strncmp(args[0], "track-sc", 8) == 0) {
|
||||||
args[0][9] == '\0' && args[0][8] >= '0' &&
|
|
||||||
args[0][8] < '0' + MAX_SESS_STKCTR) { /* track-sc 0..9 */
|
|
||||||
struct sample_expr *expr;
|
struct sample_expr *expr;
|
||||||
unsigned int where;
|
unsigned int where;
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
|
unsigned int tsc_num;
|
||||||
|
const char *tsc_num_str;
|
||||||
|
|
||||||
cur_arg = 1;
|
cur_arg = 1;
|
||||||
proxy->conf.args.ctx = ARGC_TRK;
|
proxy->conf.args.ctx = ARGC_TRK;
|
||||||
|
|
||||||
|
tsc_num_str = &args[0][8];
|
||||||
|
if (cfg_parse_track_sc_num(&tsc_num, tsc_num_str, tsc_num_str + strlen(tsc_num_str), &err) == -1) {
|
||||||
|
ha_alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-response %s' rule : %s.\n",
|
||||||
|
file, linenum, proxy_type_str(proxy), proxy->id, args[0], err);
|
||||||
|
free(err);
|
||||||
|
goto out_err;
|
||||||
|
}
|
||||||
|
|
||||||
expr = sample_parse_expr((char **)args, &cur_arg, file, linenum, &err, &proxy->conf.args);
|
expr = sample_parse_expr((char **)args, &cur_arg, file, linenum, &err, &proxy->conf.args);
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
ha_alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-response %s' rule : %s.\n",
|
ha_alert("parsing [%s:%d] : error detected in %s '%s' while parsing 'http-response %s' rule : %s.\n",
|
||||||
@ -9194,7 +9211,7 @@ struct act_rule *parse_http_res_cond(const char **args, const char *file, int li
|
|||||||
cur_arg++;
|
cur_arg++;
|
||||||
}
|
}
|
||||||
rule->arg.trk_ctr.expr = expr;
|
rule->arg.trk_ctr.expr = expr;
|
||||||
rule->action = ACT_ACTION_TRK_SC0 + args[0][8] - '0';
|
rule->action = ACT_ACTION_TRK_SC0 + tsc_num;
|
||||||
rule->check_ptr = check_trk_action;
|
rule->check_ptr = check_trk_action;
|
||||||
} else if (((custom = action_http_res_custom(args[0])) != NULL)) {
|
} else if (((custom = action_http_res_custom(args[0])) != NULL)) {
|
||||||
char *errmsg = NULL;
|
char *errmsg = NULL;
|
||||||
|
@ -730,14 +730,20 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
|
|||||||
rule->arg.cap.hdr = hdr;
|
rule->arg.cap.hdr = hdr;
|
||||||
rule->action = ACT_TCP_CAPTURE;
|
rule->action = ACT_TCP_CAPTURE;
|
||||||
}
|
}
|
||||||
else if (strncmp(args[arg], "track-sc", 8) == 0 &&
|
else if (strncmp(args[arg], "track-sc", 8) == 0) {
|
||||||
args[arg][9] == '\0' && args[arg][8] >= '0' &&
|
|
||||||
args[arg][8] < '0' + MAX_SESS_STKCTR) { /* track-sc 0..9 */
|
|
||||||
struct sample_expr *expr;
|
struct sample_expr *expr;
|
||||||
int kw = arg;
|
int kw = arg;
|
||||||
|
unsigned int tsc_num;
|
||||||
|
const char *tsc_num_str;
|
||||||
|
|
||||||
arg++;
|
arg++;
|
||||||
|
|
||||||
|
tsc_num_str = &args[kw][8];
|
||||||
|
if (cfg_parse_track_sc_num(&tsc_num, tsc_num_str, tsc_num_str + strlen(tsc_num_str), err) == -1) {
|
||||||
|
memprintf(err, "'%s %s %s' : %s", args[0], args[1], args[kw], *err);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
curpx->conf.args.ctx = ARGC_TRK;
|
curpx->conf.args.ctx = ARGC_TRK;
|
||||||
expr = sample_parse_expr(args, &arg, file, line, err, &curpx->conf.args);
|
expr = sample_parse_expr(args, &arg, file, line, err, &curpx->conf.args);
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
@ -772,7 +778,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
|
|||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
rule->arg.trk_ctr.expr = expr;
|
rule->arg.trk_ctr.expr = expr;
|
||||||
rule->action = ACT_ACTION_TRK_SC0 + args[kw][8] - '0';
|
rule->action = ACT_ACTION_TRK_SC0 + tsc_num;
|
||||||
rule->check_ptr = check_trk_action;
|
rule->check_ptr = check_trk_action;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[arg], "expect-proxy") == 0) {
|
else if (strcmp(args[arg], "expect-proxy") == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user