]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
11 years agoMINOR: stats: report correct throttling percentage for servers in slowstart
Willy Tarreau [Thu, 21 Nov 2013 14:30:45 +0000 (15:30 +0100)] 
MINOR: stats: report correct throttling percentage for servers in slowstart

The column used to report the throttle percentage when a server is in
slowstart is based on the time only. This is wrong, because server weights
in slowstart are updated at most once a second, so the reported value is
wrong at least fo rone second during each step, which means all the time
when using short delays (< 20s).

The second point is that it's disturbing to see a weight < 100% without
any throttle at the end of the period (during the last second), because
the effective weight has not yet been updated.

Instead, we now compute the exact ratio between eweight and uweight and
report it. It's always accurate and describes the value being used instead
of using only the date.

It can be backported to 1.4 though it's not particularly important.

11 years agoBUG/MAJOR: server: weight calculation fails for map-based algorithms
Willy Tarreau [Thu, 21 Nov 2013 10:22:01 +0000 (11:22 +0100)] 
BUG/MAJOR: server: weight calculation fails for map-based algorithms

A crash was reported by Igor at owind when changing a server's weight
on the CLI. Lukas Tribus could reproduce a related bug where setting
a server's weight would result in the new weight being multiplied by
the initial one. The two bugs are the same.

The incorrect weight calculation results in the total farm weight being
larger than what was initially allocated, causing the map index to be out
of bounds on some hashes. It's easy to reproduce using "balance url_param"
with a variable param, or with "balance static-rr".

It appears that the calculation is made at many places and is not always
right and not always wrong the same way. Thus, this patch introduces a
new function "server_recalc_eweight()" which is dedicated to this task
of computing ->eweight from many other elements including uweight and
current time (for slowstart), and all users now switch to use this
function.

The patch is a bit large but the code was not trivially fixable in a way
that could guarantee this situation would not occur anymore. The fix is
much more readable and has been verified to work with all algorithms,
with both consistent and map-based hashes, and even with static-rr.

Slowstart was tested as well, just like enable/disable server.

The same bug is very likely present in 1.4 as well, so the patch will
probably need to be backported eventhough it will not apply as-is.

Thanks to Lukas and Igor for the information they provided to reproduce it.

11 years agoBUG/MEDIUM: checks: fix slow start regression after fix attempt
Willy Tarreau [Thu, 21 Nov 2013 10:50:50 +0000 (11:50 +0100)] 
BUG/MEDIUM: checks: fix slow start regression after fix attempt

Commit 2e99390 (BUG/MEDIUM: checks: fix slowstart behaviour when server
tracking is in use) moved the slowstart task initialization within the
health check code and leaves it unset when checks are disabled. The
problem is that it's possible to trigger slowstart from the CLI by
issuing "disable server XXX / enable server XXX" even when checks are
disabled. The result is a crash when trying to wake up the slowstart
task of that server.

Move the task initialization earlier so that it is done even if the
checks are disabled.

This patch should be backported to 1.4 since the commit above was
backported there.

11 years agoMINOR: buffer: align the last output line if there are less than 8 characters left
Godbach [Thu, 21 Nov 2013 02:21:22 +0000 (10:21 +0800)] 
MINOR: buffer: align the last output line if there are less than 8 characters left

Commit c08057c does the align job for buffer_dump(), but it has not fixed the
issue that less than 8 characters are left in the last line as below:

Dumping contents from byte 0 to byte 119
         0  1  2  3  4  5  6  7    8  9  a  b  c  d  e  f
  0000: 47 45 54 20 2f 69 6e 64 - 65 78 2e 68 74 6d 20 48   GET /index.htm H
  0010: 54 54 50 2f 31 2e 30 0d - 0a 55 73 65 72 2d 41 67   TTP/1.0..User-Ag
  ...
  0060: 6e 65 63 74 69 6f 6e 3a - 20 4b 65 65 70 2d 41 6c   nection: Keep-Al
  0070: 69 76 65 0d 0a 0d 0a                              ive....

The last line of the hex column is still overlapped by the text column. Since
there will be additional "- " for the output line which has no less than 8
characters, two additional spaces should be present when there is less than 8
characters in order to do alignment. The result after being fixed is as below:

Dumping contents from byte 0 to byte 119
         0  1  2  3  4  5  6  7    8  9  a  b  c  d  e  f
  0000: 47 45 54 20 2f 69 6e 64 - 65 78 2e 68 74 6d 20 48   GET /index.htm H
  0010: 54 54 50 2f 31 2e 30 0d - 0a 55 73 65 72 2d 41 67   TTP/1.0..User-Ag
  ...
  0060: 6e 65 63 74 69 6f 6e 3a - 20 4b 65 65 70 2d 41 6c   nection: Keep-Al
  0070: 69 76 65 0d 0a 0d 0a                                ive....

Signed-off-by: Godbach <nylzhaowei@gmail.com>
11 years agoDOC: Documentation for hashing function, with test results.
Bhaskar Maddala [Wed, 20 Nov 2013 17:55:21 +0000 (12:55 -0500)] 
DOC: Documentation for hashing function, with test results.

Summary:
Added a document for hashing under internal docs explaining
hashing in haproxy along with the results of tests under the test
folder.

These documents together explain the motivation for adding
options for hashing algorithms with the option of enabling or
disabling of avalanche.

11 years agoMEDIUM: Move health element to struct check
Simon Horman [Sun, 24 Feb 2013 08:23:38 +0000 (17:23 +0900)] 
MEDIUM: Move health element to struct check

This is in preparation for associating a agent check
with a server which runs as well as the server's existing check.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoMEDIUM: Add state to struct check
Simon Horman [Sun, 24 Feb 2013 08:23:38 +0000 (17:23 +0900)] 
MEDIUM: Add state to struct check

Add state to struct check. This is currently used to store one bit,
CHK_RUNNING, which is set if a check is running and clear otherwise.
This bit was previously SRV_CHK_RUNNING of the state element of struct
server.

This is in preparation for associating a agent check
with a server which runs as well as the server's existing check.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
11 years agoMEDIUM: cfgparse: Factor out check initialisation
Simon Horman [Sat, 23 Feb 2013 06:14:19 +0000 (15:14 +0900)] 
MEDIUM: cfgparse: Factor out check initialisation

This is in preparation for struct server having two elements
of type struct check.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoMEDIUM: Paramatise functions over the check of a server
Simon Horman [Sat, 23 Feb 2013 06:35:38 +0000 (15:35 +0900)] 
MEDIUM: Paramatise functions over the check of a server

Paramatise the following functions over the check of a server

* set_server_down
* set_server_up
* srv_getinter
* server_status_printf
* set_server_check_status
* set_server_disabled
* set_server_enabled

Generally the server parameter of these functions has been removed.
Where it is still needed it is obtained using check->server.

This is in preparation for associating a agent check
with a server which runs as well as the server's existing check.
By paramatising these functions they may act on each of the checks
without further significant modification.

Explanation of the SSP_O_HCHK portion of this change:

* Prior to this patch SSP_O_HCHK serves a single purpose which
  is to tell server_status_printf() weather it should print
  the details of the check of a server or not.

  With the paramatisation that this patch adds there are two cases.
  1) Printing the details of the check in which case a
     valid check parameter is needed.
  2) Not printing the details of the check in which case
     the contents check parameter are unused.

  In case 1) we could pass SSP_O_HCHK and a valid check and;
  In case 2) we could pass !SSP_O_HCHK and any value for check
  including NULL.

  If NULL is used for case 2) then SSP_O_HCHK becomes supurfulous
  and as NULL is used for case 2) SSP_O_HCHK has been removed.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoMEDIUM: Move result element to struct check
