MINOR: backend: make headers and RDP cookie also use arg_str/len
These ones used to rely on separate variables called hh_name/hh_len
but they are exclusive with the former. Let's use the same variable
which becomes a generic argument name and length for the LB algorithm.
diff --git a/include/types/backend.h b/include/types/backend.h
index ec1f5a9..3271eea 100644
--- a/include/types/backend.h
+++ b/include/types/backend.h
@@ -144,7 +144,7 @@
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 */
+ char *arg_str; /* name of the URL parameter/header/cookie 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 */
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 39e9940..448b5a2 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -323,8 +323,6 @@
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 *hh_name; /* name of the header parameter used for hashing */
- int hh_len; /* strlen(hh_name), computed only once */
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 */
diff --git a/src/backend.c b/src/backend.c
index 9b6f316..7a1acec 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -401,7 +401,7 @@
unsigned int hash = 0;
struct http_txn *txn = s->txn;
struct proxy *px = s->be;
- unsigned int plen = px->hh_len;
+ unsigned int plen = px->lbprm.arg_len;
unsigned long len;
struct hdr_ctx ctx;
const char *p;
@@ -414,7 +414,7 @@
ctx.idx = 0;
/* if the message is chunked, we skip the chunk size, but use the value as len */
- http_find_header2(px->hh_name, plen, c_ptr(&s->req, -http_hdr_rewind(&txn->req)), &txn->hdr_idx, &ctx);
+ http_find_header2(px->lbprm.arg_str, plen, c_ptr(&s->req, -http_hdr_rewind(&txn->req)), &txn->hdr_idx, &ctx);
/* if the header is not found or empty, let's fallback to round robin */
if (!ctx.idx || !ctx.vlen)
@@ -424,7 +424,7 @@
if (px->lbprm.tot_used == 1)
goto hash_done;
- /* Found a the hh_name in the headers.
+ /* Found the param_name in the headers.
* we will compute the hash based on this value ctx.val.
*/
len = ctx.vlen;
@@ -490,7 +490,7 @@
rewind = co_data(&s->req);
c_rew(&s->req, rewind);
- ret = fetch_rdp_cookie_name(s, &smp, px->hh_name, px->hh_len);
+ ret = fetch_rdp_cookie_name(s, &smp, px->lbprm.arg_str, px->lbprm.arg_len);
len = smp.data.u.str.data;
c_adv(&s->req, rewind);
@@ -502,7 +502,7 @@
if (px->lbprm.tot_used == 1)
goto hash_done;
- /* Found a the hh_name in the headers.
+ /* Found the param_name in the headers.
* we will compute the hash based on this value ctx.val.
*/
hash = gen_hash(px, smp.data.u.str.area, len);
@@ -1799,9 +1799,9 @@
curproxy->lbprm.algo &= ~BE_LB_ALGO;
curproxy->lbprm.algo |= BE_LB_ALGO_HH;
- free(curproxy->hh_name);
- curproxy->hh_len = end - beg;
- curproxy->hh_name = my_strndup(beg, end - beg);
+ 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;
if (*args[1]) {
@@ -1827,14 +1827,14 @@
return -1;
}
- free(curproxy->hh_name);
- curproxy->hh_name = my_strndup(beg, end - beg);
- curproxy->hh_len = end - beg;
+ free(curproxy->lbprm.arg_str);
+ curproxy->lbprm.arg_str = my_strndup(beg, end - beg);
+ curproxy->lbprm.arg_len = end - beg;
}
else if ( *(args[0] + 10 ) == '\0' ) { /* default cookie name 'mstshash' */
- free(curproxy->hh_name);
- curproxy->hh_name = strdup("mstshash");
- curproxy->hh_len = strlen(curproxy->hh_name);
+ free(curproxy->lbprm.arg_str);
+ curproxy->lbprm.arg_str = strdup("mstshash");
+ curproxy->lbprm.arg_len = strlen(curproxy->lbprm.arg_str);
}
else { /* syntax */
memprintf(err, "rdp-cookie : missing cookie name.");
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index b737ffa..4a6c73b 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -474,9 +474,6 @@
curproxy->uri_len_limit = defproxy.uri_len_limit;
curproxy->uri_dirs_depth1 = defproxy.uri_dirs_depth1;
- if (defproxy.hh_name)
- curproxy->hh_name = strdup(defproxy.hh_name);
- curproxy->hh_len = defproxy.hh_len;
curproxy->hh_match_domain = defproxy.hh_match_domain;
if (defproxy.conn_src.iface_name)
@@ -622,7 +619,6 @@
free(defproxy.dyncookie_key);
free(defproxy.cookie_domain);
free(defproxy.lbprm.arg_str);
- free(defproxy.hh_name);
free(defproxy.capture_name);
free(defproxy.monitor_uri);
free(defproxy.defbe.name);