2123 Commits

Author SHA1 Message Date
Willy Tarreau
96c148b0d2 [MINOR] halog: do not consider byte 0x8A as end of line
A bug in the algorithm used to find an LF in multiple bytes at once
made byte 0x80 trigger detection of byte 0x00, thus 0x8A matches byte
0x0A. In practice, this issue never happens since byte 0x8A won't be
displayed in logs (or it will be encoded). This could still possibly
happen in mixed logs.
2011-09-09 08:21:55 +02:00
Willy Tarreau
52b2d228ed [MEDIUM] stats: offer the possibility to kill sessions by server
It's now possible to issue "shutdown sessions server <back/srv>" and have
all this server's sessions immediately killed.
2011-09-07 23:56:16 +02:00
Willy Tarreau
d52c41ea2d [CLEANUP] stats: centralize tests for backend/server inputs on the CLI
The tests were repeated many times. Let's put them at one single place.
2011-09-07 23:56:16 +02:00
Willy Tarreau
a295edc51c [MEDIUM] stats: offer the possibility to kill a session from the CLI
It's now possible to issue "shutdown session 0xXXXXXXXX" and have this
session immediately killed. Useful for long-running fantoms.
2011-09-07 23:56:16 +02:00
Willy Tarreau
a2a64e9689 [MEDIUM] session: make session_shutdown() an independant function
We already had the ability to kill a connection, but it was only
for the checks. Now we can do this for any session, and for this we
add a specific flag "K" to the logs.
2011-09-07 23:01:56 +02:00
Willy Tarreau
532a450ebc [MEDIUM] stats: add the ability to enable/disable/shutdown a frontend at runtime
The stats socket now allows the admin to disable, enable or shutdown a frontend.
This can be used when a bug is discovered in a configuration and it's desirable
to fix it but the rules in place don't allow to change a running config. Thus it
becomes possible to kill the frontend to release the port and start a new one in
a separate process.

This can also be used to temporarily make haproxy return TCP resets to incoming
requests to pretend the service is not bound. For instance, this may be useful
to quickly flush a very deep SYN backlog.

The frontend check and lookup code was factored with the "set maxconn" usage.
2011-09-07 22:50:52 +02:00
Willy Tarreau
c03ebbfca4 [BUG] peers: ensure the peers are resumed if they were paused
Upon an incoming soft restart request, we first pause all frontends and
peers. If the caller changes its mind and asks us to resume (eg: failed
binding), we must resume all the frontends and peers. Unfortunately the
peers were not resumed.

The code was arranged to avoid code duplication (which used to hide the
issue till now).
2011-09-07 22:47:43 +02:00
Willy Tarreau
122541c06a [BUG] peers: don't keep a peers section which has a NULL frontend
If a peers section has no peer named as the local peer, we must destroy
it, otherwise a NULL peer frontend remains in the lists and a segfault
can happen upon a soft restart.

We also now report the missing peer name in order to help troubleshooting.
2011-09-07 22:47:43 +02:00
Willy Tarreau
ce8fe259b5 [CLEANUP] proxy: make pause_proxy() perform the required controls and emit the logs
It avoids duplicated code in the caller.
2011-09-07 22:47:43 +02:00
Willy Tarreau
b249e8454c [BUG] peers: the peer frontend must not emit any log
Peers' frontends must have logging disabled by default, which was not
the case, so logs were randomly emitted upon restart, sometimes causing
a new process to fail to replace the old one.
2011-09-07 22:47:43 +02:00
Willy Tarreau
3c63fd828a [MEDIUM] don't limit peers nor stats socket to maxconn nor maxconnrate
The peers and the stats socket are control sockets, they must not be
limited by traffic rules.
2011-09-07 22:47:42 +02:00
Willy Tarreau
3ae65a16b9 [BUG] peers: don't pre-allocate 65000 connections to each peer
This made sense a long time ago but since the maxconn is dynamically
computed from the tracking tables, it does not make any sense anymore
and will harm future changes.
2011-09-07 22:47:42 +02:00
Willy Tarreau
f5b22875cd [MEDIUM] stats: add the ability to adjust the global maxconnrate
Using "set rate-limit connections global <xxx>" on the CLI, we can now
adjust the per-process connection rate limiting (equal to global.maxconnrate).
2011-09-07 22:47:42 +02:00
Willy Tarreau
9cd552d8f4 [MINOR] stats: report the current and max global connection rates
The HTML page reports the current process connection rate, and the
"show info" command on the stats socket also reports the conn rate
limit and the max conn rate that was once reached.