Simon Horman [Sat, 23 Feb 2013 22:25:29 +0000 (07:25 +0900)] 
MEDIUM: Move result element to struct check

Move result element from struct server to struct check
This allows check results to be independent of the check's server.

This is in preparation for associating a agent check
with a server which runs as well as the server's existing check.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoMEDIUM: Split up struct server's check element
Simon Horman [Sat, 23 Feb 2013 01:16:43 +0000 (10:16 +0900)] 
MEDIUM: Split up struct server's check element

This is in preparation for associating a agent check
with a server which runs as well as the server's existing check.

The split has been made by:
* Moving elements of struct server's check element that will
  be shared by both checks into a new check_common element
  of struct server.
* Moving the remaining elements to a new struct check and
  making struct server's check element a struct check.
* Adding a server element to struct check, a back-pointer
  to the server element it is a member of.
  - At this time the server could be obtained using
    container_of, however, this will not be so easy
    once a second struct check element is added to struct server
    to accommodate an agent health check.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoCLEANUP: Remove unused 'last_slowstart_change' field from struct peer
Simon Horman [Fri, 1 Nov 2013 07:48:30 +0000 (16:48 +0900)] 
CLEANUP: Remove unused 'last_slowstart_change' field from struct peer

This was inadvertently added by "MEDIUM: checks: Add agent health check".
It appears to have never been used.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoCLEANUP: Make parameters of srv_downtime and srv_getinter const
Simon Horman [Fri, 1 Nov 2013 07:46:15 +0000 (16:46 +0900)] 
CLEANUP: Make parameters of srv_downtime and srv_getinter const

The parameters of srv_downtime and srv_getinter are not modified
and thus may be const.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoBUG/MINOR: http: fix build warning introduced with url32/url32_src
Willy Tarreau [Mon, 18 Nov 2013 17:33:22 +0000 (18:33 +0100)] 
BUG/MINOR: http: fix build warning introduced with url32/url32_src

commit 39c63c5 "url32+src - like base32+src but whole url including parameters"
was missing the last argument "const char *kw", resulting in the build warning
below :

src/proto_http.c:10351:2: warning: initialization from incompatible pointer type [enabled by default]
src/proto_http.c:10351:2: warning: (near initialization for 'sample_fetch_keywords.kw[50].process') [enabled by default]
src/proto_http.c:10352:2: warning: initialization from incompatible pointer type [enabled by default]
src/proto_http.c:10352:2: warning: (near initialization for 'sample_fetch_keywords.kw[51].process') [enabled by default]

It's harmless since it's not needed there anyway.

11 years agoBUG/MEDIUM: http: fix possible parser crash when parsing erroneous "http-request...
Willy Tarreau [Mon, 18 Nov 2013 17:04:25 +0000 (18:04 +0100)] 
BUG/MEDIUM: http: fix possible parser crash when parsing erroneous "http-request redirect" rules

Baptiste Assmann reported a bug affecting the "http-request redirect"
parser. It may randomly crash when reporting an error message if the
syntax is not OK. It happens that this is caused by the output error
message pointer which was not initialized to NULL.

This bug is 1.5-specific (introduced in dev17), no backport is needed.

11 years agourl32+src - like base32+src but whole url including parameters
Neil - HAProxy List [Mon, 4 Nov 2013 13:48:42 +0000 (13:48 +0000)] 
url32+src - like base32+src but whole url including parameters

I have a need to limit traffic to each url from each source address. much
like base32+src but the whole url including parameters (this came from
looking at the recent 'Haproxy rate limit per matching request' thread)

attached is patch that seems to do the job, its a copy and paste job of the
base32 functions

the url32 function seems to work too and using 2 machines to request the
same url locks me out of both if I abuse from either with the url32 key
function and only the one if I use url32_src.

Neil

11 years agoCLEANUP: http: merge error handling for req* and http-request *
Willy Tarreau [Sat, 16 Nov 2013 09:28:23 +0000 (10:28 +0100)] 
CLEANUP: http: merge error handling for req* and http-request *

The reqdeny/reqtarpit and http-request deny/tarpit were using
a copy-paste of the error handling code because originally the
req* actions used to maintain their own stats. This is not the
case anymore so we can use the same error blocks for both.

The http-request rulesets still has precedence over req* so no
functionality was changed.

11 years agoCLEANUP: http: homogenize processing of denied req counter
Willy Tarreau [Sat, 16 Nov 2013 09:13:35 +0000 (10:13 +0100)] 
CLEANUP: http: homogenize processing of denied req counter

The reqdeny/reqideny and reqtarpit/reqitarpit rules used to maintain
the stats counters themselves while http-request deny/tarpit and
rspdeny/rspideny used to centralize them at the point where the
error is processed.

Thus, let's do the same for reqdeny/reqtarpit so that the functions
which iterate over the rules do not have to deal with these counters
anymore.

11 years agoBUG/MINOR: stats: don't count tarpitted connections twice
Willy Tarreau [Sat, 16 Nov 2013 09:06:44 +0000 (10:06 +0100)] 
BUG/MINOR: stats: don't count tarpitted connections twice

When a connection is tarpitted, a denied req is counted once when the
action is applied, and then a failed req is counted when the tarpit
timeout expires. This is completely wrong as the tarpit is exactly
equivalent to a deny since it's a disguised deny.

So let's not increment the failed req anymore.

This fix may be backported to 1.4 which has the same issue.

11 years agoOPTIM/MINOR: mark the source address as already known on accept()
Willy Tarreau [Fri, 15 Nov 2013 23:15:40 +0000 (00:15 +0100)] 
OPTIM/MINOR: mark the source address as already known on accept()

Commit 986a9d2d12 moved the source address from the stream interface
to the session, but it did not set the flag on the connection to
report that the source address is known. Thus when logs are enabled,
we had a call to getpeername() which is redundant with the result
from accept(). This patch simply sets the flag.

11 years agoOPTIM/MEDIUM: epoll: fuse active events into polled ones during polling changes
Willy Tarreau [Fri, 15 Nov 2013 21:48:31 +0000 (22:48 +0100)] 
OPTIM/MEDIUM: epoll: fuse active events into polled ones during polling changes

When trying to speculatively send data to a server being connected to,
we see the following pattern :

    connect() = EINPROGRESS
    send() = EAGAIN
    epoll_ctl(add, W)
    epoll_wait() = EPOLLOUT
    send() = success
  > epoll_ctl(del, W)
  > recv() = EAGAIN
  > epoll_ctl(add, R)
    recv() = success
    epoll_ctl(del, R)

The reason for the failed recv() call is that the reading was marked
as speculative while we already have a polled I/O there. So we already
know when removing send write poll that the read is pending. Thus,
let's improve this by merging speculative I/O into polled I/O when
polled state changes. The result is now the following as expected :

    connect() = EINPROGRESS
    send() = EAGAIN
    epoll_ctl(add, W)
    epoll_wait() = EPOLLOUT
    send() = success
    epoll_ctl(mod, R)
    recv() = success
    epoll_ctl(del, R)

This is specific to epoll(), it doesn't make much sense at the moment
to do so for other pollers, because the cost of updating them is very
small.

The average performance gain on small requests is of 1.6% in TCP mode,
which is easily explained with the syscall stats below for 10000 forwarded
connections :

Before :
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 91.02    0.024608           0     60000         1 epoll_wait
  2.19    0.000593           0     20000           shutdown
  1.52    0.000412           0     10000     10000 connect
  1.36    0.000367           0     29998      9998 sendto
  1.09    0.000294           0     49993           epoll_ctl
  0.93    0.000252           0     50004     20002 recvfrom
  0.79    0.000214           0     20005           close
  0.62    0.000167           0     20001     10001 accept4
  0.25    0.000067           0     20002           setsockopt
  0.13    0.000035           0     10001           socket
  0.10    0.000028           0     10001           fcntl

