]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
10 years agoMEDIUM: lua: change the sleep function core
Thierry FOURNIER [Wed, 4 Mar 2015 14:51:09 +0000 (15:51 +0100)] 
MEDIUM: lua: change the sleep function core

This patch uses the last yield functionalities. The sleep function
just return the wake up time.

10 years agoMEDIUM: lua: interrupt the Lua execution for running other process
Thierry FOURNIER [Tue, 3 Mar 2015 16:37:37 +0000 (17:37 +0100)] 
MEDIUM: lua: interrupt the Lua execution for running other process

This patch permits to interrupt the Lua execution each n# of
instructions. It is useful for controling the execution time
of an Lua code, and permits at the HAProxy schedule to process
some others tasks waiting execution.

10 years agoMINOR: lua: adds "forced yield" flag
Thierry FOURNIER [Tue, 3 Mar 2015 16:29:06 +0000 (17:29 +0100)] 
MINOR: lua: adds "forced yield" flag

This flag indicate that the current yield is returned by the Lua
execution task control. If this flag is set, the current task may
quit but will be set in the run queue to be re-executed immediatly.

This patch modify the "hlua_yieldk()" function, it adds an argument
that contain a field containing yield options.

10 years agoMEDIUM: lua: each yielding function returns a wake up time.
Thierry FOURNIER [Tue, 3 Mar 2015 16:17:55 +0000 (17:17 +0100)] 
MEDIUM: lua: each yielding function returns a wake up time.

This is used to ensure that the task doesn't become a zombie
when the Lua returns a yield. The yield wrapper ensure that an
timer used for waking up the task will be set.

The timer is reseted to TICK_ETERNITY if the Lua execution is
done.

10 years agoMINOR: lua: set skeleton for Lua execution expiration
Thierry FOURNIER [Tue, 3 Mar 2015 15:52:26 +0000 (16:52 +0100)] 
MINOR: lua: set skeleton for Lua execution expiration

This first patch permits to cofigure the Lua execution exipiration.
This expiration is configured but it is not yet avalaible, it will
be add in a future patch.

10 years agoMINOR: lua: use bitfield and macro in place of integer and enum
Thierry FOURNIER [Tue, 3 Mar 2015 14:17:35 +0000 (15:17 +0100)] 
MINOR: lua: use bitfield and macro in place of integer and enum

In the future, the lua execution must return scheduling informations.
We want more than one flag, so I convert an integer used with an
enum into an interer used as bitfield.

10 years agoMINOR: lua: remove some #define
Thierry FOURNIER [Wed, 4 Mar 2015 15:48:34 +0000 (16:48 +0100)] 
MINOR: lua: remove some #define

The #define compilation directives are centralized in the hlua
include files. This permits to remove ome #ifdef from the haproxy
main code.

10 years agoMINOR: remove unused declaration.
Thierry FOURNIER [Wed, 4 Mar 2015 15:46:37 +0000 (16:46 +0100)] 
MINOR: remove unused declaration.

This declaration is removed in the patch 'Lua initialisation on demand".
commit id 05ac42455fab8bba252bf124d6c450402429fd39

10 years agoBUG/MAJOR: lua: send function fails and return bad bytes
Thierry FOURNIER [Wed, 4 Mar 2015 10:44:47 +0000 (11:44 +0100)] 
BUG/MAJOR: lua: send function fails and return bad bytes

In some cases the Lua "send" function fails. This is caused by the
return of "buffer_replace2()" is not tested. I checked avalaible space
in the buffer and I supposed than "buffer_replace2()" took all the
data. In some cases, "buffer_replace2()" cannot take the incoming
data, it returns the amount of data copied.

This patch check the amount of data really copied by "buffer_replace2()"
and advance the buffer with taking this value in account.

10 years agoBUILD/CLEANUP: systemd: avoid a warning due to mixed code and declaration
Cyril Bonté [Tue, 3 Mar 2015 22:26:14 +0000 (23:26 +0100)] 
BUILD/CLEANUP: systemd: avoid a warning due to mixed code and declaration

Gcc complains because the systemd wrapper mixed code and declaration :
"warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]".

10 years agoBUILD: try to automatically detect the Lua library name
Cyril Bonté [Tue, 3 Mar 2015 22:13:03 +0000 (23:13 +0100)] 
BUILD: try to automatically detect the Lua library name

Depending on the distribution, the Lua library can have different names.
Some distributions will require -llua5.2, others -llua52, and other systems may
require -llua.

Now, the Makefile will try to guess the library name, in order of priority :
"lua5.2", "lua52", or "lua".

10 years agoBUILD: lua: missing ifdef related to SSL when enabling LUA
Baptiste Assmann [Mon, 2 Mar 2015 20:40:06 +0000 (21:40 +0100)] 
BUILD: lua: missing ifdef related to SSL when enabling LUA

A couple of ifdef are missing around SSL related functions in LUA.
It prevents from compiling LUA without SSL.
Current patch fix this.

10 years agoBUG/MEDIUM: lua: segfault when calling haproxy sample fetches from lua
Cyril Bonté [Sun, 1 Mar 2015 23:08:41 +0000 (00:08 +0100)] 
BUG/MEDIUM: lua: segfault when calling haproxy sample fetches from lua

When a Lua script calls an internal haproxy sample fetch, it may segfault in
some conditions :
- when a fetch has no argument,
- when there is no room left to store the special type ARGT_STOP in the argument
  list (this one shouldn't happen currently as there isn't any sample fetch with
  enough arguments to fill the allocated buffer).

Example of Lua code which reproduces a segfault :
core.register_fetches("segfault", function(txn, ...)
  return txn.req_ver(txn)
end)