Note that the max value can be cleared using "clear counters".
2011-09-07 22:47:42 +02:00
Willy Tarreau
81c25d0ee6 [MEDIUM] add support for global.maxconnrate to limit the per-process conn rate.
This one enforces a per-process connection rate limit, regardless of what
may be set per frontend. It can be a way to limit the CPU usage of a process
being severely attacked.

The side effect is that the global process connection rate is now measured
for each incoming connection, so it will be possible to report it.
2011-09-07 22:47:42 +02:00
Willy Tarreau
91886b692a [MEDIUM] stats: add the "set maxconn" setting to the command line interface
This option permits to change the global maxconn setting within the
limit that was set by the initial value, which is now reported as the
hard maxconn value. This allows to immediately accept more concurrent
connections or to stop accepting new ones until the value passes below
the indicated setting.

The main use of this option is on systems where many haproxy instances
are loaded and admins need to re-adjust resource sharing at run time
to regain a bit of fairness between processes.
2011-09-07 22:47:41 +02:00
Willy Tarreau
abacc2cfd1 [CLEANUP] remove a useless test in manage_global_listener_queue()
The test for the empty list was done twice.
2011-09-07 18:09:27 +02:00
Willy Tarreau
c2adf8b906 [MEDIUM] stats: disable complex socket reservation for stats socket
The way the unix socket is initialized is awkward. Some of the settings are put
in the sockets itself, other ones in the backend. And more importantly the
global.maxsock value is adjusted so that the stats socket evades the global
maxconn value. This complexifies maxsock computations for nothing, since the
stats socket is not supposed to receive hundreds of concurrent connections when
the global maxconn is very low. What is needed however is to ensure that there
are always connections left for the stats socket even when traffic sockets are
saturated, but this guarantee is not offered anymore by current code.

So as of now, the stats socket is subject to the global maxconn limitation just
as any other socket until a reservation mechanism is implemented.
2011-09-07 18:05:48 +02:00
Willy Tarreau
46fa8355c0 [CLEANUP] remove dirty left-over of a debugging message
This debug message was added in commit e9b2602a and not noticed once
committed.
2011-09-07 11:55:40 +02:00
Willy Tarreau
61a40c7402 [MINOR] halog: support backslash-escaped quotes
Some syslog servers escape quotes, which make the resulting logs unusable
for URL processing since the parser looks for the first field beginning
with a quote. It now supports also fields starting with backslash and
quote in order to address this. No performance impact was measured.
2011-09-06 08:11:27 +02:00
Willy Tarreau
d3007ffa6f [MINOR] halog: add -hs/-HS to filter by HTTP status code range
The code was merged with the error code checking which is very similar and
which shares the same information. The new test adds about 1% slowdown to
error checking but makes it more reliable when facing wrongly formated
status codes.
2011-09-05 02:09:24 +02:00
Willy Tarreau
b48f958e05 [CLEANUP] cfgparse: fix reported options for the "bind" keyword 2011-09-05 01:17:06 +02:00
Willy Tarreau
8263b91a53 [DOC] add a few old and uncommitted docs
These docs were still lying in my directory uncommitted. They're not
very important but can be useful for developers who seek info about
internals.
2011-09-05 01:04:44 +02:00
Willy Tarreau
ad14f753ea [MINOR] http: take a capture of bad content-lengths.
Sometimes a bad content-length header is encountered and this causes
an abort. It's hard to debug without a trace, so let's take a capture
of the contents when this happens.
2011-09-05 00:54:57 +02:00
Willy Tarreau
3b8c08a174 [MINOR] http: take a capture of truncated responses
If a server starts to respond but stops before the body, then we
capture the truncated response. We don't do this on the request
because it would happen too often upon stupid attacks.
2011-09-05 00:54:56 +02:00
Willy Tarreau
fec4d89b24 [MINOR] http: take a capture of too large requests and responses
It's hard to prove a request or response is too large if there is no
capture, so let's take a snapshot of those too.
2011-09-05 00:54:56 +02:00
Willy Tarreau
509433391a [MINOR] stats: display "<NONE>" instead of the frontend name when unknown
"show sess" should display "<NONE>" instead of the frontend's name as
the backend's.
2011-09-05 00:54:56 +02:00
Willy Tarreau
588bd4f813 [BUG] http: trailing white spaces must also be trimmed after headers
Trailing spaces after headers were not trimmed, only the leading ones
were. An issue was detected today with a content-length value which
was padded with spaces and which was rejected. Recent updates to the
http-bis draft made it a lot more clear that such spaces must be ignored,
so this is what this patch does.