After:
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 87.59    0.024269           0     50012         1 epoll_wait
  3.19    0.000884           0     20000           shutdown
  2.33    0.000646           0     29996      9996 sendto
  2.02    0.000560           0     10005     10003 connect
  1.40    0.000387           0     40013     10013 recvfrom
  1.35    0.000374           0     40000           epoll_ctl
  0.64    0.000178           0     20001     10001 accept4
  0.55    0.000152           0     20005           close
  0.45    0.000124           0     20002           setsockopt
  0.31    0.000086           0     10001           fcntl
  0.17    0.000047           0     10001           socket

Overall :
   -16.6% epoll_wait
   -20%   recvfrom
   -20%   epoll_ctl

On HTTP, the gain is even better :

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 80.43    0.015386           0     60006         1 epoll_wait
  4.61    0.000882           0     30000     10000 sendto
  3.74    0.000715           0     20001     10001 accept4
  3.35    0.000640           0     10000     10000 connect
  2.66    0.000508           0     20005           close
  1.34    0.000257           0     30002     10002 recvfrom
  1.27    0.000242           0     30005           epoll_ctl
  1.20    0.000230           0     10000           shutdown
  0.62    0.000119           0     20003           setsockopt
  0.40    0.000077           0     10001           socket
  0.39    0.000074           0     10001           fcntl
willy@wtap:haproxy$ head -15 apres.txt
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 83.47    0.020301           0     50008         1 epoll_wait
  4.26    0.001036           0     20005           close
  3.30    0.000803           0     30000     10000 sendto
  2.55    0.000621           0     20001     10001 accept4
  1.76    0.000428           0     10000     10000 connect
  1.20    0.000292           0     10000           shutdown
  1.14    0.000278           0     20001         1 recvfrom
  0.86    0.000210           0     20003           epoll_ctl
  0.71    0.000173           0     20003           setsockopt
  0.49    0.000120           0     10001           socket
  0.25    0.000060           0     10001           fcntl

Overall :
  -16.6% epoll_wait
  -33%   recvfrom
  -33%   epoll_ctl

11 years agoMEDIUM: backend: add support for the wt6 hash
Willy Tarreau [Thu, 14 Nov 2013 13:30:35 +0000 (14:30 +0100)] 
MEDIUM: backend: add support for the wt6 hash

This function was designed for haproxy while testing other functions
in the past. Initially it was not planned to be used given the not
very interesting numbers it showed on real URL data : it is not as
smooth as the other ones. But later tests showed that the other ones
are extremely sensible to the server count and the type of input data,
especially DJB2 which must not be used on numeric input. So in fact
this function is still a generally average performer and it can make
sense to merge it in the end, as it can provide an alternative to
sdbm+avalanche or djb2+avalanche for consistent hashing or when hashing
on numeric data such as a source IP address or a visitor identifier in
a URL parameter.

11 years agoMEDIUM: backend: Implement avalanche as a modifier of the hashing functions.
Bhaskar Maddala [Tue, 5 Nov 2013 16:54:02 +0000 (11:54 -0500)] 
MEDIUM: backend: Implement avalanche as a modifier of the hashing functions.

Summary:
Avalanche is supported not as a native hashing choice, but a modifier
on the hashing function. Note that this means that possible configs
written after 1.5-dev4 using "hash-type avalanche" will get an informative
error instead. But as discussed on the mailing list it seems nobody ever
used it anyway, so let's fix it before the final 1.5 release.

The default values were selected for backward compatibility with previous
releases, as discussed on the mailing list, which means that the consistent
hashing will still apply the avalanche hash by default when no explicit
algorithm is specified.

Examples
  (default) hash-type map-based
Map based hashing using sdbm without avalanche

  (default) hash-type consistent
Consistent hashing using sdbm with avalanche

Additional Examples:

  (a) hash-type map-based sdbm
Same as default for map-based above
  (b) hash-type map-based sdbm avalanche
Map based hashing using sdbm with avalanche
  (c) hash-type map-based djb2
Map based hashing using djb2 without avalanche
  (d) hash-type map-based djb2 avalanche
Map based hashing using djb2 with avalanche
  (e) hash-type consistent sdbm avalanche
Same as default for consistent above
  (f) hash-type consistent sdbm
Consistent hashing using sdbm without avalanche
  (g) hash-type consistent djb2
Consistent hashing using djb2 without avalanche
  (h) hash-type consistent djb2 avalanche
Consistent hashing using djb2 with avalanche

11 years agoMEDIUM: backend: Enhance hash-type directive with an algorithm options
Bhaskar [Wed, 30 Oct 2013 03:30:51 +0000 (23:30 -0400)] 
MEDIUM: backend: Enhance hash-type directive with an algorithm options

Summary:
In testing at tumblr, we found that using djb2 hashing instead of the
default sdbm hashing resulted is better workload distribution to our backends.

This commit implements a change, that allows the user to specify the hash
function they want to use. It does not limit itself to consistent hashing
scenarios.

The supported hash functions are sdbm (default), and djb2.

For a discussion of the feature and analysis, see mailing list thread
"Consistent hashing alternative to sdbm" :

      http://marc.info/?l=haproxy&m=138213693909219

Note: This change does NOT make changes to new features, for instance,
applying an avalance hashing always being performed before applying
consistent hashing.

11 years agoBUG/MINOR: acl: remove patterns from the tree before freeing them
Willy Tarreau [Thu, 14 Nov 2013 15:00:12 +0000 (16:00 +0100)] 
BUG/MINOR: acl: remove patterns from the tree before freeing them

A call to free_pattern_tree() upon exit() is made to free all ACL
patterns allocated in a tree (strings or IP addresses). Unfortunately
it happens that this function has been bogus from the beginning, it
walks over the whole tree, frees the nodes but forgets to remove them
from the tree prior to freeing them. So after visiting a leaf, the
next eb_next() call will require to revisit some of the upper nodes
that were just freed. This can remain unnoticed for a long time because
free() often just marks the area as free. But in cases of aggressive
memory freeing, the location will not be mapped anymore and the process
segfaults.

Note that the bug has no impact other than polluting kernel logs and
frightening sysadmins, since it happens just before exit().

Simply adding the debug code below makes it easier to reproduce the
same bug :

while (node) {
next = eb_next(node);
+ node->node_p = (void *)-1;
free(node);
node = next;
}

Many thanks to the StackExchange team for their very detailed bug report
that permitted to quickly understand this non-obvious bug!

This fix should be backported to 1.4 which introduced the bug.

11 years agoMINOR: buffer: align the last output line of buffer_dump()
Godbach [Thu, 14 Nov 2013 02:15:20 +0000 (10:15 +0800)] 
MINOR: buffer: align the last output line of buffer_dump()

If the dumped length of buffer is not multiple of 16, the last output line can
be seen as below:

Dumping contents from byte 0 to byte 125
         0  1  2  3  4  5  6  7    8  9  a  b  c  d  e  f
  0000: 47 45 54 20 2f 69 6e 64 - 65 78 2e 68 74 6d 20 48   GET /index.htm H
  0010: 54 54 50 2f 31 2e 30 0d - 0a 55 73 65 72 2d 41 67   TTP/1.0..User-Ag
  ...
  0060: 30 0d 0a 43 6f 6e 6e 65 - 63 74 69 6f 6e 3a 20 4b   0..Connection: K
  0070: 65 65 70 2d 41 6c 69 76 - 65 0d 0a 0d 0a   eep-Alive....