10 years agoMINOR: lua: add a compilation error message when compiled with an incompatible version
Cyril Bonté [Sun, 1 Mar 2015 23:08:40 +0000 (00:08 +0100)] 
MINOR: lua: add a compilation error message when compiled with an incompatible version

haproxy Lua support begins with Lua 5.2. In order to ease the diagnostic on
compilation error, a preprocessor error is added when an incompatible version
is used.

The compatibility is determined by the presence of LUA_VERSION_NUM and its
magic value (502 for Lua 5.2.x).

10 years agoMINOR: report the Lua version in -vv
Cyril Bonté [Sun, 1 Mar 2015 23:08:39 +0000 (00:08 +0100)] 
MINOR: report the Lua version in -vv

As of the other libraries used by haproxy, it can be useful to display the Lua
version used at compilation time.
A new line is added to "haproxy -vv", which shows if Lua is supported by the
binary, and with which version it was compiled.

10 years agoMINOR: lua: typo in an error message
Cyril Bonté [Sun, 1 Mar 2015 23:08:38 +0000 (00:08 +0100)] 
MINOR: lua: typo in an error message

A small typo was introduced in an error message, occuring when too many
arguments are provided ("Malformed argument mask").

10 years agoMEDIUM: lua: Lua initialisation "on demand"
Thierry FOURNIER [Fri, 27 Feb 2015 17:37:27 +0000 (18:37 +0100)] 
MEDIUM: lua: Lua initialisation "on demand"

Actually, the Lua context is always initilized in each
session, even if the session doesn't use Lua. This
behavior cause 5% performances loss.

This patch initilize the Lua only if it is use by the
session. The initialization is now on demand.

10 years agoBUILD: lua: cleanup many mixed occurrences declarations & code
Willy Tarreau [Fri, 27 Feb 2015 15:38:20 +0000 (16:38 +0100)] 
BUILD: lua: cleanup many mixed occurrences declarations & code

The code was a bit of a pain to follow because of this, especially
when some of it heavily relies on longjmp... This refreshing makes
it slightly easier to read.

10 years agoMINOR: lua: txn: add binding for closing the client connection.
Thierry FOURNIER [Tue, 17 Feb 2015 17:42:34 +0000 (18:42 +0100)] 
MINOR: lua: txn: add binding for closing the client connection.

10 years agoMINOR: lua: core: can yield an execution stack
Thierry FOURNIER [Tue, 17 Feb 2015 14:01:59 +0000 (15:01 +0100)] 
MINOR: lua: core: can yield an execution stack

This patch provides a yield function. This function permits to
give back the hand at the HAProxy scheduler. It is used when the
lua processing consumes a lot of time.

10 years agoMINOR: lua: core: can set the nice of the current task
Thierry FOURNIER [Mon, 16 Feb 2015 18:34:56 +0000 (19:34 +0100)] 
MINOR: lua: core: can set the nice of the current task

This patch adds an LUA binding that permits to change the
task priority.

10 years agoMINOR: lua: txn: object "txn" provides two objects "channel"
Thierry FOURNIER [Tue, 17 Feb 2015 13:59:53 +0000 (14:59 +0100)] 
MINOR: lua: txn: object "txn" provides two objects "channel"

This patch adds two functions that creates and returns channel
object from a txn object.

10 years agoMINOR: lua: channel: add "channel" class
Thierry FOURNIER [Mon, 9 Feb 2015 15:38:34 +0000 (16:38 +0100)] 
MINOR: lua: channel: add "channel" class

The channel class permits manipulation of channels. A channel is
an FIFO buffer between the client and the server. This class provides
function to read, write, forward, destroy and alter data between
the input and the ouput of the buffer.

10 years agoMINOR: lua: core: pattern and acl manipulation
Thierry FOURNIER [Wed, 4 Feb 2015 12:21:04 +0000 (13:21 +0100)] 
MINOR: lua: core: pattern and acl manipulation

The functions added by this patch add LUA bindings for the ACL
and map manipulation.

10 years agoMEDIUM: lua: socket: add "socket" class for TCP I/O
Thierry FOURNIER [Mon, 16 Feb 2015 18:27:16 +0000 (19:27 +0100)] 
MEDIUM: lua: socket: add "socket" class for TCP I/O

This patch adds the TCP I/O functionnality. The class implemented
provides the same functions than the "lua socket" project. This
make network compatibility with another LUA project. The documentation
is located here:

   http://w3.impa.br/~diego/software/luasocket/tcp.html

10 years agoMINOR: lua: core: add sleep functions
Thierry FOURNIER [Mon, 16 Feb 2015 18:43:25 +0000 (19:43 +0100)] 
MINOR: lua: core: add sleep functions

This version of sleep is based on a coroutine. A sleeping
task is started and a signal is registered. This sleep version
must disapear to be replaced by a version using the internal
timers.

10 years agoMINOR: lua: add bindings for tcp and http actions
Thierry FOURNIER [Mon, 16 Feb 2015 19:23:40 +0000 (20:23 +0100)] 
MINOR: lua: add bindings for tcp and http actions

This patch adds the runtime environment for http and tcp actions.
It provides also the function for action registering.

10 years agoMINOR: lua: register and execute converters in LUA
Thierry FOURNIER [Mon, 16 Feb 2015 19:21:12 +0000 (20:21 +0100)] 
MINOR: lua: register and execute converters in LUA

This patch permits to write LUA converters. Note that
all the converters declared trough LUA are automatically
prefixed by "lua.".

The Lua converters needs the current session to be executed,
but the writed and executed Lua code must be static and
contextless. The TXN object is not created for the converters.