It should be backported to 1.4.
2011-09-05 00:54:56 +02:00
Willy Tarreau
631f01c2f1 [MINOR] make use of addr_to_str() and get_host_port() to replace many inet_ntop()
Many inet_ntop calls were partially right, which was hard to detect given
the complex combinations. Some of them were relying on the listener's proto
instead of the address itself, which could have been different when dealing
with an accept-proxy connection.

The new addr_to_str() function does the dirty job and returns the family, which
makes it particularly suited to calls from switch/case statements. A large number
of if/else statements were removed and the stats output could even be cleaned up
in the case of session dump.

As a side effect of doing this, the resulting code is smaller by almost 1kB.
All changed parts have been tested and provided expected output.
2011-09-05 00:54:36 +02:00
Willy Tarreau
3c92c5f682 [DOC] fixed a few "sensible" -> "sensitive" errors
Similar words in different languages meaning different things...
Reported by Bryce Jasmer.
2011-09-05 00:54:36 +02:00
Willy Tarreau
86ad42c5b7 [MINOR] make use of set_host_port() and get_host_port() to get rid of family mismatches
This also simplifies the code and makes it more auditable.
2011-09-05 00:54:35 +02:00
Willy Tarreau
542a31d6c3 [BUG] backend: risk of picking a wrong port when mapping is used with crossed families
A similar issue as the previous one causes port mapping to fail in some
combinations of client and server address families. Using the macros fixes
the issue.
2011-08-27 12:07:49 +02:00
Willy Tarreau
48da04a6af [BUG] checks: use the correct destination port for sending checks
In the number of switch/case statements added for IPv6 changes,
one was wrong and caused the check port to be ignored for outgoing
connection because the socket's family was not taken at the right
place. Use the set_host_port() macro instead to fix the issue.

The same cleanup could be performed at a number of other places
and should follow shortly.

Special thanks to Stephane Bakhos of Techboom for reporting a
detailed analysis of this bug.
2011-08-27 11:51:36 +02:00
Willy Tarreau
e17a8d02d9 [BUG] possible crash in 'show table' on stats socket
Patch d5b9fd95 was missing an initialisation of "ctx.table.target", which caused
"show table" to segfault if it was issued after a "show errors" (target pointer == -1).
2011-08-24 08:23:34 +02:00
Willy Tarreau
c9ebc446b8 [CLEANUP] update the year in the copyright banner
It was still 2010 !
2011-08-23 00:23:54 +02:00
Willy Tarreau
43d8fb2d3a [REORG] build: move syscall redefinition to specific places
Some older libc don't define splice() and and don't define _syscall*()
either, which causes build errors if splicing is enabled.

To solve this, we now split the syscall redefinition into two layers :
  - one file per syscall (epoll, splice)
  - one common file to declare the _syscall*() macros

The code is cleaner because files using the syscalls just have to include
their respective file. It's not adviced to merge multiple syscall families
into a same file if all are not intended to be used simultaneously, because
defining unused static functions causes warnings to be emitted during build.

As a result, the new USE_MY_SPLICE parameter was added in order to be able
to define the splice() syscall separately.
2011-08-23 00:11:25 +02:00
Willy Tarreau
87cf51406c [MEDIUM] http: make x-forwarded-for addition conditional
If "option forwardfor" has the "if-none" argument, then the header is
only added when the request did not already have one. This option has
security implications, and should not be set blindly.
2011-08-19 22:57:24 +02:00
Willy Tarreau
1ee51a6581 [BUG] check: http-check expect + regex would crash in defaults section
Manoj Kumar reported a case where haproxy would crash upon start-up. The
cause was an "http-check expect" statement declared in the defaults section,
which caused a NULL regex to be used during the check. This statement is not
allowed in defaults sections precisely because this requires saving a copy
of the regex in the default proxy. But the check was not made to prevent it
from being declared there, hence the issue.

