]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
8 years agoDOC: lua: Add documentation about variable manipulation from applet
Thierry FOURNIER / OZON.IO [Mon, 12 Dec 2016 15:25:30 +0000 (16:25 +0100)] 
DOC: lua: Add documentation about variable manipulation from applet

This patch adds documentation about set_var, unset_var and get_var
functions added in the Class AppletHTTP and AppletTCP.

8 years agoDOC: lua: Documentation about some entry missing
Thierry FOURNIER / OZON.IO [Mon, 12 Dec 2016 15:24:16 +0000 (16:24 +0100)] 
DOC: lua: Documentation about some entry missing

The parameter "value" of the function TXN.set_var() was not documented.

This is a regression from the commit 85d79c94a93211b156ec644e164b178f5d7101fa.
This patch must be backported in 1.7

8 years agoMINOR: proxy: Add fe_name/be_name fetchers next to existing fe_id/be_id
Marcin Deranek [Mon, 12 Dec 2016 13:08:05 +0000 (14:08 +0100)] 
MINOR: proxy: Add fe_name/be_name fetchers next to existing fe_id/be_id

These 2 patches add ability to fetch frontend/backend name in your
logic, so they can be used later to make routing decisions (fe_name) or
taking some actions based on backend which responded to request (be_name).
In our case we needed a fetcher to be able to extract information we
needed from frontend name.

8 years agoBUG/MINOR: stats: fix be/sessions/max output in html stats
Willy Tarreau [Mon, 12 Dec 2016 14:07:29 +0000 (15:07 +0100)] 
BUG/MINOR: stats: fix be/sessions/max output in html stats

"Tadas / XtGem" reported that the max value was wrong and would report
the current value instead. This needs to be backported to 1.7.

8 years agoMINOR: lua: give HAProxy variable access to the applets
Thierry FOURNIER / OZON.IO [Mon, 12 Dec 2016 11:31:54 +0000 (12:31 +0100)] 
MINOR: lua: give HAProxy variable access to the applets

This patch give function for manipulating variables inside the
applet HTTP and applet TCP functions.

8 years agoCLEANUP: hlua: just indent functions
Thierry FOURNIER / OZON.IO [Mon, 12 Dec 2016 11:29:34 +0000 (12:29 +0100)] 
CLEANUP: hlua: just indent functions

Function indentation. The code is not modified. This is done in
the goal of better integration of the next patch

8 years agoBUILD: rearrange target files by build time
Willy Tarreau [Sun, 11 Dec 2016 21:12:33 +0000 (22:12 +0100)] 
BUILD: rearrange target files by build time

When doing a parallel build on multiple CPUs it's common that at the end
a few CPUs only are busy compiling very large files while the other ones
have finished. By placing the largest files first, we can ensure that in
the worst case they are present from the beginning to the end, and that
other processes are free to take smaller files. This ordering was made
based on a measurement consisting in counting the number of times a given
file appears in the build. The top ten looks like this :

    145 src/cfgparse.c
    131 src/proto_http.c
     83 src/ssl_sock.c
     74 src/stats.c
     73 src/stream.c
     55 src/flt_spoe.c
     48 src/server.c
     46 src/pattern.c
     43 src/checks.c
     42 src/flt_http_comp.c

Only a few files were moved, ssl_sock would need to be moved as well but
that would not be a convenient thing to do in the makefile. This new
order allows to save about 10-15% of build time on 4 CPUs, which is nice.

8 years agoMINOR: lua: Allow argument for actions
Thierry FOURNIER / OZON.IO [Fri, 9 Dec 2016 17:03:31 +0000 (18:03 +0100)] 
MINOR: lua: Allow argument for actions

(http|tcp)-(request|response) action cannot take arguments from the
configuration file. Arguments are useful for executing the action with
a special context.

This patch adds the possibility of passing arguments to an action. It
runs exactly like sample fetches and other Lua wrappers.

Note that this patch implements a 'TODO'.

8 years agoBUG/MEDIUM: variables: some variable name can hide another ones
Thierry FOURNIER / OZON.IO [Mon, 12 Dec 2016 11:42:14 +0000 (12:42 +0100)] 
BUG/MEDIUM: variables: some variable name can hide another ones

The variable are compared only using text, the final '\0' (or the
string length) are not checked. So, the variable name "txn.internal"
matchs other one call "txn.int".

This patch fix this behavior

It must be backported ni 1.6 and 1.7

8 years agoDOC: mention that req_tot is for both frontends and backends
Willy Tarreau [Mon, 12 Dec 2016 13:31:46 +0000 (14:31 +0100)] 
DOC: mention that req_tot is for both frontends and backends

Thierry reported that only frontends were mentionned while the stats
are for both. To be backported to 1.7.

8 years agoBUG/MINOR: http: don't send an extra CRLF after a Set-Cookie in a redirect
Matthieu Guegan [Mon, 5 Dec 2016 10:35:54 +0000 (11:35 +0100)] 
BUG/MINOR: http: don't send an extra CRLF after a Set-Cookie in a redirect

By investigating a keep-alive issue with CloudFlare, we[1] found that
when using the 'set-cookie' option in a redirect (302) HAproxy is adding
an extra `\r\n`.

Triggering rule :

`http-request redirect location / set-cookie Cookie=value if [...]`

Expected result :

```
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-length: 0
Location: /
Set-Cookie: Cookie=value; path=/;
Connection: close
```

Actual result :

```
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-length: 0
Location: /
Set-Cookie: Cookie=value; path=/;

Connection: close
```

This extra `\r\n` seems to be harmless with another HAproxy instance in
front of it (sanitizing) or when using a browser. But we confirm that
the CloudFlare NGINX implementation is not able to handle this. It
seems that both 'Content-length: 0' and extra carriage return broke RFC
(to be confirmed).

When looking into the code, this carriage-return was already present in
1.3.X versions but just before closing the connection which was ok I
think. Then, with 1.4.X the keep-alive feature was added and this piece
of code remains unchanged.

[1] all credit for the bug finding goes to CloudFlare Support Team