Yes, the hex column will be overlapped by the text column. Both the hex and
text column should be aligned at their own area as below:

Dumping contents from byte 0 to byte 125
         0  1  2  3  4  5  6  7    8  9  a  b  c  d  e  f
  0000: 47 45 54 20 2f 69 6e 64 - 65 78 2e 68 74 6d 20 48   GET /index.htm H
  0010: 54 54 50 2f 31 2e 30 0d - 0a 55 73 65 72 2d 41 67   TTP/1.0..User-Ag
  ...
  0060: 30 0d 0a 43 6f 6e 6e 65 - 63 74 69 6f 6e 3a 20 4b   0..Connection: K
  0070: 65 65 70 2d 41 6c 69 76 - 65 0d 0a 0d 0a            eep-Alive....

Signed-off-by: Godbach <nylzhaowei@gmail.com>
11 years agoMINOR: tcp: don't use tick_add_ifset() when timeout is known to be set
Willy Tarreau [Mon, 4 Nov 2013 14:56:53 +0000 (15:56 +0100)] 
MINOR: tcp: don't use tick_add_ifset() when timeout is known to be set

These two useless tests propably result from a copy-paste. The test is
performed in the condition to enter the block.

11 years agoMINOR: acl: add a warning when an ACL keyword is used without any value
Willy Tarreau [Mon, 4 Nov 2013 17:09:12 +0000 (18:09 +0100)] 
MINOR: acl: add a warning when an ACL keyword is used without any value

It's quite common to write directives like the following :

  tcp-request reject if WAIT_END { sc0_inc_gpc0 }

This one will never reject, because sc0_inc_gpc0 is provided no value
to compare against. The proper form should have been something like this :

  tcp-request reject if WAIT_END { sc0_inc_gpc0 gt 0 }

or :

  tcp-request reject if WAIT_END { sc0_inc_gpc0 -m found }

Now we detect the absence of any argument on the command line and emit
a warning suggesting alternatives or the use of "--" to really avoid
matching anything (might be used when debugging).

11 years agoBUG/MEDIUM: acl: do not evaluate next terms after a miss
Willy Tarreau [Wed, 30 Oct 2013 18:30:32 +0000 (19:30 +0100)] 
BUG/MEDIUM: acl: do not evaluate next terms after a miss

When a condition does something like :

   action if A B C || D E F

