mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-09 19:51:36 +01:00
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.
This commit is contained in:
parent
4c03d1c9b6
commit
484ff07691
@ -144,7 +144,7 @@ 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 */
|
||||
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 */
|
||||
|
||||
@ -323,8 +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 */
|
||||
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 */
|
||||
|
||||
@ -401,7 +401,7 @@ static struct server *get_server_hh(struct stream *s, const struct server *avoid
|
||||
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 @@ static struct server *get_server_hh(struct stream *s, const struct server *avoid
|
||||
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 @@ static struct server *get_server_hh(struct stream *s, const struct server *avoid
|
||||
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 @@ static struct server *get_server_rch(struct stream *s, const struct server *avoi
|
||||
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 @@ static struct server *get_server_rch(struct stream *s, const struct server *avoi
|
||||
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 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy)
|
||||
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 @@ int backend_parse_balance(const char **args, char **err, struct proxy *curproxy)
|
||||
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.");
|
||||
|
||||
@ -474,9 +474,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;
|
||||
|
||||
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 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user