]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
9 years agoMEDIUM: tcp: add new tcp action "silent-drop"
Willy Tarreau [Sun, 23 Aug 2015 23:43:45 +0000 (01:43 +0200)] 
MEDIUM: tcp: add new tcp action "silent-drop"

This stops the evaluation of the rules and makes the client-facing
connection suddenly disappear using a system-dependant way that tries
to prevent the client from being notified. The effect it then that the
client still sees an established connection while there's none on
HAProxy. The purpose is to achieve a comparable effect to "tarpit"
except that it doesn't use any local resource at all on the machine
running HAProxy. It can resist much higher loads than "tarpit", and
slow down stronger attackers. It is important to undestand the impact
of using this mechanism. All stateful equipments placed between the
client and HAProxy (firewalls, proxies, load balancers) will also keep
the established connection for a long time and may suffer from this
action. On modern Linux systems running with enough privileges, the
TCP_REPAIR socket option is used to block the emission of a TCP
reset. On other systems, the socket's TTL is reduced to 1 so that the
TCP reset doesn't pass the first router, though it's still delivered to
local networks.

9 years agoDOC: remove outdated actions lists on tcp-request/response
Willy Tarreau [Mon, 28 Sep 2015 16:47:38 +0000 (18:47 +0200)] 
DOC: remove outdated actions lists on tcp-request/response

The valid actions are enumerated in the text, and the small set listed
in the definition is not accurate.

9 years agoBUG/MEDIUM: tcp: fix inverted condition to call custom actions
Willy Tarreau [Mon, 28 Sep 2015 15:50:10 +0000 (17:50 +0200)] 
BUG/MEDIUM: tcp: fix inverted condition to call custom actions

