From: Willy Tarreau Date: Mon, 14 Jan 2019 15:04:54 +0000 (+0100) Subject: MINOR: backend: make the header hash use arg_opt1 for use_domain_only X-Git-Tag: v2.0-dev1~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fed8586b5a96efae97207d0a7f290ef5361b2bf;p=thirdparty%2Fhaproxy.git MINOR: backend: make the header hash use arg_opt1 for use_domain_only This is only a boolean extra arg. Let's map it to arg_opt1 and remove hh_match_domain from struct proxy. --- diff --git a/include/types/proxy.h b/include/types/proxy.h index 448b5a2445..1e4115edf9 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -323,7 +323,6 @@ struct proxy { 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 */ - int hh_match_domain; /* toggle use of special match function */ 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 */ diff --git a/src/backend.c b/src/backend.c index 7a1acec76c..cc4eb97d6b 100644 --- a/src/backend.c +++ b/src/backend.c @@ -394,7 +394,8 @@ static struct server *get_server_ph_post(struct stream *s, const struct server * * performance by avoiding bounces between servers in contexts where sessions * are shared but cookies are not usable. If the parameter is not found, NULL * is returned. If any server is found, it will be returned. If no valid server - * is found, NULL is returned. + * is found, NULL is returned. When lbprm.arg_opt1 is set, the hash will only + * apply to the middle part of a domain name ("use_domain_only" option). */ static struct server *get_server_hh(struct stream *s, const struct server *avoid) { @@ -429,7 +430,7 @@ static struct server *get_server_hh(struct stream *s, const struct server *avoid */ len = ctx.vlen; p = (char *)ctx.line + ctx.val; - if (!px->hh_match_domain) { + if (!px->lbprm.arg_opt1) { hash = gen_hash(px, p, len); } else { int dohash = 0; @@ -1802,14 +1803,14 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy) free(curproxy->lbprm.arg_str); curproxy->lbprm.arg_len = end - beg; curproxy->lbprm.arg_str = my_strndup(beg, end - beg); - curproxy->hh_match_domain = 0; + curproxy->lbprm.arg_opt1 = 0; if (*args[1]) { if (strcmp(args[1], "use_domain_only")) { memprintf(err, "%s only accepts 'use_domain_only' modifier (got '%s').", args[0], args[1]); return -1; } - curproxy->hh_match_domain = 1; + curproxy->lbprm.arg_opt1 = 1; } } else if (!strncmp(args[0], "rdp-cookie", 10)) { diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 9774bba5f8..cdeefd0a87 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -479,8 +479,6 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) curproxy->uri_len_limit = defproxy.uri_len_limit; curproxy->uri_dirs_depth1 = defproxy.uri_dirs_depth1; - curproxy->hh_match_domain = defproxy.hh_match_domain; - 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;