]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: backend: remap the balance uri settings to lbprm.arg_opt{1,2,3}
authorWilly Tarreau <w@1wt.eu>
Mon, 14 Jan 2019 15:14:15 +0000 (16:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Jan 2019 18:33:17 +0000 (19:33 +0100)
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

include/types/proxy.h
src/backend.c
src/cfgparse-listen.c

index 1e4115edf9b199a466582f4373aabdd6bcdbd21f..765e81d8eabd0b7ea93d387e6ae7123354fdf3f6 100644 (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 */
index cc4eb97d6b8b7f46cf923f101a9e5f1efe8f20a9..6cca128cacaf908899ff60bdc8380ca2c900702a 100644 (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 {
index cdeefd0a879abbf1be9e6a4836fa6f58b2ba1fe8..7514a47efb9d318114fb8effc0a23c8300da1e7c 100644 (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;