10 years agoMINOR: lua: register and execute sample-fetches in LUA
Thierry FOURNIER [Mon, 16 Feb 2015 19:19:18 +0000 (20:19 +0100)] 
MINOR: lua: register and execute sample-fetches in LUA

This patch permits to write LUA samples fetches. Note that
all the fethes declared trough LUA are automatically prefixed
by "lua.".

10 years agoMINOR: lua: txn: add lua function in TXN that returns an array of http headers
Thierry FOURNIER [Mon, 16 Feb 2015 19:22:55 +0000 (20:22 +0100)] 
MINOR: lua: txn: add lua function in TXN that returns an array of http headers

This patch adds an LUA binding that returns an array of
HTTP headers. The key is the header name and the value is
the header value.

10 years agoMINOR: lua: txn: import existing sample-fetches in the class TXN
Thierry FOURNIER [Mon, 16 Feb 2015 19:14:51 +0000 (20:14 +0100)] 
MINOR: lua: txn: import existing sample-fetches in the class TXN

This patch adds the browsing of all the HAProxy fetches and
create associated LUA functions. The HAProxy internal fetches
can be used in LUA trough the class "TXN".

Note that the symbols "-", "+" and "." in the name of current
sample fetch are rewrited as "_" in LUA because ".", "-" and "+"
are operators.

10 years agoMINOR: lua: add shared context in the lua stack
Thierry FOURNIER [Wed, 25 Feb 2015 10:43:21 +0000 (11:43 +0100)] 
MINOR: lua: add shared context in the lua stack

The shared context is a global reference dedicated to one Lua stack.
Even if the TXN is not required, the shared context it is associated
with a TXN object. In fact, the shared has no sense outside a TXN
context

10 years agoMINOR: lua: txn: create class TXN associated with the transaction.
Thierry FOURNIER [Mon, 16 Feb 2015 19:11:43 +0000 (20:11 +0100)] 
MINOR: lua: txn: create class TXN associated with the transaction.

This class of functions permit to access to all the functions
associated with the transaction like http header, HAProxy internal
fetches, etc ...

This patch puts the skeleton of this class. The class will be
enhanced later.

10 years agoMINOR: lua: add sample and args type converters
Thierry FOURNIER [Fri, 23 Jan 2015 10:36:30 +0000 (11:36 +0100)] 
MINOR: lua: add sample and args type converters

These function are used for converting LUA value in HAProxy values.
This is helpful with sample-fetch and converter wrappers.

10 years agoMEDIUM: lua: add coroutine as tasks.
Thierry FOURNIER [Fri, 23 Jan 2015 11:13:00 +0000 (12:13 +0100)] 
MEDIUM: lua: add coroutine as tasks.

This LUA subsystem permits to execute LUA code in parallel of the
main HAProxy activity. This is useful for periodic updates or
special checks.

10 years agoMINOR: lua: post initialisation bindings
Thierry FOURNIER [Fri, 23 Jan 2015 11:08:30 +0000 (12:08 +0100)] 
MINOR: lua: post initialisation bindings

This system permits to execute some lua function after than HAProxy
complete his initialisation. These functions are executed between
the end of the configuration parsing and check and the begin of the
scheduler.

10 years agoMINOR: lua: core: create "core" class and object
Thierry FOURNIER [Fri, 23 Jan 2015 13:07:08 +0000 (14:07 +0100)] 
MINOR: lua: core: create "core" class and object

This object provides main HAProxy functions. This first version
creates an empty object. It will be enhanced later.

10 years agoMINOR: lua: add the configuration directive "lua-load"
Thierry FOURNIER [Fri, 23 Jan 2015 14:57:06 +0000 (15:57 +0100)] 
MINOR: lua: add the configuration directive "lua-load"

This directive is encoutered in the global section of the HAProxy
configuration file. It permits to load and execute an LUA file.

10 years agoMEDIUM: lua: "com" signals
Thierry FOURNIER [Fri, 23 Jan 2015 10:08:20 +0000 (11:08 +0100)] 
MEDIUM: lua: "com" signals

This system permits to send signals between lua tasks. A main lua stack can
register the signal in a coprocess. When the coprocess finish his job, it
send a signal, and the associated task is wakes. If the main lua execution
stack stop (with or without errors), the list or pending signals is purged.

10 years agoMINOR: lua: add runtime execution context
Thierry FOURNIER [Fri, 23 Jan 2015 13:27:52 +0000 (14:27 +0100)] 
MINOR: lua: add runtime execution context

The functions added permits to execute the LUA stack execution in
HAProxy. It provides all the runtie environment and initialise the
main LUA stack.

10 years agoMINOR: lua: add ease functions
Thierry FOURNIER [Wed, 25 Feb 2015 17:48:12 +0000 (18:48 +0100)] 
MINOR: lua: add ease functions

This patch adds little convenient functions useful for lua basic
manipulation.

10 years agoMEDIUM: lua: lua integration in the build and init system.
Thierry FOURNIER [Fri, 23 Jan 2015 13:06:13 +0000 (14:06 +0100)] 
MEDIUM: lua: lua integration in the build and init system.

This is the first step of the lua integration. We add the useful
files in the HAProxy project. These files contains the main
includes, the Makefile options and empty initialisation function.
Is is the LUA skeleton.

10 years agoMINOR: channel: functions to get data from a buffer without copy
Thierry FOURNIER [Mon, 16 Feb 2015 18:26:48 +0000 (19:26 +0100)] 
MINOR: channel: functions to get data from a buffer without copy

We now have functions to retrieve one block and one line from
either the input or the output part of a buffer. They return
up to two (pointer,length) values in case the buffer wraps.