tcp-request connection had an inverted condition on action_ptr, resulting
in no registered actions to be usable since commit 4214873 ("MEDIUM: actions:
remove ACTION_STOP") merged in 1.6-dev5. Very few new actions were impacted.
No backport is needed.

9 years agoMEDIUM: logs: pass the trailing "\n" as an iovec
Dragan Dosen [Mon, 28 Sep 2015 14:01:03 +0000 (16:01 +0200)] 
MEDIUM: logs: pass the trailing "\n" as an iovec

This patch passes the trailing "\n" as an iovec in the function
__send_log(), so that we don't need to modify the original log message.

9 years agoMEDIUM: logs: have global.log_send_hostname not contain the trailing space
Dragan Dosen [Mon, 28 Sep 2015 11:28:21 +0000 (13:28 +0200)] 
MEDIUM: logs: have global.log_send_hostname not contain the trailing space

This patch unifies global.log_send_hostname addition in the log header
processing.

9 years agoDOC: mention support for the RFC5424 syslog message format
Dragan Dosen [Mon, 28 Sep 2015 15:16:47 +0000 (17:16 +0200)] 
DOC: mention support for the RFC5424 syslog message format

Document the new log "format" argument and the "log-format-sd" statement.

9 years agoMEDIUM: init: completely deallocate unused peers
Willy Tarreau [Mon, 28 Sep 2015 14:39:25 +0000 (16:39 +0200)] 
MEDIUM: init: completely deallocate unused peers

When peers are stopped due to not being running on the appropriate
process, we want to completely release them and unregister their signals
and task in order to ensure there's no way they may be called in the
future.

Note: ideally we should have a list of all tables attached to a peers
section being disabled in order to unregister them and void their
sync_task. It doesn't appear to be *that* easy for now.

9 years agoBUG/MEDIUM: proxy: do not wake stopped proxies' tasks during soft_stop()
Willy Tarreau [Mon, 28 Sep 2015 14:35:04 +0000 (16:35 +0200)] 
BUG/MEDIUM: proxy: do not wake stopped proxies' tasks during soft_stop()

When performing a soft stop, we used to wake up every proxy's task and
each of their table's task. The problem is that since we're able to stop
proxies and peers not bound to a specific process, we may end up calling
random junk by doing so of the proxy we're waking up is already stopped.
This causes a segfault to appear during soft reloads for old processes
not bound to a peers section if such a section exists in other processes.

Let's only consider proxies that are not stopped when doing this.

This fix must be backported to 1.5 which also has the same issue.

9 years agoBUG/MEDIUM: proxy: ignore stopped peers
Willy Tarreau [Mon, 28 Sep 2015 14:27:44 +0000 (16:27 +0200)] 
BUG/MEDIUM: proxy: ignore stopped peers

Since commit f83d3fe ("MEDIUM: init: stop any peers section not bound
to the correct process"), it is possible to stop unused peers on certain
processes. The problem is that the pause/resume/stop functions are not
aware of this and will pass a NULL proxy pointer to the respective
functions, resulting in segfaults in unbound processes during soft
restarts.

Properly check that the peers' frontend is still valid before calling
them.

This bug also affects 1.5 so the fix must be backported. Note that this
fix is not enough to completely get rid of the segfault, the next one
is needed as well.

9 years agoDOC: fix some broken unexpected unicode chars in the Lua doc.
Willy Tarreau [Mon, 28 Sep 2015 13:39:10 +0000 (15:39 +0200)] 
DOC: fix some broken unexpected unicode chars in the Lua doc.

A few chars didn't render properly in some terminals and had no
reason for being there.

9 years agoDOC: lua: some documentation update
Thierry FOURNIER [Fri, 25 Sep 2015 19:43:56 +0000 (21:43 +0200)] 
DOC: lua: some documentation update

this update embbeds some fix of existing function, and the applet documentation.

9 years agoDOC: add David Carlier as maintainer of da.c
Willy Tarreau [Mon, 28 Sep 2015 11:37:30 +0000 (13:37 +0200)] 
DOC: add David Carlier as maintainer of da.c

David is willing to handle any issue related to da.c.

9 years agoDOC: README: DeviceAtlas sample configuration updates
David Carlier [Fri, 25 Sep 2015 13:06:08 +0000 (14:06 +0100)] 
DOC: README: DeviceAtlas sample configuration updates

Needs to distinguish the convertor and the fetch type samples.
More explanations are made about their specific purposes.

9 years agoDOC: DeviceAtlas new keywords
David Carlier [Fri, 25 Sep 2015 13:09:21 +0000 (14:09 +0100)] 
DOC: DeviceAtlas new keywords

A new entry in the configuration's documentation to set optionally
the name of the client's cookie used for the detection.

9 years agoMAJOR: da: Update of the DeviceAtlas API module
David Carlier [Fri, 25 Sep 2015 13:16:30 +0000 (14:16 +0100)] 
MAJOR: da: Update of the DeviceAtlas API module

Introduction of the new keyword about the client's cookie name
via a new config entry.

Splits the work between the original convertor and the new fetch type.
The latter iterates through the whole list of HTTP headers but first,
make sure the request data are ready to process and set the input
to the string type rightly.

The API is then able to filter itself which headers are gueninely useful,
with a special care of the Client's cookie.

[WT: the immediate impact for the end user is that configs making use of
    "da-csv" won't load anymore and will need to be modified to use either
    "da-csv-conv" or "da-csv-fetch"]

9 years agoMINOR: global: Few new struct fields for da module
David Carlier [Fri, 25 Sep 2015 13:13:44 +0000 (14:13 +0100)] 
MINOR: global: Few new struct fields for da module

The name and length of the client cookie, useful for extracting
cookie value's function and a simple bitfield one to define if
set or not.

9 years agoMINOR: proto_http: Externalisation of previously internal functions
David Carlier [Fri, 25 Sep 2015 13:10:50 +0000 (14:10 +0100)] 
MINOR: proto_http: Externalisation of previously internal functions

Needs to expose the HTTP headers 'iterator' and the client's cookie
value extraction functions.

9 years agoMEDIUM: logs: add a new RFC5424 log-format for the structured-data
Dragan Dosen [Fri, 25 Sep 2015 17:17:44 +0000 (19:17 +0200)] 
MEDIUM: logs: add a new RFC5424 log-format for the structured-data

This patch adds a new RFC5424-specific log-format for the structured-data
that is automatically send by __send_log() when the sender is in RFC5424
mode.

A new statement "log-format-sd" should be used in order to set log-format
for the structured-data part in RFC5424 formatted syslog messages.
Example:

    log-format-sd [exampleSDID@1234\ bytes=\"%B\"\ status=\"%ST\"]

9 years agoMEDIUM: logs: add support for RFC5424 header format per logger
Dragan Dosen [Tue, 22 Sep 2015 14:05:32 +0000 (16:05 +0200)] 
MEDIUM: logs: add support for RFC5424 header format per logger

The function __send_log() iterates over senders and passes the header as
the first vector to sendmsg(), thus it can send a logger-specific header
in each message.

A new logger arguments "format rfc5424" should be used in order to enable
RFC5424 header format. For example:

    log 10.2.3.4:1234 len 2048 format rfc5424 local2 info

9 years agoMEDIUM: logs: remove the hostname, tag and pid part from the logheader
Dragan Dosen [Sat, 19 Sep 2015 20:35:44 +0000 (22:35 +0200)] 
MEDIUM: logs: remove the hostname, tag and pid part from the logheader

At the moment we have to call snprintf() for every log line just to
rebuild a constant. Thanks to sendmsg(), we send the message in 3 parts:
time-based header, proxy-specific hostname+log-tag+pid, session-specific
message.

9 years agoMEDIUM: log: use a separate buffer for the header and for the message
Dragan Dosen [Sat, 19 Sep 2015 20:09:02 +0000 (22:09 +0200)] 
MEDIUM: log: use a separate buffer for the header and for the message

Make sendmsg() use two vectors, one for the message header that is updated
by update_log_hdr() and one for the message buffer.

9 years agoMEDIUM: log: replace sendto() with sendmsg() in __send_log()
Dragan Dosen [Wed, 16 Sep 2015 16:25:42 +0000 (18:25 +0200)] 
MEDIUM: log: replace sendto() with sendmsg() in __send_log()

This patch replaces sendto() with sendmsg() in __send_log() and makes use
of an iovec to send the log message.

9 years agoBUG/MEDIUM: main: Freeing a bunch of static pointers
David Carlier [Fri, 25 Sep 2015 11:02:25 +0000 (12:02 +0100)] 
BUG/MEDIUM: main: Freeing a bunch of static pointers

static_table_key, get_http_auth_buff and swap_buffer static variables
are now freed during deinit and the two previously new functions are
called as well. In addition, the 'trash' string buffer is cleared.

9 years agoMINOR: chunk: New function free_trash_buffers()
David Carlier [Fri, 25 Sep 2015 10:58:12 +0000 (11:58 +0100)] 
MINOR: chunk: New function free_trash_buffers()

This new function is meant to be called in the general deinit phase,
to free those two internal chunks.

9 years agoMINOR: cfgparse: New function cfg_unregister_sections()
David Carlier [Fri, 25 Sep 2015 10:49:18 +0000 (11:49 +0100)] 
MINOR: cfgparse: New function cfg_unregister_sections()

A new function introduced meant to be called during general deinit phase.
During the configuration parsing, the section entries are all allocated.
This new function free them.

9 years agoMEDIUM: config: set tune.maxrewrite to 1024 by default
Willy Tarreau [Mon, 28 Sep 2015 11:53:23 +0000 (13:53 +0200)] 
MEDIUM: config: set tune.maxrewrite to 1024 by default

The tune.maxrewrite parameter used to be pre-initialized to half of
the buffer size since the very early days when buffers were very small.
It has grown to absurdly large values over the years to reach 8kB for a
16kB buffer. This prevents large requests from being accepted, which is
the opposite of the initial goal.

Many users fix it to 1024 which is already quite large for header
addition.

So let's change the default setting policy :
  - pre-initialize it to 1024
  - let the user tweak it
  - in any case, limit it to tune.bufsize / 2

This results in 15kB usable to buffer HTTP messages instead of 8kB, and
doesn't affect existing configurations which already force it.

9 years agoBUG/MINOR: config: check that tune.bufsize is always positive
Willy Tarreau [Mon, 28 Sep 2015 11:49:53 +0000 (13:49 +0200)] 
BUG/MINOR: config: check that tune.bufsize is always positive

We must not accept negative values for tune.bufsize as they will only
result in crashing the process during the parsing.

9 years agoMINOR: lua: add AppletHTTP class and service
Thierry FOURNIER [Fri, 18 Sep 2015 07:04:27 +0000 (09:04 +0200)] 
MINOR: lua: add AppletHTTP class and service

This class is used by Lua code for running as an applet called in HTTP mode
It defines also the associated lua service

9 years agoMINOR: lua: add AppletTCP class and service
Thierry FOURNIER [Sat, 19 Sep 2015 10:36:17 +0000 (12:36 +0200)] 
MINOR: lua: add AppletTCP class and service

This class is used by Lua code for running as an applet called in TCP mode.
It defines also the lua service.

9 years agoMINOR: stream/applet: add use-service action
Thierry FOURNIER [Sun, 27 Sep 2015 17:29:33 +0000 (19:29 +0200)] 
MINOR: stream/applet: add use-service action

This new target can be called from the frontend or the backend. It
is evaluated just before the backend choice and just before the server
choice. So, the input stream or HTTP request can be forwarded to a
server or to an internal service.

9 years agoMINOR: applet: add an execution timeout
Thierry FOURNIER [Mon, 21 Sep 2015 22:02:58 +0000 (00:02 +0200)] 
MINOR: applet: add an execution timeout

This patch only declares the execution timeout variable. The applet
must be respect or ignore it. For example an applet who doing some
network accesses and doesn't control its execution yime should use
this timeout.

9 years agoMINOR: applet: add init function
Thierry FOURNIER [Fri, 11 Sep 2015 06:50:34 +0000 (08:50 +0200)] 
MINOR: applet: add init function

this patch adds init function for the applet. the HAProxy standard
applet (peers, stats, lua) have no standard way for the applet
initialisation. This new function pointer have for goal to try to
standardize the applet initialization.

9 years agoBUG/MEDIUM: lua: don't reset undesired flags in hlua_ctx_resume
Thierry FOURNIER [Sun, 27 Sep 2015 23:02:01 +0000 (01:02 +0200)] 
BUG/MEDIUM: lua: don't reset undesired flags in hlua_ctx_resume

Some flags like HLUA_MUST_GC must not be cleared otherwise sessions are
not properly cleaned.

9 years agoMEDIUM: action: add a new flag ACT_FLAG_FIRST
Willy Tarreau [Sun, 27 Sep 2015 21:34:39 +0000 (23:34 +0200)] 
MEDIUM: action: add a new flag ACT_FLAG_FIRST

This flag is used by custom actions to know that they're called for the
first time. The only case where it's not set is when they're resuming
from a yield. It will be needed to let them know when they have to
allocate some resources.

9 years agoOPTIM/MEDIUM: lua: executes the garbage collector only when using cosocket
Thierry FOURNIER [Sun, 27 Sep 2015 20:53:33 +0000 (22:53 +0200)] 
OPTIM/MEDIUM: lua: executes the garbage collector only when using cosocket

The garbage collector is a little bit heavy to run, and it was added
only for cosockets. This patch prevent useless executions when no
cosockets are used.

9 years agoMEDIUM: lua: change the GC policy
Thierry FOURNIER [Sun, 27 Sep 2015 20:17:19 +0000 (22:17 +0200)] 
MEDIUM: lua: change the GC policy

The GC is run each times that an Lua function exit with an error or with a success.

9 years agoBUG/MEDIUM: lua: socket destroy before reading pending data
Thierry FOURNIER [Sun, 27 Sep 2015 17:29:38 +0000 (19:29 +0200)] 
BUG/MEDIUM: lua: socket destroy before reading pending data

When the channel is down, the applet is waked up. Before this patch,
the applet closes the stream and the unread data are discarded.

After this patch, the stream is not closed except if the buffers are
empty.

It will be closed later by the close function, or by the garbage collector.

9 years agoMINOR: lua/applet: the cosocket applet should use appctx_wakeup in place of task_wakeup
Thierry FOURNIER [Sat, 26 Sep 2015 15:02:35 +0000 (17:02 +0200)] 
MINOR: lua/applet: the cosocket applet should use appctx_wakeup in place of task_wakeup

It seems that in the new applet system, the applet me be wakeup with the
function appctx_wakeup() in place of the function task_wakeup().

9 years agoCLEANUP: config: make the errorloc/errorfile messages less confusing
Willy Tarreau [Sun, 27 Sep 2015 13:13:30 +0000 (15:13 +0200)] 
CLEANUP: config: make the errorloc/errorfile messages less confusing

Some users believe that "status code XXX not handled" means "not handled
by haproxy". Let's be clear that's only about the option.

9 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@".

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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).

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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().

9 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.

9 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.

9 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

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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).

9 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().

9 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.

9 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).

9 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.

9 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.

9 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.

9 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.

9 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.

9 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)

9 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)

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.

9 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.