Commit Graph

4628 Commits

Author SHA1 Message Date
Willy Tarreau
8a8d83b85c REORG: applet: move the applet definitions out of stream_interface
We're tidying the definitions so that appctx lives on its own. A new
set of applet.h files has been added for this purpose.
2015-04-23 17:56:16 +02:00
Willy Tarreau
00a37f0029 MEDIUM: applet: make the applet not depend on a stream interface anymore
Now that applet's functions only take an appctx in argument, not a
stream interface. This slightly simplifies the code and will be needed
to take the appctx out of the stream interface.
2015-04-23 17:56:16 +02:00
Willy Tarreau
19c8161b3d MINOR: applet: add a new "owner" pointer in the appctx
This pointer indicates what stream-interface the appctx belongs to, just
like we have for the connections.
2015-04-23 17:56:16 +02:00
Simon Horman
b167b6bff9 MEDIUM: stats: Differentiate between DRAIN and DRAIN (agent)
Differentiate between DRAIN and DRAIN (agent) when reporting stats.
This is consistent with the distinction made between DOWN and DOWN (agent).

Signed-off-by: Simon Horman <horms@verge.net.au>
2015-04-23 09:57:56 +02:00
Simon Horman
4463d19d48 MEDIUM: stats: Only report drain state in stats if server has SRV_ADMF_DRAIN set
There are some similarities between a weight of zero and the
administratively set drain state: both allow existing connections
to continue while not accepting any new ones.

However, when reporting a server state generally a distinction is made
between state=UP,weight=0 and state=DRAIN,weight=*. This patch makes
stats reporting consistent in this regard.

This patch does not alter the behaviour that if a server's weight
is zero then its stats row is blue when accessed via HTML. This remains
the case regardless of if the state is UP or DRAIN.

Signed-off-by: Simon Horman <horms@verge.net.au>
2015-04-23 09:57:53 +02:00
Simon Horman
837bfa74db MEDIUM: stats: Separate server state and colour in stats
There is a relationship between the state and colour of a server in
stats, however, it is not a one-to-one relationship and the current
implementation has proved fragile.

This patch attempts to address that problem by clearly separating
state and colour.

A follow-up patch will further distinguish between DRAIN states
and DRAINING colours.

Signed-off-by: Simon Horman <horms@verge.net.au>
2015-04-23 09:57:51 +02:00
Simon Horman
4d2eab61d4 MEDIUM: stats: Add enum srv_stats_state
Add an enumeration to make the handling of the states of servers
in status messages somewhat clearer.

This is the first of a two-step attempt to disentangle the state and
colour of status information. A subsequent patch will separate state
colours from the states themselves.

This patch should not make any functional changes.

Signed-off-by: Simon Horman <horms@verge.net.au>
2015-04-23 09:57:49 +02:00
Jason Harvey
8310480499 DOC: Fix L4TOUT typo in documentation
Fix documentation typo. L4TMOUT->L4TOUT.
2015-04-21 18:20:06 +02:00
Willy Tarreau
ee335e65dc BUG/MEDIUM: http: properly retrieve the front connection
Commit 350f487 ("CLEANUP: session: simplify references to chn_{prod,cons}(&s->{req,res})")
introduced a regression causing the cli_conn to be picked from the server
side instead of the client side, so the XFF header is not appended anymore
since the connection is NULL.

Thanks to Reinis Rozitis for reporting this bug. No backport is needed
as it's 1.6-specific.
2015-04-21 18:15:13 +02:00
Willy Tarreau
e3a71ffc54 DOC: update the entities diagrams
The recent changes were significant enough to warrant an update to the
entities diagram. It tries to be accurate, though it doesn't represent
applets.
2015-04-21 14:15:40 +02:00
Willy Tarreau
7365dad40f BUG/MEDIUM: stream-int: always reset si->ops when si->end is nullified
It happened after changing the stream interface deinitialization
sequence that we got random crashes with si_shutw() being called
on NULL si->end. The reason was that si->ops was not reset after
a call to si_release_endpoint() which is sometimes called directly.

Thus we now move the resetting of si->ops just after any si->end
assignment. It happens that si_detach() is now just the same as
si_release_endpoint() and stream_int_unregister_handler(). Some
cleanup will have to be performed there.