10 years agoMEDIUM: http/tcp: permit to resume http and tcp custom actions
Thierry FOURNIER [Wed, 25 Feb 2015 12:36:14 +0000 (13:36 +0100)] 
MEDIUM: http/tcp: permit to resume http and tcp custom actions

Later, the processing of some actions needs to be interrupted and resumed
later. This patch permit to resume the actions. The actions that needs
to run with the resume mode are not yet avalaible. It will be soon with
Lua patches. So the code added by this patch is untestable for the moment.

The list of "tcp_exec_req_rules" cannot resme because is called by the
unresumable function "accept_session".

10 years agoMEDIUM: http: change the code returned by the response processing rule functions
Thierry FOURNIER [Wed, 25 Feb 2015 12:51:19 +0000 (13:51 +0100)] 
MEDIUM: http: change the code returned by the response processing rule functions

Actually, this function returns a pointer on the rule that stop
the evaluation of the rule list. Later we integrate the possibility
of interrupt and resue the processsing of some actions. The current
response mode is not sufficient to returns the "interrupt" information.

The pointer returned is never used, so I change the return type of
this function by an enum. With this enum, the function is ready to
return the "interupt" value.

10 years agoMEDIUM: buffer: make bo_putblk/bo_putstr/bo_putchk return the number of bytes copied.
Thierry FOURNIER [Fri, 6 Feb 2015 17:40:20 +0000 (18:40 +0100)] 
MEDIUM: buffer: make bo_putblk/bo_putstr/bo_putchk return the number of bytes copied.

This is not used yet. Planned for LUA.

10 years agoMEDIUM: tcp: add register keyword system.
Thierry FOURNIER [Fri, 12 Dec 2014 18:41:33 +0000 (19:41 +0100)] 
MEDIUM: tcp: add register keyword system.

This patch introduces an action keyword registration system for TCP
rulesets similar to what is available for HTTP rulesets. This sytem
will be useful with lua.

10 years agoMINOR: includes: fix a lot of missing or useless includes
Thierry FOURNIER [Tue, 16 Dec 2014 14:41:18 +0000 (15:41 +0100)] 
MINOR: includes: fix a lot of missing or useless includes

These modifications are done for resolving cross-dependent
includes in the upcoming LUA code.

<proto/channel.h> misses <types/channel.h>.

<types/acl.h> doesn't use <types/session.h> because the session
is already declared in the file as undefined pointer.

appsession.c misses <unistd.h> to use "write()".

Declare undefined pointer "struct session" for <types/proxy.h>
and <types/queue.h>. These includes dont need the detail of this
struct.

10 years agoMINOR: global: export many symbols.
Thierry FOURNIER [Mon, 8 Dec 2014 18:50:43 +0000 (19:50 +0100)] 
MINOR: global: export many symbols.

The functions "val_payload_lv" and "val_hdr" are useful with
lua. The lua automatic binding for sample fetchs needs to
compare check functions.

The "arg_type_names" permit to display error messages.

10 years agoMINOR: sample: add function for browsing samples.
Thierry FOURNIER [Mon, 8 Dec 2014 13:49:19 +0000 (14:49 +0100)] 
MINOR: sample: add function for browsing samples.

This function is useful with the incoming lua functions.

10 years agoMINOR: global: export function and permits to not resolve DNS names
Thierry FOURNIER [Tue, 25 Nov 2014 11:02:25 +0000 (12:02 +0100)] 
MINOR: global: export function and permits to not resolve DNS names

exports the commonly used function str2ip. The function str2ip2 is
created and permits to not resolve DNS names.

10 years agoMINOR: sample: add private argument to the struct sample_fetch
Thierry FOURNIER [Sun, 7 Dec 2014 17:37:57 +0000 (18:37 +0100)] 
MINOR: sample: add private argument to the struct sample_fetch

The add of this private argument is to prepare the integration
of the lua fetchs.

10 years agoMINOR: converters: give the session pointer as converter argument
Thierry FOURNIER [Mon, 23 Feb 2015 14:11:11 +0000 (15:11 +0100)] 
MINOR: converters: give the session pointer as converter argument

Some usages of the converters need to know the attached session. The Lua
needs the session for retrieving his running context. This patch adds
the "session" as an argument of the converters prototype.

10 years agoMINOR: converters: add a "void *private" argument to converters
Thierry FOURNIER [Mon, 15 Dec 2014 15:18:39 +0000 (16:18 +0100)] 
MINOR: converters: add a "void *private" argument to converters

This permits to store specific configuration pointer. It is useful
with future Lua integration.

10 years agoMEDIUM: channel: wake up any request analyzer on response activity
Thierry FOURNIER [Thu, 26 Feb 2015 09:40:09 +0000 (10:40 +0100)] 
MEDIUM: channel: wake up any request analyzer on response activity

This behavior is already existing for the "WAIT_HTTP" analyzer,
this patch just extends the system to any analyzer that would
be waked up on response activity.

10 years agoMEDIUM: protocol: automatically pick the proto associated to the connection.
Thierry FOURNIER [Wed, 14 Jan 2015 10:31:49 +0000 (11:31 +0100)] 
MEDIUM: protocol: automatically pick the proto associated to the connection.

When the destination IP is dynamically set, we can't use the "target"
to define the proto. This patch ensures that we always use the protocol
associated with the address family. The proto field was removed from
the server and check structs.

10 years agoMEDIUM: protocol: use a family array to index the protocol handlers
Willy Tarreau [Fri, 20 Feb 2015 15:53:25 +0000 (16:53 +0100)] 
MEDIUM: protocol: use a family array to index the protocol handlers