If B returns a miss (can't tell true or false), C must not
be evaluated. This is important when C has a side effect
(eg: sc*_inc_gpc0). However the second part after the ||
can still be evaluated.

11 years agoBUG/MEDIUM: tcp: do not skip tracking rules on second pass
Willy Tarreau [Wed, 30 Oct 2013 18:24:00 +0000 (19:24 +0100)] 
BUG/MEDIUM: tcp: do not skip tracking rules on second pass

The track-sc* tcp rules are bogus. The test to verify if the
tracked counter was already assigned is performed in the same
condition as the test for the action. The effect is that a
rule which tracks a counter that is already being tracked
is implicitly converted to an accept because the default
rule is an accept.

This bug only affects 1.5-dev releases.

11 years agoBUG/MINOR: peers: set the accept date in outgoing connections
Willy Tarreau [Tue, 1 Oct 2013 15:06:10 +0000 (17:06 +0200)] 
BUG/MINOR: peers: set the accept date in outgoing connections

Without this, "show sess" on the CLI reports a wrong age.

11 years agoBUG/MEDIUM: session: risk of crash on out of memory conditions
Willy Tarreau [Sun, 20 Oct 2013 21:10:28 +0000 (23:10 +0200)] 
BUG/MEDIUM: session: risk of crash on out of memory conditions

In session_accept(), if we face a memory allocation error, we try to
emit an HTTP 500 error message in HTTP mode. The problem is that we
must not use http_error_message() for this since it dereferences the
session which can be NULL in this case.

We don't need the session to build the error message anyway since
this function only uses it to retrieve the backend and frontend to
get the most suited error message. Let's pick it ourselves, we're
at the beginning of the session, only the frontend is relevant.

This bug is 1.5-specific.

11 years agoBUILD/MINOR: missing header file
Thierry FOURNIER [Wed, 16 Oct 2013 14:19:38 +0000 (16:19 +0200)] 
BUILD/MINOR: missing header file

In the header file "types/proto_http.h", the list are used
but the header file "mini-clist.h" is not included.

11 years agoMINOR: http: change url_decode to return the size of the decoded string.
Thierry FOURNIER [Fri, 4 Oct 2013 14:27:27 +0000 (16:27 +0200)] 
MINOR: http: change url_decode to return the size of the decoded string.

Currently url_decode returns 1 or 0 depending on whether it could decode
the string or not. For some future use cases, it will be needed to get the
decoded string length after a successful decoding, so let's make it return
that value, and fall back to a negative one in case of error.

11 years agoMINOR: http: some exported functions were not in the header file
Thierry FOURNIER [Tue, 15 Oct 2013 09:43:19 +0000 (11:43 +0200)] 
MINOR: http: some exported functions were not in the header file

Export the following functions:
 - find_hdr_value_end
 - http_header_match2
 - http_remove_header2
 - http_header_add_tail2

11 years agoCLEANUP: The function "regex_exec" needs the string length but in many case they...
Thierry FOURNIER [Tue, 15 Oct 2013 11:41:44 +0000 (13:41 +0200)] 
CLEANUP: The function "regex_exec" needs the string length but in many case they expect null terminated char.

If haproxy is compiled with the USE_PCRE_JIT option, the length of the
string is used. If it is compiled without this option the function doesn't
use the length and expects a null terminated string.

The prototype of the function is ambiguous, and depends on the
compilation option. The developer can think that the length is always
used, and many bugs can be created.

This patch makes sure that the length is used. The regex_exec function
adds the final '\0' if it is needed.

11 years agoMINOR: Makefile: provide cscope rule
William Lallemand [Fri, 18 Oct 2013 14:26:39 +0000 (16:26 +0200)] 
MINOR: Makefile: provide cscope rule

"make cscope" builds tags for cscope.

11 years agoBUG/MINOR: acl: implicit arguments of ACL keywords were not properly resolved
Willy Tarreau [Tue, 22 Oct 2013 17:10:06 +0000 (19:10 +0200)] 
BUG/MINOR: acl: implicit arguments of ACL keywords were not properly resolved

William Lallemand reported a bug which happens when an ACL keyword using an
implicit argument (eg: a proxy name) is used : the keyword is not properly
set in the arglist field, resulting in an error about the previous keyword
being returned, or "(null)" if the faulty ACL appears first.

The bug only affects error reporting and is 1.5-specific, so no backport is
nedeed.

11 years agoBUG/MEDIUM: http: accept full buffers on smp_prefetch_http
Willy Tarreau [Mon, 14 Oct 2013 20:41:30 +0000 (22:41 +0200)] 
BUG/MEDIUM: http: accept full buffers on smp_prefetch_http

Bertrand Jacquin reported a but when using tcp_request content rules
on large POST HTTP requests. The issue is that smp_prefetch_http()
first tries to validate an input buffer, but only if the buffer is
not full. This test is wrong since it must only be performed after
the parsing has failed, otherwise we don't accept POST requests which
fill the buffer as valid HTTP requests.

This bug is 1.5-specific, no backport needed.

11 years agoCLEANUP: regex: Create regex_comp function that compiles regex using compilation...
Thierry FOURNIER [Mon, 14 Oct 2013 12:07:36 +0000 (14:07 +0200)] 
CLEANUP: regex: Create regex_comp function that compiles regex using compilation options

The current file "regex.h" define an abstraction for the regex. It
provides the same struct name and the same "regexec" function for the
3 regex types supported: standard libc, basic pcre and jit pcre.

The regex compilation function is not provided by this file. If the
developper wants to use regex, he must write regex compilation code
containing "#define *JIT*".

This patch provides a unique regex compilation function according to
the compilation options.

In addition, the "regex.h" file checks the presence of the "#define
PCRE_CONFIG_JIT" when "USE_PCRE_JIT" is enabled. If this flag is not
present, the pcre lib doesn't support JIT and "#error" is emitted.

11 years agoCLEANUP: stream_interface: cleanup loop information in si_conn_send_loop()
Godbach [Fri, 11 Oct 2013 07:48:29 +0000 (15:48 +0800)] 
CLEANUP: stream_interface: cleanup loop information in si_conn_send_loop()

Though si_conn_send_loop() does not loop over ->snd_buf() after commit ed7f836,
there is still some codes left which use `while` but only execute once. This
commit does the cleanup job and rename si_conn_send_loop() to si_conn_send().

Signed-off-by: Godbach <nylzhaowei@gmail.com>
11 years agoDOC: missing http-send-name-header keyword in keyword table
Baptiste Assmann [Wed, 9 Oct 2013 19:57:02 +0000 (21:57 +0200)] 
DOC: missing http-send-name-header keyword in keyword table

This one was in the doc but not in the keyword matrix.

11 years agoDOC: missing information for the "description" keyword
Baptiste Assmann [Wed, 9 Oct 2013 04:51:49 +0000 (06:51 +0200)] 
DOC: missing information for the "description" keyword

This keyword was not documented.

11 years agoBUILD/MINOR: missing header file
Thierry FOURNIER [Wed, 9 Oct 2013 13:23:01 +0000 (15:23 +0200)] 
BUILD/MINOR: missing header file

In the header file "common/regex.h", the C keyword NULL is used. This
keyword is referenced into the header file "stdlib.h", but this is not
included.

11 years agoBUG/MINOR: ssl: verifyhost does not match empty strings on wildcard.
Emeric Brun [Tue, 8 Oct 2013 09:39:35 +0000 (11:39 +0200)] 
BUG/MINOR: ssl: verifyhost does not match empty strings on wildcard.

RFC6125 does not specify if wildcard matches empty strings but
classical browsers implementations does.
After the fix foo*bar.exemple.om matches foobar.exemple.com.

11 years agoMINOR: ssl: optimization of verifyhost on wildcard certificates.
Emeric Brun [Tue, 8 Oct 2013 09:27:28 +0000 (11:27 +0200)] 
MINOR: ssl: optimization of verifyhost on wildcard certificates.

Optimizes verifyhost on wildcard certificates avoiding travel several times
the same string.

11 years agoBUG/MINOR: ssl: potential memory leaks using ssl_c_key_alg or ssl_c_sig_alg.
Emeric Brun [Mon, 7 Oct 2013 12:31:44 +0000 (14:31 +0200)] 
BUG/MINOR: ssl: potential memory leaks using ssl_c_key_alg or ssl_c_sig_alg.

The leak occurs in an error case which practically never happens.

11 years agoBUG/MINOR: deinit: free server map which is allocated in init_server_map()
Godbach [Wed, 2 Oct 2013 09:10:11 +0000 (17:10 +0800)] 
BUG/MINOR: deinit: free server map which is allocated in init_server_map()

Both static-rr and hash with type map-based call init_server_map() to allocate
server map, so the server map should be freed while doing cleanup if one of
the above load balance algorithms is used.

Signed-off-by: Godbach <nylzhaowei@gmail.com>
[wt: removed the unneeded "if" before the free]

11 years agoDOC: fix typo in comments
Godbach [Mon, 30 Sep 2013 03:23:10 +0000 (11:23 +0800)] 
DOC: fix typo in comments

Hi Willy,

There is a patch to fix typo in comments, please check the attachment
for you information.

The commit log is as below:

commit 9824d1b3740ac2746894f1aa611c795366c84210
Author: Godbach <nylzhaowei@gmail.com>
Date:   Mon Sep 30 11:05:42 2013 +0800

    DOC: fix typo in comments

      0x20000000 -> 0x40000000
      vuf -> buf
      ethod -> Method

Signed-off-by: Godbach <nylzhaowei@gmail.com>
--
Best Regards,
Godbach

From 9824d1b3740ac2746894f1aa611c795366c84210 Mon Sep 17 00:00:00 2001
From: Godbach <nylzhaowei@gmail.com>
Date: Mon, 30 Sep 2013 11:05:42 +0800
Subject: [PATCH] DOC: fix typo in comments

  0x20000000 -> 0x40000000
  vuf -> buf
  ethod -> Method

Signed-off-by: Godbach <nylzhaowei@gmail.com>
11 years agoDOC: ssl: update build instructions to use new SSL_* variables
Lukas Tribus [Mon, 30 Sep 2013 22:28:03 +0000 (00:28 +0200)] 
DOC: ssl: update build instructions to use new SSL_* variables

Since commit 9a05945bd ("BUILD: add SSL_INC/SSL_LIB variables to force the
path to openssl") we have SSL_INC and SSL_LIB to point to the libssl
installation.

This commits updates the build instructions in README accordingly.

11 years agoDOC: remove -s and -l options from the manpage
Apollon Oikonomopoulos [Sun, 29 Sep 2013 20:04:27 +0000 (23:04 +0300)] 
DOC: remove -s and -l options from the manpage

These options are no longer supported since 1.3, so remove them from the
manpage.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
11 years agoDOC: update manpage reference to haproxy-en.txt
Apollon Oikonomopoulos [Sun, 29 Sep 2013 20:04:13 +0000 (23:04 +0300)] 
DOC: update manpage reference to haproxy-en.txt

The manpage refers to haproxy-en.txt, which is obsolete. Update the reference
to point to configuration.txt, together with the location on Debian systems.

Also capitalize "Debian".

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
11 years agoDOC: add manpage references to all system calls
Apollon Oikonomopoulos [Sun, 29 Sep 2013 20:03:51 +0000 (23:03 +0300)] 
DOC: add manpage references to all system calls

Add a man section to every system call reference, giving users pointers to the
respective manpages.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
11 years agoDOC: add missing options to the manpage
Apollon Oikonomopoulos [Sun, 29 Sep 2013 20:03:37 +0000 (23:03 +0300)] 
DOC: add missing options to the manpage

Document -L, -v(v), -C, -dS and -dM, as they were missing from the manpage.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
11 years agoBUG/MINOR: acl: fix improper string size assignment in proxy argument
Willy Tarreau [Sun, 29 Sep 2013 09:36:53 +0000 (11:36 +0200)] 
BUG/MINOR: acl: fix improper string size assignment in proxy argument

This minor bug was found using the coccinelle script "da.cocci". The
len was initialized twice instead of setting the size. It's harmless
since no operations are performed on this empty string but needs to
be fixed anyway.

11 years agoMINOR: http: compute response time before processing headers
Willy Tarreau [Mon, 23 Sep 2013 14:44:27 +0000 (16:44 +0200)] 
MINOR: http: compute response time before processing headers

At the moment, HTTP response time is computed after response headers are
processed. This can misleadingly assign to the server some heavy local
processing (eg: regex), and also prevents response headers from passing
information related to the response time (which can sometimes be useful
for stats).

Let's retrieve the reponse time before processing the headers instead.

Note that in order to remain compatible with what was previously done,
we disable the response time when we get a 502 or any bad response. This
should probably be changed in 1.6 since it does not make sense anymore
to lose this information.

11 years agoBUG/MINOR: fix forcing fastinter in "on-error"
Sergiy Prykhodko [Sat, 21 Sep 2013 09:05:00 +0000 (12:05 +0300)] 
BUG/MINOR: fix forcing fastinter in "on-error"

health_adjust() should requeue the task after changing its expire timer.

I noticed it on devel servers without load. We have long inter (10 seconds)
and short fasinter (100ms). But according to webserver logs, after a failed
request next check request was called with same 10s interval.

This patch should probably be backported to 1.4 which has the same feature.

11 years agoBUILD: ssl: compilation issue with openssl v0.9.6.
Emeric Brun [Tue, 17 Sep 2013 13:47:48 +0000 (15:47 +0200)] 
BUILD: ssl: compilation issue with openssl v0.9.6.

Failed to compile with openssl 0.9.6 since the 'verifyhost' feature.

11 years agoBUG/MEDIUM: ssl: potential memory leak using verifyhost
Emeric Brun [Tue, 17 Sep 2013 13:19:54 +0000 (15:19 +0200)] 
BUG/MEDIUM: ssl: potential memory leak using verifyhost

If server certificate presents dns aliases, a memory leak appears
on health checks when 'verifyhost' statement is used.

11 years agoBUILD: add SSL_INC/SSL_LIB variables to force the path to openssl
Willy Tarreau [Tue, 17 Sep 2013 13:26:39 +0000 (15:26 +0200)] 
BUILD: add SSL_INC/SSL_LIB variables to force the path to openssl

When trying to build with various versions of openssl, forcing the
path is still cumbersome. Let's add SSL_INC and SSL_LIB similar to
PCRE_INC and PCRE_LIB to allow forcing the path to the SSL includes
and libs.

11 years agoMINOR: payload: provide the "res.len" fetch method
Willy Tarreau [Wed, 11 Sep 2013 21:28:46 +0000 (23:28 +0200)] 
MINOR: payload: provide the "res.len" fetch method

This fetch method returns the response buffer len, similarly
to req.len for the request. Previously it was only possible
to rely on "res.payload(0,size) -m found" to find if at least
that amount of data was available, which was a bit tricky.

11 years agoMINOR: tcp: add new "close" action for tcp-response
Willy Tarreau [Wed, 11 Sep 2013 21:20:29 +0000 (23:20 +0200)] 
MINOR: tcp: add new "close" action for tcp-response

This new action immediately closes the connection with the server
when the condition is met. The first such rule executed ends the
rules evaluation. The main purpose of this action is to force a
connection to be finished between a client and a server after an
exchange when the application protocol expects some long time outs
to elapse first. The goal is to eliminate idle connections which
take signifiant resources on servers with certain protocols.

11 years agoMEDIUM: stick-tables: flush old entries upon soft-stop
Willy Tarreau [Wed, 4 Sep 2013 15:54:01 +0000 (17:54 +0200)] 
MEDIUM: stick-tables: flush old entries upon soft-stop

When a process with large stick tables is replaced by a new one and remains
present until the last connection finishes, it keeps these data in memory
for nothing since they will never be used anymore by incoming connections,
except during syncing with the new process. This is especially problematic
when dealing with long session protocols such as WebSocket as it becomes
possible to stack many processes and eat a lot of memory.

So the idea here is to know if a table still needs to be synced or not,
and to purge all unused entries once the sync is complete. This means that
after a few hundred milliseconds when everything has been synchronized with
the new process, only a few entries will remain allocated (only the ones
held by sessions during the restart) and all the remaining memory will be
freed.

Note that we carefully do that only after the grace period is expired so as
not to impact a possible proxy that needs to accept a few more connections
before leaving.

Doing this required to add a sync counter to the stick tables, to know how
many peer sync sessions are still in progress in order not to flush the entries
until all synchronizations are completed.

11 years agoBUG/MEDIUM: fix broken send_proxy on FreeBSD
Willy Tarreau [Tue, 3 Sep 2013 07:02:11 +0000 (09:02 +0200)] 
BUG/MEDIUM: fix broken send_proxy on FreeBSD

David Berard reported that send-proxy was broken on FreeBSD and tracked the
issue to be an error returned by send(). We already had the same issue in
the past in another area which was addressed by the following commit :

   0ea0cf6 BUG: raw_sock: also consider ENOTCONN in addition to EAGAIN

In fact, on Linux send() returns EAGAIN when the connection is not yet
established while other OSes return ENOTCONN. Let's consider ENOTCONN for
send-proxy there as the same as EAGAIN.

David confirmed that this change properly fixed the issue.

Another place was affected as well (health checks with send-proxy), and
was fixed.

This fix does not need any backport since it only affects 1.5.

11 years agoMINOR: ssl: Add statement 'verifyhost' to "server" statements
Evan Broder [Thu, 27 Jun 2013 07:05:25 +0000 (00:05 -0700)] 
MINOR: ssl: Add statement 'verifyhost' to "server" statements

verifyhost allows you to specify a hostname that the remote server's
SSL certificate must match. Connections that don't match will be
closed with an SSL error.

11 years agoDOC: add a mention about the limited chunk size
Willy Tarreau [Sat, 31 Aug 2013 06:16:26 +0000 (08:16 +0200)] 
DOC: add a mention about the limited chunk size

We now indicate that PD flags can be returned for chunk sizes >= 2GB.

11 years agoBUG/MINOR: log: junk at the end of syslog packet
William Lallemand [Fri, 30 Aug 2013 12:17:46 +0000 (14:17 +0200)] 
BUG/MINOR: log: junk at the end of syslog packet

With a facily of 2 or 1 digit, the send size was wrong and bytes with
unknown value were sent.
The size was calculated using the start of the buffer and not the start
of the data which varies with the number of digits of the facility.

This bug was reported by Samuel Stoller and reported by Lukas Tribus.

11 years agoBUG/MEDIUM: unique_id: junk in log on empty unique_id
William Lallemand [Wed, 28 Aug 2013 13:44:19 +0000 (15:44 +0200)] 
BUG/MEDIUM: unique_id: junk in log on empty unique_id

When a request fail, the unique_id was allocated but not generated.
The string was not initialized and junk was printed in the log with %ID.

This patch changes the behavior of the unique_id. The unique_id is now
generated when a request failed.

This bug was reported by Patrick Hemmer.

11 years agoBUG/MEDIUM: unique_id: HTTP request counter must be unique!
Willy Tarreau [Tue, 13 Aug 2013 15:51:07 +0000 (17:51 +0200)] 
BUG/MEDIUM: unique_id: HTTP request counter must be unique!

The HTTP request counter is incremented non atomically, which means that
many requests can log the same ID. Let's increment it when it is consumed
so that we avoid this case.

This bug was reported by Patrick Hemmer. It's 1.5-specific and does not
need to be backported.

11 years agoMINOR: config: warn when a server with no specific port uses rdp-cookie
Willy Tarreau [Tue, 13 Aug 2013 15:19:08 +0000 (17:19 +0200)] 
MINOR: config: warn when a server with no specific port uses rdp-cookie

Mathew Levett reported an issue which is a bit nasty and hard to track
down. RDP cookies contain both the IP and the port, and haproxy matches
them exactly. So if a server has no port specified (or a remapped port),
it will never match a port specified in a cookie. Better warn the user
when this is detected.

11 years agoMINOR: ssl: use MAXPATHLEN instead of PATH_MAX
Willy Tarreau [Tue, 13 Aug 2013 14:59:39 +0000 (16:59 +0200)] 
MINOR: ssl: use MAXPATHLEN instead of PATH_MAX

Apollon Oikonomopoulos reported a build failure on Hurd where PATH_MAX
is not defined. The only place where it is referenced is ssl_sock.c,
all other places use MAXPATHLEN instead, with a fallback to 128 when
the OS does not define it. So let's switch to MAXPATHLEN as well.

11 years agoBUG/MINOR: cli: "clear table" must not kill entries that don't match condition
Willy Tarreau [Tue, 13 Aug 2013 14:44:40 +0000 (16:44 +0200)] 
BUG/MINOR: cli: "clear table" must not kill entries that don't match condition

Mark Brooks reported the following issue :

"My table looks like this -

  0x24a8294: key=192.168.136.10 use=0 exp=1761492 server_id=3
  0x24a8344: key=192.168.136.11 use=0 exp=1761506 server_id=2
  0x24a83f4: key=192.168.136.12 use=0 exp=1761520 server_id=3
  0x24a84a4: key=192.168.136.13 use=0 exp=1761534 server_id=2
  0x24a8554: key=192.168.136.14 use=0 exp=1761548 server_id=3
  0x24a8604: key=192.168.136.15 use=0 exp=1761563 server_id=2
  0x24a86b4: key=192.168.136.16 use=0 exp=1761580 server_id=3
  0x24a8764: key=192.168.136.17 use=0 exp=1761592 server_id=2
  0x24a8814: key=192.168.136.18 use=0 exp=1761607 server_id=3
  0x24a88c4: key=192.168.136.19 use=0 exp=1761622 server_id=2
  0x24a8974: key=192.168.136.20 use=0 exp=1761636 server_id=3
  0x24a8a24: key=192.168.136.21 use=0 exp=1761649 server_id=2

im running the command -

  socat unix-connect:/var/run/haproxy.stat stdio <<< 'clear table VIP_Name-2 data.server_id eq 2'

Id assume that the entries with server_id = 2 would be removed but its
removing everything each time."

The cause of the issue is a missing test for skip_entry when deciding
whether to clear the key or not. The test was present when only the
last node is to be removed, so removing only the first node from a
list of two always did the right thing, explaining why it remained
unnoticed in basic unit tests.

The bug was introduced by commit 8fa52f4e which attempted to fix a
previous issue with this feature where only the last node was removed.

This bug is 1.5-specific and does not require any backport.

11 years agoBUG/MINOR: use the same check condition for server as other algorithms
Godbach [Wed, 7 Aug 2013 01:48:23 +0000 (09:48 +0800)] 
BUG/MINOR: use the same check condition for server as other algorithms

Such load balance algorithms as roundrobin, leastconn and first will check the
server after being selected with the following condition:
if (!s->maxconn || (!s->nbpend && s->served < srv_dynamic_maxconn(s)))

But static-rr uses the different one in map_get_server_rr()  as below:
if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv))
After viewing this difference, it is a better choice for static-rr to use the
same check condition as other algorithms.