It's not sure whether this problem can impact 1.5 since in 1.5
applets are part of the default embedded stream handler. The only
way it could cause some trouble is if it's used with a connection,
which doesn't seem possible at first glance.
2015-04-21 14:15:22 +02:00
Willy Tarreau
152b81e7b2 BUG/MAJOR: tcp/http: fix current_rule assignment when restarting over a ruleset
Commit bc4c1ac ("MEDIUM: http/tcp: permit to resume http and tcp custom
actions") introduced the ability to interrupt and restart processing in
the middle of a TCP/HTTP ruleset. But it doesn't do it in a consistent
way : it checks current_rule_list, immediately dereferences current_rule,
which is only set in certain cases and never cleared. So that broke the
tcp-request content rules when the processing was interrupted due to
missing data, because current_rule was not yet set (segfault) or could
have been inherited from another ruleset if it was used in a backend
(random behaviour).

The proper way to do it is to always set current_rule before dereferencing
it. But we don't want to set it for all rules because we don't want any
action to provide a checkpointing mechanism. So current_rule is set to NULL
before entering the loop, and only used if not NULL and if current_rule_list
matches the current list. This way they both serve as a guard for the other
one. This fix also makes the current rule point to the rule instead of its
list element, as it's much easier to manipulate.

No backport is needed, this is 1.6-specific.
2015-04-20 13:46:20 +02:00
Willy Tarreau
e759749b50 BUG/MEDIUM: init: don't limit cpu-map to the first 32 processes only
We have to allow 32 or 64 processes depending on the machine's word
size, and on 64-bit machines only the first 32 processes were properly
bound.

This fix should be backported to 1.5.
2015-04-20 11:36:57 +02:00
Willy Tarreau
af2fd584f3 BUG/MEDIUM: listener: don't report an error when resuming unbound listeners
Pavlos Parissis reported that a sequence of disable/enable on a frontend
performed on the CLI can result in an error if the frontend has several
"bind" lines each bound to different processes. This is because the
resume_listener() function returns a failure for frontends not part of
the current process instead of returning a success to pretend there was
no failure.

This fix should be backported to 1.5.
2015-04-14 12:10:06 +02:00
Willy Tarreau
10146c9c51 CLEANUP: poll: move the conditions for waiting out of the poll functions
The poll() functions have become a bit dirty because they now check the
size of the signal queue, the FD cache and the number of tasks. It's not
their job, this must be moved to the caller. In the end it simplifies the
code because the expiration date is now set to now_ms if we must not wait,
and this achieves in exactly the same result and is cleaner. The change
looks large due to the change of indent for blocks which were inside an
"if" block.
2015-04-13 20:47:51 +02:00
CJ Ess
108b1dd69d MEDIUM: http: configurable http result codes for http-request deny
This patch adds support for error codes 429 and 405 to Haproxy and a
"deny_status XXX" option to "http-request deny" where you can specify which
code is returned with 403 being the default. We really want to do this the
"haproxy way" and hope to have this patch included in the mainline. We'll
be happy address any feedback on how this is implemented.
2015-04-11 10:34:54 +02:00
Alexander Rigbo
fc65af0c61 BUG/MINOR: ssl: Display correct filename in error message
This patch should be backported to 1.5.
2015-04-11 10:28:59 +02:00
Willy Tarreau
73b65acd46 MINOR: stream: pass the pointer to the origin explicitly to stream_new()
We don't pass sess->origin anymore but the pointer to the previous step. Now
it should be much easier to chain elements together once applets are moved out
of streams. Indeed, the session is only used for configuration and not for the
dynamic chaining anymore.
2015-04-08 18:26:29 +02:00
Willy Tarreau
678be62981 MEDIUM: session: adjust the connection flags before stream_new()
It's not the stream's job to manipulate the connection's flags, it's
more related to the session that accepted the new connection. And the
only case where we have to do it conditionally is based on the frontend
which is known from the session, thus it makes sense to do it there.
2015-04-08 18:18:15 +02:00
Willy Tarreau
042cd75bc2 MINOR: session: maintain the session count stats in the session, not the stream
This has nothing to do in the stream, as we'll face absurdities when chaining
multiple streams. The session is where it must be accounted for.
2015-04-08 18:10:49 +02:00
Willy Tarreau
1b90511eeb CLEANUP: namespaces: fix protection against multiple inclusions
The include file did not protect correctly against multiple inclusions,
as it didn't define the file name after checking for it. That's currently
harmless as the file is only included from .c but that could change.
2015-04-08 17:31:40 +02:00
Thierry FOURNIER
3def393f8d MINOR: lua: map system integration in Lua
This patch cretes a new Map class that permits to do some lookup in
HAProxy maps. This Map class is integration in the HAProxy update
system, so we can modify the map throught the socket.
2015-04-07 15:56:21 +02:00
Thierry FOURNIER
04c57b3357 MINOR: lua: (req|res)_get_headers return more than one header value
the functions (req|res)_get_headers() return only the last entry
for each header with the same name. This patch fix this behavior.
Each header name contain an array of values.
2015-04-07 15:56:14 +02:00
Thierry FOURNIER
2e4893cb7f DOC: lua: some fixes
- remove trailing spces
 - update fetches ans converters documentation
2015-04-07 15:55:58 +02:00
Willy Tarreau
d414f8e8b7 CLEANUP: stream-int: swap stream-int and appctx declarations
This is just in order to remove two forward declarations of si_applet
and stream_interface that are not needed once properly ordered.
2015-04-06 11:43:45 +02:00
Willy Tarreau
0c5c68ec28 MINOR: peers: no need for setting timeouts / conn_retries in peer_session_create()
For the client side this is done already by stream_new(). For the
server side it will be done when establishing the connection.
2015-04-06 11:37:36 +02:00
Willy Tarreau
7ddf7c5641 MINOR: lua: no need for setting timeouts / conn_retries in hlua_socket_new()
For the client side this is done already by stream_new(). For the
server side it will be done when establishing the connection.
2015-04-06 11:37:36 +02:00
Willy Tarreau
61cf7c885d MINOR: lua: minor cleanup in hlua_socket_new()
Just limit the number of dereferences of socket-> since we allocate
the stream at the beginning.
2015-04-06 11:37:36 +02:00
Willy Tarreau
d420a975d7 MEDIUM: lua: make use of stream_new() to create an outgoing connection
This significantly simplifies the session management because we don't
have to know all the intimate tricks of setting up a stream and a
session.
2015-04-06 11:37:36 +02:00
Willy Tarreau
d1769b8b9a MEDIUM: stream: don't rely on the session's listener anymore in stream_new()
When the stream is instanciated from an applet, it doesn't necessarily
have a listener. The listener was sparsely used there, just to retrieve
the task function, update the listeners' stats, and set the analysers
and default target, both of which are often zero from applets. Thus
these elements are now initialized with default values that the caller
is free to change if desired.
2015-04-06 11:37:35 +02:00
Willy Tarreau
fb9f584956 CLEANUP: frontend: remove one useless local variable
"p" was a copy of sess->fe which itself is also used. It's used in a
few cases, let's remove it and reduce the code as well.
2015-04-06 11:37:35 +02:00
Willy Tarreau
c8815efb06 MEDIUM: frontend: move some remaining stream settings to stream_new()
The auto-forwarding mechanism in case no analyser is set is generic
to the streams. Also the timeouts on the client side are better preset
in the stream initialization as well.
2015-04-06 11:37:35 +02:00
Willy Tarreau
e0232f1e33 MEDIUM: frontend: don't restrict frontend_accept() to connections anymore
Now it can also initialize streams initiated by applets. This will be
needed for HTTP/2.
2015-04-06 11:37:35 +02:00
Willy Tarreau
f9d1bc6d9a MEDIUM: frontend: move the fd-specific settings to session_accept_fd()
The frontend is generic and does not depend on a file descriptor,
so applying some socket options to the incoming fd is not its role.
Let's move the setsockopt() calls earlier in session_accept_fd()
where others are done as well.
2015-04-06 11:37:35 +02:00
Willy Tarreau
99eb0f13bc MEDIUM: frontend: move some stream initialisation to stream_new()
This is mostly what is related to logging, and which is more of
a stream initialization than anything frontend-specific.
2015-04-06 11:37:35 +02:00
Willy Tarreau
02d863866d MEDIUM: stream: return the stream upon accept()
The function was called stream_accept_session(), let's rename it
stream_new() and make it return the newly allocated pointer. It's
more convenient for some callers who need it.
2015-04-06 11:37:34 +02:00
Willy Tarreau
c5a7ff4a86 MEDIUM: frontend: make ->accept only return +/-1
This function was specified as being able to return 3 states, which had
repercussions to the stream accept function. It was used at the time
when the frontend would do the monitoring itself. This is not the case
anymore, so let's simplify this.
2015-04-06 11:37:34 +02:00
Willy Tarreau
342bfb180c MEDIUM: peers: make use of stream_accept_session()
Instead of going through some obscure initialization sequences, we now
rely on the stream code to initialize our stream. Some parts are still
a bit tricky as we cannot call the frontend's accept code which is only
made for appctx in input. So part of the initialization past the stream
code is what ought to be in the frontend code instead. Still, even
without this, these are 71 lines that were removed.
2015-04-06 11:37:34 +02:00
Willy Tarreau
470280ef63 MEDIUM: stream: also accept appctx as origin in stream_accept_session()
It's likely that the code could be simplified a bit though.
2015-04-06 11:37:34 +02:00
Willy Tarreau
f2b9874bcf MEDIUM: stream: isolate connection-specific initialization code
In stream_accept_session(), we perform some operations that explicitly
want a connection as the origin, but we'll soon have other types of
origin (eg: applet). Thus change the test to ensure we only call this
code with connections. Additionally, we refrain from calling fe->accept()
if the origin is not a connection, because for now the only fe->accept()
may only use a connection (frontend_accept).
2015-04-06 11:37:34 +02:00
Willy Tarreau
ce7eec9186 CLEANUP: stream.c: do not re-attach the connection to the stream
This was a leftover from the initial code, it's not needed at all
anymore.
2015-04-06 11:37:33 +02:00
Willy Tarreau
18b95a4b27 MINOR: session: set the CO_FL_CONNECTED flag on the connection once ready
If we know there's no handshake, we must set the flag on the connection,
it's not the job of the stream initializer to do it.
2015-04-06 11:37:33 +02:00
Willy Tarreau
8baf906366 MEDIUM: peers: initialize the task before the stream
Thanks to this we should be able to make use of stream_accept_session()
now.
2015-04-06 11:37:33 +02:00
Willy Tarreau
4099a7c273 MINOR: peers: make use of session_new() when creating a new session
It's better than open-coding it.
2015-04-06 11:37:33 +02:00
Willy Tarreau
64beab202c MINOR: session: make use of session_new() when creating a new session
It's better than open-coding it.
2015-04-06 11:37:33 +02:00
Willy Tarreau
c38f71cfcd MINOR: session: introduce session_new()
This one creates a new session and does the minimum initialization.
2015-04-06 11:37:33 +02:00
Willy Tarreau
d990baf0cc MEDIUM: peers: move the appctx initialization earlier
The purpose is to initialize the appctx prior to the stream in
order to reuse stream_accept_session().
2015-04-06 11:37:32 +02:00
Willy Tarreau
a7513f5d00 MINOR: stream-int: make appctx_new() take the applet in argument
Doing so simplifies the initialization of a new appctx. We don't
need appctx_set_applet() anymore.
2015-04-06 11:37:32 +02:00
Willy Tarreau
9903f0e1a2 REORG: session: move the session parts out of stream.c
This concerns everythins related to accepting a new session and
expiring the embryonic session. There's still a hard-coded call
to stream_accept_session() which could be set somewhere in the
frontend, but for now it's not a problem.
2015-04-06 11:37:32 +02:00
Willy Tarreau
32990b531b MEDIUM: session: remove the task pointer from the session
Now that the previous changes were made, we can add a struct task
pointer to stream_complete() and get rid of it in struct session.

The new relation between connection, session and task are like this :

          orig -- sess <-- context
           |                   |
           v                   |
          conn -- owner ---> task

Some session-specific parts should now move away from stream.
2015-04-06 11:37:32 +02:00