MINOR: backend: remap the balance uri settings to lbprm.arg_opt{1,2,3}

The algo-specific settings move from the proxy to the LB algo this way :
  - uri_whole => arg_opt1
  - uri_len_limit => arg_opt2
  - uri_dirs_depth1 => arg_opt3
This commit is contained in:
Willy Tarreau 2019-01-14 16:14:15 +01:00
parent 9fed8586b5
commit a9a7249966
3 changed files with 13 additions and 19 deletions

View File

@ -320,9 +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 */
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 */
char *capture_name; /* beginning of the name of the cookie to capture */
int capture_namelen; /* length of the cookie name to match */
int capture_len; /* length of the string to be captured */

View File

@ -197,7 +197,9 @@ static struct server *get_server_sh(struct proxy *px, const char *addr, int len,
* ends at the question mark. Depending on the number of active/backup servers,
* it will either look for active servers, or for backup servers.
* If any server is found, it will be returned. If no valid server is found,
* NULL is returned.
* NULL is returned. The lbprm.arg_opt{1,2,3} values correspond respectively to
* the "whole" optional argument (boolean), the "len" argument (numeric) and
* the "depth" argument (numeric).
*
* This code was contributed by Guillaume Dallaire, who also selected this hash
* algorithm out of a tens because it gave him the best results.
@ -217,18 +219,18 @@ static struct server *get_server_uh(struct proxy *px, char *uri, int uri_len, co
if (px->lbprm.tot_used == 1)
goto hash_done;
if (px->uri_len_limit)
uri_len = MIN(uri_len, px->uri_len_limit);
if (px->lbprm.arg_opt2) // "len"
uri_len = MIN(uri_len, px->lbprm.arg_opt2);
start = end = uri;
while (uri_len--) {
c = *end;
if (c == '/') {
slashes++;
if (slashes == px->uri_dirs_depth1) /* depth+1 */
if (slashes == px->lbprm.arg_opt3) /* depth+1 */
break;
}
else if (c == '?' && !px->uri_whole)
else if (c == '?' && !px->lbprm.arg_opt1) // "whole"
break;
end++;
}
@ -1733,10 +1735,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_UH;
curproxy->uri_whole = 0;
curproxy->uri_len_limit = 0;
curproxy->uri_dirs_depth1 = 0;
curproxy->lbprm.arg_opt1 = 0; // "whole"
curproxy->lbprm.arg_opt2 = 0; // "len"
curproxy->lbprm.arg_opt3 = 0; // "depth"
while (*args[arg]) {
if (!strcmp(args[arg], "len")) {
@ -1744,7 +1745,7 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy)
memprintf(err, "%s : '%s' expects a positive integer (got '%s').", args[0], args[arg], args[arg+1]);
return -1;
}
curproxy->uri_len_limit = atoi(args[arg+1]);
curproxy->lbprm.arg_opt2 = atoi(args[arg+1]);
arg += 2;
}
else if (!strcmp(args[arg], "depth")) {
@ -1755,11 +1756,11 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy)
/* hint: we store the position of the ending '/' (depth+1) so
* that we avoid a comparison while computing the hash.
*/
curproxy->uri_dirs_depth1 = atoi(args[arg+1]) + 1;
curproxy->lbprm.arg_opt3 = atoi(args[arg+1]) + 1;
arg += 2;
}
else if (!strcmp(args[arg], "whole")) {
curproxy->uri_whole = 1;
curproxy->lbprm.arg_opt1 = 1;
arg += 1;
}
else {

View File

@ -475,10 +475,6 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
curproxy->lbprm.arg_opt2 = defproxy.lbprm.arg_opt2;
curproxy->lbprm.arg_opt3 = defproxy.lbprm.arg_opt3;
curproxy->uri_whole = defproxy.uri_whole;
curproxy->uri_len_limit = defproxy.uri_len_limit;
curproxy->uri_dirs_depth1 = defproxy.uri_dirs_depth1;
if (defproxy.conn_src.iface_name)
curproxy->conn_src.iface_name = strdup(defproxy.conn_src.iface_name);
curproxy->conn_src.iface_len = defproxy.conn_src.iface_len;