This change will only affect static-rr. Though all hash algorithms with type
map-based will use the same server map as static-rr, they call another function
map_get_server_hash() to get server.

Signed-off-by: Godbach <nylzhaowei@gmail.com>
11 years agoMINOR: payload: allow the payload sample fetches to retrieve arbitrary lengths
Willy Tarreau [Fri, 2 Aug 2013 09:07:32 +0000 (11:07 +0200)] 
MINOR: payload: allow the payload sample fetches to retrieve arbitrary lengths

When using req.payload and res.payload to look up for specific content at an
arbitrary location, we're often facing the problem of not knowing the input
buffer length. If the length argument is larger than the buffer length, the
function did not match, and if they're smaller, there is a risk of not getting
the expected content. This is especially true when looking for data in SOAP
requests.

So let's make some provisions for scanning the whole buffer by specifying a
length of 0 bytes. This greatly simplifies the processing of random-sized
input data.

11 years agoMINOR: cli: make it possible to enter multiple values at once with "set table"
Willy Tarreau [Thu, 1 Aug 2013 19:11:42 +0000 (21:11 +0200)] 
MINOR: cli: make it possible to enter multiple values at once with "set table"

The "set table" statement allows to create new entries with their respective
values. Till now it was limited to a single data type per line, requiring as
many "set table" statements as the desired data types to be set. Since this
is only a parser limitation, this patch gets rid of it. It also allows the
creation of a key with no data types (all reset to their default values).

