2006-06-25 20:48:02 -04:00
/*
* Proxy variables and functions .
*
2009-03-05 17:48:25 -05:00
* Copyright 2000 - 2009 Willy Tarreau < w @ 1 wt . eu >
2006-06-25 20:48:02 -04:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version
* 2 of the License , or ( at your option ) any later version .
*
*/
# include <fcntl.h>
# include <unistd.h>
2007-11-30 12:38:35 -05:00
# include <string.h>
2006-06-25 20:48:02 -04:00
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/stat.h>
2020-06-09 03:07:15 -04:00
# include <import/eb32tree.h>
# include <import/ebistree.h>
2020-05-27 06:58:42 -04:00
# include <haproxy/api.h>
2020-06-09 03:07:15 -04:00
# include <haproxy/applet-t.h>
# include <haproxy/capture-t.h>
2020-06-04 18:00:29 -04:00
# include <haproxy/cfgparse.h>
2020-06-04 14:19:54 -04:00
# include <haproxy/cli.h>
2020-05-27 10:10:29 -04:00
# include <haproxy/errors.h>
2020-06-09 03:07:15 -04:00
# include <haproxy/fd.h>
2020-06-04 15:29:29 -04:00
# include <haproxy/filters.h>
2020-06-04 11:05:57 -04:00
# include <haproxy/global.h>
2020-06-04 15:21:03 -04:00
# include <haproxy/http_ana.h>
2021-02-12 02:49:47 -05:00
# include <haproxy/http_htx.h>
2020-06-04 08:58:24 -04:00
# include <haproxy/listener.h>
2020-06-04 16:01:04 -04:00
# include <haproxy/log.h>
2020-06-04 05:29:21 -04:00
# include <haproxy/obj_type-t.h>
2020-06-04 12:38:21 -04:00
# include <haproxy/peers.h>
2020-06-02 03:38:52 -04:00
# include <haproxy/pool.h>
2020-10-07 10:52:43 -04:00
# include <haproxy/protocol.h>
2020-06-09 03:07:15 -04:00
# include <haproxy/proto_tcp.h>
2020-06-04 16:29:18 -04:00
# include <haproxy/proxy.h>
2020-06-04 17:20:13 -04:00
# include <haproxy/server-t.h>
2020-06-09 03:07:15 -04:00
# include <haproxy/signal.h>
2020-06-04 13:58:55 -04:00
# include <haproxy/stats-t.h>
2020-06-04 17:46:14 -04:00
# include <haproxy/stream.h>
2020-06-04 14:45:39 -04:00
# include <haproxy/stream_interface.h>
2020-06-04 11:25:40 -04:00
# include <haproxy/task.h>
2021-02-12 02:49:47 -05:00
# include <haproxy/tcpcheck.h>
2020-06-01 05:05:15 -04:00
# include <haproxy/time.h>
2006-06-25 20:48:02 -04:00
2011-07-25 10:33:49 -04:00
int listeners ; /* # of proxy listeners, set by cfgparse */
2017-11-24 10:54:05 -05:00
struct proxy * proxies_list = NULL ; /* list of all existing proxies */
2009-10-04 17:04:08 -04:00
struct eb_root used_proxy_id = EB_ROOT ; /* list of proxy IDs in use */
2014-03-15 02:22:35 -04:00
struct eb_root proxy_by_name = EB_ROOT ; /* tree of proxies sorted by name */
2010-12-12 08:00:34 -05:00
unsigned int error_snapshot_id = 0 ; /* global ID assigned to each error then incremented */
2006-06-25 20:48:02 -04:00
2018-11-11 09:40:36 -05:00
/* proxy->options */
const struct cfg_opt cfg_opts [ ] =
{
{ " abortonclose " , PR_O_ABRT_CLOSE , PR_CAP_BE , 0 , 0 } ,
{ " allbackups " , PR_O_USE_ALL_BK , PR_CAP_BE , 0 , 0 } ,
{ " checkcache " , PR_O_CHK_CACHE , PR_CAP_BE , 0 , PR_MODE_HTTP } ,
{ " clitcpka " , PR_O_TCP_CLI_KA , PR_CAP_FE , 0 , 0 } ,
{ " contstats " , PR_O_CONTSTATS , PR_CAP_FE , 0 , 0 } ,
{ " dontlognull " , PR_O_NULLNOLOG , PR_CAP_FE , 0 , 0 } ,
{ " http_proxy " , PR_O_HTTP_PROXY , PR_CAP_FE | PR_CAP_BE , 0 , PR_MODE_HTTP } ,
{ " http-buffer-request " , PR_O_WREQ_BODY , PR_CAP_FE | PR_CAP_BE , 0 , PR_MODE_HTTP } ,
{ " http-ignore-probes " , PR_O_IGNORE_PRB , PR_CAP_FE , 0 , PR_MODE_HTTP } ,
{ " prefer-last-server " , PR_O_PREF_LAST , PR_CAP_BE , 0 , PR_MODE_HTTP } ,
{ " logasap " , PR_O_LOGASAP , PR_CAP_FE , 0 , 0 } ,
{ " nolinger " , PR_O_TCP_NOLING , PR_CAP_FE | PR_CAP_BE , 0 , 0 } ,
{ " persist " , PR_O_PERSIST , PR_CAP_BE , 0 , 0 } ,
{ " srvtcpka " , PR_O_TCP_SRV_KA , PR_CAP_BE , 0 , 0 } ,
2019-05-22 13:24:06 -04:00
# ifdef USE_TPROXY
2018-11-11 09:40:36 -05:00
{ " transparent " , PR_O_TRANSP , PR_CAP_BE , 0 , 0 } ,
# else
{ " transparent " , 0 , 0 , 0 , 0 } ,
# endif
{ NULL , 0 , 0 , 0 , 0 }
} ;
/* proxy->options2 */
const struct cfg_opt cfg_opts2 [ ] =
{
2019-05-22 13:24:06 -04:00
# ifdef USE_LINUX_SPLICE
2018-11-11 09:40:36 -05:00
{ " splice-request " , PR_O2_SPLIC_REQ , PR_CAP_FE | PR_CAP_BE , 0 , 0 } ,
{ " splice-response " , PR_O2_SPLIC_RTR , PR_CAP_FE | PR_CAP_BE , 0 , 0 } ,
{ " splice-auto " , PR_O2_SPLIC_AUT , PR_CAP_FE | PR_CAP_BE , 0 , 0 } ,
# else
{ " splice-request " , 0 , 0 , 0 , 0 } ,
{ " splice-response " , 0 , 0 , 0 , 0 } ,
{ " splice-auto " , 0 , 0 , 0 , 0 } ,
# endif
{ " accept-invalid-http-request " , PR_O2_REQBUG_OK , PR_CAP_FE , 0 , PR_MODE_HTTP } ,
{ " accept-invalid-http-response " , PR_O2_RSPBUG_OK , PR_CAP_BE , 0 , PR_MODE_HTTP } ,
{ " dontlog-normal " , PR_O2_NOLOGNORM , PR_CAP_FE , 0 , 0 } ,
{ " log-separate-errors " , PR_O2_LOGERRORS , PR_CAP_FE , 0 , 0 } ,
{ " log-health-checks " , PR_O2_LOGHCHKS , PR_CAP_BE , 0 , 0 } ,
{ " socket-stats " , PR_O2_SOCKSTAT , PR_CAP_FE , 0 , 0 } ,
{ " tcp-smart-accept " , PR_O2_SMARTACC , PR_CAP_FE , 0 , 0 } ,
{ " tcp-smart-connect " , PR_O2_SMARTCON , PR_CAP_BE , 0 , 0 } ,
{ " independent-streams " , PR_O2_INDEPSTR , PR_CAP_FE | PR_CAP_BE , 0 , 0 } ,
{ " http-use-proxy-header " , PR_O2_USE_PXHDR , PR_CAP_FE , 0 , PR_MODE_HTTP } ,
{ " http-pretend-keepalive " , PR_O2_FAKE_KA , PR_CAP_BE , 0 , PR_MODE_HTTP } ,
{ " http-no-delay " , PR_O2_NODELAY , PR_CAP_FE | PR_CAP_BE , 0 , PR_MODE_HTTP } ,
2019-07-15 04:16:58 -04:00
{ " http-use-htx " , 0 , PR_CAP_FE | PR_CAP_BE , 0 , 0 } , // deprecated
MEDIUM: mux-h1: Add the support of headers adjustment for bogus HTTP/1 apps
There is no standard case for HTTP header names because, as stated in the
RFC7230, they are case-insensitive. So applications must handle them in a
case-insensitive manner. But some bogus applications erroneously rely on the
case used by most browsers. This problem becomes critical with HTTP/2
because all header names must be exchanged in lowercase. And HAProxy uses the
same convention. All header names are sent in lowercase to clients and servers,
regardless of the HTTP version.
This design choice is linked to the HTX implementation. So, for previous
versions (2.0 and 1.9), a workaround is to disable the HTX mode to fall
back to the legacy HTTP mode.
Since the legacy HTTP mode was removed, some users reported interoperability
issues because their application was not able anymore to handle HTTP/1 message
received from HAProxy. So, we've decided to add a way to change the case of some
headers before sending them. It is now possible to define a "mapping" between a
lowercase header name and a version supported by the bogus application. To do
so, you must use the global directives "h1-case-adjust" and
"h1-case-adjust-file". Then options "h1-case-adjust-bogus-client" and
"h1-case-adjust-bogus-server" may be used in proxy sections to enable the
conversion. See the configuration manual for more info.
Of course, our advice is to urgently upgrade these applications for
interoperability concerns and because they may be vulnerable to various types of
content smuggling attacks. But, if your are really forced to use an unmaintained
bogus application, you may use these directive, at your own risks.
If it is relevant, this feature may be backported to 2.0.
2019-07-22 10:18:24 -04:00
{ " h1-case-adjust-bogus-client " , PR_O2_H1_ADJ_BUGCLI , PR_CAP_FE , 0 , PR_MODE_HTTP } ,
{ " h1-case-adjust-bogus-server " , PR_O2_H1_ADJ_BUGSRV , PR_CAP_BE , 0 , PR_MODE_HTTP } ,
2020-06-02 11:33:56 -04:00
{ " disable-h2-upgrade " , PR_O2_NO_H2_UPGRADE , PR_CAP_FE , 0 , PR_MODE_HTTP } ,
2018-11-11 09:40:36 -05:00
{ NULL , 0 , 0 , 0 }
} ;
2006-12-29 08:19:17 -05:00
/*
2007-11-04 01:04:43 -05:00
* This function returns a string containing a name describing capabilities to
* report comprehensible error messages . Specifically , it will return the words
2016-10-26 05:06:28 -04:00
* " frontend " , " backend " when appropriate , or " proxy " for all other
2007-11-04 01:04:43 -05:00
* cases including the proxies declared in " listen " mode .
2006-12-29 08:19:17 -05:00
*/
2007-11-04 01:04:43 -05:00
const char * proxy_cap_str ( int cap )
2006-12-29 08:19:17 -05:00
{
2007-11-04 01:04:43 -05:00
if ( ( cap & PR_CAP_LISTEN ) ! = PR_CAP_LISTEN ) {
if ( cap & PR_CAP_FE )
return " frontend " ;
else if ( cap & PR_CAP_BE )
return " backend " ;
}
return " proxy " ;
2006-12-29 08:19:17 -05:00
}
2007-11-03 18:41:58 -04:00
/*
* This function returns a string containing the mode of the proxy in a format
* suitable for error messages .
*/
const char * proxy_mode_str ( int mode ) {
if ( mode = = PR_MODE_TCP )
return " tcp " ;
else if ( mode = = PR_MODE_HTTP )
return " http " ;
2018-10-26 08:47:40 -04:00
else if ( mode = = PR_MODE_CLI )
return " cli " ;
2007-11-03 18:41:58 -04:00
else
return " unknown " ;
}
2009-10-10 12:35:51 -04:00
/*
* This function scans the list of backends and servers to retrieve the first
* backend and the first server with the given names , and sets them in both
* parameters . It returns zero if either is not found , or non - zero and sets
* the ones it did not found to NULL . If a NULL pointer is passed for the
* backend , only the pointer to the server will be updated .
*/
int get_backend_server ( const char * bk_name , const char * sv_name ,
struct proxy * * bk , struct server * * sv )
{
struct proxy * p ;
struct server * s ;
2014-03-15 02:57:11 -04:00
int sid ;
2009-10-10 12:35:51 -04:00
* sv = NULL ;
2012-10-04 02:47:34 -04:00
sid = - 1 ;
2009-10-10 16:33:08 -04:00
if ( * sv_name = = ' # ' )
sid = atoi ( sv_name + 1 ) ;
2015-05-26 05:24:42 -04:00
p = proxy_be_by_name ( bk_name ) ;
2009-10-10 12:35:51 -04:00
if ( bk )
* bk = p ;
if ( ! p )
return 0 ;
for ( s = p - > srv ; s ; s = s - > next )
2012-11-14 18:15:18 -05:00
if ( ( sid > = 0 & & s - > puid = = sid ) | |
( sid < 0 & & strcmp ( s - > id , sv_name ) = = 0 ) )
2009-10-10 12:35:51 -04:00
break ;
* sv = s ;
if ( ! s )
return 0 ;
return 1 ;
}
2007-12-02 19:30:13 -05:00
/* This function parses a "timeout" statement in a proxy section. It returns
* - 1 if there is any error , 1 for a warning , otherwise zero . If it does not
2012-05-08 13:47:01 -04:00
* return zero , it will write an error or warning message into a preallocated
* buffer returned at < err > . The trailing is not be written . The function must
* be called with < args > pointing to the first command line word , with < proxy >
* pointing to the proxy being parsed , and < defpx > to the default proxy or NULL .
* As a special case for compatibility with older configs , it also accepts
* " {cli|srv|con}timeout " in args [ 0 ] .
2007-12-02 19:30:13 -05:00
*/
2008-07-09 14:34:27 -04:00
static int proxy_parse_timeout ( char * * args , int section , struct proxy * proxy ,
2012-09-18 14:02:48 -04:00
struct proxy * defpx , const char * file , int line ,
char * * err )
2007-12-02 19:30:13 -05:00
{
unsigned timeout ;
int retval , cap ;
const char * res , * name ;
2008-07-06 18:09:58 -04:00
int * tv = NULL ;
int * td = NULL ;
2007-12-02 19:30:13 -05:00
retval = 0 ;
2008-07-09 14:34:27 -04:00
/* simply skip "timeout" but remain compatible with old form */
if ( strcmp ( args [ 0 ] , " timeout " ) = = 0 )
args + + ;
2007-12-02 19:30:13 -05:00
name = args [ 0 ] ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
if ( strcmp ( args [ 0 ] , " client " ) = = 0 ) {
2007-12-02 19:30:13 -05:00
name = " client " ;
2007-12-02 19:38:36 -05:00
tv = & proxy - > timeout . client ;
td = & defpx - > timeout . client ;
2007-12-02 19:30:13 -05:00
cap = PR_CAP_FE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " tarpit " ) = = 0 ) {
2007-12-02 19:30:13 -05:00
tv = & proxy - > timeout . tarpit ;
td = & defpx - > timeout . tarpit ;
2008-01-06 07:40:03 -05:00
cap = PR_CAP_FE | PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " http-keep-alive " ) = = 0 ) {
2010-01-10 08:46:16 -05:00
tv = & proxy - > timeout . httpka ;
td = & defpx - > timeout . httpka ;
cap = PR_CAP_FE | PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " http-request " ) = = 0 ) {
2008-01-06 07:24:40 -05:00
tv = & proxy - > timeout . httpreq ;
td = & defpx - > timeout . httpreq ;
2009-07-12 04:03:17 -04:00
cap = PR_CAP_FE | PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " server " ) = = 0 ) {
2007-12-02 19:30:13 -05:00
name = " server " ;
2007-12-02 19:38:36 -05:00
tv = & proxy - > timeout . server ;
td = & defpx - > timeout . server ;
2007-12-02 19:30:13 -05:00
cap = PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " connect " ) = = 0 ) {
2007-12-02 19:30:13 -05:00
name = " connect " ;
2007-12-02 19:38:36 -05:00
tv = & proxy - > timeout . connect ;
td = & defpx - > timeout . connect ;
2007-12-02 19:30:13 -05:00
cap = PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " check " ) = = 0 ) {
2008-01-20 19:54:06 -05:00
tv = & proxy - > timeout . check ;
td = & defpx - > timeout . check ;
cap = PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " queue " ) = = 0 ) {
2007-12-02 19:30:13 -05:00
tv = & proxy - > timeout . queue ;
td = & defpx - > timeout . queue ;
cap = PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " tunnel " ) = = 0 ) {
2012-05-12 06:50:00 -04:00
tv = & proxy - > timeout . tunnel ;
td = & defpx - > timeout . tunnel ;
cap = PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " client-fin " ) = = 0 ) {
2014-05-10 08:30:07 -04:00
tv = & proxy - > timeout . clientfin ;
td = & defpx - > timeout . clientfin ;
cap = PR_CAP_FE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " server-fin " ) = = 0 ) {
2014-05-10 08:30:07 -04:00
tv = & proxy - > timeout . serverfin ;
td = & defpx - > timeout . serverfin ;
cap = PR_CAP_BE ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " clitimeout " ) = = 0 ) {
2019-05-14 14:57:59 -04:00
memprintf ( err , " the '%s' directive is not supported anymore since HAProxy 2.1. Use 'timeout client'. " , args [ 0 ] ) ;
return - 1 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " srvtimeout " ) = = 0 ) {
2019-05-14 14:57:59 -04:00
memprintf ( err , " the '%s' directive is not supported anymore since HAProxy 2.1. Use 'timeout server'. " , args [ 0 ] ) ;
return - 1 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " contimeout " ) = = 0 ) {
2019-05-14 14:57:59 -04:00
memprintf ( err , " the '%s' directive is not supported anymore since HAProxy 2.1. Use 'timeout connect'. " , args [ 0 ] ) ;
return - 1 ;
2007-12-02 19:30:13 -05:00
} else {
2012-05-08 13:47:01 -04:00
memprintf ( err ,
" 'timeout' supports 'client', 'server', 'connect', 'check', "
2014-05-10 08:30:07 -04:00
" 'queue', 'http-keep-alive', 'http-request', 'tunnel', 'tarpit', "
" 'client-fin' and 'server-fin' (got '%s') " ,
2012-05-08 13:47:01 -04:00
args [ 0 ] ) ;
2007-12-02 19:30:13 -05:00
return - 1 ;
}
if ( * args [ 1 ] = = 0 ) {
2012-05-08 13:47:01 -04:00
memprintf ( err , " 'timeout %s' expects an integer value (in milliseconds) " , name ) ;
2007-12-02 19:30:13 -05:00
return - 1 ;
}
res = parse_time_err ( args [ 1 ] , & timeout , TIME_UNIT_MS ) ;
2019-06-07 13:00:37 -04:00
if ( res = = PARSE_TIME_OVER ) {
memprintf ( err , " timer overflow in argument '%s' to 'timeout %s' (maximum value is 2147483647 ms or ~24.8 days) " ,
args [ 1 ] , name ) ;
return - 1 ;
}
else if ( res = = PARSE_TIME_UNDER ) {
memprintf ( err , " timer underflow in argument '%s' to 'timeout %s' (minimum non-null value is 1 ms) " ,
args [ 1 ] , name ) ;
return - 1 ;
}
else if ( res ) {
2012-05-08 13:47:01 -04:00
memprintf ( err , " unexpected character '%c' in 'timeout %s' " , * res , name ) ;
2007-12-02 19:30:13 -05:00
return - 1 ;
}
if ( ! ( proxy - > cap & cap ) ) {
2012-05-08 13:47:01 -04:00
memprintf ( err , " 'timeout %s' will be ignored because %s '%s' has no %s capability " ,
name , proxy_type_str ( proxy ) , proxy - > id ,
( cap & PR_CAP_BE ) ? " backend " : " frontend " ) ;
2007-12-02 19:30:13 -05:00
retval = 1 ;
}
2008-07-06 18:09:58 -04:00
else if ( defpx & & * tv ! = * td ) {
2012-05-08 13:47:01 -04:00
memprintf ( err , " overwriting 'timeout %s' which was already specified " , name ) ;
2007-12-02 19:30:13 -05:00
retval = 1 ;
}
2014-05-22 02:24:46 -04:00
if ( * args [ 2 ] ! = 0 ) {
memprintf ( err , " 'timeout %s' : unexpected extra argument '%s' after value '%s'. " , name , args [ 2 ] , args [ 1 ] ) ;
retval = - 1 ;
}
2008-07-06 18:09:58 -04:00
* tv = MS_TO_TICKS ( timeout ) ;
2007-12-02 19:30:13 -05:00
return retval ;
}
2009-03-05 17:48:25 -05:00
/* This function parses a "rate-limit" statement in a proxy section. It returns
* - 1 if there is any error , 1 for a warning , otherwise zero . If it does not
2012-05-08 13:47:01 -04:00
* return zero , it will write an error or warning message into a preallocated
* buffer returned at < err > . The function must be called with < args > pointing
* to the first command line word , with < proxy > pointing to the proxy being
* parsed , and < defpx > to the default proxy or NULL .
2009-03-05 17:48:25 -05:00
*/
static int proxy_parse_rate_limit ( char * * args , int section , struct proxy * proxy ,
2012-09-18 14:02:48 -04:00
struct proxy * defpx , const char * file , int line ,
char * * err )
2009-03-05 17:48:25 -05:00
{
2020-01-15 19:34:27 -05:00
int retval ;
2012-05-08 13:47:01 -04:00
char * res ;
2009-03-05 17:48:25 -05:00
unsigned int * tv = NULL ;
unsigned int * td = NULL ;
unsigned int val ;
retval = 0 ;
2012-05-08 13:47:01 -04:00
if ( strcmp ( args [ 1 ] , " sessions " ) = = 0 ) {
2009-05-10 12:52:49 -04:00
tv = & proxy - > fe_sps_lim ;
td = & defpx - > fe_sps_lim ;
2012-05-08 13:47:01 -04:00
}
else {
memprintf ( err , " '%s' only supports 'sessions' (got '%s') " , args [ 0 ] , args [ 1 ] ) ;
2009-03-05 17:48:25 -05:00
return - 1 ;
}
2012-05-08 13:47:01 -04:00
if ( * args [ 2 ] = = 0 ) {
memprintf ( err , " '%s %s' expects expects an integer value (in sessions/second) " , args [ 0 ] , args [ 1 ] ) ;
2009-03-05 17:48:25 -05:00
return - 1 ;
}
2012-05-08 13:47:01 -04:00
val = strtoul ( args [ 2 ] , & res , 0 ) ;
2009-03-05 17:48:25 -05:00
if ( * res ) {
2012-05-08 13:47:01 -04:00
memprintf ( err , " '%s %s' : unexpected character '%c' in integer value '%s' " , args [ 0 ] , args [ 1 ] , * res , args [ 2 ] ) ;
2009-03-05 17:48:25 -05:00
return - 1 ;
}
2020-01-15 19:34:27 -05:00
if ( ! ( proxy - > cap & PR_CAP_FE ) ) {
memprintf ( err , " %s %s will be ignored because %s '%s' has no frontend capability " ,
args [ 0 ] , args [ 1 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
2009-03-05 17:48:25 -05:00
retval = 1 ;
}
else if ( defpx & & * tv ! = * td ) {
2012-05-08 13:47:01 -04:00
memprintf ( err , " overwriting %s %s which was already specified " , args [ 0 ] , args [ 1 ] ) ;
2009-03-05 17:48:25 -05:00
retval = 1 ;
}
* tv = val ;
return retval ;
}
2014-04-25 07:58:37 -04:00
/* This function parses a "max-keep-alive-queue" statement in a proxy section.
* It returns - 1 if there is any error , 1 for a warning , otherwise zero . If it
* does not return zero , it will write an error or warning message into a
* preallocated buffer returned at < err > . The function must be called with
* < args > pointing to the first command line word , with < proxy > pointing to
* the proxy being parsed , and < defpx > to the default proxy or NULL .
*/
static int proxy_parse_max_ka_queue ( char * * args , int section , struct proxy * proxy ,
struct proxy * defpx , const char * file , int line ,
char * * err )
{
int retval ;
char * res ;
unsigned int val ;
retval = 0 ;
if ( * args [ 1 ] = = 0 ) {
memprintf ( err , " '%s' expects expects an integer value (or -1 to disable) " , args [ 0 ] ) ;
return - 1 ;
}
val = strtol ( args [ 1 ] , & res , 0 ) ;
if ( * res ) {
memprintf ( err , " '%s' : unexpected character '%c' in integer value '%s' " , args [ 0 ] , * res , args [ 1 ] ) ;
return - 1 ;
}
if ( ! ( proxy - > cap & PR_CAP_BE ) ) {
memprintf ( err , " %s will be ignored because %s '%s' has no backend capability " ,
args [ 0 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
retval = 1 ;
}
/* we store <val+1> so that a user-facing value of -1 is stored as zero (default) */
proxy - > max_ka_queue = val + 1 ;
return retval ;
}
2015-05-26 11:44:32 -04:00
/* This function parses a "declare" statement in a proxy section. It returns -1
* if there is any error , 1 for warning , otherwise 0. If it does not return zero ,
* it will write an error or warning message into a preallocated buffer returned
* at < err > . The function must be called with < args > pointing to the first command
* line word , with < proxy > pointing to the proxy being parsed , and < defpx > to the
* default proxy or NULL .
*/
static int proxy_parse_declare ( char * * args , int section , struct proxy * curpx ,
struct proxy * defpx , const char * file , int line ,
char * * err )
{
/* Capture keyword wannot be declared in a default proxy. */
if ( curpx = = defpx ) {
2018-11-15 14:50:44 -05:00
memprintf ( err , " '%s' not available in default section " , args [ 0 ] ) ;
2015-05-26 11:44:32 -04:00
return - 1 ;
}
2021-01-07 23:35:52 -05:00
/* Capture keyword is only available in frontend. */
2015-05-26 11:44:32 -04:00
if ( ! ( curpx - > cap & PR_CAP_FE ) ) {
2018-11-15 14:50:44 -05:00
memprintf ( err , " '%s' only available in frontend or listen section " , args [ 0 ] ) ;
2015-05-26 11:44:32 -04:00
return - 1 ;
}
/* Check mandatory second keyword. */
if ( ! args [ 1 ] | | ! * args [ 1 ] ) {
memprintf ( err , " '%s' needs a second keyword that specify the type of declaration ('capture') " , args [ 0 ] ) ;
return - 1 ;
}
2018-11-15 14:46:55 -05:00
/* Actually, declare is only available for declaring capture
2015-05-26 11:44:32 -04:00
* slot , but in the future it can declare maps or variables .
2018-11-15 14:46:55 -05:00
* So , this section permits to check and switch according with
2015-05-26 11:44:32 -04:00
* the second keyword .
*/
if ( strcmp ( args [ 1 ] , " capture " ) = = 0 ) {
char * error = NULL ;
long len ;
struct cap_hdr * hdr ;
/* Check the next keyword. */
if ( ! args [ 2 ] | | ! * args [ 2 ] | |
( strcmp ( args [ 2 ] , " response " ) ! = 0 & &
strcmp ( args [ 2 ] , " request " ) ! = 0 ) ) {
memprintf ( err , " '%s %s' requires a direction ('request' or 'response') " , args [ 0 ] , args [ 1 ] ) ;
return - 1 ;
}
/* Check the 'len' keyword. */
if ( ! args [ 3 ] | | ! * args [ 3 ] | | strcmp ( args [ 3 ] , " len " ) ! = 0 ) {
memprintf ( err , " '%s %s' requires a capture length ('len') " , args [ 0 ] , args [ 1 ] ) ;
return - 1 ;
}
/* Check the length value. */
if ( ! args [ 4 ] | | ! * args [ 4 ] ) {
memprintf ( err , " '%s %s': 'len' requires a numeric value that represents the "
" capture length " ,
args [ 0 ] , args [ 1 ] ) ;
return - 1 ;
}
/* convert the length value. */
len = strtol ( args [ 4 ] , & error , 10 ) ;
if ( * error ! = ' \0 ' ) {
memprintf ( err , " '%s %s': cannot parse the length '%s'. " ,
args [ 0 ] , args [ 1 ] , args [ 3 ] ) ;
return - 1 ;
}
/* check length. */
if ( len < = 0 ) {
memprintf ( err , " length must be > 0 " ) ;
return - 1 ;
}
/* register the capture. */
2016-04-03 07:48:43 -04:00
hdr = calloc ( 1 , sizeof ( * hdr ) ) ;
2015-05-26 11:44:32 -04:00
hdr - > name = NULL ; /* not a header capture */
hdr - > namelen = 0 ;
hdr - > len = len ;
hdr - > pool = create_pool ( " caphdr " , hdr - > len + 1 , MEM_F_SHARED ) ;
if ( strcmp ( args [ 2 ] , " request " ) = = 0 ) {
hdr - > next = curpx - > req_cap ;
hdr - > index = curpx - > nb_req_cap + + ;
curpx - > req_cap = hdr ;
}
if ( strcmp ( args [ 2 ] , " response " ) = = 0 ) {
hdr - > next = curpx - > rsp_cap ;
hdr - > index = curpx - > nb_rsp_cap + + ;
curpx - > rsp_cap = hdr ;
}
return 0 ;
}
else {
memprintf ( err , " unknown declaration type '%s' (supports 'capture') " , args [ 1 ] ) ;
return - 1 ;
}
}
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
/* This function parses a "retry-on" statement */
static int
proxy_parse_retry_on ( char * * args , int section , struct proxy * curpx ,
struct proxy * defpx , const char * file , int line ,
char * * err )
{
int i ;
if ( ! ( * args [ 1 ] ) ) {
memprintf ( err , " '%s' needs at least one keyword to specify when to retry " , args [ 0 ] ) ;
return - 1 ;
}
if ( ! ( curpx - > cap & PR_CAP_BE ) ) {
memprintf ( err , " '%s' only available in backend or listen section " , args [ 0 ] ) ;
return - 1 ;
}
curpx - > retry_type = 0 ;
for ( i = 1 ; * ( args [ i ] ) ; i + + ) {
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
if ( strcmp ( args [ i ] , " conn-failure " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_CONN_FAILED ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " empty-response " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_DISCONNECTED ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " response-timeout " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_TIMEOUT ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 401 " ) = = 0 )
2020-11-12 05:14:05 -05:00
curpx - > retry_type | = PR_RE_401 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 403 " ) = = 0 )
2020-11-12 05:14:05 -05:00
curpx - > retry_type | = PR_RE_403 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 404 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_404 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 408 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_408 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 425 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_425 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 500 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_500 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 501 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_501 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 502 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_502 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 503 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_503 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 504 " ) = = 0 )
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
curpx - > retry_type | = PR_RE_504 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " 0rtt-rejected " ) = = 0 )
2019-05-03 16:46:27 -04:00
curpx - > retry_type | = PR_RE_EARLY_ERROR ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " junk-response " ) = = 0 )
2019-05-03 17:01:47 -04:00
curpx - > retry_type | = PR_RE_JUNK_REQUEST ;
MINOR: streams: Introduce a new retry-on keyword, all-retryable-errors.
Add a new retry-on keyword, "all-retryable-errors", that activates retry
for all errors that are considered retryable.
This currently activates retry for "conn-failure", "empty-response",
"junk-respones", "response-timeout", "0rtt-rejected", "500", "502", "503" and
"504".
2019-05-10 12:05:40 -04:00
else if ( ! ( strcmp ( args [ i ] , " all-retryable-errors " ) ) )
curpx - > retry_type | = PR_RE_CONN_FAILED | PR_RE_DISCONNECTED |
PR_RE_TIMEOUT | PR_RE_500 | PR_RE_502 |
PR_RE_503 | PR_RE_504 | PR_RE_EARLY_ERROR |
PR_RE_JUNK_REQUEST ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
else if ( strcmp ( args [ i ] , " none " ) = = 0 ) {
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
if ( i ! = 1 | | * args [ i + 1 ] ) {
memprintf ( err , " '%s' 'none' keyworld only usable alone " , args [ 0 ] ) ;
return - 1 ;
}
} else {
memprintf ( err , " '%s': unknown keyword '%s' " , args [ 0 ] , args [ i ] ) ;
return - 1 ;
}
}
return 0 ;
}
2020-07-08 23:58:51 -04:00
# ifdef TCP_KEEPCNT
2020-07-08 22:13:20 -04:00
/* This function parses "{cli|srv}tcpka-cnt" statements */
static int proxy_parse_tcpka_cnt ( char * * args , int section , struct proxy * proxy ,
struct proxy * defpx , const char * file , int line ,
char * * err )
{
int retval ;
char * res ;
unsigned int tcpka_cnt ;
retval = 0 ;
if ( * args [ 1 ] = = 0 ) {
memprintf ( err , " '%s' expects an integer value " , args [ 0 ] ) ;
return - 1 ;
}
tcpka_cnt = strtol ( args [ 1 ] , & res , 0 ) ;
if ( * res ) {
memprintf ( err , " '%s' : unexpected character '%c' in integer value '%s' " , args [ 0 ] , * res , args [ 1 ] ) ;
return - 1 ;
}
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
if ( strcmp ( args [ 0 ] , " clitcpka-cnt " ) = = 0 ) {
2020-07-08 22:13:20 -04:00
if ( ! ( proxy - > cap & PR_CAP_FE ) ) {
memprintf ( err , " %s will be ignored because %s '%s' has no frontend capability " ,
args [ 0 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
retval = 1 ;
}
proxy - > clitcpka_cnt = tcpka_cnt ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " srvtcpka-cnt " ) = = 0 ) {
2020-07-08 22:13:20 -04:00
if ( ! ( proxy - > cap & PR_CAP_BE ) ) {
memprintf ( err , " %s will be ignored because %s '%s' has no backend capability " ,
args [ 0 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
retval = 1 ;
}
proxy - > srvtcpka_cnt = tcpka_cnt ;
} else {
/* unreachable */
memprintf ( err , " '%s': unknown keyword " , args [ 0 ] ) ;
return - 1 ;
}
return retval ;
}
2020-07-08 23:58:51 -04:00
# endif
2020-07-08 22:13:20 -04:00
2020-07-08 23:58:51 -04:00
# ifdef TCP_KEEPIDLE
2020-07-08 22:13:20 -04:00
/* This function parses "{cli|srv}tcpka-idle" statements */
static int proxy_parse_tcpka_idle ( char * * args , int section , struct proxy * proxy ,
struct proxy * defpx , const char * file , int line ,
char * * err )
{
int retval ;
const char * res ;
unsigned int tcpka_idle ;
retval = 0 ;
if ( * args [ 1 ] = = 0 ) {
memprintf ( err , " '%s' expects an integer value " , args [ 0 ] ) ;
return - 1 ;
}
res = parse_time_err ( args [ 1 ] , & tcpka_idle , TIME_UNIT_S ) ;
if ( res = = PARSE_TIME_OVER ) {
memprintf ( err , " timer overflow in argument '%s' to '%s' (maximum value is 2147483647 ms or ~24.8 days) " ,
args [ 1 ] , args [ 0 ] ) ;
return - 1 ;
}
else if ( res = = PARSE_TIME_UNDER ) {
memprintf ( err , " timer underflow in argument '%s' to '%s' (minimum non-null value is 1 ms) " ,
args [ 1 ] , args [ 0 ] ) ;
return - 1 ;
}
else if ( res ) {
memprintf ( err , " unexpected character '%c' in argument to <%s>. \n " , * res , args [ 0 ] ) ;
return - 1 ;
}
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
if ( strcmp ( args [ 0 ] , " clitcpka-idle " ) = = 0 ) {
2020-07-08 22:13:20 -04:00
if ( ! ( proxy - > cap & PR_CAP_FE ) ) {
memprintf ( err , " %s will be ignored because %s '%s' has no frontend capability " ,
args [ 0 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
retval = 1 ;
}
proxy - > clitcpka_idle = tcpka_idle ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " srvtcpka-idle " ) = = 0 ) {
2020-07-08 22:13:20 -04:00
if ( ! ( proxy - > cap & PR_CAP_BE ) ) {
memprintf ( err , " %s will be ignored because %s '%s' has no backend capability " ,
args [ 0 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
retval = 1 ;
}
proxy - > srvtcpka_idle = tcpka_idle ;
} else {
/* unreachable */
memprintf ( err , " '%s': unknown keyword " , args [ 0 ] ) ;
return - 1 ;
}
return retval ;
}
2020-07-08 23:58:51 -04:00
# endif
2020-07-08 22:13:20 -04:00
2020-07-08 23:58:51 -04:00
# ifdef TCP_KEEPINTVL
2020-07-08 22:13:20 -04:00
/* This function parses "{cli|srv}tcpka-intvl" statements */
static int proxy_parse_tcpka_intvl ( char * * args , int section , struct proxy * proxy ,
struct proxy * defpx , const char * file , int line ,
char * * err )
{
int retval ;
const char * res ;
unsigned int tcpka_intvl ;
retval = 0 ;
if ( * args [ 1 ] = = 0 ) {
memprintf ( err , " '%s' expects an integer value " , args [ 0 ] ) ;
return - 1 ;
}
res = parse_time_err ( args [ 1 ] , & tcpka_intvl , TIME_UNIT_S ) ;
if ( res = = PARSE_TIME_OVER ) {
memprintf ( err , " timer overflow in argument '%s' to '%s' (maximum value is 2147483647 ms or ~24.8 days) " ,
args [ 1 ] , args [ 0 ] ) ;
return - 1 ;
}
else if ( res = = PARSE_TIME_UNDER ) {
memprintf ( err , " timer underflow in argument '%s' to '%s' (minimum non-null value is 1 ms) " ,
args [ 1 ] , args [ 0 ] ) ;
return - 1 ;
}
else if ( res ) {
memprintf ( err , " unexpected character '%c' in argument to <%s>. \n " , * res , args [ 0 ] ) ;
return - 1 ;
}
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
if ( strcmp ( args [ 0 ] , " clitcpka-intvl " ) = = 0 ) {
2020-07-08 22:13:20 -04:00
if ( ! ( proxy - > cap & PR_CAP_FE ) ) {
memprintf ( err , " %s will be ignored because %s '%s' has no frontend capability " ,
args [ 0 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
retval = 1 ;
}
proxy - > clitcpka_intvl = tcpka_intvl ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
} else if ( strcmp ( args [ 0 ] , " srvtcpka-intvl " ) = = 0 ) {
2020-07-08 22:13:20 -04:00
if ( ! ( proxy - > cap & PR_CAP_BE ) ) {
memprintf ( err , " %s will be ignored because %s '%s' has no backend capability " ,
args [ 0 ] , proxy_type_str ( proxy ) , proxy - > id ) ;
retval = 1 ;
}
proxy - > srvtcpka_intvl = tcpka_intvl ;
} else {
/* unreachable */
memprintf ( err , " '%s': unknown keyword " , args [ 0 ] ) ;
return - 1 ;
}
return retval ;
}
2020-07-08 23:58:51 -04:00
# endif
2020-07-08 22:13:20 -04:00
2014-03-15 02:22:35 -04:00
/* This function inserts proxy <px> into the tree of known proxies. The proxy's
* name is used as the storing key so it must already have been initialized .
*/
void proxy_store_name ( struct proxy * px )
{
px - > conf . by_name . key = px - > id ;
ebis_insert ( & proxy_by_name , & px - > conf . by_name ) ;
}
2015-05-26 09:25:32 -04:00
/* Returns a pointer to the first proxy matching capabilities <cap> and id
* < id > . NULL is returned if no match is found . If < table > is non - zero , it
* only considers proxies having a table .
2011-08-02 05:25:54 -04:00
*/
2015-05-26 09:25:32 -04:00
struct proxy * proxy_find_by_id ( int id , int cap , int table )
2015-05-26 05:24:42 -04:00
{
2015-05-26 09:25:32 -04:00
struct eb32_node * n ;
2011-08-02 05:25:54 -04:00
2015-05-26 09:25:32 -04:00
for ( n = eb32_lookup ( & used_proxy_id , id ) ; n ; n = eb32_next ( n ) ) {
struct proxy * px = container_of ( n , struct proxy , conf . id ) ;
2014-03-15 02:43:51 -04:00
2015-05-26 09:25:32 -04:00
if ( px - > uuid ! = id )
break ;
2009-11-01 21:27:13 -05:00
2015-05-26 09:25:32 -04:00
if ( ( px - > cap & cap ) ! = cap )
continue ;
2014-03-15 02:43:51 -04:00
2019-03-14 02:07:41 -04:00
if ( table & & ( ! px - > table | | ! px - > table - > size ) )
2015-05-26 09:25:32 -04:00
continue ;
2014-03-15 02:43:51 -04:00
2015-05-26 09:25:32 -04:00
return px ;
}
return NULL ;
}
2014-03-15 02:43:51 -04:00
2015-05-26 09:25:32 -04:00
/* Returns a pointer to the first proxy matching either name <name>, or id
* < name > if < name > begins with a ' # ' . NULL is returned if no match is found .
* If < table > is non - zero , it only considers proxies having a table .
*/
struct proxy * proxy_find_by_name ( const char * name , int cap , int table )
{
struct proxy * curproxy ;
2015-05-26 05:24:42 -04:00
2015-05-26 09:25:32 -04:00
if ( * name = = ' # ' ) {
curproxy = proxy_find_by_id ( atoi ( name + 1 ) , cap , table ) ;
if ( curproxy )
2015-05-26 05:35:41 -04:00
return curproxy ;
2009-11-01 21:27:13 -05:00
}
2014-03-15 02:43:51 -04:00
else {
struct ebpt_node * node ;
for ( node = ebis_lookup ( & proxy_by_name , name ) ; node ; node = ebpt_next ( node ) ) {
curproxy = container_of ( node , struct proxy , conf . by_name ) ;
if ( strcmp ( curproxy - > id , name ) ! = 0 )
break ;
if ( ( curproxy - > cap & cap ) ! = cap )
continue ;
2009-11-01 21:27:13 -05:00
2019-03-14 02:07:41 -04:00
if ( table & & ( ! curproxy - > table | | ! curproxy - > table - > size ) )
2015-05-26 05:24:42 -04:00
continue ;
2015-05-26 05:35:41 -04:00
return curproxy ;
2014-03-15 02:43:51 -04:00
}
}
2015-05-26 05:35:41 -04:00
return NULL ;
2009-11-01 21:27:13 -05:00
}
2015-05-27 10:46:26 -04:00
/* Finds the best match for a proxy with capabilities <cap>, name <name> and id
* < id > . At most one of < id > or < name > may be different provided that < cap > is
* valid . Either < id > or < name > may be left unspecified ( 0 ) . The purpose is to
* find a proxy based on some information from a previous configuration , across
* reloads or during information exchange between peers .
*
* Names are looked up first if present , then IDs are compared if present . In
* case of an inexact match whatever is forced in the configuration has
* precedence in the following order :
* - 1 ) forced ID ( proves a renaming / change of proxy type )
* - 2 ) proxy name + type ( may indicate a move if ID differs )
* - 3 ) automatic ID + type ( may indicate a renaming )
*
* Depending on what is found , we can end up in the following situations :
*
* name id cap | possible causes
* - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
* - - - - - - | nothing found
* - - - - ok | nothing found
* - - ok - - | proxy deleted , ID points to next one
* - - ok ok | proxy renamed , or deleted with ID pointing to next one
* ok - - - - | proxy deleted , but other half with same name still here ( before )
* ok - - ok | proxy ' s ID changed ( proxy moved in the config file )
* ok ok - - | proxy deleted , but other half with same name still here ( after )
* ok ok ok | perfect match
*
* Upon return if < diff > is not NULL , it is zeroed then filled with up to 3 bits :
2015-07-03 05:03:33 -04:00
* - PR_FBM_MISMATCH_ID : proxy was found but ID differs
* ( and ID was not zero )
* - PR_FBM_MISMATCH_NAME : proxy was found by ID but name differs
* ( and name was not NULL )
* - PR_FBM_MISMATCH_PROXYTYPE : a proxy of different type was found with
* the same name and / or id
2015-05-27 10:46:26 -04:00
*
* Only a valid proxy is returned . If capabilities do not match , NULL is
* returned . The caller can check < diff > to report detailed warnings / errors ,
* and decide whether or not to use what was found .
*/
struct proxy * proxy_find_best_match ( int cap , const char * name , int id , int * diff )
{
struct proxy * byname ;
struct proxy * byid ;
if ( ! name & & ! id )
return NULL ;
if ( diff )
* diff = 0 ;
byname = byid = NULL ;
if ( name ) {
byname = proxy_find_by_name ( name , cap , 0 ) ;
if ( byname & & ( ! id | | byname - > uuid = = id ) )
return byname ;
}
2018-11-15 14:46:55 -05:00
/* remaining possibilities :
2015-05-27 10:46:26 -04:00
* - name not set
* - name set but not found
* - name found , but ID doesn ' t match .
*/
if ( id ) {
byid = proxy_find_by_id ( id , cap , 0 ) ;
if ( byid ) {
if ( byname ) {
/* id+type found, name+type found, but not all 3.
* ID wins only if forced , otherwise name wins .
*/
if ( byid - > options & PR_O_FORCED_ID ) {
if ( diff )
2015-07-03 05:03:33 -04:00
* diff | = PR_FBM_MISMATCH_NAME ;
2015-05-27 10:46:26 -04:00
return byid ;
}
else {
if ( diff )
2015-07-03 05:03:33 -04:00
* diff | = PR_FBM_MISMATCH_ID ;
2015-05-27 10:46:26 -04:00
return byname ;
}
}
2018-11-15 14:46:55 -05:00
/* remaining possibilities :
2015-05-27 10:46:26 -04:00
* - name not set
* - name set but not found
*/
if ( name & & diff )
2015-07-03 05:03:33 -04:00
* diff | = PR_FBM_MISMATCH_NAME ;
2015-05-27 10:46:26 -04:00
return byid ;
}
/* ID not found */
if ( byname ) {
if ( diff )
2015-07-03 05:03:33 -04:00
* diff | = PR_FBM_MISMATCH_ID ;
2015-05-27 10:46:26 -04:00
return byname ;
}
}
2018-11-15 14:46:55 -05:00
/* All remaining possibilities will lead to NULL. If we can report more
2015-05-27 10:46:26 -04:00
* detailed information to the caller about changed types and / or name ,
* we ' ll do it . For example , we could detect that " listen foo " was
* split into " frontend foo_ft " and " backend foo_bk " if IDs are forced .
* - name not set , ID not found
* - name not found , ID not set
* - name not found , ID not found
*/
if ( ! diff )
return NULL ;
if ( name ) {
byname = proxy_find_by_name ( name , 0 , 0 ) ;
if ( byname & & ( ! id | | byname - > uuid = = id ) )
2015-07-03 05:03:33 -04:00
* diff | = PR_FBM_MISMATCH_PROXYTYPE ;
2015-05-27 10:46:26 -04:00
}
if ( id ) {
byid = proxy_find_by_id ( id , 0 , 0 ) ;
if ( byid ) {
if ( ! name )
2015-07-03 05:03:33 -04:00
* diff | = PR_FBM_MISMATCH_PROXYTYPE ; /* only type changed */
2015-05-27 10:46:26 -04:00
else if ( byid - > options & PR_O_FORCED_ID )
2015-07-03 05:03:33 -04:00
* diff | = PR_FBM_MISMATCH_NAME | PR_FBM_MISMATCH_PROXYTYPE ; /* name and type changed */
2015-05-27 10:46:26 -04:00
/* otherwise it's a different proxy that was returned */
}
}
return NULL ;
}
2008-02-17 19:26:35 -05:00
/*
* This function finds a server with matching name within selected proxy .
* It also checks if there are more matching servers with
* requested name as this often leads into unexpected situations .
*/
struct server * findserver ( const struct proxy * px , const char * name ) {
struct server * cursrv , * target = NULL ;
if ( ! px )
return NULL ;
for ( cursrv = px - > srv ; cursrv ; cursrv = cursrv - > next ) {
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
if ( strcmp ( cursrv - > id , name ) ! = 0 )
2008-02-17 19:26:35 -05:00
continue ;
if ( ! target ) {
target = cursrv ;
continue ;
}
2017-11-24 10:50:31 -05:00
ha_alert ( " Refusing to use duplicated server '%s' found in proxy: %s! \n " ,
name , px - > id ) ;
2008-02-17 19:26:35 -05:00
return NULL ;
}
return target ;
}
2009-03-15 08:46:16 -04:00
/* This function checks that the designated proxy has no http directives
* enabled . It will output a warning if there are , and will fix some of them .
* It returns the number of fatal errors encountered . This should be called
* at the end of the configuration parsing if the proxy is not in http mode .
* The < file > argument is used to construct the error message .
*/
2009-06-22 09:48:36 -04:00
int proxy_cfg_ensure_no_http ( struct proxy * curproxy )
2009-03-15 08:46:16 -04:00
{
if ( curproxy - > cookie_name ! = NULL ) {
2017-11-24 10:50:31 -05:00
ha_warning ( " config : cookie will be ignored for %s '%s' (needs 'mode http'). \n " ,
proxy_type_str ( curproxy ) , curproxy - > id ) ;
2009-03-15 08:46:16 -04:00
}
if ( curproxy - > monitor_uri ! = NULL ) {
2017-11-24 10:50:31 -05:00
ha_warning ( " config : monitor-uri will be ignored for %s '%s' (needs 'mode http'). \n " ,
proxy_type_str ( curproxy ) , curproxy - > id ) ;
2009-03-15 08:46:16 -04:00
}
2009-10-03 06:21:20 -04:00
if ( curproxy - > lbprm . algo & BE_LB_NEED_HTTP ) {
2009-03-15 08:46:16 -04:00
curproxy - > lbprm . algo & = ~ BE_LB_ALGO ;
curproxy - > lbprm . algo | = BE_LB_ALGO_RR ;
2017-11-24 10:50:31 -05:00
ha_warning ( " config : Layer 7 hash not possible for %s '%s' (needs 'mode http'). Falling back to round robin. \n " ,
proxy_type_str ( curproxy ) , curproxy - > id ) ;
2009-03-15 08:46:16 -04:00
}
2009-11-09 15:27:51 -05:00
if ( curproxy - > to_log & ( LW_REQ | LW_RESP ) ) {
curproxy - > to_log & = ~ ( LW_REQ | LW_RESP ) ;
2017-11-24 10:50:31 -05:00
ha_warning ( " parsing [%s:%d] : HTTP log/header format not usable with %s '%s' (needs 'mode http'). \n " ,
curproxy - > conf . lfs_file , curproxy - > conf . lfs_line ,
proxy_type_str ( curproxy ) , curproxy - > id ) ;
2009-11-09 15:27:51 -05:00
}
2013-04-12 12:13:46 -04:00
if ( curproxy - > conf . logformat_string = = default_http_log_format | |
curproxy - > conf . logformat_string = = clf_http_log_format ) {
/* Note: we don't change the directive's file:line number */
curproxy - > conf . logformat_string = default_tcp_log_format ;
2017-11-24 10:50:31 -05:00
ha_warning ( " parsing [%s:%d] : 'option httplog' not usable with %s '%s' (needs 'mode http'). Falling back to 'option tcplog'. \n " ,
curproxy - > conf . lfs_file , curproxy - > conf . lfs_line ,
proxy_type_str ( curproxy ) , curproxy - > id ) ;
2012-05-31 13:30:26 -04:00
}
2009-03-15 08:46:16 -04:00
return 0 ;
}
2011-07-28 19:49:03 -04:00
/* Perform the most basic initialization of a proxy :
* memset ( ) , list_init ( * ) , reset_timeouts ( * ) .
2011-09-07 12:41:08 -04:00
* Any new proxy or peer should be initialized via this function .
2011-07-28 19:49:03 -04:00
*/
void init_new_proxy ( struct proxy * p )
{
memset ( p , 0 , sizeof ( struct proxy ) ) ;
2012-11-11 18:42:33 -05:00
p - > obj_type = OBJ_TYPE_PROXY ;
2018-05-11 12:52:31 -04:00
p - > pendconns = EB_ROOT ;
2011-07-28 19:49:03 -04:00
LIST_INIT ( & p - > acl ) ;
LIST_INIT ( & p - > http_req_rules ) ;
2013-06-11 10:06:12 -04:00
LIST_INIT ( & p - > http_res_rules ) ;
2020-01-22 03:26:35 -05:00
LIST_INIT ( & p - > http_after_res_rules ) ;
2011-07-28 19:49:03 -04:00
LIST_INIT ( & p - > redirect_rules ) ;
LIST_INIT ( & p - > mon_fail_cond ) ;
LIST_INIT ( & p - > switching_rules ) ;
2012-04-05 15:09:48 -04:00
LIST_INIT ( & p - > server_rules ) ;
2011-07-28 19:49:03 -04:00
LIST_INIT ( & p - > persist_rules ) ;
LIST_INIT ( & p - > sticking_rules ) ;
LIST_INIT ( & p - > storersp_rules ) ;
LIST_INIT ( & p - > tcp_req . inspect_rules ) ;
LIST_INIT ( & p - > tcp_rep . inspect_rules ) ;
LIST_INIT ( & p - > tcp_req . l4_rules ) ;
2016-10-21 10:37:51 -04:00
LIST_INIT ( & p - > tcp_req . l5_rules ) ;
2019-08-08 09:47:21 -04:00
MT_LIST_INIT ( & p - > listener_queue ) ;
2011-10-12 11:50:54 -04:00
LIST_INIT ( & p - > logsrvs ) ;
2012-02-08 10:37:49 -05:00
LIST_INIT ( & p - > logformat ) ;
2015-09-25 13:17:44 -04:00
LIST_INIT ( & p - > logformat_sd ) ;
2012-03-12 07:48:57 -04:00
LIST_INIT ( & p - > format_unique_id ) ;
2012-09-13 11:54:29 -04:00
LIST_INIT ( & p - > conf . bind ) ;
2012-09-20 10:48:07 -04:00
LIST_INIT ( & p - > conf . listeners ) ;
2020-01-13 09:52:01 -05:00
LIST_INIT ( & p - > conf . errors ) ;
MAJOR: sample: maintain a per-proxy list of the fetch args to resolve
While ACL args were resolved after all the config was parsed, it was not the
case with sample fetch args because they're almost everywhere now.
The issue is that ACLs now solely rely on sample fetches, so their args
resolving doesn't work anymore. And many fetches involving a server, a
proxy or a userlist don't work at all.
The real issue is that at the bottom layers we have no information about
proxies, line numbers, even ACLs in order to report understandable errors,
and that at the top layers we have no visibility over the locations where
fetches are referenced (think log node).
After failing multiple unsatisfying solutions attempts, we now have a new
concept of args list. The principle is that every proxy has a list head
which contains a number of indications such as the config keyword, the
context where it's used, the file and line number, etc... and a list of
arguments. This list head is of the same type as the elements, so it
serves as a template for adding new elements. This way, it is filled from
top to bottom by the callers with the information they have (eg: line
numbers, ACL name, ...) and the lower layers just have to duplicate it and
add an element when they face an argument they cannot resolve yet.
Then at the end of the configuration parsing, a loop passes over each
proxy's list and resolves all the args in sequence. And this way there is
all necessary information to report verbose errors.
The first immediate benefit is that for the first time we got very precise
location of issues (arg number in a keyword in its context, ...). Second,
in order to do this we had to parse log-format and unique-id-format a bit
earlier, so that was a great opportunity for doing so when the directives
are encountered (unless it's a default section). This way, the recorded
line numbers for these args are the ones of the place where the log format
is declared, not the end of the file.
Userlists report slightly more information now. They're the only remaining
ones in the ACL resolving function.
2013-04-02 10:34:32 -04:00
LIST_INIT ( & p - > conf . args . list ) ;
2016-02-04 07:40:26 -05:00
LIST_INIT ( & p - > filter_configs ) ;
2020-04-02 12:05:11 -04:00
LIST_INIT ( & p - > tcpcheck_rules . preset_vars ) ;
2011-07-28 19:49:03 -04:00
2021-02-12 03:15:16 -05:00
p - > defsrv . id = " default-server " ;
p - > conf . used_listener_id = EB_ROOT ;
p - > conf . used_server_id = EB_ROOT ;
p - > used_server_addr = EB_ROOT_UNIQUE ;
2011-07-28 19:49:03 -04:00
/* Timeouts are defined as -1 */
proxy_reset_timeouts ( p ) ;
p - > tcp_rep . inspect_delay = TICK_ETERNITY ;
2012-10-04 02:47:34 -04:00
/* initial uuid is unassigned (-1) */
p - > uuid = - 1 ;
2017-06-02 09:33:24 -04:00
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
/* Default to only allow L4 retries */
p - > retry_type = PR_RE_CONN_FAILED ;
2020-11-10 08:24:31 -05:00
p - > extra_counters_fe = NULL ;
p - > extra_counters_be = NULL ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_INIT ( & p - > lock ) ;
2011-07-28 19:49:03 -04:00
}
2021-02-12 02:19:01 -05:00
/* Preset default settings onto proxy <defproxy>. */
void proxy_preset_defaults ( struct proxy * defproxy )
{
defproxy - > mode = PR_MODE_TCP ;
defproxy - > disabled = 0 ;
defproxy - > maxconn = cfg_maxpconn ;
defproxy - > conn_retries = CONN_RETRIES ;
defproxy - > redispatch_after = 0 ;
defproxy - > options = PR_O_REUSE_SAFE ;
defproxy - > max_out_conns = MAX_SRV_LIST ;
defproxy - > defsrv . check . inter = DEF_CHKINTR ;
defproxy - > defsrv . check . fastinter = 0 ;
defproxy - > defsrv . check . downinter = 0 ;
defproxy - > defsrv . agent . inter = DEF_CHKINTR ;
defproxy - > defsrv . agent . fastinter = 0 ;
defproxy - > defsrv . agent . downinter = 0 ;
defproxy - > defsrv . check . rise = DEF_RISETIME ;
defproxy - > defsrv . check . fall = DEF_FALLTIME ;
defproxy - > defsrv . agent . rise = DEF_AGENT_RISETIME ;
defproxy - > defsrv . agent . fall = DEF_AGENT_FALLTIME ;
defproxy - > defsrv . check . port = 0 ;
defproxy - > defsrv . agent . port = 0 ;
defproxy - > defsrv . maxqueue = 0 ;
defproxy - > defsrv . minconn = 0 ;
defproxy - > defsrv . maxconn = 0 ;
defproxy - > defsrv . max_reuse = - 1 ;
defproxy - > defsrv . max_idle_conns = - 1 ;
defproxy - > defsrv . pool_purge_delay = 5000 ;
defproxy - > defsrv . slowstart = 0 ;
defproxy - > defsrv . onerror = DEF_HANA_ONERR ;
defproxy - > defsrv . consecutive_errors_limit = DEF_HANA_ERRLIMIT ;
defproxy - > defsrv . uweight = defproxy - > defsrv . iweight = 1 ;
defproxy - > email_alert . level = LOG_ALERT ;
defproxy - > load_server_state_from_file = PR_SRV_STATE_FILE_UNSPEC ;
# if defined(USE_QUIC)
quic_transport_params_init ( & defproxy - > defsrv . quic_params , 0 ) ;
# endif
}
2021-02-12 02:49:47 -05:00
/* Allocates a new proxy <name> of type <cap> found at position <file:linenum>,
* preset it from the defaults of < defproxy > and returns it . Un case of error ,
* an alert is printed and NULL is returned . If < errmsg > is not NULL , an error
2021-02-12 03:15:16 -05:00
* message will be returned there in case of fatal error . If < defproxy > is NULL ,
* the documented default settings will be used instead .
2021-02-12 02:49:47 -05:00
*/
struct proxy * alloc_new_proxy ( const char * name , unsigned int cap , const char * file , int linenum , const struct proxy * defproxy , char * * errmsg )
{
struct logsrv * tmplogsrv ;
struct proxy * curproxy ;
char * tmpmsg = NULL ;
if ( ( curproxy = calloc ( 1 , sizeof ( * curproxy ) ) ) = = NULL ) {
memprintf ( errmsg , " proxy '%s': out of memory " , name ) ;
goto fail ;
}
init_new_proxy ( curproxy ) ;
curproxy - > conf . args . file = curproxy - > conf . file = strdup ( file ) ;
curproxy - > conf . args . line = curproxy - > conf . line = linenum ;
curproxy - > last_change = now . tv_sec ;
curproxy - > id = strdup ( name ) ;
curproxy - > cap = cap ;
proxy_store_name ( curproxy ) ;
2021-02-12 03:15:16 -05:00
if ( ! defproxy ) {
proxy_preset_defaults ( curproxy ) ;
goto done ;
}
/* set default values from the specified default proxy */
2021-02-12 02:49:47 -05:00
memcpy ( & curproxy - > defsrv , & defproxy - > defsrv , sizeof ( curproxy - > defsrv ) ) ;
curproxy - > disabled = defproxy - > disabled ;
curproxy - > options = defproxy - > options ;
curproxy - > options2 = defproxy - > options2 ;
curproxy - > no_options = defproxy - > no_options ;
curproxy - > no_options2 = defproxy - > no_options2 ;
curproxy - > bind_proc = defproxy - > bind_proc ;
curproxy - > except_net = defproxy - > except_net ;
curproxy - > except_mask = defproxy - > except_mask ;
curproxy - > except_to = defproxy - > except_to ;
curproxy - > except_mask_to = defproxy - > except_mask_to ;
curproxy - > retry_type = defproxy - > retry_type ;
if ( defproxy - > fwdfor_hdr_len ) {
curproxy - > fwdfor_hdr_len = defproxy - > fwdfor_hdr_len ;
curproxy - > fwdfor_hdr_name = strdup ( defproxy - > fwdfor_hdr_name ) ;
}
if ( defproxy - > orgto_hdr_len ) {
curproxy - > orgto_hdr_len = defproxy - > orgto_hdr_len ;
curproxy - > orgto_hdr_name = strdup ( defproxy - > orgto_hdr_name ) ;
}
if ( defproxy - > server_id_hdr_len ) {
curproxy - > server_id_hdr_len = defproxy - > server_id_hdr_len ;
curproxy - > server_id_hdr_name = strdup ( defproxy - > server_id_hdr_name ) ;
}
/* initialize error relocations */
if ( ! proxy_dup_default_conf_errors ( curproxy , defproxy , & tmpmsg ) ) {
memprintf ( errmsg , " proxy '%s' : %s " , curproxy - > id , tmpmsg ) ;
goto fail ;
}
if ( curproxy - > cap & PR_CAP_FE ) {
curproxy - > maxconn = defproxy - > maxconn ;
curproxy - > backlog = defproxy - > backlog ;
curproxy - > fe_sps_lim = defproxy - > fe_sps_lim ;
curproxy - > to_log = defproxy - > to_log & ~ LW_COOKIE & ~ LW_REQHDR & ~ LW_RSPHDR ;
curproxy - > max_out_conns = defproxy - > max_out_conns ;
curproxy - > clitcpka_cnt = defproxy - > clitcpka_cnt ;
curproxy - > clitcpka_idle = defproxy - > clitcpka_idle ;
curproxy - > clitcpka_intvl = defproxy - > clitcpka_intvl ;
}
if ( curproxy - > cap & PR_CAP_BE ) {
curproxy - > lbprm . algo = defproxy - > lbprm . algo ;
curproxy - > lbprm . hash_balance_factor = defproxy - > lbprm . hash_balance_factor ;
curproxy - > fullconn = defproxy - > fullconn ;
curproxy - > conn_retries = defproxy - > conn_retries ;
curproxy - > redispatch_after = defproxy - > redispatch_after ;
curproxy - > max_ka_queue = defproxy - > max_ka_queue ;
curproxy - > tcpcheck_rules . flags = ( defproxy - > tcpcheck_rules . flags & ~ TCPCHK_RULES_UNUSED_RS ) ;
curproxy - > tcpcheck_rules . list = defproxy - > tcpcheck_rules . list ;
if ( ! LIST_ISEMPTY ( & defproxy - > tcpcheck_rules . preset_vars ) ) {
if ( ! dup_tcpcheck_vars ( & curproxy - > tcpcheck_rules . preset_vars ,
& defproxy - > tcpcheck_rules . preset_vars ) ) {
memprintf ( errmsg , " proxy '%s': failed to duplicate tcpcheck preset-vars " , name ) ;
goto fail ;
}
}
curproxy - > ck_opts = defproxy - > ck_opts ;
if ( defproxy - > cookie_name )
curproxy - > cookie_name = strdup ( defproxy - > cookie_name ) ;
curproxy - > cookie_len = defproxy - > cookie_len ;
if ( defproxy - > dyncookie_key )
curproxy - > dyncookie_key = strdup ( defproxy - > dyncookie_key ) ;
if ( defproxy - > cookie_domain )
curproxy - > cookie_domain = strdup ( defproxy - > cookie_domain ) ;
if ( defproxy - > cookie_maxidle )
curproxy - > cookie_maxidle = defproxy - > cookie_maxidle ;
if ( defproxy - > cookie_maxlife )
curproxy - > cookie_maxlife = defproxy - > cookie_maxlife ;
if ( defproxy - > rdp_cookie_name )
curproxy - > rdp_cookie_name = strdup ( defproxy - > rdp_cookie_name ) ;
curproxy - > rdp_cookie_len = defproxy - > rdp_cookie_len ;
if ( defproxy - > cookie_attrs )
curproxy - > cookie_attrs = strdup ( defproxy - > cookie_attrs ) ;
if ( defproxy - > lbprm . arg_str )
curproxy - > lbprm . arg_str = strdup ( defproxy - > lbprm . arg_str ) ;
curproxy - > lbprm . arg_len = defproxy - > lbprm . arg_len ;
curproxy - > lbprm . arg_opt1 = defproxy - > lbprm . arg_opt1 ;
curproxy - > lbprm . arg_opt2 = defproxy - > lbprm . arg_opt2 ;
curproxy - > lbprm . arg_opt3 = defproxy - > lbprm . arg_opt3 ;
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 ;
curproxy - > conn_src . opts = defproxy - > conn_src . opts ;
# if defined(CONFIG_HAP_TRANSPARENT)
curproxy - > conn_src . tproxy_addr = defproxy - > conn_src . tproxy_addr ;
# endif
curproxy - > load_server_state_from_file = defproxy - > load_server_state_from_file ;
curproxy - > srvtcpka_cnt = defproxy - > srvtcpka_cnt ;
curproxy - > srvtcpka_idle = defproxy - > srvtcpka_idle ;
curproxy - > srvtcpka_intvl = defproxy - > srvtcpka_intvl ;
}
if ( curproxy - > cap & PR_CAP_FE ) {
if ( defproxy - > capture_name )
curproxy - > capture_name = strdup ( defproxy - > capture_name ) ;
curproxy - > capture_namelen = defproxy - > capture_namelen ;
curproxy - > capture_len = defproxy - > capture_len ;
}
if ( curproxy - > cap & PR_CAP_FE ) {
curproxy - > timeout . client = defproxy - > timeout . client ;
curproxy - > timeout . clientfin = defproxy - > timeout . clientfin ;
curproxy - > timeout . tarpit = defproxy - > timeout . tarpit ;
curproxy - > timeout . httpreq = defproxy - > timeout . httpreq ;
curproxy - > timeout . httpka = defproxy - > timeout . httpka ;
if ( defproxy - > monitor_uri )
curproxy - > monitor_uri = strdup ( defproxy - > monitor_uri ) ;
curproxy - > monitor_uri_len = defproxy - > monitor_uri_len ;
if ( defproxy - > defbe . name )
curproxy - > defbe . name = strdup ( defproxy - > defbe . name ) ;
/* get either a pointer to the logformat string or a copy of it */
curproxy - > conf . logformat_string = defproxy - > conf . logformat_string ;
if ( curproxy - > conf . logformat_string & &
curproxy - > conf . logformat_string ! = default_http_log_format & &
curproxy - > conf . logformat_string ! = default_tcp_log_format & &
curproxy - > conf . logformat_string ! = clf_http_log_format )
curproxy - > conf . logformat_string = strdup ( curproxy - > conf . logformat_string ) ;
if ( defproxy - > conf . lfs_file ) {
curproxy - > conf . lfs_file = strdup ( defproxy - > conf . lfs_file ) ;
curproxy - > conf . lfs_line = defproxy - > conf . lfs_line ;
}
/* get either a pointer to the logformat string for RFC5424 structured-data or a copy of it */
curproxy - > conf . logformat_sd_string = defproxy - > conf . logformat_sd_string ;
if ( curproxy - > conf . logformat_sd_string & &
curproxy - > conf . logformat_sd_string ! = default_rfc5424_sd_log_format )
curproxy - > conf . logformat_sd_string = strdup ( curproxy - > conf . logformat_sd_string ) ;
if ( defproxy - > conf . lfsd_file ) {
curproxy - > conf . lfsd_file = strdup ( defproxy - > conf . lfsd_file ) ;
curproxy - > conf . lfsd_line = defproxy - > conf . lfsd_line ;
}
}
if ( curproxy - > cap & PR_CAP_BE ) {
curproxy - > timeout . connect = defproxy - > timeout . connect ;
curproxy - > timeout . server = defproxy - > timeout . server ;
curproxy - > timeout . serverfin = defproxy - > timeout . serverfin ;
curproxy - > timeout . check = defproxy - > timeout . check ;
curproxy - > timeout . queue = defproxy - > timeout . queue ;
curproxy - > timeout . tarpit = defproxy - > timeout . tarpit ;
curproxy - > timeout . httpreq = defproxy - > timeout . httpreq ;
curproxy - > timeout . httpka = defproxy - > timeout . httpka ;
curproxy - > timeout . tunnel = defproxy - > timeout . tunnel ;
curproxy - > conn_src . source_addr = defproxy - > conn_src . source_addr ;
}
curproxy - > mode = defproxy - > mode ;
curproxy - > uri_auth = defproxy - > uri_auth ; /* for stats */
/* copy default logsrvs to curproxy */
list_for_each_entry ( tmplogsrv , & defproxy - > logsrvs , list ) {
struct logsrv * node = malloc ( sizeof ( * node ) ) ;
if ( ! node ) {
memprintf ( errmsg , " proxy '%s': out of memory " , name ) ;
goto fail ;
}
memcpy ( node , tmplogsrv , sizeof ( struct logsrv ) ) ;
node - > ref = tmplogsrv - > ref ;
LIST_INIT ( & node - > list ) ;
LIST_ADDQ ( & curproxy - > logsrvs , & node - > list ) ;
}
curproxy - > conf . uniqueid_format_string = defproxy - > conf . uniqueid_format_string ;
if ( curproxy - > conf . uniqueid_format_string )
curproxy - > conf . uniqueid_format_string = strdup ( curproxy - > conf . uniqueid_format_string ) ;
chunk_dup ( & curproxy - > log_tag , & defproxy - > log_tag ) ;
if ( defproxy - > conf . uif_file ) {
curproxy - > conf . uif_file = strdup ( defproxy - > conf . uif_file ) ;
curproxy - > conf . uif_line = defproxy - > conf . uif_line ;
}
/* copy default header unique id */
if ( isttest ( defproxy - > header_unique_id ) ) {
const struct ist copy = istdup ( defproxy - > header_unique_id ) ;
if ( ! isttest ( copy ) ) {
memprintf ( errmsg , " proxy '%s': out of memory for unique-id-header " , name ) ;
goto fail ;
}
curproxy - > header_unique_id = copy ;
}
/* default compression options */
if ( defproxy - > comp ! = NULL ) {
curproxy - > comp = calloc ( 1 , sizeof ( * curproxy - > comp ) ) ;
curproxy - > comp - > algos = defproxy - > comp - > algos ;
curproxy - > comp - > types = defproxy - > comp - > types ;
}
curproxy - > grace = defproxy - > grace ;
if ( defproxy - > check_path )
curproxy - > check_path = strdup ( defproxy - > check_path ) ;
if ( defproxy - > check_command )
curproxy - > check_command = strdup ( defproxy - > check_command ) ;
if ( defproxy - > email_alert . mailers . name )
curproxy - > email_alert . mailers . name = strdup ( defproxy - > email_alert . mailers . name ) ;
if ( defproxy - > email_alert . from )
curproxy - > email_alert . from = strdup ( defproxy - > email_alert . from ) ;
if ( defproxy - > email_alert . to )
curproxy - > email_alert . to = strdup ( defproxy - > email_alert . to ) ;
if ( defproxy - > email_alert . myhostname )
curproxy - > email_alert . myhostname = strdup ( defproxy - > email_alert . myhostname ) ;
curproxy - > email_alert . level = defproxy - > email_alert . level ;
curproxy - > email_alert . set = defproxy - > email_alert . set ;
2021-02-12 03:15:16 -05:00
done :
2021-02-12 02:49:47 -05:00
return curproxy ;
fail :
/* Note: in case of fatal error here, we WILL make valgrind unhappy,
* but its not worth trying to unroll everything here just before
* quitting .
*/
free ( tmpmsg ) ;
free ( curproxy ) ;
return NULL ;
}
2020-10-07 10:31:39 -04:00
/* to be called under the proxy lock after stopping some listeners. This will
* automatically update the p - > disabled flag after stopping the last one , and
* will emit a log indicating the proxy ' s condition . The function is idempotent
* so that it will not emit multiple logs ; a proxy will be disabled only once .
*/
void proxy_cond_disable ( struct proxy * p )
{
if ( p - > disabled )
return ;
if ( p - > li_ready + p - > li_paused > 0 )
return ;
p - > disabled = 1 ;
if ( ! ( proc_mask ( p - > bind_proc ) & pid_bit ) )
goto silent ;
/* Note: syslog proxies use their own loggers so while it's somewhat OK
* to report them being stopped as a warning , we must not spam their log
* servers which are in fact production servers . For other types ( CLI ,
* peers , etc ) we must not report them at all as they ' re not really on
* the data plane but on the control plane .
*/
if ( p - > mode = = PR_MODE_TCP | | p - > mode = = PR_MODE_HTTP | | p - > mode = = PR_MODE_SYSLOG )
ha_warning ( " Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld). \n " ,
p - > id , p - > fe_counters . cum_conn , p - > be_counters . cum_conn ) ;
if ( p - > mode = = PR_MODE_TCP | | p - > mode = = PR_MODE_HTTP )
send_log ( p , LOG_WARNING , " Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld). \n " ,
p - > id , p - > fe_counters . cum_conn , p - > be_counters . cum_conn ) ;
silent :
if ( p - > table & & p - > table - > size & & p - > table - > sync_task )
task_wakeup ( p - > table - > sync_task , TASK_WOKEN_MSG ) ;
if ( p - > task )
task_wakeup ( p - > task , TASK_WOKEN_MSG ) ;
}
2006-06-25 20:48:02 -04:00
/*
2011-07-25 10:33:49 -04:00
* This is the proxy management task . It enables proxies when there are enough
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 18:22:06 -04:00
* free streams , or stops them when the table is full . It is designed to be
2011-07-25 10:33:49 -04:00
* called as a task which is woken up upon stopping or when rate limiting must
* be enforced .
2006-06-25 20:48:02 -04:00
*/
2018-05-25 08:04:04 -04:00
struct task * manage_proxy ( struct task * t , void * context , unsigned short state )
2006-06-25 20:48:02 -04:00
{
2018-05-25 08:04:04 -04:00
struct proxy * p = context ;
2011-07-25 10:33:49 -04:00
int next = TICK_ETERNITY ;
2009-03-06 03:18:27 -05:00
unsigned int wait ;
2006-06-25 20:48:02 -04:00
2011-07-25 10:33:49 -04:00
/* We should periodically try to enable listeners waiting for a
* global resource here .
*/
/* first, let's check if we need to stop the proxy */
2020-09-24 02:39:22 -04:00
if ( unlikely ( stopping & & ! p - > disabled ) ) {
2011-07-25 10:33:49 -04:00
int t ;
t = tick_remain ( now_ms , p - > stop_time ) ;
if ( t = = 0 ) {
stop_proxy ( p ) ;
/* try to free more memory */
2017-11-24 11:34:44 -05:00
pool_gc ( NULL ) ;
2011-07-25 10:33:49 -04:00
}
else {
next = tick_first ( next , p - > stop_time ) ;
}
}
2011-07-25 05:54:17 -04:00
2013-09-04 11:54:01 -04:00
/* If the proxy holds a stick table, we need to purge all unused
* entries . These are all the ones in the table with ref_cnt = = 0
* and all the ones in the pool used to allocate new entries . Any
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 18:22:06 -04:00
* entry attached to an existing stream waiting for a store will
2013-09-04 11:54:01 -04:00
* be in neither list . Any entry being dumped will have ref_cnt > 0.
* However we protect tables that are being synced to peers .
*/
2020-09-24 02:39:22 -04:00
if ( unlikely ( stopping & & p - > disabled & & p - > table & & p - > table - > current ) ) {
2019-03-14 02:07:41 -04:00
if ( ! p - > table - > syncing ) {
stktable_trash_oldest ( p - > table , p - > table - > current ) ;
2017-11-24 11:34:44 -05:00
pool_gc ( NULL ) ;
2013-09-04 11:54:01 -04:00
}
2019-03-14 02:07:41 -04:00
if ( p - > table - > current ) {
2013-09-04 11:54:01 -04:00
/* some entries still remain, let's recheck in one second */
next = tick_first ( next , tick_add ( now_ms , 1000 ) ) ;
}
}
2011-07-25 10:33:49 -04:00
/* the rest below is just for frontends */
if ( ! ( p - > cap & PR_CAP_FE ) )
goto out ;
2011-07-25 01:37:28 -04:00
2011-07-25 10:33:49 -04:00
/* check the various reasons we may find to block the frontend */
2020-09-24 01:35:46 -04:00
if ( unlikely ( p - > feconn > = p - > maxconn ) )
2011-07-25 10:33:49 -04:00
goto out ;
2009-03-05 17:48:25 -05:00
2011-07-25 10:33:49 -04:00
if ( p - > fe_sps_lim & &
( wait = next_event_delay ( & p - > fe_sess_per_sec , p - > fe_sps_lim , 0 ) ) ) {
/* we're blocking because a limit was reached on the number of
* requests / s on the frontend . We want to re - check ASAP , which
* means in 1 ms before estimated expiration date , because the
* timer will have settled down .
*/
next = tick_first ( next , tick_add ( now_ms , wait ) ) ;
goto out ;
2006-06-25 20:48:02 -04:00
}
2011-07-25 10:33:49 -04:00
/* The proxy is not limited so we can re-enable any waiting listener */
2019-12-10 08:10:52 -05:00
dequeue_proxy_listeners ( p ) ;
2011-07-25 10:33:49 -04:00
out :
t - > expire = next ;
task_queue ( t ) ;
return t ;
2006-06-25 20:48:02 -04:00
}
2017-03-23 17:44:13 -04:00
static int proxy_parse_hard_stop_after ( char * * args , int section_type , struct proxy * curpx ,
struct proxy * defpx , const char * file , int line ,
char * * err )
{
const char * res ;
if ( ! * args [ 1 ] ) {
memprintf ( err , " '%s' expects <time> as argument. \n " , args [ 0 ] ) ;
return - 1 ;
}
res = parse_time_err ( args [ 1 ] , & global . hard_stop_after , TIME_UNIT_MS ) ;
2019-06-07 13:00:37 -04:00
if ( res = = PARSE_TIME_OVER ) {
memprintf ( err , " timer overflow in argument '%s' to '%s' (maximum value is 2147483647 ms or ~24.8 days) " ,
args [ 1 ] , args [ 0 ] ) ;
return - 1 ;
}
else if ( res = = PARSE_TIME_UNDER ) {
memprintf ( err , " timer underflow in argument '%s' to '%s' (minimum non-null value is 1 ms) " ,
args [ 1 ] , args [ 0 ] ) ;
return - 1 ;
}
else if ( res ) {
2017-03-23 17:44:13 -04:00
memprintf ( err , " unexpected character '%c' in argument to <%s>. \n " , * res , args [ 0 ] ) ;
return - 1 ;
}
return 0 ;
}
2018-05-25 08:04:04 -04:00
struct task * hard_stop ( struct task * t , void * context , unsigned short state )
2017-03-23 17:44:13 -04:00
{
struct proxy * p ;
struct stream * s ;
if ( killed ) {
2017-11-24 10:50:31 -05:00
ha_warning ( " Some tasks resisted to hard-stop, exiting now. \n " ) ;
2017-03-23 17:44:13 -04:00
send_log ( NULL , LOG_WARNING , " Some tasks resisted to hard-stop, exiting now. \n " ) ;
2019-06-02 05:11:29 -04:00
killed = 2 ;
t - > expire = TICK_ETERNITY ;
return t ;
2017-03-23 17:44:13 -04:00
}
2017-11-24 10:50:31 -05:00
ha_warning ( " soft-stop running for too long, performing a hard-stop. \n " ) ;
2017-03-23 17:44:13 -04:00
send_log ( NULL , LOG_WARNING , " soft-stop running for too long, performing a hard-stop. \n " ) ;
2017-11-24 10:54:05 -05:00
p = proxies_list ;
2017-03-23 17:44:13 -04:00
while ( p ) {
if ( ( p - > cap & PR_CAP_FE ) & & ( p - > feconn > 0 ) ) {
2017-11-24 10:50:31 -05:00
ha_warning ( " Proxy %s hard-stopped (%d remaining conns will be closed). \n " ,
p - > id , p - > feconn ) ;
2017-03-23 17:44:13 -04:00
send_log ( p , LOG_WARNING , " Proxy %s hard-stopped (%d remaining conns will be closed). \n " ,
p - > id , p - > feconn ) ;
}
p = p - > next ;
}
list_for_each_entry ( s , & streams , list ) {
stream_shutdown ( s , SF_ERR_KILLED ) ;
}
killed = 1 ;
t - > expire = tick_add ( now_ms , MS_TO_TICKS ( 1000 ) ) ;
return t ;
}
2006-06-25 20:48:02 -04:00
/*
* this function disables health - check servers so that the process will quickly be ignored
* by load balancers . Note that if a proxy was already in the PAUSED state , then its grace
* time will not be used since it would already not listen anymore to the socket .
*/
void soft_stop ( void )
{
struct proxy * p ;
2017-03-23 17:44:13 -04:00
struct task * task ;
2006-06-25 20:48:02 -04:00
stopping = 1 ;
2019-12-28 09:36:02 -05:00
/* disable busy polling to avoid cpu eating for the new process */
global . tune . options & = ~ GTUNE_BUSY_POLLING ;
2017-03-23 17:44:13 -04:00
if ( tick_isset ( global . hard_stop_after ) ) {
2017-09-27 08:59:38 -04:00
task = task_new ( MAX_THREADS_MASK ) ;
2017-03-23 17:44:13 -04:00
if ( task ) {
task - > process = hard_stop ;
task_schedule ( task , tick_add ( now_ms , global . hard_stop_after ) ) ;
}
else {
2017-11-24 10:50:31 -05:00
ha_alert ( " out of memory trying to allocate the hard-stop task. \n " ) ;
2017-03-23 17:44:13 -04:00
}
}
2020-10-07 10:52:43 -04:00
/* stop all stoppable listeners, resulting in disabling all proxies
* that don ' t use a grace period .
*/
protocol_stop_now ( ) ;
2017-11-24 10:54:05 -05:00
p = proxies_list ;
2008-06-23 08:00:57 -04:00
tv_update_date ( 0 , 1 ) ; /* else, the old time before select will be used */
2006-06-25 20:48:02 -04:00
while ( p ) {
2020-09-24 02:39:22 -04:00
if ( ! p - > disabled ) {
2017-11-24 10:50:31 -05:00
ha_warning ( " Stopping %s %s in %d ms. \n " , proxy_cap_str ( p - > cap ) , p - > id , p - > grace ) ;
2008-10-10 11:51:34 -04:00
send_log ( p , LOG_WARNING , " Stopping %s %s in %d ms. \n " , proxy_cap_str ( p - > cap ) , p - > id , p - > grace ) ;
2008-07-06 18:09:58 -04:00
p - > stop_time = tick_add ( now_ms , p - > grace ) ;
2010-09-23 12:44:36 -04:00
2015-09-28 10:35:04 -04:00
/* Note: do not wake up stopped proxies' task nor their tables'
* tasks as these ones might point to already released entries .
*/
2019-03-14 02:07:41 -04:00
if ( p - > table & & p - > table - > size & & p - > table - > sync_task )
task_wakeup ( p - > table - > sync_task , TASK_WOKEN_MSG ) ;
2015-09-28 10:35:04 -04:00
if ( p - > task )
task_wakeup ( p - > task , TASK_WOKEN_MSG ) ;
}
2006-06-25 20:48:02 -04:00
p = p - > next ;
}
2011-07-25 05:16:24 -04:00
2010-08-27 12:26:11 -04:00
/* signal zero is used to broadcast the "stopping" event */
signal_handler ( 0 ) ;
2006-06-25 20:48:02 -04:00
}
2011-07-24 12:28:10 -04:00
/* Temporarily disables listening on all of the proxy's listeners. Upon
2020-09-24 01:44:34 -04:00
* success , the proxy enters the PR_PAUSED state . The function returns 0
2011-09-07 13:14:57 -04:00
* if it fails , or non - zero on success .
2006-06-25 20:48:02 -04:00
*/
2011-09-07 13:14:57 -04:00
int pause_proxy ( struct proxy * p )
2006-06-25 20:48:02 -04:00
{
struct listener * l ;
2011-09-07 13:14:57 -04:00
2020-09-24 02:39:22 -04:00
if ( ! ( p - > cap & PR_CAP_FE ) | | p - > disabled | | ! p - > li_ready )
2011-09-07 13:14:57 -04:00
return 1 ;
2020-09-24 01:44:34 -04:00
list_for_each_entry ( l , & p - > conf . listeners , by_fe )
pause_listener ( l ) ;
2011-09-07 13:14:57 -04:00
2020-09-24 01:44:34 -04:00
if ( p - > li_ready ) {
2017-11-24 10:50:31 -05:00
ha_warning ( " %s %s failed to enter pause mode. \n " , proxy_cap_str ( p - > cap ) , p - > id ) ;
2011-09-07 13:14:57 -04:00
send_log ( p , LOG_WARNING , " %s %s failed to enter pause mode. \n " , proxy_cap_str ( p - > cap ) , p - > id ) ;
return 0 ;
}
return 1 ;
2008-10-12 06:07:48 -04:00
}
/*
* This function completely stops a proxy and releases its listeners . It has
* to be called when going down in order to release the ports so that another
* process may bind to them . It must also be called on disabled proxies at the
2018-11-16 10:57:21 -05:00
* end of start - up . If all listeners are closed , the proxy is set to the
2019-07-24 11:42:44 -04:00
* PR_STSTOPPED state . The function takes the proxy ' s lock so it ' s safe to
* call from multiple places .
2008-10-12 06:07:48 -04:00
*/
void stop_proxy ( struct proxy * p )
{
struct listener * l ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & p - > lock ) ;
2019-07-24 11:42:44 -04:00
2020-10-07 10:20:34 -04:00
list_for_each_entry ( l , & p - > conf . listeners , by_fe )
stop_listener ( l , 1 , 0 , 0 ) ;
2019-07-24 11:42:44 -04:00
2020-10-16 09:10:11 -04:00
if ( ! p - > disabled & & ! p - > li_ready ) {
/* might be just a backend */
p - > disabled = 1 ;
}
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & p - > lock ) ;
2006-06-25 20:48:02 -04:00
}
2011-09-07 15:33:14 -04:00
/* This function resumes listening on the specified proxy. It scans all of its
* listeners and tries to enable them all . If any of them fails , the proxy is
* put back to the paused state . It returns 1 upon success , or zero if an error
* is encountered .
*/
int resume_proxy ( struct proxy * p )
{
struct listener * l ;
int fail ;
2020-09-24 02:39:22 -04:00
if ( p - > disabled | | ! p - > li_paused )
2011-09-07 15:33:14 -04:00
return 1 ;
fail = 0 ;
2012-09-20 10:48:07 -04:00
list_for_each_entry ( l , & p - > conf . listeners , by_fe ) {
2011-09-07 15:33:14 -04:00
if ( ! resume_listener ( l ) ) {
int port ;
2020-08-27 01:48:42 -04:00
port = get_host_port ( & l - > rx . addr ) ;
2011-09-07 15:33:14 -04:00
if ( port ) {
2017-11-24 10:50:31 -05:00
ha_warning ( " Port %d busy while trying to enable %s %s. \n " ,
port , proxy_cap_str ( p - > cap ) , p - > id ) ;
2011-09-07 15:33:14 -04:00
send_log ( p , LOG_WARNING , " Port %d busy while trying to enable %s %s. \n " ,
port , proxy_cap_str ( p - > cap ) , p - > id ) ;
}
else {
2017-11-24 10:50:31 -05:00
ha_warning ( " Bind on socket %d busy while trying to enable %s %s. \n " ,
l - > luid , proxy_cap_str ( p - > cap ) , p - > id ) ;
2011-09-07 15:33:14 -04:00
send_log ( p , LOG_WARNING , " Bind on socket %d busy while trying to enable %s %s. \n " ,
l - > luid , proxy_cap_str ( p - > cap ) , p - > id ) ;
}
/* Another port might have been enabled. Let's stop everything. */
fail = 1 ;
break ;
}
}
if ( fail ) {
pause_proxy ( p ) ;
return 0 ;
}
return 1 ;
}
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 18:22:06 -04:00
/* Set current stream's backend to <be>. Nothing is done if the
* stream already had a backend assigned , which is indicated by
2015-04-02 19:14:29 -04:00
* s - > flags & SF_BE_ASSIGNED .
2009-07-07 09:10:31 -04:00
* All flags , stats and counters which need be updated are updated .
2009-07-12 02:27:39 -04:00
* Returns 1 if done , 0 in case of internal error , eg : lack of resource .
2009-07-07 09:10:31 -04:00
*/
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 18:22:06 -04:00
int stream_set_backend ( struct stream * s , struct proxy * be )
2009-07-07 09:10:31 -04:00
{
2015-04-02 19:14:29 -04:00
if ( s - > flags & SF_BE_ASSIGNED )
2009-07-12 02:27:39 -04:00
return 1 ;
2016-06-21 05:54:52 -04:00
if ( flt_set_stream_backend ( s , be ) < 0 )
return 0 ;
2009-07-07 09:10:31 -04:00
s - > be = be ;
2017-06-02 09:33:24 -04:00
HA_ATOMIC_UPDATE_MAX ( & be - > be_counters . conn_max ,
HA_ATOMIC_ADD ( & be - > beconn , 1 ) ) ;
2009-07-07 09:10:31 -04:00
proxy_inc_be_ctr ( be ) ;
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 18:22:06 -04:00
/* assign new parameters to the stream from the new backend */
[MEDIUM] new option "independant-streams" to stop updating read timeout on writes
By default, when data is sent over a socket, both the write timeout and the
read timeout for that socket are refreshed, because we consider that there is
activity on that socket, and we have no other means of guessing if we should
receive data or not.
While this default behaviour is desirable for almost all applications, there
exists a situation where it is desirable to disable it, and only refresh the
read timeout if there are incoming data. This happens on sessions with large
timeouts and low amounts of exchanged data such as telnet session. If the
server suddenly disappears, the output data accumulates in the system's
socket buffers, both timeouts are correctly refreshed, and there is no way
to know the server does not receive them, so we don't timeout. However, when
the underlying protocol always echoes sent data, it would be enough by itself
to detect the issue using the read timeout. Note that this problem does not
happen with more verbose protocols because data won't accumulate long in the
socket buffers.
When this option is set on the frontend, it will disable read timeout updates
on data sent to the client. There probably is little use of this case. When
the option is set on the backend, it will disable read timeout updates on
data sent to the server. Doing so will typically break large HTTP posts from
slow lines, so use it with caution.
2009-10-03 16:01:18 -04:00
s - > si [ 1 ] . flags & = ~ SI_FL_INDEP_STR ;
if ( be - > options2 & PR_O2_INDEPSTR )
s - > si [ 1 ] . flags | = SI_FL_INDEP_STR ;
BUG/MEDIUM: stream: fix client-fin/server-fin handling
A tcp half connection can cause 100% CPU on expiration.
First reproduced with this haproxy configuration :
global
tune.bufsize 10485760
defaults
timeout server-fin 90s
timeout client-fin 90s
backend node2
mode tcp
timeout server 900s
timeout connect 10s
server def 127.0.0.1:3333
frontend fe_api
mode tcp
timeout client 900s
bind :1990
use_backend node2
Ie timeout server-fin shorter than timeout server, the backend server
sends data, this package is left in the cache of haproxy, the backend
server continue sending fin package, haproxy recv fin package. this
time the session information is as follows:
time the session information is as follows:
0x2373470: proto=tcpv4 src=127.0.0.1:39513 fe=fe_api be=node2
srv=def ts=08 age=1s calls=3 rq[f=848000h,i=0,an=00h,rx=14m58s,wx=,ax=]
rp[f=8004c020h,i=0,an=00h,rx=,wx=14m58s,ax=] s0=[7,0h,fd=6,ex=]
s1=[7,18h,fd=7,ex=] exp=14m58s
rp has set the CF_SHUTR state, next, the client sends the fin package,
session information is as follows:
0x2373470: proto=tcpv4 src=127.0.0.1:39513 fe=fe_api be=node2
srv=def ts=08 age=38s calls=4 rq[f=84a020h,i=0,an=00h,rx=,wx=,ax=]
rp[f=8004c020h,i=0,an=00h,rx=1m11s,wx=14m21s,ax=] s0=[7,0h,fd=6,ex=]
s1=[9,10h,fd=7,ex=] exp=1m11s
After waiting 90s, session information is as follows:
0x2373470: proto=tcpv4 src=127.0.0.1:39513 fe=fe_api be=node2
srv=def ts=04 age=4m11s calls=718074391 rq[f=84a020h,i=0,an=00h,rx=,wx=,ax=]
rp[f=8004c020h,i=0,an=00h,rx=?,wx=10m49s,ax=] s0=[7,0h,fd=6,ex=]
s1=[9,10h,fd=7,ex=] exp=? run(nice=0)
cpu information:
6899 root 20 0 112224 21408 4260 R 100.0 0.7 3:04.96 haproxy
Buffering is set to ensure that there is data in the haproxy buffer, and haproxy
can receive the fin package, set the CF_SHUTR flag, If the CF_SHUTR flag has been
set, The following code does not clear the timeout message, causing cpu 100%:
stream.c:process_stream:
if (unlikely((res->flags & (CF_SHUTR|CF_READ_TIMEOUT)) == CF_READ_TIMEOUT)) {
if (si_b->flags & SI_FL_NOHALF)
si_b->flags |= SI_FL_NOLINGER;
si_shutr(si_b);
}
If you have closed the read, set the read timeout does not make sense.
With or without cf_shutr, read timeout is set:
if (tick_isset(s->be->timeout.serverfin)) {
res->rto = s->be->timeout.serverfin;
res->rex = tick_add(now_ms, res->rto);
}
After discussion on the mailing list, setting half-closed timeouts the
hard way here doesn't make sense. They should be set only at the moment
the shutdown() is performed. It will also solve a special case which was
already reported of some half-closed timeouts not working when the shutw()
is performed directly at the stream-interface layer (no analyser involved).
Since the stream interface layer cannot know the timeout values, we'll have
to store them directly in the stream interface so that they are used upon
shutw(). This patch does this, fixing the problem.
An easier reproducer to validate the fix is to keep the huge buffer and
shorten all timeouts, then call it under tcploop server and client, and
wait 3 seconds to see haproxy run at 100% CPU :
global
tune.bufsize 10485760
listen px
bind :1990
timeout client 90s
timeout server 90s
timeout connect 1s
timeout server-fin 3s
timeout client-fin 3s
server def 127.0.0.1:3333
$ tcploop 3333 L W N20 A P100 F P10000 &
$ tcploop 127.0.0.1:1990 C S10000000 F
2017-03-10 12:41:51 -05:00
if ( tick_isset ( be - > timeout . serverfin ) )
s - > si [ 1 ] . hcto = be - > timeout . serverfin ;
2015-05-01 16:42:08 -04:00
/* We want to enable the backend-specific analysers except those which
* were already run as part of the frontend / listener . Note that it would
* be more reliable to store the list of analysers that have been run ,
* but what we do here is OK for now .
*/
2017-01-09 10:33:19 -05:00
s - > req . analysers | = be - > be_req_ana & ~ ( strm_li ( s ) ? strm_li ( s ) - > analysers : 0 ) ;
2015-05-01 16:42:08 -04:00
2009-07-12 03:47:04 -04:00
/* If the target backend requires HTTP processing, we have to allocate
2019-07-16 08:16:10 -04:00
* the HTTP transaction if we did not have one .
2009-07-12 03:47:04 -04:00
*/
2015-04-03 17:46:31 -04:00
if ( unlikely ( ! s - > txn & & be - > http_needed ) ) {
if ( unlikely ( ! http_alloc_txn ( s ) ) )
2009-07-12 03:47:04 -04:00
return 0 ; /* not enough memory */
2010-05-31 11:01:36 -04:00
/* and now initialize the HTTP transaction state */
http_init_txn ( s ) ;
2009-07-12 03:47:04 -04:00
}
2015-12-02 03:57:32 -05:00
/* Be sure to filter request headers if the backend is an HTTP proxy and
* if there are filters attached to the stream . */
if ( s - > be - > mode = = PR_MODE_HTTP & & HAS_FILTERS ( s ) )
BUG/MAJOR: channel: Fix the definition order of channel analyzers
It is important to defined analyzers (AN_REQ_* and AN_RES_*) in the same order
they are evaluated in process_stream. This order is really important because
during analyzers evaluation, we run them in the order of the lower bit to the
higher one. This way, when an analyzer adds/removes another one during its
evaluation, we know if it is located before or after it. So, when it adds an
analyzer which is located before it, we can switch to it immediately, even if it
has already been called once but removed since.
With the time, and introduction of new analyzers, this order was broken up. the
main problems come from the filter analyzers. We used values not related with
their evaluation order. Furthermore, we used same values for request and response
analyzers.
So, to fix the bug, filter analyzers have been splitted in 2 distinct lists to
have different analyzers for the request channel than those for the response
channel. And of course, we have moved them to the right place.
Some other analyzers have been reordered to respect the evaluation order:
* AN_REQ_HTTP_TARPIT has been moved just before AN_REQ_SRV_RULES
* AN_REQ_PRST_RDP_COOKIE has been moved just before AN_REQ_STICKING_RULES
* AN_RES_STORE_RULES has been moved just after AN_RES_WAIT_HTTP
Note today we have 29 analyzers, all stored into a 32 bits bitfield. So we can
still add 4 more analyzers before having a problem. A good way to fend off the
problem for a while could be to have a different bitfield for request and
response analyzers.
[wt: all of this must be backported to 1.7, and part of it must be backported
to 1.6 and 1.5]
2017-01-05 08:06:34 -05:00
s - > req . analysers | = AN_REQ_FLT_HTTP_HDRS ;
2015-12-02 03:57:32 -05:00
2015-04-03 17:46:31 -04:00
if ( s - > txn ) {
2019-04-08 04:53:51 -04:00
/* If we chain a TCP frontend to an HTX backend, we must upgrade
* the client mux */
2019-07-15 09:00:25 -04:00
if ( ! IS_HTX_STRM ( s ) & & be - > mode = = PR_MODE_HTTP ) {
2019-04-08 04:53:51 -04:00
struct connection * conn = objt_conn ( strm_sess ( s ) - > origin ) ;
struct conn_stream * cs = objt_cs ( s - > si [ 0 ] . end ) ;
if ( conn & & cs ) {
si_rx_endp_more ( & s - > si [ 0 ] ) ;
2019-07-03 07:08:18 -04:00
/* Make sure we're unsubscribed, the the new
* mux will probably want to subscribe to
* the underlying XPRT
*/
if ( s - > si [ 0 ] . wait_event . events )
conn - > mux - > unsubscribe ( cs , s - > si [ 0 ] . wait_event . events ,
& s - > si [ 0 ] . wait_event ) ;
2019-07-15 05:42:52 -04:00
if ( conn_upgrade_mux_fe ( conn , cs , & s - > req . buf , ist ( " " ) , PROTO_MODE_HTTP ) = = - 1 )
2019-04-08 04:53:51 -04:00
return 0 ;
CLEANUP: Compare the return value of `XXXcmp()` functions with zero
According to coding-style.txt it is recommended to use:
`strcmp(a, b) == 0` instead of `!strcmp(a, b)`
So let's do this.
The change was performed by running the following (very long) coccinelle patch
on src/:
@@
statement S;
expression E;
expression F;
@@
if (
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
(
S
|
{ ... }
)
@@
statement S;
expression E;
expression F;
@@
if (
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
(
S
|
{ ... }
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) != 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
G &&
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
G ||
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
&& G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
|| G
)
@@
expression E;
expression F;
expression G;
@@
(
- !
(
dns_hostname_cmp
|
eb_memcmp
|
memcmp
|
strcasecmp
|
strcmp
|
strncasecmp
|
strncmp
)
- (E, F)
+ (E, F) == 0
)
2021-01-02 16:31:53 -05:00
if ( strcmp ( conn - > mux - > name , " H2 " ) = = 0 ) {
2019-07-31 12:05:26 -04:00
/* For HTTP/2, destroy the conn_stream,
* disable logging , and pretend that we
* failed , to that the stream is
* silently destroyed . The new mux
* will create new streams .
*/
2019-08-09 12:01:15 -04:00
cs_free ( cs ) ;
2019-07-31 12:05:26 -04:00
si_detach_endpoint ( & s - > si [ 0 ] ) ;
s - > logs . logwait = 0 ;
s - > logs . level = 0 ;
s - > flags | = SF_IGNORE ;
return 0 ;
}
2021-01-21 11:31:04 -05:00
s - > req . flags & = ~ ( CF_READ_PARTIAL | CF_AUTO_CONNECT ) ;
s - > req . total = 0 ;
s - > flags | = SF_IGNORE ;
2019-04-08 04:53:51 -04:00
}
}
2019-12-20 09:59:20 -05:00
else if ( IS_HTX_STRM ( s ) & & be - > mode ! = PR_MODE_HTTP ) {
/* If a TCP backend is assgiend to an HTX stream, return
* an error . It may happens for a new stream on a
2020-06-21 12:42:57 -04:00
* previously upgraded connections . */
2019-12-20 09:59:20 -05:00
if ( ! ( s - > flags & SF_ERR_MASK ) )
s - > flags | = SF_ERR_INTERNAL ;
return 0 ;
}
2019-04-08 04:53:51 -04:00
2015-05-01 16:42:08 -04:00
/* we may request to parse a request body */
2019-07-16 08:16:10 -04:00
if ( be - > options & PR_O_WREQ_BODY )
2015-05-01 16:42:08 -04:00
s - > req . analysers | = AN_REQ_HTTP_BODY ;
2015-04-03 17:46:31 -04:00
}
s - > flags | = SF_BE_ASSIGNED ;
2011-05-30 12:10:30 -04:00
if ( be - > options2 & PR_O2_NODELAY ) {
2014-11-27 14:45:39 -05:00
s - > req . flags | = CF_NEVER_WAIT ;
s - > res . flags | = CF_NEVER_WAIT ;
2011-05-30 12:10:30 -04:00
}
2009-07-12 02:27:39 -04:00
return 1 ;
2009-07-07 09:10:31 -04:00
}
2018-09-07 11:43:26 -04:00
/* Capture a bad request or response and archive it in the proxy's structure.
* It is relatively protocol - agnostic so it requires that a number of elements
* are passed :
* - < proxy > is the proxy where the error was detected and where the snapshot
* needs to be stored
2018-11-15 14:46:55 -05:00
* - < is_back > indicates that the error happened when receiving the response
2018-09-07 11:43:26 -04:00
* - < other_end > is a pointer to the proxy on the other side when known
* - < target > is the target of the connection , usually a server or a proxy
* - < sess > is the session which experienced the error
* - < ctx > may be NULL or should contain any info relevant to the protocol
* - < buf > is the buffer containing the offending data
* - < buf_ofs > is the position of this buffer ' s input data in the input
* stream , starting at zero . It may be passed as zero if unknown .
* - < buf_out > is the portion of < buf - > data > which was already forwarded and
* which precedes the buffer ' s input . The buffer ' s input starts at
* buf - > head + buf_out .
* - < err_pos > is the pointer to the faulty byte in the buffer ' s input .
* - < show > is the callback to use to display < ctx > . It may be NULL .
*/
void proxy_capture_error ( struct proxy * proxy , int is_back ,
struct proxy * other_end , enum obj_type * target ,
const struct session * sess ,
const struct buffer * buf , long buf_ofs ,
unsigned int buf_out , unsigned int err_pos ,
const union error_snapshot_ctx * ctx ,
void ( * show ) ( struct buffer * , const struct error_snapshot * ) )
{
struct error_snapshot * es ;
unsigned int buf_len ;
int len1 , len2 ;
2018-09-07 13:02:32 -04:00
unsigned int ev_id ;
ev_id = HA_ATOMIC_XADD ( & error_snapshot_id , 1 ) ;
2018-09-07 14:07:17 -04:00
buf_len = b_data ( buf ) - buf_out ;
es = malloc ( sizeof ( * es ) + buf_len ) ;
2018-09-07 13:02:32 -04:00
if ( ! es )
return ;
2018-09-07 14:07:17 -04:00
es - > buf_len = buf_len ;
es - > ev_id = ev_id ;
2018-09-07 11:43:26 -04:00
2020-01-06 05:37:00 -05:00
len1 = b_size ( buf ) - b_peek_ofs ( buf , buf_out ) ;
2018-09-07 11:43:26 -04:00
if ( len1 > buf_len )
len1 = buf_len ;
2018-09-07 14:07:17 -04:00
if ( len1 ) {
2018-09-07 11:43:26 -04:00
memcpy ( es - > buf , b_peek ( buf , buf_out ) , len1 ) ;
2018-09-07 14:07:17 -04:00
len2 = buf_len - len1 ;
2018-09-07 11:43:26 -04:00
if ( len2 )
memcpy ( es - > buf + len1 , b_orig ( buf ) , len2 ) ;
}
es - > buf_err = err_pos ;
es - > when = date ; // user-visible date
es - > srv = objt_server ( target ) ;
es - > oe = other_end ;
2020-03-12 10:30:17 -04:00
if ( sess & & objt_conn ( sess - > origin ) & & conn_get_src ( __objt_conn ( sess - > origin ) ) )
2019-07-17 09:20:02 -04:00
es - > src = * __objt_conn ( sess - > origin ) - > src ;
2018-09-07 11:43:26 -04:00
else
memset ( & es - > src , 0 , sizeof ( es - > src ) ) ;
es - > buf_wrap = b_wrap ( buf ) - b_peek ( buf , buf_out ) ;
es - > buf_out = buf_out ;
es - > buf_ofs = buf_ofs ;
/* be sure to indicate the offset of the first IN byte */
if ( es - > buf_ofs > = es - > buf_len )
es - > buf_ofs - = es - > buf_len ;
else
es - > buf_ofs = 0 ;
/* protocol-specific part now */
if ( ctx )
es - > ctx = * ctx ;
else
memset ( & es - > ctx , 0 , sizeof ( es - > ctx ) ) ;
es - > show = show ;
2018-09-07 13:02:32 -04:00
/* note: we still lock since we have to be certain that nobody is
* dumping the output while we free .
*/
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & proxy - > lock ) ;
2018-09-07 13:02:32 -04:00
if ( is_back ) {
es = HA_ATOMIC_XCHG ( & proxy - > invalid_rep , es ) ;
} else {
es = HA_ATOMIC_XCHG ( & proxy - > invalid_req , es ) ;
}
free ( es ) ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & proxy - > lock ) ;
2018-09-07 11:43:26 -04:00
}
MEDIUM: config: don't enforce a low frontend maxconn value anymore
Historically the default frontend's maxconn used to be quite low (2000),
which was sufficient two decades ago but often proved to be a problem
when users had purposely set the global maxconn value but forgot to set
the frontend's.
There is no point in keeping this arbitrary limit for frontends : when
the global maxconn is lower, it's already too high and when the global
maxconn is much higher, it becomes a limiting factor which causes trouble
in production.
This commit allows the value to be set to zero, which becomes the new
default value, to mean it's not directly limited, or in fact it's set
to the global maxconn. Since this operation used to be performed before
computing a possibly automatic global maxconn based on memory limits,
the calculation of the maxconn value and its propagation to the backends'
fullconn has now moved to a dedicated function, proxy_adjust_all_maxconn(),
which is called once the global maxconn is stabilized.
This comes with two benefits :
1) a configuration missing "maxconn" in the defaults section will not
limit itself to a magically hardcoded value but will scale up to the
global maxconn ;
2) when the global maxconn is not set and memory limits are used instead,
the frontends' maxconn automatically adapts, and the backends' fullconn
as well.
2019-02-27 11:25:52 -05:00
/* Configure all proxies which lack a maxconn setting to use the global one by
* default . This avoids the common mistake consisting in setting maxconn only
* in the global section and discovering the hard way that it doesn ' t propagate
* through the frontends . These values are also propagated through the various
2020-06-21 12:42:57 -04:00
* targeted backends , whose fullconn is finally calculated if not yet set .
MEDIUM: config: don't enforce a low frontend maxconn value anymore
Historically the default frontend's maxconn used to be quite low (2000),
which was sufficient two decades ago but often proved to be a problem
when users had purposely set the global maxconn value but forgot to set
the frontend's.
There is no point in keeping this arbitrary limit for frontends : when
the global maxconn is lower, it's already too high and when the global
maxconn is much higher, it becomes a limiting factor which causes trouble
in production.
This commit allows the value to be set to zero, which becomes the new
default value, to mean it's not directly limited, or in fact it's set
to the global maxconn. Since this operation used to be performed before
computing a possibly automatic global maxconn based on memory limits,
the calculation of the maxconn value and its propagation to the backends'
fullconn has now moved to a dedicated function, proxy_adjust_all_maxconn(),
which is called once the global maxconn is stabilized.
This comes with two benefits :
1) a configuration missing "maxconn" in the defaults section will not
limit itself to a magically hardcoded value but will scale up to the
global maxconn ;
2) when the global maxconn is not set and memory limits are used instead,
the frontends' maxconn automatically adapts, and the backends' fullconn
as well.
2019-02-27 11:25:52 -05:00
*/
void proxy_adjust_all_maxconn ( )
{
struct proxy * curproxy ;
struct switching_rule * swrule1 , * swrule2 ;
for ( curproxy = proxies_list ; curproxy ; curproxy = curproxy - > next ) {
2020-09-24 02:39:22 -04:00
if ( curproxy - > disabled )
MEDIUM: config: don't enforce a low frontend maxconn value anymore
Historically the default frontend's maxconn used to be quite low (2000),
which was sufficient two decades ago but often proved to be a problem
when users had purposely set the global maxconn value but forgot to set
the frontend's.
There is no point in keeping this arbitrary limit for frontends : when
the global maxconn is lower, it's already too high and when the global
maxconn is much higher, it becomes a limiting factor which causes trouble
in production.
This commit allows the value to be set to zero, which becomes the new
default value, to mean it's not directly limited, or in fact it's set
to the global maxconn. Since this operation used to be performed before
computing a possibly automatic global maxconn based on memory limits,
the calculation of the maxconn value and its propagation to the backends'
fullconn has now moved to a dedicated function, proxy_adjust_all_maxconn(),
which is called once the global maxconn is stabilized.
This comes with two benefits :
1) a configuration missing "maxconn" in the defaults section will not
limit itself to a magically hardcoded value but will scale up to the
global maxconn ;
2) when the global maxconn is not set and memory limits are used instead,
the frontends' maxconn automatically adapts, and the backends' fullconn
as well.
2019-02-27 11:25:52 -05:00
continue ;
if ( ! ( curproxy - > cap & PR_CAP_FE ) )
continue ;
if ( ! curproxy - > maxconn )
curproxy - > maxconn = global . maxconn ;
/* update the target backend's fullconn count : default_backend */
if ( curproxy - > defbe . be )
curproxy - > defbe . be - > tot_fe_maxconn + = curproxy - > maxconn ;
else if ( ( curproxy - > cap & PR_CAP_LISTEN ) = = PR_CAP_LISTEN )
curproxy - > tot_fe_maxconn + = curproxy - > maxconn ;
list_for_each_entry ( swrule1 , & curproxy - > switching_rules , list ) {
/* For each target of switching rules, we update their
* tot_fe_maxconn , except if a previous rule points to
* the same backend or to the default backend .
*/
if ( swrule1 - > be . backend ! = curproxy - > defbe . be ) {
2019-03-07 09:02:52 -05:00
/* note: swrule1->be.backend isn't a backend if the rule
* is dynamic , it ' s an expression instead , so it must not
* be dereferenced as a backend before being certain it is .
*/
MEDIUM: config: don't enforce a low frontend maxconn value anymore
Historically the default frontend's maxconn used to be quite low (2000),
which was sufficient two decades ago but often proved to be a problem
when users had purposely set the global maxconn value but forgot to set
the frontend's.
There is no point in keeping this arbitrary limit for frontends : when
the global maxconn is lower, it's already too high and when the global
maxconn is much higher, it becomes a limiting factor which causes trouble
in production.
This commit allows the value to be set to zero, which becomes the new
default value, to mean it's not directly limited, or in fact it's set
to the global maxconn. Since this operation used to be performed before
computing a possibly automatic global maxconn based on memory limits,
the calculation of the maxconn value and its propagation to the backends'
fullconn has now moved to a dedicated function, proxy_adjust_all_maxconn(),
which is called once the global maxconn is stabilized.
This comes with two benefits :
1) a configuration missing "maxconn" in the defaults section will not
limit itself to a magically hardcoded value but will scale up to the
global maxconn ;
2) when the global maxconn is not set and memory limits are used instead,
the frontends' maxconn automatically adapts, and the backends' fullconn
as well.
2019-02-27 11:25:52 -05:00
list_for_each_entry ( swrule2 , & curproxy - > switching_rules , list ) {
if ( swrule2 = = swrule1 ) {
2019-03-07 09:02:52 -05:00
if ( ! swrule1 - > dynamic )
swrule1 - > be . backend - > tot_fe_maxconn + = curproxy - > maxconn ;
MEDIUM: config: don't enforce a low frontend maxconn value anymore
Historically the default frontend's maxconn used to be quite low (2000),
which was sufficient two decades ago but often proved to be a problem
when users had purposely set the global maxconn value but forgot to set
the frontend's.
There is no point in keeping this arbitrary limit for frontends : when
the global maxconn is lower, it's already too high and when the global
maxconn is much higher, it becomes a limiting factor which causes trouble
in production.
This commit allows the value to be set to zero, which becomes the new
default value, to mean it's not directly limited, or in fact it's set
to the global maxconn. Since this operation used to be performed before
computing a possibly automatic global maxconn based on memory limits,
the calculation of the maxconn value and its propagation to the backends'
fullconn has now moved to a dedicated function, proxy_adjust_all_maxconn(),
which is called once the global maxconn is stabilized.
This comes with two benefits :
1) a configuration missing "maxconn" in the defaults section will not
limit itself to a magically hardcoded value but will scale up to the
global maxconn ;
2) when the global maxconn is not set and memory limits are used instead,
the frontends' maxconn automatically adapts, and the backends' fullconn
as well.
2019-02-27 11:25:52 -05:00
break ;
}
else if ( ! swrule2 - > dynamic & & swrule2 - > be . backend = = swrule1 - > be . backend ) {
/* there are multiple refs of this backend */
break ;
}
}
}
}
}
/* automatically compute fullconn if not set. We must not do it in the
* loop above because cross - references are not yet fully resolved .
*/
for ( curproxy = proxies_list ; curproxy ; curproxy = curproxy - > next ) {
2020-09-24 02:39:22 -04:00
if ( curproxy - > disabled )
MEDIUM: config: don't enforce a low frontend maxconn value anymore
Historically the default frontend's maxconn used to be quite low (2000),
which was sufficient two decades ago but often proved to be a problem
when users had purposely set the global maxconn value but forgot to set
the frontend's.
There is no point in keeping this arbitrary limit for frontends : when
the global maxconn is lower, it's already too high and when the global
maxconn is much higher, it becomes a limiting factor which causes trouble
in production.
This commit allows the value to be set to zero, which becomes the new
default value, to mean it's not directly limited, or in fact it's set
to the global maxconn. Since this operation used to be performed before
computing a possibly automatic global maxconn based on memory limits,
the calculation of the maxconn value and its propagation to the backends'
fullconn has now moved to a dedicated function, proxy_adjust_all_maxconn(),
which is called once the global maxconn is stabilized.
This comes with two benefits :
1) a configuration missing "maxconn" in the defaults section will not
limit itself to a magically hardcoded value but will scale up to the
global maxconn ;
2) when the global maxconn is not set and memory limits are used instead,
the frontends' maxconn automatically adapts, and the backends' fullconn
as well.
2019-02-27 11:25:52 -05:00
continue ;
/* If <fullconn> is not set, let's set it to 10% of the sum of
* the possible incoming frontend ' s maxconns .
*/
if ( ! curproxy - > fullconn & & ( curproxy - > cap & PR_CAP_BE ) ) {
/* we have the sum of the maxconns in <total>. We only
* keep 10 % of that sum to set the default fullconn , with
* a hard minimum of 1 ( to avoid a divide by zero ) .
*/
curproxy - > fullconn = ( curproxy - > tot_fe_maxconn + 9 ) / 10 ;
if ( ! curproxy - > fullconn )
curproxy - > fullconn = 1 ;
}
}
}
2018-09-07 11:43:26 -04:00
/* Config keywords below */
2013-06-21 17:16:39 -04:00
static struct cfg_kw_list cfg_kws = { ILH , {
2017-03-23 17:44:13 -04:00
{ CFG_GLOBAL , " hard-stop-after " , proxy_parse_hard_stop_after } ,
2008-07-09 14:34:27 -04:00
{ CFG_LISTEN , " timeout " , proxy_parse_timeout } ,
2019-05-14 14:57:59 -04:00
{ CFG_LISTEN , " clitimeout " , proxy_parse_timeout } , /* This keyword actually fails to parse, this line remains for better error messages. */
{ CFG_LISTEN , " contimeout " , proxy_parse_timeout } , /* This keyword actually fails to parse, this line remains for better error messages. */
{ CFG_LISTEN , " srvtimeout " , proxy_parse_timeout } , /* This keyword actually fails to parse, this line remains for better error messages. */
2009-03-05 17:48:25 -05:00
{ CFG_LISTEN , " rate-limit " , proxy_parse_rate_limit } ,
2014-04-25 07:58:37 -04:00
{ CFG_LISTEN , " max-keep-alive-queue " , proxy_parse_max_ka_queue } ,
2015-05-26 11:44:32 -04:00
{ CFG_LISTEN , " declare " , proxy_parse_declare } ,
MEDIUM: streams: Add the ability to retry a request on L7 failure.
When running in HTX mode, if we sent the request, but failed to get the
answer, either because the server just closed its socket, we hit a server
timeout, or we get a 404, 408, 425, 500, 501, 502, 503 or 504 error,
attempt to retry the request, exactly as if we just failed to connect to
the server.
To do so, add a new backend keyword, "retry-on".
It accepts a list of keywords, which can be "none" (never retry),
"conn-failure" (we failed to connect, or to do the SSL handshake),
"empty-response" (the server closed the connection without answering),
"response-timeout" (we timed out while waiting for the server response),
or "404", "408", "425", "500", "501", "502", "503" and "504".
The default is "conn-failure".
2019-04-05 09:30:12 -04:00
{ CFG_LISTEN , " retry-on " , proxy_parse_retry_on } ,
2020-07-08 23:58:51 -04:00
# ifdef TCP_KEEPCNT
2020-07-08 22:13:20 -04:00
{ CFG_LISTEN , " clitcpka-cnt " , proxy_parse_tcpka_cnt } ,
{ CFG_LISTEN , " srvtcpka-cnt " , proxy_parse_tcpka_cnt } ,
2020-07-08 23:58:51 -04:00
# endif
# ifdef TCP_KEEPIDLE
{ CFG_LISTEN , " clitcpka-idle " , proxy_parse_tcpka_idle } ,
2020-07-08 22:13:20 -04:00
{ CFG_LISTEN , " srvtcpka-idle " , proxy_parse_tcpka_idle } ,
2020-07-08 23:58:51 -04:00
# endif
# ifdef TCP_KEEPINTVL
{ CFG_LISTEN , " clitcpka-intvl " , proxy_parse_tcpka_intvl } ,
2020-07-08 22:13:20 -04:00
{ CFG_LISTEN , " srvtcpka-intvl " , proxy_parse_tcpka_intvl } ,
2020-07-08 23:58:51 -04:00
# endif
2008-07-09 14:34:27 -04:00
{ 0 , NULL , NULL } ,
} } ;
2018-11-25 13:14:37 -05:00
INITCALL1 ( STG_REGISTER , cfg_register_keywords , & cfg_kws ) ;
2016-11-24 06:02:29 -05:00
/* Expects to find a frontend named <arg> and returns it, otherwise displays various
* adequate error messages and returns NULL . This function is designed to be used by
* functions requiring a frontend on the CLI .
*/
struct proxy * cli_find_frontend ( struct appctx * appctx , const char * arg )
{
struct proxy * px ;
if ( ! * arg ) {
2019-08-09 05:21:01 -04:00
cli_err ( appctx , " A frontend name is expected. \n " ) ;
2016-11-24 06:02:29 -05:00
return NULL ;
}
px = proxy_fe_by_name ( arg ) ;
if ( ! px ) {
2019-08-09 05:21:01 -04:00
cli_err ( appctx , " No such frontend. \n " ) ;
2016-11-24 06:02:29 -05:00
return NULL ;
}
return px ;
}
2017-03-14 15:08:46 -04:00
/* Expects to find a backend named <arg> and returns it, otherwise displays various
* adequate error messages and returns NULL . This function is designed to be used by
* functions requiring a frontend on the CLI .
*/
struct proxy * cli_find_backend ( struct appctx * appctx , const char * arg )
{
struct proxy * px ;
if ( ! * arg ) {
2019-08-09 05:21:01 -04:00
cli_err ( appctx , " A backend name is expected. \n " ) ;
2017-03-14 15:08:46 -04:00
return NULL ;
}
px = proxy_be_by_name ( arg ) ;
if ( ! px ) {
2019-08-09 05:21:01 -04:00
cli_err ( appctx , " No such backend. \n " ) ;
2017-03-14 15:08:46 -04:00
return NULL ;
}
return px ;
}
2020-07-01 01:00:59 -04:00
/* parse a "show servers [state|conn]" CLI line, returns 0 if it wants to start
* the dump or 1 if it stops immediately . If an argument is specified , it will
* set the proxy pointer into cli . p0 and its ID into cli . i0 . It sets cli . o0 to
* 0 for " state " , or 1 for " conn " .
2016-11-18 20:25:36 -05:00
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_show_servers ( char * * args , char * payload , struct appctx * appctx , void * private )
2016-11-18 20:25:36 -05:00
{
2016-12-16 12:23:39 -05:00
struct proxy * px ;
2016-11-18 20:25:36 -05:00
2020-07-01 01:00:59 -04:00
appctx - > ctx . cli . o0 = * args [ 2 ] = = ' c ' ; // "conn" vs "state"
2016-11-18 20:25:36 -05:00
/* check if a backend name has been provided */
if ( * args [ 3 ] ) {
/* read server state from local file */
2016-12-16 12:23:39 -05:00
px = proxy_be_by_name ( args [ 3 ] ) ;
2016-11-18 20:25:36 -05:00
2019-08-09 05:21:01 -04:00
if ( ! px )
return cli_err ( appctx , " Can't find backend. \n " ) ;
2016-12-16 12:23:39 -05:00
appctx - > ctx . cli . p0 = px ;
appctx - > ctx . cli . i0 = px - > uuid ;
2016-11-18 20:25:36 -05:00
}
return 0 ;
}
2021-02-11 16:51:26 -05:00
/* helper to dump server addr */
static void dump_server_addr ( const struct sockaddr_storage * addr , char * addr_str )
{
addr_str [ 0 ] = ' \0 ' ;
switch ( addr - > ss_family ) {
case AF_INET :
case AF_INET6 :
addr_to_str ( addr , addr_str , INET6_ADDRSTRLEN + 1 ) ;
break ;
default :
memcpy ( addr_str , " - \0 " , 2 ) ;
break ;
}
}
2020-07-01 01:02:42 -04:00
/* dumps server state information for all the servers found in backend cli.p0.
2016-11-18 20:25:36 -05:00
* These information are all the parameters which may change during HAProxy runtime .
* By default , we only export to the last known server state file format .
* These information can be used at next startup to recover same level of server state .
2016-12-16 12:23:39 -05:00
* It uses the proxy pointer from cli . p0 , the proxy ' s id from cli . i0 and the server ' s
* pointer from cli . p1 .
2016-11-18 20:25:36 -05:00
*/
2020-07-01 01:02:42 -04:00
static int dump_servers_state ( struct stream_interface * si )
2016-11-18 20:25:36 -05:00
{
struct appctx * appctx = __objt_appctx ( si - > end ) ;
2016-12-16 12:23:39 -05:00
struct proxy * px = appctx - > ctx . cli . p0 ;
2016-11-18 20:25:36 -05:00
struct server * srv ;
char srv_addr [ INET6_ADDRSTRLEN + 1 ] ;
2021-02-11 16:51:26 -05:00
char srv_agent_addr [ INET6_ADDRSTRLEN + 1 ] ;
char srv_check_addr [ INET6_ADDRSTRLEN + 1 ] ;
2016-11-18 20:25:36 -05:00
time_t srv_time_since_last_change ;
int bk_f_forced_id , srv_f_forced_id ;
2018-07-02 11:00:54 -04:00
char * srvrecord ;
2016-11-18 20:25:36 -05:00
/* we don't want to report any state if the backend is not enabled on this process */
2019-02-02 11:39:53 -05:00
if ( ! ( proc_mask ( px - > bind_proc ) & pid_bit ) )
2016-11-18 20:25:36 -05:00
return 1 ;
2016-12-16 12:23:39 -05:00
if ( ! appctx - > ctx . cli . p1 )
appctx - > ctx . cli . p1 = px - > srv ;
2016-11-18 20:25:36 -05:00
2016-12-16 12:23:39 -05:00
for ( ; appctx - > ctx . cli . p1 ! = NULL ; appctx - > ctx . cli . p1 = srv - > next ) {
srv = appctx - > ctx . cli . p1 ;
2016-11-18 20:25:36 -05:00
2021-02-11 16:51:26 -05:00
dump_server_addr ( & srv - > addr , srv_addr ) ;
dump_server_addr ( & srv - > check . addr , srv_check_addr ) ;
dump_server_addr ( & srv - > agent . addr , srv_agent_addr ) ;
2016-11-18 20:25:36 -05:00
srv_time_since_last_change = now . tv_sec - srv - > last_change ;
2016-12-16 12:23:39 -05:00
bk_f_forced_id = px - > options & PR_O_FORCED_ID ? 1 : 0 ;
2016-11-18 20:25:36 -05:00
srv_f_forced_id = srv - > flags & SRV_F_FORCED_ID ? 1 : 0 ;
2018-07-02 11:00:54 -04:00
srvrecord = NULL ;
if ( srv - > srvrq & & srv - > srvrq - > name )
srvrecord = srv - > srvrq - > name ;
2020-07-01 01:00:59 -04:00
if ( appctx - > ctx . cli . o0 = = 0 ) {
/* show servers state */
chunk_printf ( & trash ,
" %d %s "
" %d %s %s "
" %d %d %d %d %ld "
" %d %d %d %d %d "
2020-11-14 13:25:33 -05:00
" %d %d %s %u "
2021-02-11 16:51:26 -05:00
" %s %d %d "
" %s %s %d "
2020-07-01 01:00:59 -04:00
" \n " ,
px - > uuid , px - > id ,
srv - > puid , srv - > id , srv_addr ,
srv - > cur_state , srv - > cur_admin , srv - > uweight , srv - > iweight , ( long int ) srv_time_since_last_change ,
srv - > check . status , srv - > check . result , srv - > check . health , srv - > check . state , srv - > agent . state ,
bk_f_forced_id , srv_f_forced_id , srv - > hostname ? srv - > hostname : " - " , srv - > svc_port ,
2021-02-11 16:51:26 -05:00
srvrecord ? srvrecord : " - " , srv - > use_ssl , srv - > check . port ,
srv_check_addr , srv_agent_addr , srv - > agent . port ) ;
2020-07-01 01:00:59 -04:00
} else {
/* show servers conn */
int thr ;
chunk_printf ( & trash ,
" %s/%s %d/%d %s %u - %u %u %u %u %u %u %d %u " ,
px - > id , srv - > id , px - > uuid , srv - > puid , srv_addr , srv - > svc_port ,
srv - > pool_purge_delay ,
srv - > curr_used_conns , srv - > max_used_conns , srv - > est_need_conns ,
srv - > curr_idle_nb , srv - > curr_safe_nb , ( int ) srv - > max_idle_conns , srv - > curr_idle_conns ) ;
2020-07-02 09:19:57 -04:00
for ( thr = 0 ; thr < global . nbthread & & srv - > curr_idle_thr ; thr + + )
2020-07-01 01:00:59 -04:00
chunk_appendf ( & trash , " %u " , srv - > curr_idle_thr [ thr ] ) ;
chunk_appendf ( & trash , " \n " ) ;
}
REORG: channel: finally rename the last bi_* / bo_* functions
For HTTP/2 we'll need some buffer-only equivalent functions to some of
the ones applying to channels and still squatting the bi_* / bo_*
namespace. Since these names have kept being misleading for quite some
time now and are really getting annoying, it's time to rename them. This
commit will use "ci/co" as the prefix (for "channel in", "channel out")
instead of "bi/bo". The following ones were renamed :
bi_getblk_nc, bi_getline_nc, bi_putblk, bi_putchr,
bo_getblk, bo_getblk_nc, bo_getline, bo_getline_nc, bo_inject,
bi_putchk, bi_putstr, bo_getchr, bo_skip, bi_swpbuf
2017-10-19 08:32:15 -04:00
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 ) {
2018-11-15 05:08:52 -05:00
si_rx_room_blk ( si ) ;
2016-11-18 20:25:36 -05:00
return 0 ;
}
}
return 1 ;
}
/* Parses backend list or simply use backend name provided by the user to return
2016-12-16 12:23:39 -05:00
* states of servers to stdout . It dumps proxy < cli . p0 > and stops if < cli . i0 > is
* non - null .
2016-11-18 20:25:36 -05:00
*/
static int cli_io_handler_servers_state ( struct appctx * appctx )
{
struct stream_interface * si = appctx - > owner ;
struct proxy * curproxy ;
chunk_reset ( & trash ) ;
if ( appctx - > st2 = = STAT_ST_INIT ) {
2016-12-16 12:23:39 -05:00
if ( ! appctx - > ctx . cli . p0 )
2017-11-24 10:54:05 -05:00
appctx - > ctx . cli . p0 = proxies_list ;
2016-11-18 20:25:36 -05:00
appctx - > st2 = STAT_ST_HEAD ;
}
if ( appctx - > st2 = = STAT_ST_HEAD ) {
2020-07-01 01:00:59 -04:00
if ( appctx - > ctx . cli . o0 = = 0 )
chunk_printf ( & trash , " %d \n # %s \n " , SRV_STATE_FILE_VERSION , SRV_STATE_FILE_FIELD_NAMES ) ;
else
chunk_printf ( & trash ,
" # bkname/svname bkid/svid addr port - purge_delay used_cur used_max need_est unsafe_nb safe_nb idle_lim idle_cur idle_per_thr[%d] \n " ,
global . nbthread ) ;
REORG: channel: finally rename the last bi_* / bo_* functions
For HTTP/2 we'll need some buffer-only equivalent functions to some of
the ones applying to channels and still squatting the bi_* / bo_*
namespace. Since these names have kept being misleading for quite some
time now and are really getting annoying, it's time to rename them. This
commit will use "ci/co" as the prefix (for "channel in", "channel out")
instead of "bi/bo". The following ones were renamed :
bi_getblk_nc, bi_getline_nc, bi_putblk, bi_putchr,
bo_getblk, bo_getblk_nc, bo_getline, bo_getline_nc, bo_inject,
bi_putchk, bi_putstr, bo_getchr, bo_skip, bi_swpbuf
2017-10-19 08:32:15 -04:00
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 ) {
2018-11-15 05:08:52 -05:00
si_rx_room_blk ( si ) ;
2016-11-18 20:25:36 -05:00
return 0 ;
}
appctx - > st2 = STAT_ST_INFO ;
}
/* STAT_ST_INFO */
2016-12-16 12:23:39 -05:00
for ( ; appctx - > ctx . cli . p0 ! = NULL ; appctx - > ctx . cli . p0 = curproxy - > next ) {
curproxy = appctx - > ctx . cli . p0 ;
2016-11-18 20:25:36 -05:00
/* servers are only in backends */
if ( curproxy - > cap & PR_CAP_BE ) {
2020-07-01 01:02:42 -04:00
if ( ! dump_servers_state ( si ) )
2016-11-18 20:25:36 -05:00
return 0 ;
}
/* only the selected proxy is dumped */
2016-12-16 12:23:39 -05:00
if ( appctx - > ctx . cli . i0 )
2016-11-18 20:25:36 -05:00
break ;
}
return 1 ;
}
2016-12-16 12:01:15 -05:00
/* Parses backend list and simply report backend names. It keeps the proxy
* pointer in cli . p0 .
*/
2016-11-22 06:34:16 -05:00
static int cli_io_handler_show_backend ( struct appctx * appctx )
{
struct stream_interface * si = appctx - > owner ;
struct proxy * curproxy ;
chunk_reset ( & trash ) ;
2016-12-16 12:01:15 -05:00
if ( ! appctx - > ctx . cli . p0 ) {
2016-11-22 06:34:16 -05:00
chunk_printf ( & trash , " # name \n " ) ;
REORG: channel: finally rename the last bi_* / bo_* functions
For HTTP/2 we'll need some buffer-only equivalent functions to some of
the ones applying to channels and still squatting the bi_* / bo_*
namespace. Since these names have kept being misleading for quite some
time now and are really getting annoying, it's time to rename them. This
commit will use "ci/co" as the prefix (for "channel in", "channel out")
instead of "bi/bo". The following ones were renamed :
bi_getblk_nc, bi_getline_nc, bi_putblk, bi_putchr,
bo_getblk, bo_getblk_nc, bo_getline, bo_getline_nc, bo_inject,
bi_putchk, bi_putstr, bo_getchr, bo_skip, bi_swpbuf
2017-10-19 08:32:15 -04:00
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 ) {
2018-11-15 05:08:52 -05:00
si_rx_room_blk ( si ) ;
2016-11-22 06:34:16 -05:00
return 0 ;
}
2017-11-24 10:54:05 -05:00
appctx - > ctx . cli . p0 = proxies_list ;
2016-11-22 06:34:16 -05:00
}
2016-12-16 12:01:15 -05:00
for ( ; appctx - > ctx . cli . p0 ! = NULL ; appctx - > ctx . cli . p0 = curproxy - > next ) {
curproxy = appctx - > ctx . cli . p0 ;
2016-11-22 06:34:16 -05:00
/* looking for backends only */
if ( ! ( curproxy - > cap & PR_CAP_BE ) )
continue ;
/* we don't want to list a backend which is bound to this process */
2019-02-02 11:39:53 -05:00
if ( ! ( proc_mask ( curproxy - > bind_proc ) & pid_bit ) )
2016-11-22 06:34:16 -05:00
continue ;
chunk_appendf ( & trash , " %s \n " , curproxy - > id ) ;
REORG: channel: finally rename the last bi_* / bo_* functions
For HTTP/2 we'll need some buffer-only equivalent functions to some of
the ones applying to channels and still squatting the bi_* / bo_*
namespace. Since these names have kept being misleading for quite some
time now and are really getting annoying, it's time to rename them. This
commit will use "ci/co" as the prefix (for "channel in", "channel out")
instead of "bi/bo". The following ones were renamed :
bi_getblk_nc, bi_getline_nc, bi_putblk, bi_putchr,
bo_getblk, bo_getblk_nc, bo_getline, bo_getline_nc, bo_inject,
bi_putchk, bi_putstr, bo_getchr, bo_skip, bi_swpbuf
2017-10-19 08:32:15 -04:00
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 ) {
2018-11-15 05:08:52 -05:00
si_rx_room_blk ( si ) ;
2016-11-22 06:34:16 -05:00
return 0 ;
}
}
return 1 ;
}
2016-11-18 20:25:36 -05:00
2018-08-21 08:50:44 -04:00
/* Parses the "enable dynamic-cookies backend" directive, it always returns 1.
*
* Grabs the proxy lock and each server ' s lock .
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_enable_dyncookie_backend ( char * * args , char * payload , struct appctx * appctx , void * private )
2017-03-14 15:08:46 -04:00
{
struct proxy * px ;
struct server * s ;
if ( ! cli_has_level ( appctx , ACCESS_LVL_ADMIN ) )
return 1 ;
px = cli_find_backend ( appctx , args [ 3 ] ) ;
if ( ! px )
return 1 ;
2019-07-30 05:59:34 -04:00
/* Note: this lock is to make sure this doesn't change while another
* thread is in srv_set_dyncookie ( ) .
*/
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & px - > lock ) ;
2017-03-14 15:08:46 -04:00
px - > ck_opts | = PR_CK_DYNAMIC ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & px - > lock ) ;
2017-03-14 15:08:46 -04:00
2018-08-21 08:50:44 -04:00
for ( s = px - > srv ; s ! = NULL ; s = s - > next ) {
HA_SPIN_LOCK ( SERVER_LOCK , & s - > lock ) ;
2017-03-14 15:08:46 -04:00
srv_set_dyncookie ( s ) ;
2018-08-21 08:50:44 -04:00
HA_SPIN_UNLOCK ( SERVER_LOCK , & s - > lock ) ;
}
2017-03-14 15:08:46 -04:00
return 1 ;
}
2018-08-21 08:50:44 -04:00
/* Parses the "disable dynamic-cookies backend" directive, it always returns 1.
*
* Grabs the proxy lock and each server ' s lock .
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_disable_dyncookie_backend ( char * * args , char * payload , struct appctx * appctx , void * private )
2017-03-14 15:08:46 -04:00
{
struct proxy * px ;
struct server * s ;
if ( ! cli_has_level ( appctx , ACCESS_LVL_ADMIN ) )
return 1 ;
px = cli_find_backend ( appctx , args [ 3 ] ) ;
if ( ! px )
return 1 ;
2019-07-30 05:59:34 -04:00
/* Note: this lock is to make sure this doesn't change while another
* thread is in srv_set_dyncookie ( ) .
*/
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & px - > lock ) ;
2017-03-14 15:08:46 -04:00
px - > ck_opts & = ~ PR_CK_DYNAMIC ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & px - > lock ) ;
2017-03-14 15:08:46 -04:00
for ( s = px - > srv ; s ! = NULL ; s = s - > next ) {
2018-08-21 08:50:44 -04:00
HA_SPIN_LOCK ( SERVER_LOCK , & s - > lock ) ;
2017-03-14 15:08:46 -04:00
if ( ! ( s - > flags & SRV_F_COOKIESET ) ) {
free ( s - > cookie ) ;
s - > cookie = NULL ;
}
2018-08-21 08:50:44 -04:00
HA_SPIN_UNLOCK ( SERVER_LOCK , & s - > lock ) ;
2017-03-14 15:08:46 -04:00
}
return 1 ;
}
2018-08-21 08:50:44 -04:00
/* Parses the "set dynamic-cookie-key backend" directive, it always returns 1.
*
* Grabs the proxy lock and each server ' s lock .
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_set_dyncookie_key_backend ( char * * args , char * payload , struct appctx * appctx , void * private )
2017-03-14 15:08:46 -04:00
{
struct proxy * px ;
struct server * s ;
char * newkey ;
if ( ! cli_has_level ( appctx , ACCESS_LVL_ADMIN ) )
return 1 ;
px = cli_find_backend ( appctx , args [ 3 ] ) ;
if ( ! px )
return 1 ;
2019-08-09 05:21:01 -04:00
if ( ! * args [ 4 ] )
return cli_err ( appctx , " String value expected. \n " ) ;
2017-03-14 15:08:46 -04:00
newkey = strdup ( args [ 4 ] ) ;
2019-08-09 05:21:01 -04:00
if ( ! newkey )
return cli_err ( appctx , " Failed to allocate memory. \n " ) ;
2018-08-21 08:50:44 -04:00
2019-07-30 05:59:34 -04:00
/* Note: this lock is to make sure this doesn't change while another
* thread is in srv_set_dyncookie ( ) .
*/
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & px - > lock ) ;
2017-03-14 15:08:46 -04:00
free ( px - > dyncookie_key ) ;
px - > dyncookie_key = newkey ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & px - > lock ) ;
2017-03-14 15:08:46 -04:00
2018-08-21 08:50:44 -04:00
for ( s = px - > srv ; s ! = NULL ; s = s - > next ) {
HA_SPIN_LOCK ( SERVER_LOCK , & s - > lock ) ;
2017-03-14 15:08:46 -04:00
srv_set_dyncookie ( s ) ;
2018-08-21 08:50:44 -04:00
HA_SPIN_UNLOCK ( SERVER_LOCK , & s - > lock ) ;
}
2017-03-14 15:08:46 -04:00
return 1 ;
}
2018-08-21 08:50:44 -04:00
/* Parses the "set maxconn frontend" directive, it always returns 1.
*
* Grabs the proxy lock .
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_set_maxconn_frontend ( char * * args , char * payload , struct appctx * appctx , void * private )
2016-11-23 10:22:04 -05:00
{
struct proxy * px ;
struct listener * l ;
int v ;
if ( ! cli_has_level ( appctx , ACCESS_LVL_ADMIN ) )
return 1 ;
px = cli_find_frontend ( appctx , args [ 3 ] ) ;
if ( ! px )
return 1 ;
2019-08-09 05:21:01 -04:00
if ( ! * args [ 4 ] )
return cli_err ( appctx , " Integer value expected. \n " ) ;
2016-11-23 10:22:04 -05:00
v = atoi ( args [ 4 ] ) ;
2019-08-09 05:21:01 -04:00
if ( v < 0 )
return cli_err ( appctx , " Value out of range. \n " ) ;
2016-11-23 10:22:04 -05:00
/* OK, the value is fine, so we assign it to the proxy and to all of
* its listeners . The blocked ones will be dequeued .
*/
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & px - > lock ) ;
2018-08-21 08:50:44 -04:00
2016-11-23 10:22:04 -05:00
px - > maxconn = v ;
list_for_each_entry ( l , & px - > conf . listeners , by_fe ) {
if ( l - > state = = LI_FULL )
resume_listener ( l ) ;
}
2019-12-10 08:10:52 -05:00
if ( px - > maxconn > px - > feconn )
dequeue_proxy_listeners ( px ) ;
2016-11-23 10:22:04 -05:00
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & px - > lock ) ;
2018-08-21 08:50:44 -04:00
2016-11-23 10:22:04 -05:00
return 1 ;
}
2018-08-21 08:50:44 -04:00
/* Parses the "shutdown frontend" directive, it always returns 1.
*
* Grabs the proxy lock .
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_shutdown_frontend ( char * * args , char * payload , struct appctx * appctx , void * private )
2016-11-24 05:13:06 -05:00
{
struct proxy * px ;
if ( ! cli_has_level ( appctx , ACCESS_LVL_ADMIN ) )
return 1 ;
px = cli_find_frontend ( appctx , args [ 2 ] ) ;
if ( ! px )
return 1 ;
2020-09-24 02:39:22 -04:00
if ( px - > disabled )
2019-08-09 05:21:01 -04:00
return cli_msg ( appctx , LOG_NOTICE , " Frontend was already shut down. \n " ) ;
2016-11-24 05:13:06 -05:00
stop_proxy ( px ) ;
return 1 ;
}
2018-08-21 08:50:44 -04:00
/* Parses the "disable frontend" directive, it always returns 1.
*
* Grabs the proxy lock .
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_disable_frontend ( char * * args , char * payload , struct appctx * appctx , void * private )
2016-11-24 05:55:28 -05:00
{
struct proxy * px ;
2018-08-21 08:50:44 -04:00
int ret ;
2016-11-24 05:55:28 -05:00
if ( ! cli_has_level ( appctx , ACCESS_LVL_ADMIN ) )
return 1 ;
px = cli_find_frontend ( appctx , args [ 2 ] ) ;
if ( ! px )
return 1 ;
2020-09-24 02:39:22 -04:00
if ( px - > disabled )
2019-08-09 05:21:01 -04:00
return cli_msg ( appctx , LOG_NOTICE , " Frontend was previously shut down, cannot disable. \n " ) ;
2016-11-24 05:55:28 -05:00
2020-09-24 02:04:27 -04:00
if ( ! px - > li_ready )
return cli_msg ( appctx , LOG_NOTICE , " All sockets are already disabled. \n " ) ;
2016-11-24 05:55:28 -05:00
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & px - > lock ) ;
2018-08-21 08:50:44 -04:00
ret = pause_proxy ( px ) ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & px - > lock ) ;
2018-08-21 08:50:44 -04:00
2019-08-09 05:21:01 -04:00
if ( ! ret )
return cli_err ( appctx , " Failed to pause frontend, check logs for precise cause. \n " ) ;
2016-11-24 05:55:28 -05:00
return 1 ;
}
2018-08-21 08:50:44 -04:00
/* Parses the "enable frontend" directive, it always returns 1.
*
* Grabs the proxy lock .
*/
2018-04-18 07:26:46 -04:00
static int cli_parse_enable_frontend ( char * * args , char * payload , struct appctx * appctx , void * private )
2016-11-24 05:55:28 -05:00
{
struct proxy * px ;
2018-08-21 08:50:44 -04:00
int ret ;
2016-11-24 05:55:28 -05:00
if ( ! cli_has_level ( appctx , ACCESS_LVL_ADMIN ) )
return 1 ;
px = cli_find_frontend ( appctx , args [ 2 ] ) ;
if ( ! px )
return 1 ;
2020-09-24 02:39:22 -04:00
if ( px - > disabled )
2019-08-09 05:21:01 -04:00
return cli_err ( appctx , " Frontend was previously shut down, cannot enable. \n " ) ;
2016-11-24 05:55:28 -05:00
2020-09-24 02:04:27 -04:00
if ( px - > li_ready = = px - > li_all )
return cli_msg ( appctx , LOG_NOTICE , " All sockets are already enabled. \n " ) ;
2016-11-24 05:55:28 -05:00
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRLOCK ( PROXY_LOCK , & px - > lock ) ;
2018-08-21 08:50:44 -04:00
ret = resume_proxy ( px ) ;
2020-10-20 11:24:27 -04:00
HA_RWLOCK_WRUNLOCK ( PROXY_LOCK , & px - > lock ) ;
2018-08-21 08:50:44 -04:00
2019-08-09 05:21:01 -04:00
if ( ! ret )
return cli_err ( appctx , " Failed to resume frontend, check logs for precise cause (port conflict?) . \ n " ) ;
2016-11-24 05:55:28 -05:00
return 1 ;
}
2018-09-07 12:34:24 -04:00
/* "show errors" handler for the CLI. Returns 0 if wants to continue, 1 to stop
* now .
*/
static int cli_parse_show_errors ( char * * args , char * payload , struct appctx * appctx , void * private )
{
if ( ! cli_has_level ( appctx , ACCESS_LVL_OPER ) )
return 1 ;
if ( * args [ 2 ] ) {
struct proxy * px ;
px = proxy_find_by_name ( args [ 2 ] , 0 , 0 ) ;
if ( px )
appctx - > ctx . errors . iid = px - > uuid ;
else
appctx - > ctx . errors . iid = atoi ( args [ 2 ] ) ;
2019-08-09 05:21:01 -04:00
if ( ! appctx - > ctx . errors . iid )
return cli_err ( appctx , " No such proxy. \n " ) ;
2018-09-07 12:34:24 -04:00
}
else
appctx - > ctx . errors . iid = - 1 ; // dump all proxies
appctx - > ctx . errors . flag = 0 ;
if ( strcmp ( args [ 3 ] , " request " ) = = 0 )
appctx - > ctx . errors . flag | = 4 ; // ignore response
else if ( strcmp ( args [ 3 ] , " response " ) = = 0 )
appctx - > ctx . errors . flag | = 2 ; // ignore request
appctx - > ctx . errors . px = NULL ;
return 0 ;
}
/* This function dumps all captured errors onto the stream interface's
* read buffer . It returns 0 if the output buffer is full and it needs
* to be called again , otherwise non - zero .
*/
static int cli_io_handler_show_errors ( struct appctx * appctx )
{
struct stream_interface * si = appctx - > owner ;
extern const char * monthname [ 12 ] ;
if ( unlikely ( si_ic ( si ) - > flags & ( CF_WRITE_ERROR | CF_SHUTW ) ) )
return 1 ;
chunk_reset ( & trash ) ;
if ( ! appctx - > ctx . errors . px ) {
/* the function had not been called yet, let's prepare the
* buffer for a response .
*/
struct tm tm ;
get_localtime ( date . tv_sec , & tm ) ;
chunk_appendf ( & trash , " Total events captured on [%02d/%s/%04d:%02d:%02d:%02d.%03d] : %u \n " ,
tm . tm_mday , monthname [ tm . tm_mon ] , tm . tm_year + 1900 ,
tm . tm_hour , tm . tm_min , tm . tm_sec , ( int ) ( date . tv_usec / 1000 ) ,
error_snapshot_id ) ;
2018-09-07 13:55:44 -04:00
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 )
goto cant_send ;
2018-09-07 12:34:24 -04:00
appctx - > ctx . errors . px = proxies_list ;
appctx - > ctx . errors . bol = 0 ;
appctx - > ctx . errors . ptr = - 1 ;
}
/* we have two inner loops here, one for the proxy, the other one for
* the buffer .
*/
while ( appctx - > ctx . errors . px ) {
struct error_snapshot * es ;
2020-10-20 11:38:10 -04:00
HA_RWLOCK_RDLOCK ( PROXY_LOCK , & appctx - > ctx . errors . px - > lock ) ;
2018-09-07 13:55:44 -04:00
2018-09-07 12:34:24 -04:00
if ( ( appctx - > ctx . errors . flag & 1 ) = = 0 ) {
2018-09-07 13:02:32 -04:00
es = appctx - > ctx . errors . px - > invalid_req ;
2018-09-07 12:34:24 -04:00
if ( appctx - > ctx . errors . flag & 2 ) // skip req
goto next ;
}
else {
2018-09-07 13:02:32 -04:00
es = appctx - > ctx . errors . px - > invalid_rep ;
2018-09-07 12:34:24 -04:00
if ( appctx - > ctx . errors . flag & 4 ) // skip resp
goto next ;
}
2018-09-07 13:02:32 -04:00
if ( ! es )
2018-09-07 12:34:24 -04:00
goto next ;
if ( appctx - > ctx . errors . iid > = 0 & &
appctx - > ctx . errors . px - > uuid ! = appctx - > ctx . errors . iid & &
2020-03-12 10:30:17 -04:00
( ! es - > oe | | es - > oe - > uuid ! = appctx - > ctx . errors . iid ) )
2018-09-07 12:34:24 -04:00
goto next ;
if ( appctx - > ctx . errors . ptr < 0 ) {
/* just print headers now */
char pn [ INET6_ADDRSTRLEN ] ;
struct tm tm ;
int port ;
get_localtime ( es - > when . tv_sec , & tm ) ;
chunk_appendf ( & trash , " \n [%02d/%s/%04d:%02d:%02d:%02d.%03d] " ,
tm . tm_mday , monthname [ tm . tm_mon ] , tm . tm_year + 1900 ,
tm . tm_hour , tm . tm_min , tm . tm_sec , ( int ) ( es - > when . tv_usec / 1000 ) ) ;
switch ( addr_to_str ( & es - > src , pn , sizeof ( pn ) ) ) {
case AF_INET :
case AF_INET6 :
port = get_host_port ( & es - > src ) ;
break ;
default :
port = 0 ;
}
switch ( appctx - > ctx . errors . flag & 1 ) {
case 0 :
chunk_appendf ( & trash ,
" frontend %s (#%d): invalid request \n "
" backend %s (#%d) " ,
appctx - > ctx . errors . px - > id , appctx - > ctx . errors . px - > uuid ,
2020-03-12 10:30:17 -04:00
( es - > oe & & es - > oe - > cap & PR_CAP_BE ) ? es - > oe - > id : " <NONE> " ,
( es - > oe & & es - > oe - > cap & PR_CAP_BE ) ? es - > oe - > uuid : - 1 ) ;
2018-09-07 12:34:24 -04:00
break ;
case 1 :
chunk_appendf ( & trash ,
" backend %s (#%d): invalid response \n "
" frontend %s (#%d) " ,
appctx - > ctx . errors . px - > id , appctx - > ctx . errors . px - > uuid ,
2020-03-12 10:30:17 -04:00
es - > oe ? es - > oe - > id : " <NONE> " , es - > oe ? es - > oe - > uuid : - 1 ) ;
2018-09-07 12:34:24 -04:00
break ;
}
chunk_appendf ( & trash ,
" , server %s (#%d), event #%u, src %s:%d \n "
" buffer starts at %llu (including %u out), %u free, \n "
" len %u, wraps at %u, error at position %u \n " ,
es - > srv ? es - > srv - > id : " <NONE> " ,
es - > srv ? es - > srv - > puid : - 1 ,
es - > ev_id , pn , port ,
es - > buf_ofs , es - > buf_out ,
global . tune . bufsize - es - > buf_out - es - > buf_len ,
es - > buf_len , es - > buf_wrap , es - > buf_err ) ;
if ( es - > show )
es - > show ( & trash , es ) ;
chunk_appendf ( & trash , " \n " ) ;
2018-09-07 13:55:44 -04:00
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 )
goto cant_send_unlock ;
2018-09-07 12:34:24 -04:00
appctx - > ctx . errors . ptr = 0 ;
appctx - > ctx . errors . ev_id = es - > ev_id ;
}
if ( appctx - > ctx . errors . ev_id ! = es - > ev_id ) {
/* the snapshot changed while we were dumping it */
chunk_appendf ( & trash ,
" WARNING! update detected on this snapshot, dump interrupted. Please re-check! \n " ) ;
2018-09-07 13:55:44 -04:00
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 )
goto cant_send_unlock ;
2018-09-07 12:34:24 -04:00
goto next ;
}
/* OK, ptr >= 0, so we have to dump the current line */
2018-09-07 14:07:17 -04:00
while ( appctx - > ctx . errors . ptr < es - > buf_len & & appctx - > ctx . errors . ptr < global . tune . bufsize ) {
2018-09-07 12:34:24 -04:00
int newptr ;
int newline ;
newline = appctx - > ctx . errors . bol ;
newptr = dump_text_line ( & trash , es - > buf , global . tune . bufsize , es - > buf_len , & newline , appctx - > ctx . errors . ptr ) ;
if ( newptr = = appctx - > ctx . errors . ptr )
2018-09-07 13:55:44 -04:00
goto cant_send_unlock ;
if ( ci_putchk ( si_ic ( si ) , & trash ) = = - 1 )
goto cant_send_unlock ;
2018-09-07 12:34:24 -04:00
appctx - > ctx . errors . ptr = newptr ;
appctx - > ctx . errors . bol = newline ;
} ;
next :
2020-10-20 11:38:10 -04:00
HA_RWLOCK_RDUNLOCK ( PROXY_LOCK , & appctx - > ctx . errors . px - > lock ) ;
2018-09-07 12:34:24 -04:00
appctx - > ctx . errors . bol = 0 ;
appctx - > ctx . errors . ptr = - 1 ;
appctx - > ctx . errors . flag ^ = 1 ;
if ( ! ( appctx - > ctx . errors . flag & 1 ) )
appctx - > ctx . errors . px = appctx - > ctx . errors . px - > next ;
}
/* dump complete */
return 1 ;
2018-09-07 13:55:44 -04:00
cant_send_unlock :
2020-10-20 11:38:10 -04:00
HA_RWLOCK_RDUNLOCK ( PROXY_LOCK , & appctx - > ctx . errors . px - > lock ) ;
2018-09-07 13:55:44 -04:00
cant_send :
2018-11-15 05:08:52 -05:00
si_rx_room_blk ( si ) ;
2018-09-07 13:55:44 -04:00
return 0 ;
2018-09-07 12:34:24 -04:00
}
2016-11-18 20:25:36 -05:00
/* register cli keywords */
static struct cli_kw_list cli_kws = { { } , {
2016-11-24 05:55:28 -05:00
{ { " disable " , " frontend " , NULL } , " disable frontend : temporarily disable specific frontend " , cli_parse_disable_frontend , NULL , NULL } ,
{ { " enable " , " frontend " , NULL } , " enable frontend : re-enable specific frontend " , cli_parse_enable_frontend , NULL , NULL } ,
2016-11-23 10:22:04 -05:00
{ { " set " , " maxconn " , " frontend " , NULL } , " set maxconn frontend : change a frontend's maxconn setting " , cli_parse_set_maxconn_frontend , NULL } ,
2020-07-01 01:00:59 -04:00
{ { " show " , " servers " , " conn " , NULL } , " show servers conn [id]: dump server connections status (for backend <id>) " , cli_parse_show_servers , cli_io_handler_servers_state } ,
2016-11-18 20:25:36 -05:00
{ { " show " , " servers " , " state " , NULL } , " show servers state [id]: dump volatile server information (for backend <id>) " , cli_parse_show_servers , cli_io_handler_servers_state } ,
2016-12-16 12:01:15 -05:00
{ { " show " , " backend " , NULL } , " show backend : list backends in the current running config " , NULL , cli_io_handler_show_backend } ,
2016-11-24 05:13:06 -05:00
{ { " shutdown " , " frontend " , NULL } , " shutdown frontend : stop a specific frontend " , cli_parse_shutdown_frontend , NULL , NULL } ,
2017-03-14 15:08:46 -04:00
{ { " set " , " dynamic-cookie-key " , " backend " , NULL } , " set dynamic-cookie-key backend : change a backend secret key for dynamic cookies " , cli_parse_set_dyncookie_key_backend , NULL } ,
{ { " enable " , " dynamic-cookie " , " backend " , NULL } , " enable dynamic-cookie backend : enable dynamic cookies on a specific backend " , cli_parse_enable_dyncookie_backend , NULL } ,
{ { " disable " , " dynamic-cookie " , " backend " , NULL } , " disable dynamic-cookie backend : disable dynamic cookies on a specific backend " , cli_parse_disable_dyncookie_backend , NULL } ,
2018-09-07 12:34:24 -04:00
{ { " show " , " errors " , NULL } , " show errors : report last request and response errors for each proxy " , cli_parse_show_errors , cli_io_handler_show_errors , NULL } ,
2016-11-18 20:25:36 -05:00
{ { } , }
} } ;
2018-11-25 13:14:37 -05:00
INITCALL1 ( STG_REGISTER , cli_register_kw , & cli_kws ) ;
2006-06-25 20:48:02 -04:00
/*
* Local variables :
* c - indent - level : 8
* c - basic - offset : 8
* End :
*/