Commit Graph

4400 Commits

Author SHA1 Message Date
Cyril Bonté
577a36a174 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").
2015-03-02 13:41:09 +01:00
Thierry FOURNIER
05ac42455f 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.
2015-02-28 23:12:37 +01:00
Willy Tarreau
80f5fae591 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.
2015-02-28 23:12:36 +01:00
Thierry FOURNIER
893bfa3492 MINOR: lua: txn: add binding for closing the client connection. 2015-02-28 23:12:36 +01:00
Thierry FOURNIER
13416fe0db 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.
2015-02-28 23:12:36 +01:00
Thierry FOURNIER
37196f4ecb MINOR: lua: core: can set the nice of the current task
This patch adds an LUA binding that permits to change the
task priority.
2015-02-28 23:12:36 +01:00
Thierry FOURNIER
e94e77400a MINOR: lua: txn: object "txn" provides two objects "channel"
This patch adds two functions that creates and returns channel
object from a txn object.
2015-02-28 23:12:36 +01:00
Thierry FOURNIER
5a6d3fdf51 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.
2015-02-28 23:12:36 +01:00
Thierry FOURNIER
83758bbee7 MINOR: lua: core: pattern and acl manipulation
The functions added by this patch add LUA bindings for the ACL
and map manipulation.
2015-02-28 23:12:36 +01:00
Thierry FOURNIER
7e7ac32dad 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
2015-02-28 23:12:35 +01:00
Thierry FOURNIER
5b8608f1ed 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.
2015-02-28 23:12:35 +01:00
Thierry FOURNIER
258d8aafa6 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.
2015-02-28 23:12:35 +01:00
Thierry FOURNIER
9be813f861 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.
2015-02-28 23:12:35 +01:00
Thierry FOURNIER
fa0e5dd217 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.".
2015-02-28 23:12:35 +01:00
Thierry FOURNIER
9a819e7305 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.
2015-02-28 23:12:35 +01:00
Thierry FOURNIER
d0fa538fe3 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.
2015-02-28 23:12:35 +01:00
Thierry FOURNIER
05c0b8ab0d 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
2015-02-28 23:12:34 +01:00
Thierry FOURNIER
65f34c6367 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.
2015-02-28 23:12:34 +01:00
Thierry FOURNIER
55da165301 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.
2015-02-28 23:12:34 +01:00
Thierry FOURNIER
24f3353403 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.
2015-02-28 23:12:34 +01:00
Thierry FOURNIER
a4a0f3d7c8 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.
2015-02-28 23:12:34 +01:00
Thierry FOURNIER
2ba18a2aa6 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.
2015-02-28 23:12:34 +01:00
Thierry FOURNIER
6c9b52cbc2 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.
2015-02-28 23:12:34 +01:00
Thierry FOURNIER
9ff7e6e3b2 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.
2015-02-28 23:12:33 +01:00
Thierry FOURNIER
380d0930bd 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.
2015-02-28 23:12:33 +01:00
Thierry FOURNIER
e8b9a40d22 MINOR: lua: add ease functions
This patch adds little convenient functions useful for lua basic
manipulation.
2015-02-28 23:12:33 +01:00
Thierry FOURNIER
6f1fd48ef1 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.
2015-02-28 23:12:33 +01:00
Thierry FOURNIER
ca16b03813 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.
2015-02-28 23:12:33 +01:00
Thierry FOURNIER
bc4c1ac6ad 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".
2015-02-28 23:12:33 +01:00
Thierry FOURNIER
9e2ef999a9 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.
2015-02-28 23:12:33 +01:00
Thierry FOURNIER
549aac8d0b MEDIUM: buffer: make bo_putblk/bo_putstr/bo_putchk return the number of bytes copied.
This is not used yet. Planned for LUA.
2015-02-28 23:12:32 +01:00
Thierry FOURNIER
cc87a11842 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.
2015-02-28 23:12:32 +01:00
Thierry FOURNIER
ac836baad1 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.
2015-02-28 23:12:32 +01:00
Thierry FOURNIER
49f45af9aa 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.
2015-02-28 23:12:32 +01:00
Thierry FOURNIER
4d9a1d1a5c MINOR: sample: add function for browsing samples.
This function is useful with the incoming lua functions.
2015-02-28 23:12:32 +01:00
Thierry FOURNIER
58639a0ef3 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.
2015-02-28 23:12:32 +01:00
Thierry FOURNIER
f41a809dc9 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.
2015-02-28 23:12:31 +01:00
Thierry FOURNIER
68a556e282 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.
2015-02-28 23:12:31 +01:00
Thierry FOURNIER
1edc971919 MINOR: converters: add a "void *private" argument to converters
This permits to store specific configuration pointer. It is useful
with future Lua integration.
2015-02-28 23:12:31 +01:00
Thierry FOURNIER
b83862dd74 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.
2015-02-28 23:12:31 +01:00
Thierry FOURNIER
bb2ae64b82 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.
2015-02-28 23:12:31 +01:00
Willy Tarreau
b550d009ca 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.
2015-02-28 23:12:31 +01:00
Thierry FOURNIER
2e05a8c742 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.
2015-02-28 23:12:30 +01:00
Thierry FOURNIER
9cf7c4b9df 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.
2015-02-28 23:12:30 +01:00
Willy Tarreau
e7acee70a3 BUILD/CLEANUP: config: silent 3 warnings about mixed declarations with code
These ones were present in the tcp-check parser.
2015-02-28 23:12:30 +01:00
Willy Tarreau
622317d5e2 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!
2015-02-28 23:12:30 +01:00
Willy Tarreau
713a7566af 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.
2015-02-28 23:12:30 +01:00
Nenad Merdanovic
188ad3e9a2 DOC: Document the new tls-ticket-keys bind keyword
Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
2015-02-28 23:10:22 +01:00
Nenad Merdanovic
05552d4b98 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>
2015-02-28 23:10:22 +01:00
Simon Horman
eaabd52e29 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>
2015-02-26 07:06:50 +01:00