11 years agoMEDIUM: cli: adjust the method for feeding frequency counters in tables
Willy Tarreau [Tue, 23 Jul 2013 21:44:30 +0000 (23:44 +0200)] 
MEDIUM: cli: adjust the method for feeding frequency counters in tables

Since commit 654694e1, it has been possible to feed some data into
stick tables from the CLI. That commit considered that frequency
counters would only have their previous value set, so that they
progressively fade out. But this does not match any real world
use case in fact. The only reason for feeding a freq counter is
to pass some data learned outside. We certainly don't want to see
such data start to vanish immediately, otherwise it will force the
external scripts to loop very frequently to limit the losses.

So let's set the current value instead in order to guarantee that
the data remains stable over the full period, then starts to fade
out between 1* and 2* the period.

11 years agoMEDIUM: counters: support looking up a key in an alternate table
Willy Tarreau [Tue, 23 Jul 2013 17:56:43 +0000 (19:56 +0200)] 
MEDIUM: counters: support looking up a key in an alternate table

sc_* sample fetches now take an optional parameter which allows to look
the key in an alternate table. This is convenient to pass multiple
information for the same key at once (eg: have multiple gpc0 for the
same key, or support being fed complementary information from the CLI).
Example :

    listen front
        bind :8000
        tcp-request content track-sc0 src table local-ip
        http-response set-header src-id %[sc0_get_gpc0]+%[sc0_get_gpc0(global-ip)]
        server dummy 127.0.0.1:8001

    backend local-ip
        stick-table size 1k type ip store gpc0

    backend global-ip
        stick-table size 1k type ip store gpc0

11 years agoMEDIUM: counters: support passing the counter number as a fetch argument
Willy Tarreau [Tue, 23 Jul 2013 17:33:46 +0000 (19:33 +0200)] 
MEDIUM: counters: support passing the counter number as a fetch argument