[wt: the bug was indeed present since the Set-Cookie was introduced
 in 1.3.16, by commit 0140f25 ("[MINOR] redirect: add support for
 "set-cookie" and "clear-cookie"") so backporting to all supported
 versions is desired]

8 years agoDOC: Added 51Degrees conv and fetch functions to documentation.
Ben Shillito [Fri, 2 Dec 2016 14:25:37 +0000 (14:25 +0000)] 
DOC: Added 51Degrees conv and fetch functions to documentation.

Definitions and examples for 51d.single and 51d.all have been added to
configuration.txt so it now appears in online documentation in addition
to the README, The 51degrees-property-name-list entry has also been
updated to make it clear that multiple properties can be added.

8 years agoDOC: Fix map table's format
Ruoshan Huang [Fri, 2 Dec 2016 08:25:31 +0000 (16:25 +0800)] 
DOC: Fix map table's format

so the HTML doc parser can parse the table correctly

8 years agoBUG/MEDIUM: cli: fix "show stat resolvers" and "show tls-keys"
Willy Tarreau [Mon, 5 Dec 2016 13:50:15 +0000 (14:50 +0100)] 
BUG/MEDIUM: cli: fix "show stat resolvers" and "show tls-keys"

The recent CLI reorganization managed to break these two commands
by having their parser return 1 (indicating an end of processing)
instead of 0 to indicate new calls to the io handler were needed.

Namely the faulty commits are :
  69e9644 ("REORG: cli: move show stat resolvers to dns.c")
  32af203 ("REORG: cli: move ssl CLI functions to ssl_sock.c")

The fix is trivial and there is no other loss of functionality. Thanks
to Dragan Dosen for reporting the issue and the faulty commits. The
backport is needed in 1.7.

8 years agoBUG/MINOR: cli: allow the backslash to be escaped on the CLI
Dragan Dosen [Thu, 24 Nov 2016 10:33:12 +0000 (11:33 +0100)] 
BUG/MINOR: cli: allow the backslash to be escaped on the CLI

In 1.5-dev20, commit 48bcfda ("MEDIUM: dumpstat: make the CLI parser
understand the backslash as an escape char") introduced support for
backslash on the CLI, but it strips all backslashes in all arguments
instead of only unescaping them, making it impossible to pass a
backslash in an argument.

This will allow us to use a backslash in a command over the socket, eg.
"add acl #0 ABC\\XYZ".

[wt: this should be backported to 1.7 and 1.6]

8 years agoOPTIM: stream-int: don't disable polling anymore on DONT_READ
Willy Tarreau [Tue, 29 Nov 2016 20:47:02 +0000 (21:47 +0100)] 
OPTIM: stream-int: don't disable polling anymore on DONT_READ

Commit 5fddab0 ("OPTIM: stream_interface: disable reading when
CF_READ_DONTWAIT is set") improved the connection layer's efficiency
back in 1.5-dev13 by avoiding successive read attempts on an active
FD. But by disabling this on a polled FD, it causes an unpleasant
side effect which is that the FD that was subscribed to polling is
suddenly stopped and may need to be re-enabled once the kernel
starts to slow down on data eviction (eg: saturated server at the
other end, bursty traffic caused by too large maxpollevents).

This behaviour is observable with persistent connections when there
is a large enough connection count so that there's no data in the
early connection and polling is required, because there are then
up to 4 epoll_ctl() calls per request. It's important that the
server is slower than haproxy to cause some delays when reading
response.

The current connection layer as designed in 1.6 with the FD cache
doesn't require this trick anymore, though it still benefits from
it when it saves an FD from being uselessly polled. But compared
to the increased cost of enabling and disabling poll all the time,
it's still better to disable it. In some cases it's possible to
observe a performance increase as high as 30% by avoiding this
epoll_ctl() dance.

In the end we only want to disable it when the FD is speculatively
read and not when it's polled. For this we introduce a new function
__conn_data_done_recv() which is used to indicate that we're done
with recv() and not interested in new attempts. If/when we later
support event-triggered epoll, this function will have to change
a bit to do the same even in the polled case.

A quick test with keep-alive requests run on a dual-core / dual-
thread Atom shows a significant improvement :

single process, 0 bytes :
before: Requests per second:    12243.20 [#/sec] (mean)
after:  Requests per second:    13354.54 [#/sec] (mean)

single process, 4k :
before: Requests per second:    9639.81 [#/sec] (mean)
after:  Requests per second:    10991.89 [#/sec] (mean)

dual process, 0 bytes (unstable) :
before: Requests per second:    16900-19800 ~ 17600 [#/sec] (mean)
after:  Requests per second:    18600-21400 ~ 20500 [#/sec] (mean)

8 years agoBUG/MAJOR: stream: fix session abort on resource shortage
Willy Tarreau [Sun, 4 Dec 2016 19:05:16 +0000 (20:05 +0100)] 
BUG/MAJOR: stream: fix session abort on resource shortage

In 1.6-dev2, commit 32990b5 ("MEDIUM: session: remove the task pointer
from the session") introduced a bug which can sometimes crash the process
on resource shortage. When stream_complete() returns -1, it has already
reattached the connection to the stream, then kill_mini_session() is
called and still expects to find the task in conn->owner. Note that
since this commit, the code has moved a bit and is now in stream_new()
but the problem remains the same.

Given that we already know the task around these places, let's simply
pass the task to kill_mini_session().

The conditions currently at risk are :
  - failure to initialize filters for the new stream (lack of memory or
    any filter returning < 0 on attach())
  - failure to attach filters (any filter returning < 0 on stream_start())
  - frontend's accept() returning < 0 (allocation failure)

This fix is needed in 1.7 and 1.6.

8 years agoBUG/MINOR: http: Call XFER_DATA analyzer when HTTP txn is switched in tunnel mode
Christopher Faulet [Mon, 28 Nov 2016 13:21:27 +0000 (14:21 +0100)] 
BUG/MINOR: http: Call XFER_DATA analyzer when HTTP txn is switched in tunnel mode

This allow a filter to start to analyze data in HTTP and to fallback in TCP when
data are tunneled.

[wt: backport desired in 1.7 - no impact right now but may impact the ability
 to backport future fixes]

8 years agoBUG/MINOR: filters: Invert evaluation order of HTTP_XFER_BODY and XFER_DATA analyzers
Christopher Faulet [Mon, 28 Nov 2016 11:36:26 +0000 (12:36 +0100)] 
BUG/MINOR: filters: Invert evaluation order of HTTP_XFER_BODY and XFER_DATA analyzers

These 2 analyzers are responsible of the data forwarding in, respectively, HTTP
mode and TCP mode. Now, the analyzer responsible of the HTTP data forwarding is
called before the one responsible of the TCP data forwarding. This will allow
the filtering of tunneled data in HTTP.

[wt: backport desired in 1.7 - no impact right now but may impact the ability
 to backport future fixes]

8 years agoBUG/MINOR: filters: Protect args in macros HAS_DATA_FILTERS and IS_DATA_FILTER
Christopher Faulet [Mon, 28 Nov 2016 09:01:32 +0000 (10:01 +0100)] 
BUG/MINOR: filters: Protect args in macros HAS_DATA_FILTERS and IS_DATA_FILTER

[wt: backport needed in 1.7]

8 years agoBUG/MINOR: http: Keep the same behavior between 1.6 and 1.7 for tunneled txn
Christopher Faulet [Tue, 29 Nov 2016 13:49:54 +0000 (14:49 +0100)] 
BUG/MINOR: http: Keep the same behavior between 1.6 and 1.7 for tunneled txn

In HAProxy 1.6, When "http-tunnel" option is enabled, HTTP transactions are
tunneled as soon as possible after the headers parsing/forwarding. When the
transfer length of the response can be determined, this happens when all data
are forwarded. But for responses with an undetermined transfer length this
happens when headers are forwarded. This behavior is questionable, but this is
not the purpose of this fix...

In HAProxy 1.7, the first use-case works like in 1.6. But the second one not
because of the data filtering. HAProxy was always trying to forward data until
the server closes the connection. So the transaction was never switched in
tunnel mode. This is the expected behavior when there is a data filter. But in
the default case (no data filter), it should work like in 1.6.

This patch fixes the bug. We analyze response data until the server closes the
connection only when there is a data filter.

[wt: backport needed in 1.7]

8 years agoBUG/MEDIUM: http: Fix tunnel mode when the CONNECT method is used
Christopher Faulet [Mon, 28 Nov 2016 09:14:03 +0000 (10:14 +0100)] 
BUG/MEDIUM: http: Fix tunnel mode when the CONNECT method is used

When a 2xx response to a CONNECT request is returned, the connection must be
switched in tunnel mode immediatly after the headers, and Transfer-Encoding and
Content-Length headers must be ignored. So from the HTTP parser point of view,
there is no body.

The bug comes from the fact the flag HTTP_MSGF_XFER_LEN was not set on the
response (This flag means that the body size can be determined. In our case, it
can, it is 0). So, during data forwarding, the connection was never switched in
tunnel mode and we were blocked in a state where we were waiting that the
server closes the connection to ends the response.

Setting the flag HTTP_MSGF_XFER_LEN on the response fixed the bug.

The code of http_wait_for_response has been slightly updated to be more
readable.

[wt: 1.7-only, this is not needed in 1.6]

8 years agoDOC: Spelling fixes
Tim Düsterhus [Tue, 29 Nov 2016 01:15:19 +0000 (02:15 +0100)] 
DOC: Spelling fixes

[wt: this contains spelling fixes for both doc and code comments,
 should be backported, ignoring the parts which don't apply]

8 years agoBUG/MINOR: stats: make field_str() return an empty string on NULL
Willy Tarreau [Sat, 26 Nov 2016 14:55:59 +0000 (15:55 +0100)] 
BUG/MINOR: stats: make field_str() return an empty string on NULL

It already returns an empty string when the field is empty, but as a
preventive measure we should do the same when the string itself is a
NULL. While it is not supposed to happen, it will make the code more
resistant against failed allocations and unexpected results.

This fix should be backported to 1.7.

8 years agoBUG/MEDIUM: proxy: return "none" and "unknown" for unknown LB algos
Willy Tarreau [Sat, 26 Nov 2016 14:52:04 +0000 (15:52 +0100)] 
BUG/MEDIUM: proxy: return "none" and "unknown" for unknown LB algos

When a backend doesn't use any known LB algorithm, backend_lb_algo_str()
returns NULL. It used to cause "nil" to be printed in the stats dump
since version 1.4 but causes 1.7 to try to parse this NULL to encode
it as a CSV string, causing a crash on "show stat" in this case.

The only situation where this can happen is when "transparent" or
"dispatch" are used in a proxy, in which case the LB algorithm is
BE_LB_ALGO_NONE. Thus now we explicitly report "none" when this
situation is detected, and we preventively report "unknown" if any
unknown algorithm is detected, which may happen if such an algo is
added in the future and the function is not updated.

This fix must be backported to 1.7 and may be backported as far as
1.4, though it has less impact there.

8 years ago[RELEASE] Released version 1.8-dev0 v1.8-dev0
Willy Tarreau [Fri, 25 Nov 2016 15:55:50 +0000 (16:55 +0100)] 
[RELEASE] Released version 1.8-dev0

Released version 1.8-dev0 with the following main changes :
    - exact copy of 1.7.0

8 years ago[RELEASE] Released version 1.7.0 v1.7.0
Willy Tarreau [Fri, 25 Nov 2016 15:39:17 +0000 (16:39 +0100)] 
[RELEASE] Released version 1.7.0

Released version 1.7.0 with the following main changes :
    - SCRIPTS: make publish-release also copy the new SPOE doc
    - BUILD: http: include types/sample.h in proto_http.h
    - BUILD: debug/flags: remove test for SF_COMP_READY
    - CONTRIB: debug/flags: add check for SF_ERR_CHK_PORT
    - MINOR: lua: add function which return true if the channel is full.
    - MINOR: lua: add ip addresses and network manipulation function
    - CONTRIB: tcploop: scriptable TCP I/O for debugging purposes
    - CONTRIB: tcploop: implement fork()
    - CONTRIB: tcploop: implement logging when called with -v
    - CONTRIB: tcploop: update the usage output
    - CONTRIB: tcploop: support sending plain strings
    - CONTRIB: tcploop: don't report failed send() or recv()
    - CONTRIB: tcploop: add basic loops via a jump instruction
    - BUG/MEDIUM: channel: bad unlikely macro
    - CLEANUP: lua: move comment
    - CLEANUP: lua: control executed twice
    - BUG/MEDIUM: ssl: Store certificate filename in a variable
    - BUG/MINOR: ssl: Print correct filename when error occurs reading OCSP
    - CLEANUP: ssl: Remove goto after return dead code
    - CLEANUP: ssl: Fix bind keywords name in comments
    - DOC: ssl: Use correct wording for ca-sign-pass
    - CLEANUP: lua: avoid directly calling getsockname/getpeername()
    - BUG/MINOR: stick-table: handle out-of-memory condition gracefully
    - MINOR: cli: add private pointer and release function
    - MEDIUM: lua: Add cli handler for Lua
    - BUG/MEDIUM: connection: check the control layer before stopping polling
    - DEBUG: connection: mark the closed FDs with a value that is easier to detect
    - BUG/MEDIUM: stick-table: fix regression caused by recent fix for out-of-memory
    - BUG/MINOR: cli: properly decrement ref count on tables during failed dumps
    - BUG/MEDIUM: lua: In some case, the return of sample-fetche is ignored
    - MINOR: filters: Add check_timeouts callback to handle timers expiration on streams
    - MINOR: spoe: Add 'timeout processing' option to limit time to process an event
    - MINOR: spoe: Remove useless 'timeout ack' option
    - MINOR: spoe: Add 'option continue-on-error' statement in spoe-agent section
    - MINOR: spoe: Add "maxconnrate" and "maxerrrate" statements
    - MINOR: spoe: Add "option set-on-error" statement
    - MINOR: stats: correct documentation of process ID for typed output
    - BUILD: contrib: fix ip6range build on Centos 7
    - BUILD: fix build on Solaris 10/11
    - BUG/MINOR: cli: fix pointer size when reporting data/transport layer name
    - BUG/MINOR: cli: dequeue from the proxy when changing a maxconn
    - BUG/MINOR: cli: wake up the CLI's task after a timeout update
    - MINOR: connection: add a few functions to report the data and xprt layers' names
    - MINOR: connection: add names for transport and data layers
    - REORG: cli: split dumpstats.c in src/cli.c and src/stats.c
    - REORG: cli: split dumpstats.h in stats.h and cli.h
    - REORG: cli: move ssl CLI functions to ssl_sock.c
    - REORG: cli: move map and acl code to map.c
    - REORG: cli: move show stat resolvers to dns.c
    - MINOR: cli: create new function cli_has_level() to validate permissions
    - MINOR: server: create new function cli_find_server() to find a server
    - MINOR: proxy: create new function cli_find_frontend() to find a frontend
    - REORG: cli: move 'set server' to server.c
    - REORG: cli: move 'show pools' to memory.c
    - REORG: cli: move 'show servers' to proxy.c
    - REORG: cli: move 'show sess' to stream.c
    - REORG: cli: move 'show backend' to proxy.c
    - REORG: cli: move get/set weight to server.c
    - REORG: cli: move "show stat" to stats.c
    - REORG: cli: move "show info" to stats.c
    - REORG: cli: move dump_text(), dump_text_line(), and dump_binary() to standard.c
    - REORG: cli: move table dump/clear/set to stick_table.c
    - REORG: cli: move "show errors" out of cli.c
    - REORG: cli: make "show env" also use the generic keyword registration
    - REORG: cli: move "set timeout" to its own handler
    - REORG: cli: move "clear counters" to stats.c
    - REORG: cli: move "set maxconn global" to its own handler
    - REORG: cli: move "set maxconn server" to server.c
    - REORG: cli: move "set maxconn frontend" to proxy.c
    - REORG: cli: move "shutdown sessions server" to stream.c
    - REORG: cli: move "shutdown session" to stream.c
    - REORG: cli: move "shutdown frontend" to proxy.c
    - REORG: cli: move "{enable|disable} frontend" to proxy.c
    - REORG: cli: move "{enable|disable} server" to server.c
    - REORG: cli: move "{enable|disable} health" to server.c
    - REORG: cli: move "{enable|disable} agent" to server.c
    - REORG: cli: move the "set rate-limit" functions to their own parser
    - CLEANUP: cli: rename STAT_CLI_* to CLI_ST_*
    - CLEANUP: cli: simplify the request parser a little bit
    - CLEANUP: cli: remove assignments to st0 and st2 in keyword parsers
    - BUILD: server: remove a build warning introduced by latest series
    - BUG/MINOR: log-format: uncatched memory allocation functions
    - CLEANUP: log-format: useless file and line in json converter
    - CLEANUP/MINOR: log-format: unexport functions parse_logformat_var_args() and parse_logformat_var()
    - CLEANUP: log-format: fix return code of the function parse_logformat_var()
    - CLEANUP: log-format: fix return code of function parse_logformat_var_args()
    - CLEANUP: log-format: remove unused arguments
    - MEDIUM: log-format: strict parsing and enable fail
    - MEDIUM: log-format/conf: take into account the parse_logformat_string() return code
    - BUILD: ssl: make the SSL layer build again with openssl 0.9.8
    - BUILD: vars: remove a build warning on vars.c
    - MINOR: lua: add utility function for check boolean argument
    - MINOR: lua: Add tokenize function.
    - BUG/MINOR: conf: calloc untested
    - MINOR: http/conf: store the use_backend configuration file and line for logs
    - MEDIUM: log-format: Use standard HAProxy log system to report errors
    - CLEANUP: sample: report "converter" instead of "conv method" in error messages
    - BUG: spoe: Fix parsing of SPOE actions in ACK frames
    - MINOR: cli: make "show stat" support a proxy name
    - MINOR: cli: make "show errors" support a proxy name
    - MINOR: cli: make "show errors" capable of dumping only request or response
    - BUG/MINOR: freq-ctr: make swrate_add() support larger values
    - CLEANUP: counters: move from 3 types to 2 types
    - CLEANUP: cfgparse: cascade the warnif_misplaced_* rules
    - REORG: tcp-rules: move tcp rules processing to their own file
    - REORG: stkctr: move all the stick counters processing to stick-tables.c
    - DOC: update the roadmap file with the latest changes

8 years agoDOC: update the roadmap file with the latest changes
Willy Tarreau [Fri, 25 Nov 2016 15:32:20 +0000 (16:32 +0100)] 
DOC: update the roadmap file with the latest changes

A few points were already addressed. Mention that next changes are
for version 1.8 now.

8 years agoREORG: stkctr: move all the stick counters processing to stick-tables.c
Willy Tarreau [Fri, 25 Nov 2016 15:10:05 +0000 (16:10 +0100)] 
REORG: stkctr: move all the stick counters processing to stick-tables.c

Historically we used to have the stick counters processing put into
session.c which became stream.c. But a big part of it is now in
stick-table.c (eg: converters) but despite this we still have all
the sample fetch functions in stream.c

These parts do not depend on the stream anymore, so let's move the
remaining chunks to stick-table.c and have cleaner files.

What remains in stream.c is everything needed to attach/detach
trackers to the stream and to update the counters while the stream
is being processed.

8 years agoREORG: tcp-rules: move tcp rules processing to their own file
Willy Tarreau [Fri, 25 Nov 2016 14:49:32 +0000 (15:49 +0100)] 
REORG: tcp-rules: move tcp rules processing to their own file

There's no more reason to keep tcp rules processing inside proto_tcp.c
given that there is nothing in common there except these 3 letters : tcp.
The tcp rules are in fact connection, session and content processing rules.
Let's move them to "tcp-rules" and let them live their life there.

8 years agoCLEANUP: cfgparse: cascade the warnif_misplaced_* rules
Willy Tarreau [Fri, 25 Nov 2016 14:16:12 +0000 (15:16 +0100)] 
CLEANUP: cfgparse: cascade the warnif_misplaced_* rules

There are 8 functions each repeating what another does and adding one
extra test. We used to have some copy-paste issues in the past due to
this. Instead we now make them simply rely on the previous one and add
the final test. It's much better and much safer. The functions could
be moved to inlines but they're used at a few other locations only,
it didn't make much sense in the end.

8 years agoCLEANUP: counters: move from 3 types to 2 types
Willy Tarreau [Fri, 25 Nov 2016 13:44:52 +0000 (14:44 +0100)] 
CLEANUP: counters: move from 3 types to 2 types

We used to have 3 types of counters with a huge overlap :
  - listener counters : stats collected for each bind line
  - proxy counters : union of the frontend and backend counters
  - server counters : stats collected per server

It happens that quite a good part was common between listeners and
proxies due to the frontend counters being updated at the two locations,
and that similarly the server and proxy counters were overlapping and
being updated together.

This patch cleans this up to propose only two types of counters :
  - fe_counters: used by frontends and listeners, related to
    incoming connections activity
  - be_counters: used by backends and servers, related to outgoing
    connections activity

This allowed to remove some non-sensical counters from both parts. For
frontends, the following entries were removed :

  cum_lbconn, last_sess, nbpend_max, failed_conns, failed_resp,
  retries, redispatches, q_time, c_time, d_time, t_time

For backends, this ones was removed : intercepted_req.

While doing this it was discovered that we used to incorrectly report
intercepted_req for backends in the HTML stats, which was always zero
since it's never updated.

Also it revealed a few inconsistencies (which were not fixed as they
are harmless). For example, backends count connections (cum_conn)
instead of sessions while servers count sessions and not connections.

Over the long term, some extra cleanups may be performed by having
some counters update functions touching both the server and backend
at the same time, as well as both the frontend and listener, to
ensure that all sides have all their stats properly filled. The stats
dump will also be able to factor the dump functions by counter types.

8 years agoBUG/MINOR: freq-ctr: make swrate_add() support larger values
Willy Tarreau [Fri, 25 Nov 2016 10:55:10 +0000 (11:55 +0100)] 
BUG/MINOR: freq-ctr: make swrate_add() support larger values

Reinhard Vicinus reported that the reported average response times cannot
be larger than 16s due to the double multiply being performed by
swrate_add() which causes an overflow very quickly. Indeed, with N=512,
the highest average value is 16448.

One solution proposed by Reinhard is to turn to long long, but this
involves 64x64 multiplies and 64->32 divides, which are extremely
expensive on 32-bit platforms.

There is in fact another way to avoid the overflow without using larger
integers, it consists in avoiding the multiply using the fact that
x*(n-1)/N = x-(x/N).

Now it becomes possible to store average values as large as 8.4 millions,
which is around 2h18mn.

Interestingly, this improvement also makes the code cheaper to execute
both on 32 and on 64 bit platforms :

Before :

00000000 <swrate_add>:
   0:   8b 54 24 04             mov    0x4(%esp),%edx
   4:   8b 0a                   mov    (%edx),%ecx
   6:   89 c8                   mov    %ecx,%eax
   8:   c1 e0 09                shl    $0x9,%eax
   b:   29 c8                   sub    %ecx,%eax
   d:   8b 4c 24 0c             mov    0xc(%esp),%ecx
  11:   c1 e8 09                shr    $0x9,%eax
  14:   01 c8                   add    %ecx,%eax
  16:   89 02                   mov    %eax,(%edx)

After :

00000020 <swrate_add>:
  20:   8b 4c 24 04             mov    0x4(%esp),%ecx
  24:   8b 44 24 0c             mov    0xc(%esp),%eax
  28:   8b 11                   mov    (%ecx),%edx
  2a:   01 d0                   add    %edx,%eax
  2c:   81 c2 ff 01 00 00       add    $0x1ff,%edx
  32:   c1 ea 09                shr    $0x9,%edx
  35:   29 d0                   sub    %edx,%eax
  37:   89 01                   mov    %eax,(%ecx)

This fix may be backported to 1.6.

8 years agoMINOR: cli: make "show errors" capable of dumping only request or response
Willy Tarreau [Fri, 25 Nov 2016 08:16:37 +0000 (09:16 +0100)] 
MINOR: cli: make "show errors" capable of dumping only request or response

When dealing with many proxies, it's hard to spot response errors because
all internet-facing frontends constantly receive attacks. This patch now
makes it possible to demand that only request or response errors are dumped
by appending "request" or "reponse" to the show errors command.

8 years agoMINOR: cli: make "show errors" support a proxy name
Willy Tarreau [Fri, 25 Nov 2016 07:39:10 +0000 (08:39 +0100)] 
MINOR: cli: make "show errors" support a proxy name

Till now it was needed to know the proxy's ID while we do have the
ability to look up a proxy by its name now.

8 years agoMINOR: cli: make "show stat" support a proxy name
Willy Tarreau [Fri, 25 Nov 2016 07:50:58 +0000 (08:50 +0100)] 
MINOR: cli: make "show stat" support a proxy name

Till now it was needed to know the proxy's ID while we do have the
ability to look up a proxy by its name now.

8 years agoBUG: spoe: Fix parsing of SPOE actions in ACK frames
Christopher Faulet [Thu, 24 Nov 2016 13:53:22 +0000 (14:53 +0100)] 
BUG: spoe: Fix parsing of SPOE actions in ACK frames

For "SET-VAR" actions, data was not correctly parsed. 'idx' variable was not
correctly updated when the 3rd argument was parsed.

8 years agoCLEANUP: sample: report "converter" instead of "conv method" in error messages
Willy Tarreau [Fri, 25 Nov 2016 06:33:24 +0000 (07:33 +0100)] 
CLEANUP: sample: report "converter" instead of "conv method" in error messages

This was inherited from the very early stick-tables code but it's about
time to produce understandable error messages :-)

8 years agoMEDIUM: log-format: Use standard HAProxy log system to report errors
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 23:41:28 +0000 (00:41 +0100)] 
MEDIUM: log-format: Use standard HAProxy log system to report errors

The function log format emit its own error message using Alert(). This
patch replaces this behavior and uses the standard HAProxy error system
(with memprintf).

The benefits are:
 - cleaning the log system

 - the logformat can ignore the caller (actually the caller must set
   a flag designing the caller function).

 - Make the usage of the logformat function easy for future components.

8 years agoMINOR: http/conf: store the use_backend configuration file and line for logs
Thierry FOURNIER / OZON.IO [Thu, 24 Nov 2016 22:57:54 +0000 (23:57 +0100)] 
MINOR: http/conf: store the use_backend configuration file and line for logs

The error log of the directive use_backend doesn't provide the
file and line containing the declaration. This patch stores
theses informations.

8 years agoBUG/MINOR: conf: calloc untested
Thierry FOURNIER / OZON.IO [Thu, 24 Nov 2016 22:58:32 +0000 (23:58 +0100)] 
BUG/MINOR: conf: calloc untested

A calloc is executed without check of its returns code.

8 years agoMINOR: lua: Add tokenize function.
Thierry FOURNIER / OZON.IO [Thu, 24 Nov 2016 19:48:38 +0000 (20:48 +0100)] 
MINOR: lua: Add tokenize function.

For tokenizing a string, standard Lua recommends to use regexes.
The followinf example splits words:

   for i in string.gmatch(example, "%S+") do
      print(i)
   end

This is a little bit overkill for simply split words. This patch
adds a tokenize function which quick and do not use regexes.

8 years agoMINOR: lua: add utility function for check boolean argument
Thierry FOURNIER / OZON.IO [Thu, 24 Nov 2016 19:37:38 +0000 (20:37 +0100)] 
MINOR: lua: add utility function for check boolean argument

Strangely, the Lua API doesn't provides a function like
luaL_checkboolean(). This little function add this one.

8 years agoBUILD: vars: remove a build warning on vars.c
Willy Tarreau [Thu, 24 Nov 2016 20:23:28 +0000 (21:23 +0100)] 
BUILD: vars: remove a build warning on vars.c

gcc 3.4.6 noticed a possibly unitialized variable in vars.c, and while it
cannot happen the way the function is used, it's surprizing that newer
versions did not report it.

This fix may be backported to 1.6.

8 years agoBUILD: ssl: make the SSL layer build again with openssl 0.9.8
Willy Tarreau [Thu, 24 Nov 2016 19:07:11 +0000 (20:07 +0100)] 
BUILD: ssl: make the SSL layer build again with openssl 0.9.8

Commit 1866d6d ("MEDIUM: ssl: Add support for OpenSSL 1.1.0")
introduced support for openssl 1.1.0 and temporarily broke 0.9.8.
In the end the port was not very hard given that the only cause of
build failures were functions supposedly absent from 0.9.8 that in
fact did exist.

Thus, adding a new #if to move these functions for versions older
than 0.9.8 was enough to fix the trouble. It received very light
testing, basically only an SSL bridge decrypting and re-encrypting
traffic, and checking that everything looks right. That said, the
functions specific to 0.9.8 here compared to 1.0.x are only
SSL_SESSION_set1_id_context(), EVP_PKEY_base_id(), and
X509_PUBKEY_get0_param().

8 years agoMEDIUM: log-format/conf: take into account the parse_logformat_string() return code
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 22:50:02 +0000 (23:50 +0100)] 
MEDIUM: log-format/conf: take into account the parse_logformat_string() return code

This patch takes into account the return code of the parse_logformat_string()
function. Now the configuration parser will fail if the log_format is not
strict.

8 years agoMEDIUM: log-format: strict parsing and enable fail
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 22:11:21 +0000 (23:11 +0100)] 
MEDIUM: log-format: strict parsing and enable fail

Until now, the function parse_logformat_string() never fails. It
send warnings when it parses bad format, and returns expression in
best effort.

This patch replaces warnings by alert and returns a fail code.

Maybe the warning mode is designed for a compatibility with old
configuration versions. If it is the case, now this compatibility
is broken.

[wt: no, the reason is that an alert must cause a startup failure,
 but this will be OK with next patch]

8 years agoCLEANUP: log-format: remove unused arguments
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 21:33:24 +0000 (22:33 +0100)] 
CLEANUP: log-format: remove unused arguments

The log-format function parse_logformat_string() takes file and line
for building parsing logs. These two parameters are embedded in the
struct proxy curproxy, which is the current parsing context.

This patch removes these two unused arguments.

8 years agoCLEANUP: log-format: fix return code of function parse_logformat_var_args()
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 22:13:04 +0000 (23:13 +0100)] 
CLEANUP: log-format: fix return code of function parse_logformat_var_args()

This patch replace the successful return code from 0 to 1. The
error code is replaced from 1 to 0.

The return code of this function is actually unused, so this
patch cannot modify the behaviour.

8 years agoCLEANUP: log-format: fix return code of the function parse_logformat_var()
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 21:06:04 +0000 (22:06 +0100)] 
CLEANUP: log-format: fix return code of the function parse_logformat_var()

This patch replaces the successful return code from 0 to 1. The
error code is replaced from -1 to 0.

The return code of this function is actually unused, so this
patch cannot modify the behaviour.

8 years agoCLEANUP/MINOR: log-format: unexport functions parse_logformat_var_args() and parse_lo...
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 22:17:19 +0000 (23:17 +0100)] 
CLEANUP/MINOR: log-format: unexport functions parse_logformat_var_args() and parse_logformat_var()

Remove export of the fucntion parse_logformat_var_args() and
parse_logformat_var(). These functions are a part of the
logformat parser, and this export is useless.

8 years agoCLEANUP: log-format: useless file and line in json converter
Thierry FOURNIER / OZON.IO [Wed, 23 Nov 2016 00:13:57 +0000 (01:13 +0100)] 
CLEANUP: log-format: useless file and line in json converter

The caller must log location information, so this information is
provided two times in the log line. The error log is like this:

   [ALERT] 327/011513 (14291) : parsing [o3.conf:38]: 'http-response
   set-header': Sample fetch <method,json(rrr)> failed with : invalid
   args in conv method 'json' : Unexpected input code type at file
   'o3.conf', line 38. Allowed value are 'ascii', 'utf8', 'utf8s',
   'utf8p' and 'utf8ps'.

This patch removes the second location indication, the the same error
becomes:

   [ALERT] 327/011637 (14367) : parsing [o3.conf:38]: 'http-response
   set-header': Sample fetch <method,json(rrr)> failed with : invalid
   args in conv method 'json' : Unexpected input code type. Allowed
   value are 'ascii', 'utf8', 'utf8s', 'utf8p' and 'utf8ps'.

8 years agoBUG/MINOR: log-format: uncatched memory allocation functions
Thierry FOURNIER / OZON.IO [Tue, 22 Nov 2016 22:24:10 +0000 (23:24 +0100)] 
BUG/MINOR: log-format: uncatched memory allocation functions

Some return code of memory allocation functions are not tested.
This patch fix theses checks.

8 years agoBUILD: server: remove a build warning introduced by latest series
Willy Tarreau [Thu, 24 Nov 2016 16:32:01 +0000 (17:32 +0100)] 
BUILD: server: remove a build warning introduced by latest series

We get this when Lua is disabled, just a missing include.

In file included from src/queue.c:18:0:
include/proto/server.h:51:39: warning: 'struct appctx' declared inside parameter list [enabled by default]

8 years agoCLEANUP: cli: remove assignments to st0 and st2 in keyword parsers
Willy Tarreau [Thu, 24 Nov 2016 15:45:53 +0000 (16:45 +0100)] 
CLEANUP: cli: remove assignments to st0 and st2 in keyword parsers

Now it's not needed anymore to set STAT_ST_INIT nor CLI_ST_CALLBACK
in the parsers, remove it in the various places.

8 years agoCLEANUP: cli: simplify the request parser a little bit
Willy Tarreau [Thu, 24 Nov 2016 15:23:38 +0000 (16:23 +0100)] 
CLEANUP: cli: simplify the request parser a little bit

stats_sock_parse_request() was renamed cli_parse_request(). It now takes
an appctx instead of a stream interface, and presets ->st2 to 0 so that
most handlers will not have to set it anymore. The io_handler is set by
default to the keyword's IO handler so that the parser can simply change
it without having to rewrite the new state.

8 years agoCLEANUP: cli: rename STAT_CLI_* to CLI_ST_*
Willy Tarreau [Thu, 24 Nov 2016 14:53:53 +0000 (15:53 +0100)] 
CLEANUP: cli: rename STAT_CLI_* to CLI_ST_*

These are in CLI states, not stats states anymore. STAT_CLI_O_CUSTOM
was more appropriately renamed CLI_ST_CALLBACK.

8 years agoREORG: cli: move the "set rate-limit" functions to their own parser
Willy Tarreau [Thu, 24 Nov 2016 13:51:17 +0000 (14:51 +0100)] 
REORG: cli: move the "set rate-limit" functions to their own parser

All 4 rate-limit settings were handled at once given that exactly the
same checks are performed on them. In case of missing or incorrect
argument, the detailed supported options are printed with their use
case.

This was the last specific entry in the CLI parser, some additional
cleanup may still be done.

8 years agoREORG: cli: move "{enable|disable} agent" to server.c
Willy Tarreau [Thu, 24 Nov 2016 11:56:01 +0000 (12:56 +0100)] 
REORG: cli: move "{enable|disable} agent" to server.c

Also mention that "set server" is preferred now. Note that these
were the last enable/disable commands in cli.c. Also remove the
now unused expect_server_admin() function.

8 years agoREORG: cli: move "{enable|disable} health" to server.c
Willy Tarreau [Thu, 24 Nov 2016 11:51:04 +0000 (12:51 +0100)] 
REORG: cli: move "{enable|disable} health" to server.c

Also mention that "set server" is preferred now.

8 years agoREORG: cli: move "{enable|disable} server" to server.c
Willy Tarreau [Thu, 24 Nov 2016 11:47:00 +0000 (12:47 +0100)] 
REORG: cli: move "{enable|disable} server" to server.c

Also mention that "set server" is preferred now.

8 years agoREORG: cli: move "{enable|disable} frontend" to proxy.c
Willy Tarreau [Thu, 24 Nov 2016 10:55:28 +0000 (11:55 +0100)] 
REORG: cli: move "{enable|disable} frontend" to proxy.c

These are the last frontend-specific actions on the CLI. The function
expect_frontend_admin() which is not used anymore was removed.

8 years agoREORG: cli: move "shutdown frontend" to proxy.c
Willy Tarreau [Thu, 24 Nov 2016 10:13:06 +0000 (11:13 +0100)] 
REORG: cli: move "shutdown frontend" to proxy.c

Now we don't have any "shutdown" commands left in cli.c.

8 years agoREORG: cli: move "shutdown session" to stream.c
Willy Tarreau [Thu, 24 Nov 2016 10:09:25 +0000 (11:09 +0100)] 
REORG: cli: move "shutdown session" to stream.c

It really kills streams in fact, but we can't change the name now.

8 years agoREORG: cli: move "shutdown sessions server" to stream.c
Willy Tarreau [Wed, 23 Nov 2016 15:50:48 +0000 (16:50 +0100)] 
REORG: cli: move "shutdown sessions server" to stream.c

It could be argued that it's between server, stream and session but
at least due to the fact that it operates on streams, its best place
is in stream.c.

8 years agoREORG: cli: move "set maxconn frontend" to proxy.c
Willy Tarreau [Wed, 23 Nov 2016 15:22:04 +0000 (16:22 +0100)] 
REORG: cli: move "set maxconn frontend" to proxy.c

And get rid of the last specific "set maxconn" case.

8 years agoREORG: cli: move "set maxconn server" to server.c
Willy Tarreau [Wed, 23 Nov 2016 10:26:56 +0000 (11:26 +0100)] 
REORG: cli: move "set maxconn server" to server.c

It's used to manipulate the server's maxconn setting.

8 years agoREORG: cli: move "set maxconn global" to its own handler
Willy Tarreau [Wed, 23 Nov 2016 10:10:59 +0000 (11:10 +0100)] 
REORG: cli: move "set maxconn global" to its own handler

The code remained in the same file, it just simplifies the parser
and makes use of cli_has_level().

8 years agoREORG: cli: move "clear counters" to stats.c
Willy Tarreau [Wed, 23 Nov 2016 10:02:40 +0000 (11:02 +0100)] 
REORG: cli: move "clear counters" to stats.c

This command is only used to clear stats. It now relies on cli_has_level()
to validate the permissions.

8 years agoREORG: cli: move "set timeout" to its own handler
Willy Tarreau [Tue, 22 Nov 2016 19:33:32 +0000 (20:33 +0100)] 
REORG: cli: move "set timeout" to its own handler

The code remained in the same file, it just simplifies the parser.

8 years agoREORG: cli: make "show env" also use the generic keyword registration
Willy Tarreau [Tue, 22 Nov 2016 19:21:23 +0000 (20:21 +0100)] 
REORG: cli: make "show env" also use the generic keyword registration

This way we don't have any more state specific to a given yieldable
command. The other commands should be easier to move as they only
involve a parser.

8 years agoREORG: cli: move "show errors" out of cli.c
Willy Tarreau [Tue, 22 Nov 2016 18:48:51 +0000 (19:48 +0100)] 
REORG: cli: move "show errors" out of cli.c

It really belongs to proto_http.c since it's a dump for HTTP request
and response errors. Note that it's possible that some parts do not
need to be exported anymore since it really is the only place where
errors are manipulated.

8 years agoREORG: cli: move table dump/clear/set to stick_table.c
Willy Tarreau [Tue, 22 Nov 2016 17:00:53 +0000 (18:00 +0100)] 
REORG: cli: move table dump/clear/set to stick_table.c

The table dump code was a horrible mess, with common parts interleaved
all the way to deal with the various actions (set/clear/show). A few
error messages were still incorrect, as the "set" operation did not
update them so they would still report "unknown action" (now fixed).

The action was now passed as a private argument to the CLI keyword
which itself is copied into the appctx private field. It's just an
int cast to a pointer.

Some minor issues were noticed while doing this, for example when dumping
an entry by key, if the key doesn't exist, nothing is printed, not even
the table's header. It's unclear whether this was intentional but it
doesn't really match what is done for data-based dumps. It was left
unchanged for now so that a later fix can be backported if needed.

Enum entries STAT_CLI_O_TAB, STAT_CLI_O_CLR and STAT_CLI_O_SET were
removed.

8 years agoREORG: cli: move dump_text(), dump_text_line(), and dump_binary() to standard.c
Willy Tarreau [Tue, 22 Nov 2016 17:00:20 +0000 (18:00 +0100)] 
REORG: cli: move dump_text(), dump_text_line(), and dump_binary() to standard.c

These are general purpose functions, move them away.

8 years agoREORG: cli: move "show info" to stats.c
Willy Tarreau [Tue, 22 Nov 2016 15:36:53 +0000 (16:36 +0100)] 
REORG: cli: move "show info" to stats.c

Move the "show info" command to stats.c using the CLI keyword API
to register it on the CLI. The stats_dump_info_to_buffer() function
is now static again. Note, we don't need proto_ssl anymore in cli.c.

8 years agoREORG: cli: move "show stat" to stats.c
Willy Tarreau [Tue, 22 Nov 2016 15:18:05 +0000 (16:18 +0100)] 
REORG: cli: move "show stat" to stats.c

Move the "show stat" command to stats.c using the CLI keyword API
to register it on the CLI. The stats_dump_stat_to_buffer() function
is now static again.

8 years agoREORG: cli: move get/set weight to server.c
William Lallemand [Tue, 22 Nov 2016 11:34:35 +0000 (12:34 +0100)] 
REORG: cli: move get/set weight to server.c

Move get/set weight CLI functions to server.c and use the cli keyword API
to register it on the CLI.

8 years agoREORG: cli: move 'show backend' to proxy.c
William Lallemand [Tue, 22 Nov 2016 11:34:16 +0000 (12:34 +0100)] 
REORG: cli: move 'show backend' to proxy.c

Move 'show backend' CLI functions to proxy.c and use the cli keyword API
to register it on the CLI.

8 years agoREORG: cli: move 'show sess' to stream.c
William Lallemand [Mon, 21 Nov 2016 07:51:11 +0000 (08:51 +0100)] 
REORG: cli: move 'show sess' to stream.c

Move 'show sess' CLI functions to stream.c and use the cli keyword API
to register it on the CLI.

[wt: the choice of stream vs session makes sense because since 1.6 these
 really are streams that we're dumping and not sessions anymore]

8 years agoREORG: cli: move 'show servers' to proxy.c
William Lallemand [Sat, 19 Nov 2016 01:25:36 +0000 (02:25 +0100)] 
REORG: cli: move 'show servers' to proxy.c

Move 'show servers' CLI functions to proxy.c and use the cli keyword
API to register it on the CLI.

8 years agoREORG: cli: move 'show pools' to memory.c
William Lallemand [Sat, 19 Nov 2016 01:25:36 +0000 (02:25 +0100)] 
REORG: cli: move 'show pools' to memory.c

Move 'show pools' CLI functions to memory.c and use the cli keyword
API to register it on the CLI.

8 years agoREORG: cli: move 'set server' to server.c
William Lallemand [Sat, 19 Nov 2016 01:00:33 +0000 (02:00 +0100)] 
REORG: cli: move 'set server' to server.c

Move 'set server' CLI functions to server.c and use the cli keyword API
to register it on the CLI.

8 years agoMINOR: proxy: create new function cli_find_frontend() to find a frontend
Willy Tarreau [Thu, 24 Nov 2016 11:02:29 +0000 (12:02 +0100)] 
MINOR: proxy: create new function cli_find_frontend() to find a frontend

Several CLI commands require a frontend, so let's have a function to
look this one up and prepare the appropriate error message and the
appctx's state in case of failure.

8 years agoMINOR: server: create new function cli_find_server() to find a server
Willy Tarreau [Wed, 23 Nov 2016 16:15:08 +0000 (17:15 +0100)] 
MINOR: server: create new function cli_find_server() to find a server

Several CLI commands require a server, so let's have a function to
look this one up and prepare the appropriate error message and the
appctx's state in case of failure.

8 years agoMINOR: cli: create new function cli_has_level() to validate permissions
Willy Tarreau [Wed, 23 Nov 2016 16:01:39 +0000 (17:01 +0100)] 
MINOR: cli: create new function cli_has_level() to validate permissions

This function is used to check that the CLI features the appropriate
level of permissions or to prepare the adequate error message.

8 years agoREORG: cli: move show stat resolvers to dns.c
William Lallemand [Fri, 18 Nov 2016 23:58:54 +0000 (00:58 +0100)] 
REORG: cli: move show stat resolvers to dns.c

Move dns CLI functions to dns.c and use the cli keyword API to register
actions on the CLI.

8 years agoREORG: cli: move map and acl code to map.c
William Lallemand [Fri, 18 Nov 2016 18:26:17 +0000 (19:26 +0100)] 
REORG: cli: move map and acl code to map.c

Move map and acl CLI functions to map.c and use the cli keyword API to
register actions on the CLI. Then remove the now unused individual
"add" and "del" keywords.

8 years agoREORG: cli: move ssl CLI functions to ssl_sock.c
William Lallemand [Sat, 29 Oct 2016 16:09:35 +0000 (18:09 +0200)] 
REORG: cli: move ssl CLI functions to ssl_sock.c

Move ssl CLI functions to ssl_sock.c and use the cli keyword API to
register ssl actions on the CLI.

8 years agoREORG: cli: split dumpstats.h in stats.h and cli.h
William Lallemand [Mon, 21 Nov 2016 16:49:11 +0000 (17:49 +0100)] 
REORG: cli: split dumpstats.h in stats.h and cli.h

proto/dumpstats.h has been split in 4 files:

  * proto/cli.h  contains protypes for the CLI
  * proto/stats.h contains prototypes for the stats
  * types/cli.h contains definition for the CLI
  * types/stats.h contains definition for the stats

8 years agoREORG: cli: split dumpstats.c in src/cli.c and src/stats.c
William Lallemand [Mon, 21 Nov 2016 16:18:36 +0000 (17:18 +0100)] 
REORG: cli: split dumpstats.c in src/cli.c and src/stats.c

dumpstats.c was containing either the stats code and the CLI code.
The cli code has been moved to cli.c and the stats code to stats.c

8 years agoMINOR: connection: add names for transport and data layers
Willy Tarreau [Thu, 24 Nov 2016 15:58:12 +0000 (16:58 +0100)] 
MINOR: connection: add names for transport and data layers

This makes debugging easier and avoids having to put ugly checks
against certain well-known internal struct pointers.

8 years agoMINOR: connection: add a few functions to report the data and xprt layers' names
Willy Tarreau [Wed, 23 Nov 2016 17:00:08 +0000 (18:00 +0100)] 
MINOR: connection: add a few functions to report the data and xprt layers' names

These functions will be needed by "show sess" on the CLI, let's make them
globally available. It's important to note that due to the fact that we
still do not set the data and transport layers' names in the structures,
we still have to rely on some exports just to match the pointers. This is
ugly but is preferable to adding many includes since the short-term goal
is to get rid of these tests by having proper names in place.

8 years agoBUG/MINOR: cli: wake up the CLI's task after a timeout update
Willy Tarreau [Thu, 24 Nov 2016 14:35:16 +0000 (15:35 +0100)] 
BUG/MINOR: cli: wake up the CLI's task after a timeout update

When the CLI's timeout is reduced, nothing was done to take the task
up to update it. In the past it used to run inside process_stream()
so it used to be refreshed. This is not the case anymore since we have
the appctx so the task needs to be woken up in order to recompute the
new expiration date.

This fix needs to be backported to 1.6.

8 years agoBUG/MINOR: cli: dequeue from the proxy when changing a maxconn
Willy Tarreau [Thu, 24 Nov 2016 14:25:39 +0000 (15:25 +0100)] 
BUG/MINOR: cli: dequeue from the proxy when changing a maxconn

The "set maxconn frontend" statement on the CLI tries to dequeue possibly
pending requests, but due to a copy-paste error, they're dequeued on the
CLI's frontend instead of the one being changed.

The impact is very minor as it only means that possibly pending connections
will still have to wait for a previous one to complete before being accepted
when a limit is raised.

This fix has to be backported to 1.6 and 1.5.

8 years agoBUG/MINOR: cli: fix pointer size when reporting data/transport layer name
Willy Tarreau [Thu, 24 Nov 2016 14:21:26 +0000 (15:21 +0100)] 
BUG/MINOR: cli: fix pointer size when reporting data/transport layer name

In dumpstats.c we have get_conn_xprt_name() and get_conn_data_name() to
report the name of the data and transport layers used on a connection.
But when the name is not known, its pointer is reported instead. But the
static char used to report the pointer is too small as it doesn't leave
room for '0x'. Fortunately all subsystems are known so we never trigger
this case.

This fix needs to be backported to 1.6 and 1.5.

8 years agoBUILD: fix build on Solaris 10/11
David Carlier [Sun, 20 Nov 2016 10:42:38 +0000 (10:42 +0000)] 
BUILD: fix build on Solaris 10/11

uint16_t instead of u_int16_t
None ISO fields of struct tm are not present, but
by zeroyfing it, on GNU and BSD systems tm_gmtoff
field will be set.

[wt: moved the memset into each of the date functions]

8 years agoBUILD: contrib: fix ip6range build on Centos 7
Willy Tarreau [Tue, 22 Nov 2016 10:50:51 +0000 (11:50 +0100)] 
BUILD: contrib: fix ip6range build on Centos 7

Jarno Huuskonen reported that ip6range doesn't build anymore on
Centos 7 (and possibly other distros) due to "in6_u" not being known.
Using s6_addr32 instead of in6_u.u6_addr32 apparently works fine, and
it's also what the Lua code uses so it should be OK.

This patch may be backported to 1.6.

8 years agoMINOR: stats: correct documentation of process ID for typed output
Simon Horman [Mon, 21 Nov 2016 16:00:24 +0000 (17:00 +0100)] 
MINOR: stats: correct documentation of process ID for typed output

The process ID appears at the end of the first column rather than
the line.

8 years agoMINOR: spoe: Add "option set-on-error" statement
Christopher Faulet [Wed, 16 Nov 2016 14:36:19 +0000 (15:36 +0100)] 
MINOR: spoe: Add "option set-on-error" statement

It defines the variable to set when an error occurred during an event
processing. It will only be set when an error occurred in the scope of the
transaction. As for all other variables define by the SPOE, it will be
prefixed. So, if your variable name is "error" and your prefix is "my_spoe_pfx",
the variable will be "txn.my_spoe_pfx.error".

When set, the variable is the boolean "true". Note that if "option
continue-on-error" is set, the variable is not automatically removed between
events processing.

8 years agoMINOR: spoe: Add "maxconnrate" and "maxerrrate" statements
Christopher Faulet [Wed, 16 Nov 2016 14:01:12 +0000 (15:01 +0100)] 
MINOR: spoe: Add "maxconnrate" and "maxerrrate" statements

"maxconnrate" is the maximum number of connections per second. The SPOE will
stop to open new connections if the maximum is reached and will wait to acquire
an existing one.

"maxerrrate" is the maximum number of errors per second. The SPOE will stop its
processing if the maximum is reached.

These options replace hardcoded macros MAX_NEW_SPOE_APPLETS and
MAX_NEW_SPOE_APPLET_ERRS. We use it to limit SPOE activity, especially when
servers are down..