mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 17:17:06 +02:00
MEDIUM: proxy: remove acl_requires and just keep a flag "http_needed"
Proxy's acl_requires was a copy of all bits taken from ACLs, but we'll get rid of ACL flags and only rely on sample fetches soon. The proxy's acl_requires was only used to allocate an HTTP context when needed, and was even forced in HTTP mode. So better have a flag which exactly says what it's supposed to be used for.
This commit is contained in:
parent
4a96bf5a5d
commit
25320b2906
@ -84,8 +84,8 @@ struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl, int p
|
|||||||
/* Builds an ACL condition starting at the if/unless keyword. The complete
|
/* Builds an ACL condition starting at the if/unless keyword. The complete
|
||||||
* condition is returned. NULL is returned in case of error or if the first
|
* condition is returned. NULL is returned in case of error or if the first
|
||||||
* word is neither "if" nor "unless". It automatically sets the file name and
|
* word is neither "if" nor "unless". It automatically sets the file name and
|
||||||
* the line number in the condition for better error reporting, and adds the
|
* the line number in the condition for better error reporting, and sets the
|
||||||
* ACL requirements to the proxy's acl_requires. If <err> is not NULL, it will
|
* HTTP initialization requirements in the proxy. If <err> is not NULL, it will
|
||||||
* be set to an error message upon errors, that the caller will have to free.
|
* be set to an error message upon errors, that the caller will have to free.
|
||||||
*/
|
*/
|
||||||
struct acl_cond *build_acl_cond(const char *file, int line, struct proxy *px, const char **args, char **err);
|
struct acl_cond *build_acl_cond(const char *file, int line, struct proxy *px, const char **args, char **err);
|
||||||
|
@ -205,6 +205,7 @@ struct proxy {
|
|||||||
unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */
|
unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */
|
||||||
unsigned int fe_rsp_ana, be_rsp_ana; /* bitmap of common response protocol analysers for the frontend and backend */
|
unsigned int fe_rsp_ana, be_rsp_ana; /* bitmap of common response protocol analysers for the frontend and backend */
|
||||||
int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
|
int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
|
||||||
|
unsigned int http_needed; /* non-null if HTTP analyser may be used */
|
||||||
union {
|
union {
|
||||||
struct proxy *be; /* default backend, or NULL if none set */
|
struct proxy *be; /* default backend, or NULL if none set */
|
||||||
char *name; /* default backend name during config parse */
|
char *name; /* default backend name during config parse */
|
||||||
@ -227,7 +228,6 @@ struct proxy {
|
|||||||
unsigned int inspect_delay; /* inspection delay */
|
unsigned int inspect_delay; /* inspection delay */
|
||||||
struct list inspect_rules; /* inspection rules */
|
struct list inspect_rules; /* inspection rules */
|
||||||
} tcp_rep;
|
} tcp_rep;
|
||||||
int acl_requires; /* Elements required to satisfy all ACLs (ACL_USE_*) */
|
|
||||||
struct server *srv, defsrv; /* known servers; default server configuration */
|
struct server *srv, defsrv; /* known servers; default server configuration */
|
||||||
int srv_act, srv_bck; /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */
|
int srv_act, srv_bck; /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */
|
||||||
struct lbprm lbprm; /* load-balancing parameters */
|
struct lbprm lbprm; /* load-balancing parameters */
|
||||||
|
@ -1463,8 +1463,8 @@ struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl, int p
|
|||||||
/* Builds an ACL condition starting at the if/unless keyword. The complete
|
/* Builds an ACL condition starting at the if/unless keyword. The complete
|
||||||
* condition is returned. NULL is returned in case of error or if the first
|
* condition is returned. NULL is returned in case of error or if the first
|
||||||
* word is neither "if" nor "unless". It automatically sets the file name and
|
* word is neither "if" nor "unless". It automatically sets the file name and
|
||||||
* the line number in the condition for better error reporting, and adds the
|
* the line number in the condition for better error reporting, and sets the
|
||||||
* ACL requirements to the proxy's acl_requires. If <err> is not NULL, it will
|
* HTTP intiailization requirements in the proxy. If <err> is not NULL, it will
|
||||||
* be filled with a pointer to an error message in case of error, that the
|
* be filled with a pointer to an error message in case of error, that the
|
||||||
* caller is responsible for freeing. The initial location must either be
|
* caller is responsible for freeing. The initial location must either be
|
||||||
* freeable or NULL.
|
* freeable or NULL.
|
||||||
@ -1498,8 +1498,7 @@ struct acl_cond *build_acl_cond(const char *file, int line, struct proxy *px, co
|
|||||||
|
|
||||||
cond->file = file;
|
cond->file = file;
|
||||||
cond->line = line;
|
cond->line = line;
|
||||||
px->acl_requires |= cond->requires;
|
px->http_needed |= !!(cond->requires & ACL_USE_L7_ANY);
|
||||||
|
|
||||||
return cond;
|
return cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3040,8 +3040,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check if we need to allocate an hdr_idx struct for HTTP parsing */
|
/* check if we need to allocate an hdr_idx struct for HTTP parsing */
|
||||||
if (expr->fetch->use & SMP_USE_HTTP_ANY)
|
curproxy->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
|
||||||
curproxy->acl_requires |= ACL_USE_L7_ANY;
|
|
||||||
|
|
||||||
if (strcmp(args[myidx], "table") == 0) {
|
if (strcmp(args[myidx], "table") == 0) {
|
||||||
myidx++;
|
myidx++;
|
||||||
@ -6044,7 +6043,7 @@ int check_config_validity()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PR_MODE_HTTP:
|
case PR_MODE_HTTP:
|
||||||
curproxy->acl_requires |= ACL_USE_L7_ANY;
|
curproxy->http_needed = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ int frontend_accept(struct session *s)
|
|||||||
goto out_free_reqcap; /* no memory */
|
goto out_free_reqcap; /* no memory */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->fe->acl_requires & ACL_USE_L7_ANY) {
|
if (s->fe->http_needed) {
|
||||||
/* we have to allocate header indexes only if we know
|
/* we have to allocate header indexes only if we know
|
||||||
* that we may make use of them. This of course includes
|
* that we may make use of them. This of course includes
|
||||||
* (mode == PR_MODE_HTTP).
|
* (mode == PR_MODE_HTTP).
|
||||||
|
@ -347,8 +347,7 @@ void add_sample_to_logformat_list(char *text, char *arg, int arg_len, struct pro
|
|||||||
|
|
||||||
/* check if we need to allocate an hdr_idx struct for HTTP parsing */
|
/* check if we need to allocate an hdr_idx struct for HTTP parsing */
|
||||||
/* Note, we may also need to set curpx->to_log with certain fetches */
|
/* Note, we may also need to set curpx->to_log with certain fetches */
|
||||||
if (expr->fetch->use & SMP_USE_HTTP_ANY)
|
curpx->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
|
||||||
curpx->acl_requires |= ACL_USE_L7_ANY;
|
|
||||||
|
|
||||||
/* FIXME: temporary workaround for missing LW_XPRT flag needed with some
|
/* FIXME: temporary workaround for missing LW_XPRT flag needed with some
|
||||||
* sample fetches (eg: ssl*). We always set it for now on, but this will
|
* sample fetches (eg: ssl*). We always set it for now on, but this will
|
||||||
|
@ -1129,8 +1129,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check if we need to allocate an hdr_idx struct for HTTP parsing */
|
/* check if we need to allocate an hdr_idx struct for HTTP parsing */
|
||||||
if (expr->fetch->use & SMP_USE_HTTP_ANY)
|
curpx->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
|
||||||
curpx->acl_requires |= ACL_USE_L7_ANY;
|
|
||||||
|
|
||||||
if (strcmp(args[arg], "table") == 0) {
|
if (strcmp(args[arg], "table") == 0) {
|
||||||
arg++;
|
arg++;
|
||||||
|
@ -828,7 +828,7 @@ int session_set_backend(struct session *s, struct proxy *be)
|
|||||||
/* If the target backend requires HTTP processing, we have to allocate
|
/* If the target backend requires HTTP processing, we have to allocate
|
||||||
* a struct hdr_idx for it if we did not have one.
|
* a struct hdr_idx for it if we did not have one.
|
||||||
*/
|
*/
|
||||||
if (unlikely(!s->txn.hdr_idx.v && (be->acl_requires & ACL_USE_L7_ANY))) {
|
if (unlikely(!s->txn.hdr_idx.v && be->http_needed)) {
|
||||||
if ((s->txn.hdr_idx.v = pool_alloc2(pool2_hdr_idx)) == NULL)
|
if ((s->txn.hdr_idx.v = pool_alloc2(pool2_hdr_idx)) == NULL)
|
||||||
return 0; /* not enough memory */
|
return 0; /* not enough memory */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user