]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
10 years agoMINOR: lua: extend socket address to support non-IP families
Thierry FOURNIER [Sat, 26 Sep 2015 18:23:30 +0000 (20:23 +0200)] 
MINOR: lua: extend socket address to support non-IP families

The HAProxy Lua socket respects the Lua Socket tcp specs. these specs
are a little bit limited, it not permits to connect to unix socket.

this patch extends a little it the specs. It permit to accept a
syntax that begin with "unix@", "ipv4@", "ipv6@", "fd@" or "abns@".

10 years agoMINOR: standard: avoid DNS resolution from the function str2sa_range()
Thierry FOURNIER [Sat, 26 Sep 2015 18:03:36 +0000 (20:03 +0200)] 
MINOR: standard: avoid DNS resolution from the function str2sa_range()

This patch blocks the DNS resolution in the function str2sa_range(),
this is useful if the function is used during the HAProxy runtime.

10 years agoDOC: clarify how to make use of abstract sockets in socat
Willy Tarreau [Sun, 27 Sep 2015 13:03:15 +0000 (15:03 +0200)] 
DOC: clarify how to make use of abstract sockets in socat

Socat's abstract sockets can be made compatible with haproxy's provided
that an option is passed. It's not obvious, so let's mention it in the
doc.

10 years agoMEDIUM: lua: only allow actions to yield if not in a final call
Willy Tarreau [Sun, 27 Sep 2015 08:48:01 +0000 (10:48 +0200)] 
MEDIUM: lua: only allow actions to yield if not in a final call

Actions may yield but must not do it during the final call from a ruleset
because it indicates there will be no more opportunity to complete or
clean up. This is indicated by ACT_FLAG_FINAL in the action's flags,
which must be passed to hlua_resume().

Thanks to this, an action called from a TCP ruleset is properly woken
up and possibly finished when the client disconnects.

10 years agoMEDIUM: http: pass ACT_FLAG_FINAL to custom actions
Willy Tarreau [Sun, 27 Sep 2015 08:33:15 +0000 (10:33 +0200)] 
MEDIUM: http: pass ACT_FLAG_FINAL to custom actions

In HTTP it's more difficult to know when to pass the flag or not
because all actions are supposed to be final and there's no inspection
delay. Also, the input channel may very well be closed without this
being an error. So we only set the flag when option abortonclose is
set and the input channel is closed, which is the only case where the
user explicitly wants to forward a close down the chain.

10 years agoMEDIUM: actions: add new flag ACT_FLAG_FINAL to notify about last call
Willy Tarreau [Sun, 27 Sep 2015 08:06:24 +0000 (10:06 +0200)] 
MEDIUM: actions: add new flag ACT_FLAG_FINAL to notify about last call

This new flag indicates to a custom action that it must not yield because
it will not be called anymore. This addresses an issue introduced by commit
bc4c1ac ("MEDIUM: http/tcp: permit to resume http and tcp custom actions"),
which made it possible to yield even after the last call and causes Lua
actions not to be stopped when the session closes. Note that the Lua issue
is not fixed yet at this point. Also only TCP rules were handled, for now
HTTP rules continue to let the action yield since we don't know whether or
not it is a final call.

10 years agoMEDIUM: actions: pass a new "flags" argument to custom actions
Willy Tarreau [Sun, 27 Sep 2015 08:00:49 +0000 (10:00 +0200)] 
MEDIUM: actions: pass a new "flags" argument to custom actions

