From: Willy Tarreau Date: Mon, 14 Jan 2019 14:23:54 +0000 (+0100) Subject: MINOR: backend: move url_param_name/len to lbprm.arg_str/len X-Git-Tag: v2.0-dev1~210 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c03d1c9b68ec07932a5bedeb25bf5936a83b351;p=thirdparty%2Fhaproxy.git MINOR: backend: move url_param_name/len to lbprm.arg_str/len This one is exclusively used by LB parameters, when using URL param hashing. Let's move it to the lbprm struct under a more generic name. --- diff --git a/include/types/backend.h b/include/types/backend.h index b36cd4112c..ec1f5a9bca 100644 --- a/include/types/backend.h +++ b/include/types/backend.h @@ -144,6 +144,8 @@ struct lbprm { int tot_used; /* total number of servers used for LB */ int wmult; /* ratio between user weight and effective weight */ int wdiv; /* ratio between effective weight and user weight */ + char *arg_str; /* name of the URL parameter used for hashing */ + int arg_len; /* strlen(arg_str), computed only once */ struct server *fbck; /* first backup server when !PR_O_USE_ALL_BK, or NULL */ struct lb_map map; /* LB parameters for map-based algorithms */ struct lb_fwrr fwrr; diff --git a/include/types/proxy.h b/include/types/proxy.h index 14b6046c69..39e9940394 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -320,8 +320,6 @@ struct proxy { unsigned int cookie_maxlife; /* max life time for this cookie */ char *rdp_cookie_name; /* name of the RDP cookie to look for */ int rdp_cookie_len; /* strlen(rdp_cookie_name), computed only once */ - char *url_param_name; /* name of the URL parameter used for hashing */ - int url_param_len; /* strlen(url_param_name), computed only once */ int uri_len_limit; /* character limit for uri balancing algorithm */ int uri_dirs_depth1; /* directories+1 (slashes) limit for uri balancing algorithm */ int uri_whole; /* if != 0, calculates the hash from the whole uri. Still honors the len_limit and dirs_depth1 */ diff --git a/src/backend.c b/src/backend.c index 13543c90e4..9b6f316f87 100644 --- a/src/backend.c +++ b/src/backend.c @@ -271,13 +271,13 @@ static struct server *get_server_ph(struct proxy *px, const char *uri, int uri_l p++; uri_len -= (p - uri); - plen = px->url_param_len; + plen = px->lbprm.arg_len; params = p; while (uri_len > plen) { /* Look for the parameter name followed by an equal symbol */ if (params[plen] == '=') { - if (memcmp(params, px->url_param_name, plen) == 0) { + if (memcmp(params, px->lbprm.arg_str, plen) == 0) { /* OK, we have the parameter here at , and * the value after the equal sign, at

* skip the equal symbol @@ -322,7 +322,7 @@ static struct server *get_server_ph_post(struct stream *s, const struct server * struct channel *req = &s->req; struct http_msg *msg = &txn->req; struct proxy *px = s->be; - unsigned int plen = px->url_param_len; + unsigned int plen = px->lbprm.arg_len; unsigned long len = http_body_bytes(msg); const char *params = c_ptr(req, -http_data_rewind(msg)); const char *p = params; @@ -340,7 +340,7 @@ static struct server *get_server_ph_post(struct stream *s, const struct server * while (len > plen) { /* Look for the parameter name followed by an equal symbol */ if (params[plen] == '=') { - if (memcmp(params, px->url_param_name, plen) == 0) { + if (memcmp(params, px->lbprm.arg_str, plen) == 0) { /* OK, we have the parameter here at , and * the value after the equal sign, at

* skip the equal symbol @@ -1775,9 +1775,9 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy) curproxy->lbprm.algo &= ~BE_LB_ALGO; curproxy->lbprm.algo |= BE_LB_ALGO_PH; - free(curproxy->url_param_name); - curproxy->url_param_name = strdup(args[1]); - curproxy->url_param_len = strlen(args[1]); + free(curproxy->lbprm.arg_str); + curproxy->lbprm.arg_str = strdup(args[1]); + curproxy->lbprm.arg_len = strlen(args[1]); if (*args[2]) { if (strcmp(args[2], "check_post")) { memprintf(err, "%s only accepts 'check_post' modifier (got '%s').", args[0], args[2]); diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 8d2c176a89..b737ffa61c 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -467,9 +467,9 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) curproxy->rdp_cookie_name = strdup(defproxy.rdp_cookie_name); curproxy->rdp_cookie_len = defproxy.rdp_cookie_len; - if (defproxy.url_param_name) - curproxy->url_param_name = strdup(defproxy.url_param_name); - curproxy->url_param_len = defproxy.url_param_len; + if (defproxy.lbprm.arg_str) + curproxy->lbprm.arg_str = strdup(defproxy.lbprm.arg_str); + curproxy->lbprm.arg_len = defproxy.lbprm.arg_len; curproxy->uri_whole = defproxy.uri_whole; curproxy->uri_len_limit = defproxy.uri_len_limit; curproxy->uri_dirs_depth1 = defproxy.uri_dirs_depth1; @@ -621,7 +621,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) free(defproxy.rdp_cookie_name); free(defproxy.dyncookie_key); free(defproxy.cookie_domain); - free(defproxy.url_param_name); + free(defproxy.lbprm.arg_str); free(defproxy.hh_name); free(defproxy.capture_name); free(defproxy.monitor_uri); diff --git a/src/haproxy.c b/src/haproxy.c index d47dff3e37..dbc2adabc8 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2246,7 +2246,7 @@ void deinit(void) free(p->check_req); free(p->cookie_name); free(p->cookie_domain); - free(p->url_param_name); + free(p->lbprm.arg_str); free(p->capture_name); free(p->monitor_uri); free(p->rdp_cookie_name);