Instead of walking over a list, we now have a direct mapping between
protocol families and their respective handlers. This will allow fast
lookups.

10 years agoMEDIUM: task: call session analyzers if the task is woken by a message.
Thierry FOURNIER [Mon, 24 Nov 2014 13:49:56 +0000 (14:49 +0100)] 
MEDIUM: task: call session analyzers if the task is woken by a message.

When a task used to receive a message from another one, its analysers
were not called if there was no I/O activity.

10 years agoMAJOR: poll: only rely on wake_expired_tasks() to compute the wait delay
Thierry FOURNIER [Mon, 15 Dec 2014 12:26:01 +0000 (13:26 +0100)] 
MAJOR: poll: only rely on wake_expired_tasks() to compute the wait delay

Actually, HAProxy uses the function "process_runnable_tasks" and
"wake_expired_tasks" to get the next task which can expires.

If a task is added with "task_schedule" or other method during
the execution of an other task, the expiration of this new task
is not taken into account, and the execution of this task can be
too late.

Actualy, HAProxy seems to be no sensitive to this bug.

This fix moves the call to process_runnable_tasks() before the timeout
calculation and ensures that all wakeups are processed together. Only
wake_expired_tasks() needs to return a timeout now.

10 years agoBUILD/CLEANUP: config: silent 3 warnings about mixed declarations with code
Willy Tarreau [Fri, 27 Feb 2015 15:37:05 +0000 (16:37 +0100)] 
BUILD/CLEANUP: config: silent 3 warnings about mixed declarations with code

These ones were present in the tcp-check parser.

10 years agoBUILD/CLEANUP: ssl: avoid a warning due to mixed code and declaration
Willy Tarreau [Fri, 27 Feb 2015 15:36:16 +0000 (16:36 +0100)] 
BUILD/CLEANUP: ssl: avoid a warning due to mixed code and declaration

Actually it was caused by some dummy code meant to shut gcc up for
an unused argument!

10 years agoBUILD: Makefile: add -Wdeclaration-after-statement
Willy Tarreau [Fri, 27 Feb 2015 15:34:50 +0000 (16:34 +0100)] 
BUILD: Makefile: add -Wdeclaration-after-statement

This one makes it easier to detect accidentally misplaced variables
declarations in the code which are always a pain to deal with when
functions grow.

10 years agoDOC: Document the new tls-ticket-keys bind keyword
Nenad Merdanovic [Fri, 27 Feb 2015 18:56:50 +0000 (19:56 +0100)] 
DOC: Document the new tls-ticket-keys bind keyword

Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
10 years agoMEDIUM: Add support for configurable TLS ticket keys
Nenad Merdanovic [Fri, 27 Feb 2015 18:56:49 +0000 (19:56 +0100)] 
MEDIUM: Add support for configurable TLS ticket keys

Until now, the TLS ticket keys couldn't have been configured and
shared between multiple instances or multiple servers running HAproxy.
The result was that if a request got a TLS ticket from one instance/server
and it hits another one afterwards, it will have to go through the full
SSL handshake and negotation.

This patch enables adding a ticket file to the bind line, which will be
used for all SSL contexts created from that bind line. We can use the
same file on all instances or servers to mitigate this issue and have
consistent TLS tickets assigned. Clients will no longer have to negotiate
every time they change the handling process.

Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
10 years agoBUG/MEDIUM: Do not consider an agent check as failed on L7 error
Simon Horman [Thu, 26 Feb 2015 02:26:17 +0000 (11:26 +0900)] 
BUG/MEDIUM: Do not consider an agent check as failed on L7 error

As failure to connect to the agent check is not sufficient to mark it as
failed it stands to reason that an L7 error shouldn't either.

Without this fix if an L7 error occurs, for example of connectivity to the
agent is lost immediately after establishing a connection to it, then the
agent check will be considered to have failed and thus may end up with zero
health. Once this has occurred if the primary health check also reaches
zero health, which is likely if connectivity to the server is lost, then
the server will be marked as down and not be marked as up again until a
successful agent check occurs regardless of the success of any primary
health checks.

This behaviour is not correct as a failed agent check should never cause a
server to be marked as down or by extension continue to be marked as down.

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoBUG/MINOR: don't start haproxy on reload
Adam Spiers [Mon, 23 Feb 2015 15:28:41 +0000 (15:28 +0000)] 
BUG/MINOR: don't start haproxy on reload

If haproxy is not already running, reload should not start it.
Unfortunately the LSB spec does not explicitly cover this case:

  http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

but it seems like the more correct behaviour, and actually fixes a
real-world issue we saw in SUSE Cloud.

Signed-off-by: Adam Spiers <aspiers@suse.com>
10 years agoCLEANUP: extract quiet_check() to avoid duplication
Adam Spiers [Mon, 23 Feb 2015 15:28:40 +0000 (15:28 +0000)] 
CLEANUP: extract quiet_check() to avoid duplication

Signed-off-by: Adam Spiers <aspiers@suse.com>
10 years agoCLEANUP: extract temporary $LOCKFILE to eliminate duplication
Adam Spiers [Mon, 23 Feb 2015 15:28:39 +0000 (15:28 +0000)] 
CLEANUP: extract temporary $LOCKFILE to eliminate duplication

Signed-off-by: Adam Spiers <aspiers@suse.com>
10 years agoCLEANUP: extract temporary $PIDFILE to eliminate duplication
Adam Spiers [Mon, 23 Feb 2015 15:28:38 +0000 (15:28 +0000)] 
CLEANUP: extract temporary $PIDFILE to eliminate duplication