Since commit bc4c1ac ("MEDIUM: http/tcp: permit to resume http and tcp
custom actions"), some actions may yield and be called back when new
information are available. Unfortunately some of them may continue to
yield because they simply don't know that it's the last call from the
rule set. For this reason we'll need to pass a flag to the custom
action to pass such information and possibly other at the same time.

10 years agoBUG/MEDIUM: lua: wakeup task on bad conditions
Thierry FOURNIER [Sat, 26 Sep 2015 20:01:07 +0000 (22:01 +0200)] 
BUG/MEDIUM: lua: wakeup task on bad conditions

the condition was :
 * wakeup for read if the output channel contains data
 * wakeup for write if the input channel have some room.

10 years agoBUG/MEDIUM: lua: forces a garbage collection
Thierry FOURNIER [Wed, 23 Sep 2015 14:59:28 +0000 (16:59 +0200)] 
BUG/MEDIUM: lua: forces a garbage collection

When a thread stops this patch forces a garbage collection which
cleanup and free the memory.

The HAProxy Lua Socket class contains an HAProxy session, so it
uses a big amount of memory, in other this Socket class uses a
filedescriptor and maintain a connection open.

If the class Socket is stored in a global variable, the Socket stay
alive along of the life of the process (except if it is closed by the
other size, or if a timeout is reached). If the class Socket is stored
in a local variable, it must die with this variable.

The socket is closed by a call from the garbage collector. And the
portability and use of a variable is known by the same garbage collector.

so, running the GC just after the end of all Lua code ensure that the
heavy resources like the socket class are freed quickly.

10 years agoBUG/MEDIUM: lua: properly set the target on the connection
Willy Tarreau [Sat, 26 Sep 2015 15:51:09 +0000 (17:51 +0200)] 
BUG/MEDIUM: lua: properly set the target on the connection

Not having the target set on the connection causes it to be released
at the last moment, and the destination address to randomly be valid
depending on the data found in the memory at this moment. In practice
it works as long as memory poisonning is disabled. The deep reason is
that connect_server() doesn't expect to be called with SF_ADDR_SET and
an existing connection with !reuse. This causes the release of the
connection, its reallocation (!reuse), and taking the address from the
newly allocated connection. This should certainly be improved.

10 years agoBUG/MEDIUM: lua: better fix for the protocol check
Willy Tarreau [Sat, 26 Sep 2015 09:50:08 +0000 (11:50 +0200)] 
BUG/MEDIUM: lua: better fix for the protocol check

Commit d75cb0f ("BUG/MAJOR: lua: segfault after the channel data is
modified by some Lua action.") introduced a regression causing an
action run from a TCP rule in an HTTP proxy to end in HTTP error
if it terminated cleanly, because it didn't parse the HTTP request!

Relax the test so that it takes into account the opportunity for the
analysers to parse the message.

10 years agoMINOR: lua: use the proper applet wakeup mechanism
Willy Tarreau [Sat, 26 Sep 2015 09:25:05 +0000 (11:25 +0200)] 
MINOR: lua: use the proper applet wakeup mechanism

The lua code must the the appropriate wakeup mechanism for cosockets.
It wakes them up from outside the stream and outside the applet, so it
shouldn't use the applet's wakeup callback which is designed only for
use from within the applet itself. For now it didn't cause any trouble
(yet).

10 years agoBUG/MEDIUM: lua: longjmp function must be unregistered
Thierry FOURNIER [Fri, 25 Sep 2015 21:51:34 +0000 (23:51 +0200)] 
BUG/MEDIUM: lua: longjmp function must be unregistered

the longjmp function must be unregistered when we leaves the function
who install it.

10 years agoCLEANUP: lua: remove unneeded memset(0) after calloc()
Willy Tarreau [Fri, 25 Sep 2015 23:33:24 +0000 (01:33 +0200)] 
CLEANUP: lua: remove unneeded memset(0) after calloc()

No need for these memset() anymore, since calloc() was put there
to avoid them.

10 years agoCLEANUP: lua: use calloc in place of malloc
Thierry FOURNIER [Fri, 25 Sep 2015 22:51:16 +0000 (00:51 +0200)] 
CLEANUP: lua: use calloc in place of malloc

calloc is safer because it fills the allocated memory zone with zeros.

10 years agoDEBUG: add p_malloc() to return a poisonned memory area
Willy Tarreau [Fri, 25 Sep 2015 23:27:43 +0000 (01:27 +0200)] 
DEBUG: add p_malloc() to return a poisonned memory area

This one is useful to detect improperly initialized memory areas
when some suspicious malloc() are involved in random behaviours.

10 years agoBUG/MAJOR: lua: segfault after the channel data is modified by some Lua action.
Thierry FOURNIER [Fri, 25 Sep 2015 17:22:44 +0000 (19:22 +0200)] 
BUG/MAJOR: lua: segfault after the channel data is modified by some Lua action.

When an action or a fetch modify the channel data, the http request parser
pointer become inconsistent. This patch detects the modification and call
again the parser.

10 years agoMEDIUM: lua: use the function lua_rawset in place of lua_settable
Thierry FOURNIER [Fri, 25 Sep 2015 20:13:32 +0000 (22:13 +0200)] 
MEDIUM: lua: use the function lua_rawset in place of lua_settable

The function lua_settable uses the metatable for acessing data,
so in the C part, we want to index value in the real table and
not throught the meta-methods. It's much faster this way.

10 years agoMINOR: lua: identify userdata objects
Thierry FOURNIER [Fri, 18 Sep 2015 05:35:06 +0000 (07:35 +0200)] 
MINOR: lua: identify userdata objects

This patch adds lua primitives for identifying lua class
associated with userdata.

10 years agoMINOR: lua: reset pointer after use
Thierry FOURNIER [Mon, 21 Sep 2015 20:50:24 +0000 (22:50 +0200)] 
MINOR: lua: reset pointer after use

After releasing the Lua environment, this patch set the only one pointer to
the Lua stack to NULL. This prevents an accidental re-use.

10 years agoMINOR: http: split initialization
Thierry FOURNIER [Fri, 25 Sep 2015 16:53:18 +0000 (18:53 +0200)] 
MINOR: http: split initialization

The goal is to export the http txn initialisation functions for
using it in the Lua code.

10 years agoMINOR: http: export function http_msg_analyzer()
Thierry FOURNIER [Fri, 25 Sep 2015 09:06:37 +0000 (11:06 +0200)] 
MINOR: http: export function http_msg_analyzer()

Exports the function http_msg_analyzer().

10 years agoMINOR: http: export the get_reason() function
Thierry FOURNIER [Fri, 18 Sep 2015 15:59:23 +0000 (17:59 +0200)] 
MINOR: http: export the get_reason() function

This patch exports the get_reason() function.

10 years agoMINOR: http: export http_get_path() function
Thierry FOURNIER [Thu, 17 Sep 2015 17:33:35 +0000 (19:33 +0200)] 
MINOR: http: export http_get_path() function

This patch simply exports the http_get_path() function from the proto_http.c file.

10 years agoCLEANUP: lua: align defines
Thierry FOURNIER [Wed, 16 Sep 2015 19:22:28 +0000 (21:22 +0200)] 
CLEANUP: lua: align defines

Align the defined values

10 years agoMINOR: channel: rename function chn_sess to chn_strm
Thierry FOURNIER [Fri, 25 Sep 2015 06:36:11 +0000 (08:36 +0200)] 
MINOR: channel: rename function chn_sess to chn_strm

The name of the function chn_sess is no longer appropriate.
This patch renames it to chn_strm.

10 years agoMEDIUM: proto_http: smp_prefetch_http initialize txn
Thierry FOURNIER [Thu, 24 Sep 2015 06:40:18 +0000 (08:40 +0200)] 
MEDIUM: proto_http: smp_prefetch_http initialize txn

When we call the function smp_prefetch_http(), if the txn is not initialized,
it doesn't work. This patch fix this. Now, smp_prefecth_http() permits to use
http with any proxy mode.

10 years agoBUG/MEDIUM: stream-int: avoid double-call to applet->release
Willy Tarreau [Fri, 25 Sep 2015 18:24:26 +0000 (20:24 +0200)] 
BUG/MEDIUM: stream-int: avoid double-call to applet->release

While the SI_ST_DIS state is set *after* doing the close on a connection,
it was set *before* calling release on an applet. Applets have no internal
flags contrary to connections, so they have no way to detect they were
already released. Because of this it happened that applets were closed
twice, once via si_applet_release() and once via si_release_endpoint() at
the end of a transaction. The CLI applet could perform a double free in
this case, though the situation to cause it is quite hard because it
requires that the applet is stuck on output in states that produce very
few data.

In order to solve this, we now assign the SI_ST_DIS state *after* calling
->release, and we refrain from doing so if the state is already assigned.
This makes applets work much more like connections and definitely avoids
this double release.

In the future it might be worth making applets have their own flags like
connections to carry their own state regardless of the stream interface's
state, especially when dealing with connection reuse.

No backport is needed since this issue was caused by the rearchitecture
in 1.6.

10 years agoMINOR: cli: do not call the release handler on internal error.
Willy Tarreau [Fri, 25 Sep 2015 18:08:51 +0000 (20:08 +0200)] 
MINOR: cli: do not call the release handler on internal error.

It's dangerous to call this on internal state error, because it risks
to perform a double-free. This can only happen when a state is not
handled. Note that the switch/case currently doesn't offer any option
for missed states since they're all declared. Better fix this anyway.
The fix was tested by commenting out some entries in the switch/case.

10 years agoBUG/MEDIUM: cli: properly handle closed output
Willy Tarreau [Fri, 25 Sep 2015 18:06:08 +0000 (20:06 +0200)] 
BUG/MEDIUM: cli: properly handle closed output

Due to the code inherited from the early CLI mode with the non-interactive
code, the SHUTR status was only considered while waiting for a request,
which prevents the connection from properly being closed during a dump,
and the connection used to remain established. This issue didn't happen
in 1.5 because while this part was missed, the resynchronization performed
in process_session() would detect the situation and handle the cleanup.

No backport is needed.

10 years agoBUG/MINOR: stats: do not call cli_release_handler 3 times
Willy Tarreau [Fri, 25 Sep 2015 17:21:19 +0000 (19:21 +0200)] 
BUG/MINOR: stats: do not call cli_release_handler 3 times

If an error happens during a dump on the CLI, an explicit call to
cli_release_handler() is performed. This is not needed anymore since
we introduced ->release() in the applet which is called upon error.
Let's remove this confusing call which can even be risky in some
situations.

10 years agoBUG/MEDIUM: applet: fix reporting of broken write situation
Willy Tarreau [Fri, 25 Sep 2015 17:11:55 +0000 (19:11 +0200)] 
BUG/MEDIUM: applet: fix reporting of broken write situation

If an applet tries to write to a closed connection, it hangs forever.
This results in some "get map" commands on the CLI to leave orphaned
connections alive.

Now the applet wakeup function detects that the applet still wants to
write while the channel is closed for reads, which is the equivalent
to the common "broken pipe" situation. In this case, an error is
reported on the stream interface, just as it happens with connections
trying to perform a send() in a similar situation.

With this fix the stats socket is properly released.

10 years agoMINOR: stream-int: rename si_applet_done() to si_applet_wake_cb()
Willy Tarreau [Fri, 25 Sep 2015 09:45:06 +0000 (11:45 +0200)] 
MINOR: stream-int: rename si_applet_done() to si_applet_wake_cb()

This function is a callback made only for calls from the applet handler.
Rename it to remove confusion. It's currently called from the Lua code
but that's not correct, we should call the notify and update functions
instead otherwise it will not enable the applet again.

10 years agoMEDIUM: stream-int: completely remove stream_int_update_embedded()
Willy Tarreau [Thu, 24 Sep 2015 16:05:45 +0000 (18:05 +0200)] 
MEDIUM: stream-int: completely remove stream_int_update_embedded()

This one is not needed anymore as what it used to do is either
completely covered by the new stream_int_notify() function, or undesired
and inherited from the past as a side effect of introducing the
connections.

This update is theorically never called since it's assigned only when
nothing is connected to the stream interface. However a test has been
added to si_update() to stay safe if some foreign code decides to call
si_update() in unsafe situations.

10 years agoMEDIUM: stream-int: use the same stream notification function for applets and conns
Willy Tarreau [Wed, 23 Sep 2015 18:06:13 +0000 (20:06 +0200)] 
MEDIUM: stream-int: use the same stream notification function for applets and conns

The code to report completion after a connection update or an applet update
was almost the same since applets stole it from the connection. But the
differences made them hard to maintain and prevented the creation of new
functions doing only one part of the work.

This patch replaces the common code from the si_conn_wake_cb() and
si_applet_wake_cb() with a single call to stream_int_notify() which only
notifies the stream (si+channels+task) from the outside.

No functional change was made beyond this.

10 years agoMINOR: stream-int: implement the stream_int_notify() function
Willy Tarreau [Wed, 23 Sep 2015 16:40:09 +0000 (18:40 +0200)] 
MINOR: stream-int: implement the stream_int_notify() function

stream_int_notify() was taken from the common part between si_conn_wake_cb()
and si_applet_done(). It is designed to report activity to a stream from
outside its handler. It'll generally be used by lower layers to report I/O
completion but may also be used by remote streams if the buffer processing
is shared.

10 years agoMEDIUM: stream-int: clean up the conditions to enable reading in si_conn_wake_cb
Willy Tarreau [Wed, 23 Sep 2015 17:37:00 +0000 (19:37 +0200)] 
MEDIUM: stream-int: clean up the conditions to enable reading in si_conn_wake_cb

The condition to release the SI_FL_WAIT_ROOM flag was abnormally
complicated because it was inherited from 6 years ago before we used
to check for the buffer's emptiness. The CF_READ_PARTIAL flag had to be
removed, and the complex test was replaced with a simpler one checking
if *some* data were moved out or not.

The reason behind this change is to have a condition compatible with
both connections and applets, as applets currently don't work very
well in this area. Specifically, some optimizations on the applet
side cause them not to release the flag above until the buffer is
empty, which may prevent applets from taking together (eg: peers
over large haproxy buffers and small kernel buffers).

10 years agoMINOR: stream-int: move the applet_pause call out of the stream updates
Willy Tarreau [Wed, 23 Sep 2015 17:55:42 +0000 (19:55 +0200)] 
MINOR: stream-int: move the applet_pause call out of the stream updates

It's just to split the part dealing with the stream update and the part
dealing with the applet update in si_applet_done().

10 years agoMINOR: stream-int: export stream_int_update_*
Willy Tarreau [Fri, 25 Sep 2015 09:01:42 +0000 (11:01 +0200)] 
MINOR: stream-int: export stream_int_update_*

Not only these functions were not static, but we'll also want to export
them.

10 years agoMEDIUM: stream-int: call stream_int_update() from si_update()
Willy Tarreau [Fri, 25 Sep 2015 08:59:38 +0000 (10:59 +0200)] 
MEDIUM: stream-int: call stream_int_update() from si_update()

Now the call to stream_int_update() is moved to si_update(), which
is exclusively called from the stream, so that the socket layer may
be updated without updating the stream layer. This will later permit
to call it individually from other places (other tasks or applets for
example).

10 years agoMEDIUM: stream-int: factor out the stream update functions
Willy Tarreau [Fri, 25 Sep 2015 08:39:16 +0000 (10:39 +0200)] 
MEDIUM: stream-int: factor out the stream update functions

Now that we have a generic stream_int_update() function, we can
replace the equivalent part in stream_int_update_conn() and
stream_int_update_applet() to avoid code duplication.

There is no functional change, as the code is the same but split
in two functions for each call.

10 years agoMINOR: stream-int: implement a new stream_int_update() function
Willy Tarreau [Thu, 24 Sep 2015 09:32:22 +0000 (11:32 +0200)] 
MINOR: stream-int: implement a new stream_int_update() function

This function is designed to be called from within the stream handler to
update the channels' expiration timers and the stream interface's flags
based on the channels' flags. It needs to be called only once after the
channels' flags have settled down, and before they are cleared, though it
doesn't harm to call it as often as desired (it just slightly hurts
performance). It must not be called from outside of the stream handler,
as what it does will be used to compute the stream task's expiration.

The code was taken directly from stream_int_update_applet() and
stream_int_update_conn() which had exactly the same one except for
applet-specific or connection-specific status update.

10 years agoMEDIUM: stream-int: split stream_int_update_conn() into si- and conn-specific parts
Willy Tarreau [Fri, 25 Sep 2015 08:50:59 +0000 (10:50 +0200)] 
MEDIUM: stream-int: split stream_int_update_conn() into si- and conn-specific parts

The purpose is to separate the connection-specific parts so that the
stream-int specific one can be factored out. There's no functional
change here, only code displacement.

10 years agoBUG/MAJOR: applet: use a separate run queue to maintain list integrity
Willy Tarreau [Fri, 25 Sep 2015 15:56:16 +0000 (17:56 +0200)] 
BUG/MAJOR: applet: use a separate run queue to maintain list integrity

If an applet wakes up and causes the next one to sleep, the active list
is corrupted and cannot be scanned anymore, as the process then loops
over the next element.

In order to avoid this problem, we move the active applet list to a run
queue and reinit the active list. Only the first element of this queue
is checked, and if the element is not removed, it is removed and requeued
into the active list.

Since we're using a distinct list, if an applet wants to requeue another
applet into the active list, it properly gets added to the active list
and not to the run queue.

This stops the infinite loop issue that could be caused with Lua applets,
and in any future configuration where two applets could be attached
together.

10 years agoMINOR: applet: rename applet_runq to applet_active_queue
Willy Tarreau [Fri, 25 Sep 2015 15:39:23 +0000 (17:39 +0200)] 
MINOR: applet: rename applet_runq to applet_active_queue

This is not a real run queue and we're facing ugly bugs because
if this : if a an applet removes another applet from the queue,
typically the next one after itself, the list iterator loops
forever because the list's backup pointer is not valid anymore.
Before creating a run queue, let's rename this list.

10 years agoBUG/MEDIUM: acl: always accept match "found"
Willy Tarreau [Thu, 24 Sep 2015 14:37:12 +0000 (16:37 +0200)] 
BUG/MEDIUM: acl: always accept match "found"

The pattern match "found" fails to parse on binary type samples. The
reason is that it presents itself as an integer type which bin cannot
be cast into. We must always accept this match since it validates
anything on input regardless of the type. Let's just relax the parser
to accept it.

This problem might also exist in 1.5.
(cherry picked from commit 91cc2368a73198bddc3e140d267cce4ee08cf20e)

10 years agoBUG/MEDIUM: payload: make req.payload and payload_lv aware of dynamic buffers
Willy Tarreau [Thu, 24 Sep 2015 14:33:10 +0000 (16:33 +0200)] 
BUG/MEDIUM: payload: make req.payload and payload_lv aware of dynamic buffers

Due to a check between offset+len and buf->size, an empty buffer returns
"will never match". Check against tune.bufsize instead.
(cherry picked from commit 43e4039fd5d208fd9d32157d20de93d3ddf9bc0d)

10 years agoMINOR: stream-int: use si_release_endpoint() to close idle conns
Willy Tarreau [Wed, 23 Sep 2015 15:56:02 +0000 (17:56 +0200)] 
MINOR: stream-int: use si_release_endpoint() to close idle conns

We don't want to open-code the connection close code in
si_idle_conn_wake_cb() because we need to centralize some controls.

10 years agoMINOR: lua: change actions registration
Thierry FOURNIER [Wed, 23 Sep 2015 19:03:35 +0000 (21:03 +0200)] 
MINOR: lua: change actions registration

The current Lua action are not registered. The executed function is
selected according with a function name writed in the HAProxy configuration.

This patch add an action registration function. The configuration mode
described above disappear.

This change make some incompatibilities with existing configuration files for
HAProxy 1.6-dev.

10 years agoMINOR: action: add reference to the original keywork matched for the called parser.
Thierry FOURNIER [Tue, 22 Sep 2015 17:14:35 +0000 (19:14 +0200)] 
MINOR: action: add reference to the original keywork matched for the called parser.

This is usefull because the keyword can contains some condifiguration
data set while the keyword registration.

10 years agoMINOR: action: add private configuration
Thierry FOURNIER [Tue, 22 Sep 2015 16:26:42 +0000 (18:26 +0200)] 
MINOR: action: add private configuration

This private configuration pointer is used for storing some configuration
data associated the keyword, So many keywords can use the same parse
function, and this one can use a discriminator.

10 years agoBUG/MEDIUM: stream: do not dereference strm_li(stream)
Willy Tarreau [Wed, 23 Sep 2015 10:21:21 +0000 (12:21 +0200)] 
BUG/MEDIUM: stream: do not dereference strm_li(stream)

Some streams do not have a listener (eg: Lua's cosockets) so
let's check for this. For now this problem cannot happen but
it's definitely unsafe.

10 years agoBUG/MEDIUM: proxy: do not dereference strm_li(stream)
Willy Tarreau [Wed, 23 Sep 2015 10:20:10 +0000 (12:20 +0200)] 
BUG/MEDIUM: proxy: do not dereference strm_li(stream)

Some streams do not have a listener (eg: Lua's cosockets) so
let's check for this. For now this problem cannot happen but
it's definitely unsafe.

10 years agoBUG/MEDIUM: http: do not dereference strm_li(stream)
Willy Tarreau [Wed, 23 Sep 2015 10:18:14 +0000 (12:18 +0200)] 
BUG/MEDIUM: http: do not dereference strm_li(stream)

Some streams do not have a listener (eg: Lua's cosockets) so
let's check for this. For now this problem cannot happen but
it's definitely unsafe.

10 years agoBUG/MAJOR: cli: do not dereference strm_li()->proto->name
Willy Tarreau [Wed, 23 Sep 2015 10:16:43 +0000 (12:16 +0200)] 
BUG/MAJOR: cli: do not dereference strm_li()->proto->name

Or it will crash when dumping streams instanciated by an applet,
like Lua's cosockets.

10 years agoCLEANUP: stream-int: remove obsolete function si_applet_call()
Willy Tarreau [Wed, 23 Sep 2015 08:12:49 +0000 (10:12 +0200)] 
CLEANUP: stream-int: remove obsolete function si_applet_call()

This one is not used anymore and is bogus due to the way applets
now work. Remove it instead of fixing it before someone finds it
fun to use it.

10 years agoDOC: add more entries to MAINTAINERS
Willy Tarreau [Wed, 23 Sep 2015 05:41:56 +0000 (07:41 +0200)] 
DOC: add more entries to MAINTAINERS

Simon is willing to maintain mailers and external checks.

10 years agoBUG/MINOR: fct peer_prepare_ackmsg should not use trash.
Emeric Brun [Tue, 22 Sep 2015 13:50:18 +0000 (15:50 +0200)] 
BUG/MINOR: fct peer_prepare_ackmsg should not use trash.

function 'peer_prepare_ackmsg' is designed to use the argument 'msg'
instead of 'trash.str'.

There is currently no bug because the caller passes 'trash.str' in
the 'msg' argument.

10 years agoBUG/MEDIUM: peers: same table updates re-pushed after a re-connect
Emeric Brun [Tue, 22 Sep 2015 13:34:19 +0000 (15:34 +0200)] 
BUG/MEDIUM: peers: same table updates re-pushed after a re-connect

Some updates are pushed using an incremental update message after a
re-connection whereas the origin is forgotten by the peer.
These updates are never correctly acknowledged. So they are regularly
re-pushed after an idle timeout and a re-connect.

The fix consists to use an absolute update message in some cases.

10 years agoBUG/MEDIUM: peers: some table updates are randomly not pushed.
Emeric Brun [Tue, 22 Sep 2015 13:05:06 +0000 (15:05 +0200)] 
BUG/MEDIUM: peers: some table updates are randomly not pushed.

If an entry is still not present in the update tree, we could miss to schedule
for a push depending of an un-initialized value (upd.key remains un-initialized
for new sessions or isn't re-initalized for reused ones).

In the same way, if an entry is present in the tree, but its update's tick
is far in the past (> 2^31). We could consider it's still scheduled even if
it is not the case.

The fix consist to force the re-scheduling of an update if it was not present in
the updates tree or if the update is not in the scheduling window of every peers.

10 years agoBUG: dns: can't connect UDP socket on FreeBSD
Baptiste Assmann [Mon, 21 Sep 2015 18:55:08 +0000 (20:55 +0200)] 
BUG: dns: can't connect UDP socket on FreeBSD

PiBANL reported that HAProxy's DNS resolver can't "connect" its socker
on FreeBSD.
Remi Gacogne reported that we should use the function 'get_addr_len' to
get the addr structure size instead of sizeof.

10 years agoDOC: add more entries to MAINTAINERS
Willy Tarreau [Mon, 21 Sep 2015 23:07:00 +0000 (01:07 +0200)] 
DOC: add more entries to MAINTAINERS

Cyril is the most impacted by doc format changes, Thierry is the one who
knows maps and patterns infrastructure in great details.

10 years agoBUG/MINOR: args: add name for ARGT_VAR
Willy Tarreau [Mon, 21 Sep 2015 18:57:12 +0000 (20:57 +0200)] 
BUG/MINOR: args: add name for ARGT_VAR

Commit 4834bc7 ("MEDIUM: vars: adds support of variables") introduced
ARGT_VAR but forgot to put it in the names array. No backport needed.

10 years agoBUG/MEDIUM: stick-tables: fix double-decrement of tracked entries
Willy Tarreau [Mon, 21 Sep 2015 15:48:24 +0000 (17:48 +0200)] 
BUG/MEDIUM: stick-tables: fix double-decrement of tracked entries

Mailing list participant "mlist" reported negative conn_cur values in
stick tables as the result of "tcp-request connection track-sc". The
reason is that after the stick entry it copied from the session to the
stream, both the session and the stream grab a reference to the entry
and when the stream ends, it decrements one reference and one connection,
then the same is done for the session.

In fact this problem was already encountered slightly differently in the
past and addressed by Thierry using the patch below as it was believed by
then to be only a refcount issue since it was the observable symptom :

   827752e "BUG/MEDIUM: stick-tables: refcount error after copying SC..."

In reality the problem is that the stream must touch neither the refcount
nor the connection count for entries it inherits from the session. While
we have no way to tell whether a track entry was inherited from the session
(since they're simply memcpy'd), it is possible to prevent the stream from
touching an entry that already exists in the session because that's a
guarantee that it was inherited from it.

Note that it may be a temporary fix. Maybe in the future when a session
gives birth to multiple streams we'll face a situation where a session may
be updated to add more tracked entries after instanciating some streams.
The correct long-term fix is to mark some tracked entries as shared or
private (or RO/RW). That will allow the session to track more entries
even after the same trackers are being used by early streams.

No backport is needed, this is only caused by the session/stream split in 1.6.

10 years agoDOC: update coding-style to reference checkpatch.pl
Willy Tarreau [Mon, 21 Sep 2015 14:36:15 +0000 (16:36 +0200)] 
DOC: update coding-style to reference checkpatch.pl

Running the Linux kernel's checkpatch.pl is actually quite efficient
at spotting style issues and even sometimes bugs. The doc now suggests
how to use it to avoid the warnings that are specific to Linux's stricter
rules.

It properly reports errors like the following ones that were found on
real submissions so it should improve the situation for everyone :

ERROR: "foo * bar" should be "foo *bar"
+static char * tcpcheck_get_step_comment(struct check *, int);

ERROR: do not use assignment in if condition
+                       if ((comment = tcpcheck_get_step_comment(check, step)))

WARNING: trailing semicolon indicates no statements, indent implies otherwise
+                       if (elem->data && elem->free);
+                               elem->free(elem->data);

ERROR: do not initialise statics to 0 or NULL
+static struct lru64_head *ssl_ctx_lru_tree = NULL;

ERROR: space required after that ',' (ctx:VxV)
+           !X509_gmtime_adj(X509_get_notAfter(newcrt),(long)60*60*24*365))
                                                      ^
WARNING: space prohibited between function name and open parenthesis '('
+       else if (EVP_PKEY_type (capkey->type) == EVP_PKEY_RSA)

ERROR: trailing statements should be on next line
+       if (cacert) X509_free(cacert);

ERROR: space prohibited after that open parenthesis '('
+                                       !(         (srv_op_state == SRV_ST_STOPPED)

10 years agoBUG/MAJOR: peers: fix a crash when stopping peers on unbound processes
Willy Tarreau [Mon, 21 Sep 2015 13:24:58 +0000 (15:24 +0200)] 
BUG/MAJOR: peers: fix a crash when stopping peers on unbound processes

Pradeep Jindal reported and troubleshooted a bug causing haproxy to die
during startup on all processes not making use of a peers section. It
only happens with nbproc > 1 when peers are declared. Technically it's
when the peers task is stopped on processes that don't use it that the
crash occurred (a task_free() called on a NULL task pointer).

This only affects peers v2 in the dev branch, no backport is needed.

10 years agoDOC: add a MAINTAINERS file
Willy Tarreau [Mon, 21 Sep 2015 13:21:09 +0000 (15:21 +0200)] 
DOC: add a MAINTAINERS file

This one indicates who to CC when sending changes affecting certain
parts of the product.

10 years agoMINOR: 51d: Improved string handling for LRU cache
James Rosewell [Fri, 18 Sep 2015 18:53:05 +0000 (19:53 +0100)] 
MINOR: 51d: Improved string handling for LRU cache

Removed use of strlen with the data added to and retrived from the cache
by using chunk structures instead of string pointers.

10 years agoMAJOR: 51d: Upgraded to support 51Degrees V3.2 and new features
James Rosewell [Fri, 18 Sep 2015 17:28:52 +0000 (18:28 +0100)] 
MAJOR: 51d: Upgraded to support 51Degrees V3.2 and new features

Trie device detection doesn't benefit from caching compared to Pattern.
As such the LRU cache has been removed from the Trie method.

A new fetch  method has been added named 51d.all which uses all the
available HTTP headers for device device detection. The previous 51d
conv method has been changed to 51d.single where one HTTP header,
typically User-Agent, is used for detection. This method is marginally
faster but less accurate.

Three new properties are available with the Pattern method called
Method, Difference and Rank which provide insight into the validity of
the results returned.

A pool of worksets is used to avoid needing to create a new workset for
every request. The workset pool is thread safe ready to support a future
multi threaded version of HAProxy.

10 years agoBUILD: Changed 51Degrees option to support V3.2
James Rosewell [Fri, 18 Sep 2015 16:24:29 +0000 (17:24 +0100)] 
BUILD: Changed 51Degrees option to support V3.2

Added support for city hash method, turned off multi threading support
and included maths library. Removed reference to compression library
which was never needed.

10 years agoDOC: Added more explanation for 51Degrees V3.2
James Rosewell [Fri, 18 Sep 2015 16:21:37 +0000 (17:21 +0100)] 
DOC: Added more explanation for 51Degrees V3.2

Changed examples to demonstrate the the new fetch and conv methods
available with the enhancements made in version 3.2 of 51Degrees.

Added reference to the accuracy indicators available with Pattern
detection method.

10 years agoMINOR: global: Added new fields for 51Degrees device detection
James Rosewell [Fri, 18 Sep 2015 16:13:47 +0000 (17:13 +0100)] 
MINOR: global: Added new fields for 51Degrees device detection

Added support for version 3.2 of 51Degrees C library.

Added fields to store HTTP header names important to device detection
other than User-Agent.

Included a pool of worksets for use with Pattern device detection.

10 years agoMINOR: http: made CHECK_HTTP_MESSAGE_FIRST accessible to other functions
James Rosewell [Fri, 18 Sep 2015 16:11:16 +0000 (17:11 +0100)] 
MINOR: http: made CHECK_HTTP_MESSAGE_FIRST accessible to other functions

Added the definition of CHECK_HTTP_MESSAGE_FIRST and the declaration of
smp_prefetch_http to the header.

Changed smp_prefetch_http implementation to remove the static qualifier.

10 years agoDOC: add a CONTRIBUTING file
Willy Tarreau [Sun, 20 Sep 2015 20:31:42 +0000 (22:31 +0200)] 
DOC: add a CONTRIBUTING file

This file tries to explain in the most detailed way how to contribute
patches. A few parts of it were moved from the README. .gitignore was
updated.

10 years agoDOC: add the documentation about internal circular lists
Willy Tarreau [Mon, 28 Jul 2003 23:16:05 +0000 (01:16 +0200)] 
DOC: add the documentation about internal circular lists

This file was recovered from the first project where it was born 12 years
ago, but it's still convenient to understand how our circular lists work,
so let's add it.

10 years agoDOC: servers state seamless reload example
Baptiste Assmann [Fri, 18 Sep 2015 14:38:21 +0000 (16:38 +0200)] 
DOC: servers state seamless reload example

A short doc + example to help people start using seamless reload for
server state

10 years agoMINOR: cli: new stats socket command: show backend
Baptiste Assmann [Fri, 18 Sep 2015 12:49:12 +0000 (14:49 +0200)] 
MINOR: cli: new stats socket command: show backend

new stats socket command which displays only the list of backends
available in the current process.
For now only the backend name is displayed.

10 years agoMINOR: server: startup slowstart task when using seamless reload of HAProxy
Baptiste Assmann [Thu, 17 Sep 2015 20:53:59 +0000 (22:53 +0200)] 
MINOR: server: startup slowstart task when using seamless reload of HAProxy

This patch uses the start up of the health check task to also start
the warmup task when required.

This is executed only once: when HAProxy has just started up and can
be started only if the load-server-state-from-file feature is enabled
and the server was in the warmup state before a reload occurs.

10 years agoMINOR: init: server state loaded from file
Baptiste Assmann [Fri, 14 Aug 2015 14:20:52 +0000 (16:20 +0200)] 
MINOR: init: server state loaded from file

With this patch, HAProxy reads the content of server state file and
update state of servers accordingly.

10 years agoDOC: load-server-state-from-file
Baptiste Assmann [Sun, 23 Aug 2015 09:45:29 +0000 (11:45 +0200)] 
DOC: load-server-state-from-file

10 years agoMINOR: config: new backend directives: load-server-state-from-file and server-state...
Baptiste Assmann [Wed, 19 Aug 2015 14:44:03 +0000 (16:44 +0200)] 
MINOR: config: new backend directives: load-server-state-from-file and server-state-file-name

This directive gives HAProxy the ability to use the either the global
server-state-file directive or a local one using server-state-file-name to
load server states.
The state can be saved right before the reload by the init script, using
the "show servers state" command on the stats socket redirecting output into
a file.

10 years agoDOC: new global directive: server-state-file
Baptiste Assmann [Sun, 23 Aug 2015 08:06:39 +0000 (10:06 +0200)] 
DOC: new global directive: server-state-file

Documentation related to a new global directive.
Purpose of this directive is to store a file path into the global
structure of HAProxy. The file pointed by the path may be used by
HAProxy to retrieve server state from the previous running process
after a reload occured.

10 years agoMINOR: config: new global section directive: server-state-file
Baptiste Assmann [Sun, 23 Aug 2015 07:54:31 +0000 (09:54 +0200)] 
MINOR: config: new global section directive: server-state-file

This new global section directive is used to store the path to the file
where HAProxy will be able to retrieve server states across reloads.

The file pointed by this path is used to store a file which can contains
state of all servers from all backends.

10 years agoDOC: global directive server-state-base
Baptiste Assmann [Sun, 23 Aug 2015 08:00:10 +0000 (10:00 +0200)] 
DOC: global directive server-state-base

Documentation relative to the new global directive server-state-file.

10 years agoMINOR: config: new global directive server-state-base
Baptiste Assmann [Sun, 23 Aug 2015 07:22:25 +0000 (09:22 +0200)] 
MINOR: config: new global directive server-state-base

This new global directive can be used to provide a base directory where
all the server state files could be loaded.
If a server state file name starts with a slash '/', then this directive
must not be applied.

10 years agoDOC: stats socket command: show servers state
Baptiste Assmann [Fri, 8 May 2015 17:35:08 +0000 (19:35 +0200)] 
DOC: stats socket command: show servers state

Documentation related to the new command available over the stats socket
"show servers state".

A description of the fields is also included.

10 years agoMINOR: cli: new stats socket command: show servers state
Baptiste Assmann [Fri, 3 Jul 2015 06:01:20 +0000 (08:01 +0200)] 
MINOR: cli: new stats socket command: show servers state

new command 'show servers state' which dumps all variable parameters
of a server during an HAProxy process life.
Purpose is to dump current server state at current run time in order to
read them right after the reload.

The format of the output is versionned and we support version 1 for now.

10 years agoMINOR: server: Macro definition for server-state
Baptiste Assmann [Fri, 8 May 2015 21:34:06 +0000 (23:34 +0200)] 
MINOR: server: Macro definition for server-state

Introduces a few new macros used by server state save and application accros reloads:
- currently used state server file format version
- currently used state server file header fields
- MIN and MAX value for version number
- maximum number of fields that could be found in a server-state file
- an arbitrary state-file max line length

10 years agoBUG/MAJOR: can't enable a server through the stat socket
Baptiste Assmann [Fri, 18 Sep 2015 08:30:03 +0000 (10:30 +0200)] 
BUG/MAJOR: can't enable a server through the stat socket

When a server is disabled in the configuration using the "disabled"
keyword, a single flag is positionned: SRV_ADMF_CMAINT (use to be
SRV_ADMF_FMAINT)..
That said, when providing the first version of this code, we also
changed the SRV_ADMF_MAINT mask to match any of the possible MAINT
cases: SRV_ADMF_FMAINT, SRV_ADMF_IMAINT, SRV_ADMF_CMAINT

Since SRV_ADMF_CMAINT is never (and is not supposed to be) altered at
run time, once a server has this flag set up, it can never ever be
enabled again using the stats socket.

In order to fix this, we should:
- consider SRV_ADMF_CMAINT as a simple flag to report the state in the
  old configuration file (will be used after a reload to deduce the
  state of the server in a new running process)
- enabling both SRV_ADMF_CMAINT and SRV_ADMF_FMAINT when the keyword
  "disabled" is in use in the configuration
- update the mask SRV_ADMF_MAINT as it was before, to only match
  SRV_ADMF_FMAINT and SRV_ADMF_IMAINT.

The following patch perform the changes above.
It allows fixing the regression without breaking the way the up coming
feature (seamless server state accross reloads) is going to work.

Note: this is 1.6-only, no backport needed.

10 years agoMINOR: support cpu-map feature through the compile option USE_CPU_AFFINITY on FreeBSD
Pieter Baauw [Thu, 17 Sep 2015 19:26:40 +0000 (21:26 +0200)] 
MINOR: support cpu-map feature through the compile option USE_CPU_AFFINITY on FreeBSD

10 years agoDOC: add references to rise/fall for the fastinter explanation
Pieter Baauw [Thu, 17 Sep 2015 19:30:46 +0000 (21:30 +0200)] 
DOC: add references to rise/fall for the fastinter explanation

10 years agoBUG/MINOR: lua: breaks the log message if his size exceed one buffer
Thierry FOURNIER [Wed, 16 Sep 2015 10:47:03 +0000 (12:47 +0200)] 
BUG/MINOR: lua: breaks the log message if his size exceed one buffer

Previously, the log was ignored if the log message exceed one buffer.
This patch doens't ignore the log, but trancate the message.

10 years agoBUG/MAJOR: lua: potential unexpected aborts()
Thierry FOURNIER [Thu, 17 Sep 2015 09:36:37 +0000 (11:36 +0200)] 
BUG/MAJOR: lua: potential unexpected aborts()

This couple of function executes securely some Lua calls outside of
the lua runtime environment. Each Lua call can return a longjmp
if it encounter a memory error.

Lua documentation extract:

   If an error happens outside any protected environment, Lua calls
   a panic function (see lua_atpanic) and then calls abort, thus
   exiting the host application. Your panic function can avoid this
   exit by never returning (e.g., doing a long jump to your own
   recovery point outside Lua).

   The panic function runs as if it were a message handler (see
   §2.3); in particular, the error message is at the top of the
   stack. However, there is no guarantee about stack space. To push
   anything on the stack, the panic function must first check the
   available space (see §4.2).

We must check all the Lua entry point. This includes:
 - The include/proto/hlua.h exported functions
 - the task wrapper function
 - The action wrapper function
 - The converters wrapper function
 - The sample-fetch wrapper functions

It is tolerated that the initilisation function returns an abort.
Before each Lua abort, an error message is writed on stderr.

The macro SET_SAFE_LJMP initialise the longjmp. The Macro
RESET_SAFE_LJMP reset the longjmp. These function must be macro
because they must be exists in the program stack when the longjmp
is called

10 years ago[RELEASE] Released version 1.6-dev5 v1.6-dev5
Willy Tarreau [Mon, 14 Sep 2015 10:23:10 +0000 (12:23 +0200)] 
[RELEASE] Released version 1.6-dev5

Released version 1.6-dev5 with the following main changes :
    - MINOR: dns: dns_resolution structure update: time_t to unsigned int
    - BUG/MEDIUM: dns: DNS resolution doesn't start
    - BUG/MAJOR: dns: dns client resolution infinite loop
    - MINOR: dns: coding style update
    - MINOR: dns: new bitmasks to use against DNS flags
    - MINOR: dns: dns_nameserver structure update: new counter for truncated response
    - MINOR: dns: New DNS response analysis code: DNS_RESP_TRUNCATED
    - MEDIUM: dns: handling of truncated response
    - MINOR: DNS client query type failover management
    - MINOR: dns: no expected DNS record type found
    - MINOR: dns: new flag to report that no IP can be found in a DNS response packet
    - BUG/MINOR: DNS request retry counter used for retry only
    - DOC: DNS documentation updated
    - MEDIUM: actions: remove ACTION_STOP
    - BUG/MEDIUM: lua: outgoing connection was broken since 1.6-dev2 (bis)
    - BUG/MINOR: lua: last log character truncated.
    - CLEANUP: typo: bad indent
    - CLEANUP: actions: missplaced includes
    - MINOR: build: missing header
    - CLEANUP: lua: Merge log functions
    - BUG/MAJOR: http: don't manipulate the server connection if it's killed
    - BUG/MINOR: http: remove stupid HTTP_METH_NONE entry
    - BUG/MAJOR: http: don't call http_send_name_header() after an error
    - MEDIUM: tools: make str2sa_range() optionally return the FQDN
    - BUG/MINOR: tools: make str2sa_range() report unresolvable addresses
    - BUG/MEDIUM: dns: use the correct server hostname when resolving

10 years agoCLEANUP: lua: Merge log functions
Thierry FOURNIER [Fri, 11 Sep 2015 17:15:43 +0000 (19:15 +0200)] 
CLEANUP: lua: Merge log functions

All the code which emits error log have the same pattern. Its:
Send log with syslog system, and if it is allowed, display error
log on screen.

This patch replace this pattern by a macro. This reduces the number
of lines.

10 years agoMINOR: build: missing header
Thierry FOURNIER [Fri, 11 Sep 2015 06:33:33 +0000 (08:33 +0200)] 
MINOR: build: missing header

Regex header file is missing in types/action.h

Repported by Conrad Hoffmann

I cannot build the current dev's master HEAD (ec3c37d) because of this error:

> In file included from include/proto/proto_http.h:26:0,
>                  from src/stick_table.c:26:
> include/types/action.h:102:20: error: field â\80\98reâ\80\99 has incomplete type
>     struct my_regex re;    /* used by replace-header and replace-value */
>                     ^
> Makefile:771: recipe for target 'src/stick_table.o' failed
> make: *** [src/stick_table.o] Error 1

The struct act_rule defined in action.h includes a full struct my_regex
without #include-ing regex.h. Both gcc 5.2.0 and clang 3.6.2 do not allow this.

10 years agoCLEANUP: actions: missplaced includes
Thierry FOURNIER [Thu, 10 Sep 2015 16:28:10 +0000 (18:28 +0200)] 
CLEANUP: actions: missplaced includes

The include of action.h are misplaced.

10 years agoCLEANUP: typo: bad indent
Thierry FOURNIER [Fri, 4 Sep 2015 16:40:36 +0000 (18:40 +0200)] 
CLEANUP: typo: bad indent

A space alignment remains in the stream_interface.c file

10 years agoDOC: DNS documentation updated
Baptiste Assmann [Tue, 8 Sep 2015 23:11:36 +0000 (01:11 +0200)] 
DOC: DNS documentation updated

More information regarding DNS resolution:
- behavior in case of errors
- behavior when multiple name servers are configured in a resolvers
  section
- when a retry is performed
- when a query type change is performed
- make it clear that DNS resolution requires health checking enabled
  on the server

10 years agoBUG/MINOR: DNS request retry counter used for retry only
Baptiste Assmann [Tue, 8 Sep 2015 22:54:38 +0000 (00:54 +0200)] 
BUG/MINOR: DNS request retry counter used for retry only

There are two types of retries when performing a DNS resolution:
1. retry because of a timeout
2. retry of the full sequence of requests (query types failover)

Before this patch, the 'resolution->try' counter was incremented
after each send of a DNS request, which does not cover the 2 cases
above.
This patch fix this behavior.