Instead of adding code to detect its abnormal use, we decided to implement
it. It was not that much complex because the expect_str part was not used
with regexes, so it could hold the string form of the regex in order to
compile it again for every backend (there's no way to clone regexes).

This patch has been tested and works. So it's both a bugfix and a minor
feature enhancement.

It should be backported to 1.4 though it's not critical since the config
was not supposed to be supported.
2011-08-19 20:14:01 +02:00
Simon Horman
8effd3de5b [MINOR] Use DPRINTF in assign_server()
Use DPRINTF in assign_server() rather than open-coding its logic.
2011-08-18 23:52:36 +02:00
Simon Horman
7abd00d7eb [MINOR] Fix build error in stream_int_register_handler()
There is no parameter or variable fct in stream_int_register_handler()
so the build fails when DPRINTF is active.
2011-08-18 23:52:36 +02:00
Simon Horman
64b28d0727 [MINOR] Correct type in table dump examples
When dumping tables the table type is displayed
as a type name  not an integer.
2011-08-18 23:52:36 +02:00
Simon Horman
d281eedc07 [MEDIUM] Correct ipmask() logic
The netmask applied to table entries as configured using ipmask() is
stored in arg_p->data.ip not arg_i (which will be 1 if the netmask is set).
2011-08-18 23:52:35 +02:00
Simon Horman
8b7b05a92d [MEDIUM] Fix stick-table replication on soft-restart
"[MINOR] session: add a pointer to the new target into the session" (664beb8)
introduced a regression by changing the type of a peer's target from
TARG_TYPE_PROXY to TARG_TYPE_NONE. The effect of this is that during
a soft-restart the new process no longer tries to connect to the
old process to replicate its stick tables.

This patch sets the type of a peer's target as TARG_TYPE_PROXY and
replication on soft-restart works once again.
2011-08-18 23:52:35 +02:00
Willy Tarreau
f73cd1198f [MINOR] session-counters: add the ability to clear the counters
Sometimes it can be useful to reset a counter : one condition increments
it and another one resets it. It can be used to better detect abuses.
2011-08-13 01:45:16 +02:00
Herv COMMOWICK
927cdddf9c [MINOR] halog: add support for termination code matching (-tcn/-TCN)
It is now possible to filter by termination code with -tcn <termcode>, to be
able to track one kind of errors, for example after counting it with -tc.
Use -TCN <termcode> gives you the opposite.
2011-08-10 18:04:50 +02:00
Willy Tarreau
1620ec39a7 [MEDIUM] checks: group health checks methods by values and save option bits
Adding health checks has become a real pain, with cross-references to all
checks everywhere because they're all a single bit. Since they're all
exclusive, let's change this to have a check number only. We reserve 4
bits allowing up to 16 checks (15+tcp), only 7 of which are currently
used. The code has shrunk by almost 1kB and we saved a few option bits.

The "dispatch" option has been moved to px->options, making a few tests
a bit cleaner.
2011-08-06 17:08:40 +02:00
Herv COMMOWICK
a3eb39ca62 [DOC] small fixes to clearly distinguish between keyword
and variables

Variables needs to be presented inside <> to be distinguished from keywords
2011-08-06 15:52:52 +02:00
Herv COMMOWICK
ec032d63a6 [MINOR] check: add redis check support
This patch provides a new "option redis-check" statement to enable server health checks based on redis PING request (http://www.redis.io/commands/ping).
2011-08-06 15:52:47 +02:00
Herv COMMOWICK
daa824e513 [MINOR] acl: add srv_conn acl to count connections on a
specific backend server

These ACLs are used to check the number of active connections on the specified server in the specified backend.
2011-08-06 15:52:27 +02:00
Willy Tarreau
2a0f4d27a4 [MEDIUM] stats: add support for changing frontend's maxconn at runtime
The new "set maxconn frontend XXX" statement on the stats socket allows
the admin to change a frontend's maxconn value. If some connections are
queued, they will immediately be accepted up to the new limit. If the
limit is lowered, new connections acceptation might be delayed. This can
be used to temporarily reduce or increase the impact of a specific frontend's
traffic on the whole process.
2011-08-02 11:49:05 +02:00