Signed-off-by: Adam Spiers <aspiers@suse.com>
10 years agoCLEANUP: extract temporary $BIN to eliminate duplication
Adam Spiers [Mon, 23 Feb 2015 15:28:37 +0000 (15:28 +0000)] 
CLEANUP: extract temporary $BIN to eliminate duplication

Signed-off-by: Adam Spiers <aspiers@suse.com>
10 years agoCLEANUP: extract temporary $CFG to eliminate duplication
Adam Spiers [Mon, 23 Feb 2015 15:28:36 +0000 (15:28 +0000)] 
CLEANUP: extract temporary $CFG to eliminate duplication

Signed-off-by: Adam Spiers <aspiers@suse.com>
10 years agoMEDIUM: task: always ensure that the run queue is consistent
Willy Tarreau [Mon, 23 Feb 2015 15:07:01 +0000 (16:07 +0100)] 
MEDIUM: task: always ensure that the run queue is consistent

As found by Thierry Fournier, if a task manages to kill another one and
if this other task is the next one in the run queue, we can do whatever
including crashing, because the scheduler restarts from the saved next
task. For now, there is no such concept of a task killing another one,
but with Lua it will come.

A solution consists in always performing the lookup of the first task in
the scheduler's loop, but it's expensive and costs around 2% of the
performance.

Another solution consists in keeping a global next run queue node and
ensuring that when this task gets removed, it updates this pointer to
the next one. This allows to simplify the code a bit and in the end to
slightly increase the performance (0.3-0.5%). The mechanism might still
be usable if we later migrate to a multi-threaded scheduler.

10 years agoBUG/MINOR: ARG6 and ARG7 don't fit in a 32 bits word
Thierry FOURNIER [Tue, 17 Feb 2015 15:09:00 +0000 (16:09 +0100)] 
BUG/MINOR: ARG6 and ARG7 don't fit in a 32 bits word

The patch "MEDIUM: args: increase arg type to 5 bits and limit arg count
to 5" (dbc79d0a) increased the number of types supported, but forgot to
remove the ARG6/ARG7 macros.

10 years agoMINOR: http: add the new sample fetches req.hdr_names and res.hdr_names
Willy Tarreau [Fri, 20 Feb 2015 12:55:29 +0000 (13:55 +0100)] 
MINOR: http: add the new sample fetches req.hdr_names and res.hdr_names

These new sample fetches retrieve the list of header names as they appear
in the request or response. This can be used for debugging, for statistics
as well as an aid to better detect the presence of proxies or plugins on
some browsers, which alter the request compared to a regular browser by
adding or reordering headers.

10 years agoMINOR: http: add a new function to iterate over each header line
Willy Tarreau [Fri, 20 Feb 2015 12:51:36 +0000 (13:51 +0100)] 
MINOR: http: add a new function to iterate over each header line

New function http_find_next_header() will be used to scan all the input
headers for various processing and for http/1 to http/2 header mapping.

10 years agoBUG/MAJOR: peers: initialize s->buffer_wait when creating the session
Willy Tarreau [Sat, 14 Feb 2015 13:14:57 +0000 (14:14 +0100)] 
BUG/MAJOR: peers: initialize s->buffer_wait when creating the session