One very annoying issue when trying to extend the sticky counters beyond
the current 3 counters is that it requires a massive copy-paste of fetch
functions (we don't have to copy-paste code anymore), just so that the
fetch names exist.

So let's have an alternate form like "sc_*(num)" to allow passing the
counter number as an argument without having to redefine new fetch names.
The MAX_SESS_STKCTR macro defines the number of usable sticky counters,
which defaults to 3.

11 years agoMINOR: session: make the number of stick counter entries more configurable
Willy Tarreau [Tue, 23 Jul 2013 17:15:30 +0000 (19:15 +0200)] 
MINOR: session: make the number of stick counter entries more configurable

In preparation of more flexibility in the stick counters, make their
number configurable. It still defaults to 3 which is the minimum
accepted value. Changing the value alone is not sufficient to get
more counters, some bitfields still need to be updated and the TCP
actions need to be updated as well, but this update tries to be
easier, which is nice for experimentation purposes.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_trackers
Willy Tarreau [Tue, 23 Jul 2013 16:32:02 +0000 (18:32 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_trackers

smp_fetch_sc0_trackers, smp_fetch_sc1_trackers and smp_fetch_sc2_trackers
were merged into a single function which relies on the fetch name to decide
what to return.

This is also a bug fix for this feature which has never worked till its bogus
introduction by commit "2406db4 MEDIUM: counters: add sc1_trackers/sc2_trackers"
(1.5-dev10).

Instead of returning the value in the sample, it was returned as the fetch
result!

There is no need to backport this fix anyway since it's 1.5-specific and
nobody uses the feature.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_bytes_out_rate
Willy Tarreau [Tue, 23 Jul 2013 16:26:32 +0000 (18:26 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_bytes_out_rate

smp_fetch_sc0_bytes_out_rate, smp_fetch_sc1_bytes_out_rate, smp_fetch_sc2_bytes_out_rate,
smp_fetch_src_bytes_out_rate and smp_fetch_bytes_out_rate were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_kbytes_out
Willy Tarreau [Tue, 23 Jul 2013 15:39:02 +0000 (17:39 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_kbytes_out

smp_fetch_sc0_kbytes_out, smp_fetch_sc1_kbytes_out, smp_fetch_sc2_kbytes_out,
smp_fetch_src_kbytes_out and smp_fetch_kbytes_out were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_bytes_in_rate
Willy Tarreau [Tue, 23 Jul 2013 15:39:19 +0000 (17:39 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_bytes_in_rate

smp_fetch_sc0_bytes_in_rate, smp_fetch_sc1_bytes_in_rate, smp_fetch_sc2_bytes_in_rate,
smp_fetch_src_bytes_in_rate and smp_fetch_bytes_in_rate were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_kbytes_in
Willy Tarreau [Tue, 23 Jul 2013 15:17:10 +0000 (17:17 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_kbytes_in

smp_fetch_sc0_kbytes_in, smp_fetch_sc1_kbytes_in, smp_fetch_sc2_kbytes_in,
smp_fetch_src_kbytes_in and smp_fetch_kbytes_in were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_http_err_rate
Willy Tarreau [Tue, 23 Jul 2013 14:48:54 +0000 (16:48 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_http_err_rate

smp_fetch_sc0_http_err_rate, smp_fetch_sc1_http_err_rate, smp_fetch_sc2_http_err_rate,
smp_fetch_src_http_err_rate and smp_fetch_http_err_rate were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_http_err_cnt
Willy Tarreau [Tue, 23 Jul 2013 14:45:38 +0000 (16:45 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_http_err_cnt

smp_fetch_sc0_http_err_cnt, smp_fetch_sc1_http_err_cnt, smp_fetch_sc2_http_err_cnt,
smp_fetch_src_http_err_cnt and smp_fetch_http_err_cnt were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_http_req_rate
Willy Tarreau [Tue, 23 Jul 2013 14:04:37 +0000 (16:04 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_http_req_rate

smp_fetch_sc0_http_req_rate, smp_fetch_sc1_http_req_rate, smp_fetch_sc2_http_req_rate,
smp_fetch_src_http_req_rate and smp_fetch_http_req_rate were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_http_req_cnt
Willy Tarreau [Tue, 23 Jul 2013 13:55:19 +0000 (15:55 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_http_req_cnt

smp_fetch_sc0_http_req_cnt, smp_fetch_sc1_http_req_cnt, smp_fetch_sc2_http_req_cnt,
smp_fetch_src_http_req_cnt and smp_fetch_http_req_cnt were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_sess_rate
Willy Tarreau [Tue, 23 Jul 2013 13:48:01 +0000 (15:48 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_sess_rate

smp_fetch_sc0_sess_rate, smp_fetch_sc1_sess_rate, smp_fetch_sc2_sess_rate,
smp_fetch_src_sess_rate and smp_fetch_sess_rate were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_sess_cnt
Willy Tarreau [Tue, 23 Jul 2013 13:35:33 +0000 (15:35 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_sess_cnt

smp_fetch_sc0_sess_cnt, smp_fetch_sc1_sess_cnt, smp_fetch_sc2_sess_cnt,
smp_fetch_src_sess_cnt and smp_fetch_sess_cnt were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_conn_cur
Willy Tarreau [Tue, 23 Jul 2013 13:17:53 +0000 (15:17 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_conn_cur

smp_fetch_sc0_conn_cur, smp_fetch_sc1_conn_cur, smp_fetch_sc2_conn_cur,
smp_fetch_src_conn_cur and smp_fetch_conn_cur were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_conn_rate
Willy Tarreau [Tue, 23 Jul 2013 13:09:35 +0000 (15:09 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_conn_rate

smp_fetch_sc0_conn_rate, smp_fetch_sc1_conn_rate, smp_fetch_sc2_conn_rate,
smp_fetch_src_conn_rate and smp_fetch_conn_rate were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_conn_cnt
Willy Tarreau [Mon, 22 Jul 2013 22:22:50 +0000 (00:22 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_conn_cnt

smp_fetch_sc0_conn_cnt, smp_fetch_sc1_conn_cnt, smp_fetch_sc2_conn_cnt,
smp_fetch_src_conn_cnt and smp_fetch_conn_cnt were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_clr_gpc0
Willy Tarreau [Mon, 22 Jul 2013 22:10:35 +0000 (00:10 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_clr_gpc0

smp_fetch_sc0_clr_gpc0, smp_fetch_sc1_clr_gpc0, smp_fetch_sc2_clr_gpc0,
smp_fetch_src_clr_gpc0 and smp_fetch_clr_gpc0 were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_inc_gpc0
Willy Tarreau [Mon, 22 Jul 2013 22:07:04 +0000 (00:07 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_inc_gpc0

smp_fetch_sc0_inc_gpc0, smp_fetch_sc1_inc_gpc0, smp_fetch_sc2_inc_gpc0,
smp_fetch_src_inc_gpc0 and smp_fetch_inc_gpc0 were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_gpc0_rate
Willy Tarreau [Mon, 22 Jul 2013 21:47:07 +0000 (23:47 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_gpc0_rate

smp_fetch_sc0_gpc0, smp_fetch_sc1_gpc0, smp_fetch_sc2_gpc0,
smp_fetch_src_gpc0 and smp_fetch_gpc0 were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMEDIUM: counters: factor out smp_fetch_sc*_get_gpc0
Willy Tarreau [Mon, 22 Jul 2013 17:46:52 +0000 (19:46 +0200)] 
MEDIUM: counters: factor out smp_fetch_sc*_get_gpc0

smp_fetch_sc0_get_gpc0, smp_fetch_sc1_get_gpc0, smp_fetch_sc2_get_gpc0,
smp_fetch_src_get_gpc0 and smp_fetch_get_gpc0 were merged into a single
function which relies on the fetch name to decide what to return.

11 years agoMINOR: counters: provide a generic function to retrieve a stkctr for sc* and src.
Willy Tarreau [Mon, 22 Jul 2013 20:40:11 +0000 (22:40 +0200)] 
MINOR: counters: provide a generic function to retrieve a stkctr for sc* and src.

This function aims at simplifying the prefetching of the table and entry
when using any of the session counters fetches. The principle is that the
src_* variant produces a stkctr that is used instead of the one from the
session. That way we can call the same function from all session counter
fetch functions and always have a single function to support sc[0-9]_/src_.

11 years agoMINOR: counters: factor out smp_fetch_sc*_tracked
Willy Tarreau [Mon, 22 Jul 2013 16:29:29 +0000 (18:29 +0200)] 
MINOR: counters: factor out smp_fetch_sc*_tracked

The new function makes use of the sc# in the keyword to
get the counter ID.

11 years agoMINOR: payload: split smp_fetch_rdp_cookie()
Willy Tarreau [Mon, 22 Jul 2013 16:09:52 +0000 (18:09 +0200)] 
MINOR: payload: split smp_fetch_rdp_cookie()

This function is also called directly from backend.c, so let's stop
building fake args to call it as a sample fetch, and have a lower
layer more generic function instead.