Commit bf883e0 ("MAJOR: session: implement a wait-queue for sessions who
need a buffer") introduced in 1.6 forgot to initialize the buffer_wait
list when the session is initiated by an applet for a peer, resulting in
a crash. Thanks to Chris Kopp for reporting the issue.

10 years agoBUG/MEDIUM: pattern: some entries are not deleted with case insensitive match
Thierry FOURNIER [Fri, 6 Feb 2015 16:53:54 +0000 (17:53 +0100)] 
BUG/MEDIUM: pattern: some entries are not deleted with case insensitive match

ACL or map entries are not deleted with the command "del acl" or "del map"
if the case insentive flag is set.

This is because the the case insensitive string are stored in a list and the
default delete function associated with string looks in a tree. I add a check
of the case insensitive flag and execute the delete function for lists if it
is set.

This patch must be backported in 1.5 version.

10 years agoBUG/MINOR: pattern: error message missing
Thierry FOURNIER [Fri, 6 Feb 2015 16:50:55 +0000 (17:50 +0100)] 
BUG/MINOR: pattern: error message missing

This patch must be backported in 1.5 version.

10 years agoMINOR: ssl/server: add the "no-ssl-reuse" server option
Willy Tarreau [Thu, 5 Feb 2015 15:47:07 +0000 (16:47 +0100)] 
MINOR: ssl/server: add the "no-ssl-reuse" server option

This option disables SSL session reuse when SSL is used to communicate with
the server. It will force the server to perform a full handshake for every
new connection. It's probably only useful for benchmarking, troubleshooting,
and for paranoid users.

10 years agoMEDIUM: Allow suppression of email alerts by log level
Simon Horman [Fri, 6 Feb 2015 02:11:57 +0000 (11:11 +0900)] 
MEDIUM: Allow suppression of email alerts by log level

This patch adds a new option which allows configuration of the maximum
log level of messages for which email alerts will be sent.

The default is alert which is more restrictive than
the current code which sends email alerts for all priorities.
That behaviour may be configured using the new configuration
option to set the maximum level to notice or greater.

email-alert level notice

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMINOR: Remove trailing '.' from email alert messages
Simon Horman [Fri, 6 Feb 2015 02:11:56 +0000 (11:11 +0900)] 
MINOR: Remove trailing '.' from email alert messages

This removes the trailing '.' from both the header and the body of email
alerts.

The main motivation for this change is to make the format of email alerts
generated from srv_set_stopped() consistent with those generated from
set_server_check_status().

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoBUILD: add new target 'make uninstall' to support uninstalling haproxy from OS
Ilyas Bakirov [Wed, 4 Feb 2015 11:14:26 +0000 (17:14 +0600)] 
BUILD: add new target 'make uninstall' to support uninstalling haproxy from OS

10 years agoMEDIUM: tcp: implement tcp-ut bind option to set TCP_USER_TIMEOUT
Willy Tarreau [Tue, 3 Feb 2015 23:45:58 +0000 (00:45 +0100)] 
MEDIUM: tcp: implement tcp-ut bind option to set TCP_USER_TIMEOUT

On Linux since 2.6.37, it's possible to set the socket timeout for
pending outgoing data, with an accuracy of 1 millisecond. This is
pretty handy to deal with dead connections to clients and or servers.

For now we only implement it on the frontend side (bind line) so
that when a client disappears from the net, we're able to quickly
get rid of its connection and possibly release a server connection.
This can be useful with long-lived connections where an application
level timeout is not suited because long pauses are expected (remote
terminals, connection pools, etc).

Thanks to Thijs Houtenbos and John Eckersberg for the suggestion.

10 years agoDOC: Document email alerts
Simon Horman [Tue, 3 Feb 2015 04:00:44 +0000 (13:00 +0900)] 
DOC: Document email alerts

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Support sending email alerts
Simon Horman [Fri, 30 Jan 2015 02:23:00 +0000 (11:23 +0900)] 
MEDIUM: Support sending email alerts

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Allow configuration of email alerts
Simon Horman [Fri, 30 Jan 2015 02:22:59 +0000 (11:22 +0900)] 
MEDIUM: Allow configuration of email alerts

This currently does nothing beyond parsing the configuration
and storing in the proxy as there is no implementation of email alerts.

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Add parsing of mailers section
Simon Horman [Fri, 30 Jan 2015 02:22:58 +0000 (11:22 +0900)] 
MEDIUM: Add parsing of mailers section

As mailer and mailers structures and allow parsing of
a mailers section into those structures.

These structures will subsequently be freed as it is
not yet possible to use reference them in the configuration.

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Attach tcpcheck_rules to check
Simon Horman [Fri, 30 Jan 2015 02:22:57 +0000 (11:22 +0900)] 
MEDIUM: Attach tcpcheck_rules to check

This is to allow checks to be established whose tcpcheck_rules
are not those of its proxy.

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Move proto and addr fields struct check
Simon Horman [Fri, 30 Jan 2015 02:22:56 +0000 (11:22 +0900)] 
MEDIUM: Move proto and addr fields struct check

The motivation for this is to make checks more independent of each
other to allow further reuse of their infrastructure.

For nowserver->check and server->agent still always use the same values
for the addr and proto fields so this patch should not introduce any
behavioural changes.

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Add free_check() helper
Simon Horman [Fri, 30 Jan 2015 02:22:55 +0000 (11:22 +0900)] 
MEDIUM: Add free_check() helper

Add free_check() helper to free the memory allocated by init_check().

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Refactor init_check and move to checks.c
Simon Horman [Fri, 30 Jan 2015 02:22:54 +0000 (11:22 +0900)] 
MEDIUM: Refactor init_check and move to checks.c

Refactor init_check so that an error string is returned
rather than alerts being printed by it. Also
init_check to checks.c and provide a prototype to allow
it to be used from multiple C files.

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoMEDIUM: Remove connect_chk
Simon Horman [Fri, 30 Jan 2015 02:22:53 +0000 (11:22 +0900)] 
MEDIUM: Remove connect_chk

Remove connect_chk and instead call connect_proc_chk()
and connect_conn_chk(). There no longer seems to be any
value in having a wrapper function here.

Signed-off-by: Simon Horman <horms@verge.net.au>
10 years agoBUG/MINOR: stats:Fix incorrect printf type.
Warren Turkal [Tue, 27 Jan 2015 23:04:16 +0000 (15:04 -0800)] 
BUG/MINOR: stats:Fix incorrect printf type.

The value is defined in include/types/global.h to be an unsigned int.
The type format in the printf is for a signed int. This eventually wraps
around.

WT: This bug was introduced in 1.5.

10 years agoBUG/MINOR: http: abort request processing on filter failure
Willy Tarreau [Fri, 30 Jan 2015 19:58:58 +0000 (20:58 +0100)] 
BUG/MINOR: http: abort request processing on filter failure

Commit c600204 ("BUG/MEDIUM: regex: fix risk of buffer overrun in
exp_replace()") added a control of failure on the response headers,
but forgot to check for the error during request processing. So if
the filters fail to apply, we could keep the request. It might
cause some headers to silently fail to be added for example. Note
that it's tagged MINOR because a standard configuration cannot make
this case happen.

The fix should be backported to 1.5 and 1.4 though.

10 years agoBUG/MINOR: checks: prevent http keep-alive with http-check expect
Cyril Bonté [Thu, 29 Jan 2015 23:07:07 +0000 (00:07 +0100)] 
BUG/MINOR: checks: prevent http keep-alive with http-check expect

Sébastien Rohaut reported that string negation in http-check expect didn't
work as expected.

The misbehaviour is caused by responses with HTTP keep-alive. When the
condition is not met, haproxy awaits more data until the buffer is full or the
connection is closed, resulting in a check timeout when "timeout check" is
lower than the keep-alive timeout on the server side.

In order to avoid the issue, when a "http-check expect" is used, haproxy will
ask the server to disable keep-alive by automatically appending a
"Connection: close" header to the request.

10 years agoBUG/MINOR: http: fix incorrect header value offset in replace-hdr/replace-value
Willy Tarreau [Thu, 29 Jan 2015 13:01:34 +0000 (14:01 +0100)] 
BUG/MINOR: http: fix incorrect header value offset in replace-hdr/replace-value

The two http-req/http-resp actions "replace-hdr" and "replace-value" were
expecting exactly one space after the colon, which is wrong. It was causing
the first char not to be seen/modified when no space was present, and empty
headers not to be modified either. Instead of using name->len+2, we must use
ctx->val which points to the first character of the value even if there is
no value.

This fix must be backported into 1.5.

10 years agoMEDIUM: init: continue to enforce SYSTEM_MAXCONN with auto settings if set
Willy Tarreau [Wed, 28 Jan 2015 18:03:21 +0000 (19:03 +0100)] 
MEDIUM: init: continue to enforce SYSTEM_MAXCONN with auto settings if set

Commit d025648 ("MAJOR: init: automatically set maxconn and/or maxsslconn
when possible") resulted in a case where if enough memory is available,
a maxconn value larger than SYSTEM_MAXCONN could be computed, resulting
in possibly overflowing other systems resources (eg: kernel socket buffers,
conntrack entries, etc). Let's bound any automatic maxconn to SYSTEM_MAXCONN
if it is defined. Note that the value is set to DEFAULT_MAXCONN since
SYSTEM_MAXCONN forces DEFAULT_MAXCONN, thus it is not an error.

10 years agoBUG/MINOR: parse: check the validity of size string in a more strict way
Godbach [Wed, 28 Jan 2015 09:36:16 +0000 (17:36 +0800)] 
BUG/MINOR: parse: check the validity of size string in a more strict way

If a stick table is defined as below:
stick-table type ip size 50ka expire 300s

HAProxy will stop parsing size after passing through "50k" and return the value
directly. But such format string of size should not be valid. The patch checks
the next character to report error if any.

Signed-off-by: Godbach <nylzhaowei@gmail.com>
10 years agoMEDIUM: samples: provide basic arithmetic and bitwise operators
Willy Tarreau [Tue, 27 Jan 2015 14:12:13 +0000 (15:12 +0100)] 
MEDIUM: samples: provide basic arithmetic and bitwise operators

This commit introduces a new category of converters. They are bitwise and
arithmetic operators which support performing basic operations on integers.
Some bitwise operations are supported (and, or, xor, cpl) and some arithmetic
operations are supported (add, sub, mul, div, mod, neg). Some comparators
are provided (odd, even, not, bool) which make it possible to report a match
without having to write an ACL.

The detailed list of new operators as they appear in the doc is :

add(<value>)
  Adds <value> to the input value of type unsigned integer, and returns the
  result as an unsigned integer.

and(<value>)
  Performs a bitwise "AND" between <value> and the input value of type unsigned
  integer, and returns the result as an unsigned integer.

bool
  Returns a boolean TRUE if the input value of type unsigned integer is
  non-null, otherwise returns FALSE. Used in conjunction with and(), it can be
  used to report true/false for bit testing on input values (eg: verify the
  presence of a flag).

cpl
  Takes the input value of type unsigned integer, applies a twos-complement
  (flips all bits) and returns the result as an unsigned integer.

div(<value>)
  Divides the input value of type unsigned integer by <value>, and returns the
  result as an unsigned integer. If <value> is null, the largest unsigned
  integer is returned (typically 2^32-1).

even
  Returns a boolean TRUE if the input value of type unsigned integer is even
  otherwise returns FALSE. It is functionally equivalent to "not,and(1),bool".

mod(<value>)
  Divides the input value of type unsigned integer by <value>, and returns the
  remainder as an unsigned integer. If <value> is null, then zero is returned.

mul(<value>)
  Multiplies the input value of type unsigned integer by <value>, and returns
  the product as an unsigned integer. In case of overflow, the higher bits are
  lost, leading to seemingly strange values.

neg
  Takes the input value of type unsigned integer, computes the opposite value,
  and returns the remainder as an unsigned integer. 0 is identity. This
  operator is provided for reversed subtracts : in order to subtract the input
  from a constant, simply perform a "neg,add(value)".

not
  Returns a boolean FALSE if the input value of type unsigned integer is
  non-null, otherwise returns TRUE. Used in conjunction with and(), it can be
  used to report true/false for bit testing on input values (eg: verify the
  absence of a flag).

odd
  Returns a boolean TRUE if the input value of type unsigned integer is odd
  otherwise returns FALSE. It is functionally equivalent to "and(1),bool".

or(<value>)
  Performs a bitwise "OR" between <value> and the input value of type unsigned
  integer, and returns the result as an unsigned integer.

sub(<value>)
  Subtracts <value> from the input value of type unsigned integer, and returns
  the result as an unsigned integer. Note: in order to subtract the input from
  a constant, simply perform a "neg,add(value)".

xor(<value>)
  Performs a bitwise "XOR" (exclusive OR) between <value> and the input value
  of type unsigned integer, and returns the result as an unsigned integer.

10 years agoMINOR: ssl: load certificates in alphabetical order
Cyril Bonté [Sat, 24 Jan 2015 23:16:08 +0000 (00:16 +0100)] 
MINOR: ssl: load certificates in alphabetical order

As reported by Raphaël Enrici, certificates loaded from a directory are loaded
in a non predictive order. If no certificate was first loaded from a file, it
can result in different behaviours when haproxy is used in cluster.
We can also imagine other cases which weren't met yet.

Instead of using readdir(), we can use scandir() and sort files alphabetically.
This will ensure a predictive behaviour.

This patch should also be backported to 1.5.