Commit Graph

2039 Commits

Author SHA1 Message Date
Willy Tarreau
df6f0d1e49 [MINOR] halog: gain back performance before SKIP_CHAR fix
The SKIP_CHAR fix caused a measurable performance drop. Since we can
consider all chars below 0x20 as delimiters, we can avoid a cache lookup
which requires a char to pointer conversion.
2011-07-11 06:48:03 +02:00
Willy Tarreau
70c428f7c6 [MINOR] halog: add support for HTTP log matching (-H)
Now it's possible to restrict analysis to HTTP-looking logs when passing -H.
-H -v gives the opposite (most likely TCP logs).
2011-07-11 06:48:03 +02:00
Willy Tarreau
c82570edec [MINOR] halog: make SKIP_CHAR stop on field delimiters
The SKIP_CHAR() macro did not consider field delimiters, causing the timer parser
to be able to search timers at wrong places when fed with TCP logs.
2011-07-11 06:48:02 +02:00
Willy Tarreau
812e7a73b2 [BUG] halog: correctly handle truncated last line
If last line is truncated (eg: truncated file), then halog would loop on
it forever.
2011-07-11 06:48:02 +02:00
Willy Tarreau
b3eb221e78 [MEDIUM] http: add support for 'cookie' and 'set-cookie' patterns
This is used to perform cookie-based stickiness with table replication
between multiple masters and across restarts. This partially overrides
some of the appsession capabilities.
2011-07-01 16:16:17 +02:00
Willy Tarreau
d8dc99f68d [DOC] add missing entry or stick store-response 2011-07-01 11:33:25 +02:00
Simon Horman
fa46168c8f [MINOR] Add non-stick server option
Never add connections allocated to this sever to a stick-table.
This may be used in conjunction with backup to ensure that
stick-table persistence is disabled for backup servers.
2011-06-25 21:14:17 +02:00
Simon Horman
de072bd8ff [CLEANUP] Remove unnecessary casts
There is no need to cast when going to or from void *
2011-06-25 21:14:10 +02:00
Simon Horman
ab814e0a6b [MINOR] Add rdp_cookie pattern fetch function
This pattern fetch function extracts the value of the rdp cookie <name> as
a string and uses this value to match. This enables implementation of
persistence based on the mstshash cookie. This is typically done if there
is no msts cookie present.

This differs from "balance rdp-cookie" in that any balancing algorithm may
be used and thus the distribution of clients to backend servers is not
linked to a hash of the RDP cookie. It is envisaged that using a balancing
algorithm such as "balance roundrobin" or "balance leastconnect" will lead
to a more even distribution of clients to backend servers than the hash
used by "balance rdp-cookie".

Example :
	listen tse-farm
	    bind 0.0.0.0:3389
	    # wait up to 5s for an RDP cookie in the request
	    tcp-request inspect-delay 5s
	    tcp-request content accept if RDP_COOKIE
	    # apply RDP cookie persistence
	    persist rdp-cookie
	    # Persist based on the mstshash cookie
	    # This is only useful makes sense if
	    # balance rdp-cookie is not used
	    stick-table type string size 204800
	    stick on rdp_cookie(mstshash)
	    server srv1 1.1.1.1:3389
	    server srv1 1.1.1.2:3389
2011-06-25 21:07:02 +02:00
Simon Horman
e869176486 [MINOR] Make appsess{,ion}_refresh static
apsession_refresh() and apsess_refressh are only used inside apsession.c
and thus can be made static.

The only use of apsession_refresh() is appsession_task_init().
These functions have been re-ordered to avoid the need for
a forward-declaration of apsession_refresh().
2011-06-25 21:07:01 +02:00
Simon Horman
752dc4ab2d [MINOR] Add down termination condition
If a connection is closed by because the backend became unavailable
then log 'D' as the termination condition.

Signed-off-by: Simon Horman <horms@verge.net.au>
2011-06-21 22:10:56 +02:00
Simon Horman
e0d1bfb4c1 [MINOR] Allow shutdown of sessions when a server becomes unavailable
This adds the "on-marked-down shutdown-sessions" statement on "server" lines,
which causes all sessions established on a server to be killed at once when
the server goes down. The task's priority is reniced to the highest value
(1024) so that servers holding many tasks don't cause a massive slowdown due
to the wakeup storm.
2011-06-21 22:00:21 +02:00
Simon Horman
af51495397 [MINOR] Add active connection list to server
The motivation for this is to allow iteration of all the connections
of a server without the expense of iterating over the global list
of connections.

The first use of this will be to implement an option to close connections
associated with a server when is is marked as being down or in maintenance
mode.
2011-06-21 22:00:12 +02:00
Simon Horman
dec5be4ed4 [CLEANUP] session.c: Make functions static where possible 2011-06-18 20:27:19 +02:00
Simon Horman
96553775a0 [CLEANUP] peers.h: fix declarations
* The declaration of peer_session_create() does
  not match its definition. As it is only
  used inside of peers.c make it static.

* Make the declaration of peers_register_table()
  match its definition.

* Also, make all functions in peers.c that
  are not also in peers.h static
2011-06-18 20:27:19 +02:00
Simon Horman
70735c98f7 [CLEANUP] Remove assigned but unused variables
gcc (Debian 4.6.0-2) 4.6.1 20110329 (prerelease)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

...
src/proto_http.c:3029:14: warning: variable ‘del_cl’ set but not used [-Wunused-but-set-variable]
In file included from ebtree/eb64tree.c:23:0:
ebtree/eb64tree.h: In function ‘__eb64_lookup’:
ebtree/eb64tree.h:128:6: warning: variable ‘node_bit’ set but not used [-Wunused-but-set-variable]
ebtree/eb64tree.h: In function ‘__eb64i_lookup’:
ebtree/eb64tree.h:180:6: warning: variable ‘node_bit’ set but not used [-Wunused-but-set-variable]
In file included from ebtree/ebpttree.h:26:0,
                 from ebtree/ebimtree.c:23:
ebtree/eb64tree.h: In function ‘__eb64_lookup’:
ebtree/eb64tree.h:128:6: warning: variable ‘node_bit’ set but not used [-Wunused-but-set-variable]
ebtree/eb64tree.h: In function ‘__eb64i_lookup’:
ebtree/eb64tree.h:180:6: warning: variable ‘node_bit’ set but not used [-Wunused-but-set-variable]
In file included from ebtree/ebpttree.h:26:0,
                 from ebtree/ebistree.h:25,
                 from ebtree/ebistree.c:23:
ebtree/eb64tree.h: In function ‘__eb64_lookup’:
ebtree/eb64tree.h:128:6: warning: variable ‘node_bit’ set but not used [-Wunused-but-set-variable]
ebtree/eb64tree.h: In function ‘__eb64i_lookup’:
ebtree/eb64tree.h:180:6: warning: variable ‘node_bit’ set but not used [-Wunused-but-set-variable]
2011-06-18 20:21:33 +02:00
Simon Horman
619e3cc245 [MINOR] Allow showing and clearing by key of string stick tables 2011-06-17 11:39:30 +02:00
Simon Horman
cec9a22780 [MINOR] Allow showing and clearing by key of integer stick tables 2011-06-17 11:39:30 +02:00
Simon Horman
c5b89f6495 [MINOR] Allow showing and clearing by key of ipv6 stick tables 2011-06-17 11:39:30 +02:00
Simon Horman
c88b887d8d [MINOR] More flexible clearing of stick table
* Allow clearing of all entries of a table
* Allow clearing of all entries of a table
  that match a data filter
2011-06-17 11:39:29 +02:00
Simon Horman
d5b9fd9591 [MINOR] Break out all stick table socat command parsing
This will allow reuse for clearing table entries
other than by key
2011-06-17 11:39:29 +02:00
Simon Horman
17bce34a20 [MINOR] Allow listing of stick table by key 2011-06-17 11:39:29 +02:00
Simon Horman
121f305f3b [MINOR] Break out processing of clear table
This will allow the code to be reused
for showing a table filtered by key
2011-06-17 11:39:29 +02:00
Simon Horman
d936658b7b [MINOR] Break out dumping table
This will allow the code to be reused
for showing a table filtered by key

Signed-off-by: Simon Horman <horms@verge.net.au>
2011-06-17 11:39:28 +02:00
Simon Horman
9bd2c73916 [CLEANUP] dumpstats: make symbols static where possible 2011-06-17 11:39:28 +02:00
Hervé COMMOWICK
212f778d6a [BUG] checks: fix support of Mysqld >= 5.5 for mysql-check
mysqld >= 5.5 want the client to announce 4.1+ authentication support, even if we have no password, so we do this.
I also check on a debian potato mysqld 3.22 and it works too so i assume we are good from 3.22 to 5.5.

[WT: this must be backported to 1.4]
2011-06-17 11:18:52 +02:00
Willy Tarreau
ab1a3e97a4 [CLEANUP] config: remove some left-over printf debugging code from previous patch
Last patch fbb784 unexpectedly left some debugging printf messages which can be
seen in debug mode.
2011-06-14 07:49:12 +02:00
Willy Tarreau
fbb78421d4 [MINOR] config: automatically compute a default fullconn value
The fullconn value is not easy to get right when doing dynamic regulation,
as it should depend on the maxconns of the frontends that can reach a
backend. Since the parameter is mandatory, many configs are found with
an inappropriate default value.

Instead of rejecting configs without a fullconn value, we now set it to
10% of the sum of the configured maxconns of all the frontends which are
susceptible to branch to the backend. That way if new frontends are added,
the backend's fullconn automatically adjusts itself.
2011-06-05 15:43:27 +02:00
Simon Horman
df791f59b7 [DOC] Minor spelling fixes and grammatical enhancements 2011-05-31 22:54:17 +02:00
Willy Tarreau
bf9c2fcd93 [BUG] stats: support url-encoded forms
Bashkim Kasa reported that the stats admin page did not work when colons
were used in server or backend names. This was caused by url-encoding
resulting in ':' being sent as '%3A'. Now we systematically decode the
field names and values to fix this issue.
2011-05-31 22:44:28 +02:00
Willy Tarreau
44702af019 [MINOR] config: make it possible to specify a cookie even without a server
Since version 1.0.0, it's forbidden to have a cookie specified without at
least one server. This test is useless and makes it complex to write APIs
to iteratively generate working configurations. Remove the test.
2011-05-31 06:44:04 +02:00
Willy Tarreau
14acc7072e [OPTIM] stream_sock: don't use splice on too small payloads
It's more expensive to call splice() on short payloads than to use
recv()+send(). One of the reasons is that doing a splice() involves
allocating a pipe. One other reason is that the kernel will have to
copy itself if we try to splice less than a page. So let's fix a
short offset of 4kB below which we don't splice.

A quick test shows that on chunked encoded data, with splice we had
6826 syscalls (1715 splice, 3461 recv, 1650 send) while with this
patch, the same transfer resulted in 5793 syscalls (3896 recv, 1897
send).
2011-05-30 18:42:41 +02:00
Willy Tarreau
22be90b8db [OPTIM] stream_sock: avoid fast-forwarding of partial data
Fast-forwarding between file descriptors is nice but can be counter-productive
when only one part of the buffer is forwarded, because it can result in doubling
the number of send() syscalls. This is what happens on HTTP chunking, because
the chunk data are sent, then the CRLF + next chunk size are parsed and immediately
scheduled for forwarding. This results in two send() for the same block while a
single one would have done it.
2011-05-30 18:42:41 +02:00
Willy Tarreau
0729303fb0 [OPTIM] http: optimize chunking again in non-interactive mode
Now that we support the http-no-delay mode, we can optimize HTTP
chunking again by always waiting for more data to come until the
last chunk is met.

This patch may or may not be backported to 1.4, it's not a big deal,
it will mainly help for chunks which are aligned with the buffer size.
2011-05-30 18:42:41 +02:00
Willy Tarreau
96e312139a [MEDIUM] http: add support for "http-no-delay"
There are some very rare server-to-server applications that abuse the HTTP
protocol and expect the payload phase to be highly interactive, with many
interleaved data chunks in both directions within a single request. This is
absolutely not supported by the HTTP specification and will not work across
most proxies or servers. When such applications attempt to do this through
haproxy, it works but they will experience high delays due to the network
optimizations which favor performance by instructing the system to wait for
enough data to be available in order to only send full packets. Typical
delays are around 200 ms per round trip. Note that this only happens with
abnormal uses. Normal uses such as CONNECT requests nor WebSockets are not
affected.

When "option http-no-delay" is present in either the frontend or the backend
used by a connection, all such optimizations will be disabled in order to
make the exchanges as fast as possible. Of course this offers no guarantee on
the functionality, as it may break at any other place. But if it works via
HAProxy, it will work as fast as possible. This option should never be used
by default, and should never be used at all unless such a buggy application
is discovered. The impact of using this option is an increase of bandwidth
usage and CPU usage, which may significantly lower performance in high
latency environments.

This change should be backported to 1.4 since the first report of such a
misuse was in 1.4. Next patch will also be needed.
2011-05-30 18:42:41 +02:00
Willy Tarreau
f8ca19bcd9 [CLEANUP] stream_sock: remove unneeded FL_TCP and factor out test
The FL_TCP flag was a leftover from the old days we were using TCP_CORK.
With MSG_MORE it's not needed anymore so we can remove the condition and
sensibly simplify the test.
2011-05-30 18:42:40 +02:00
Willy Tarreau
8f8b492295 [MINOR] stream_sock: always clear BF_EXPECT_MORE upon complete transfer
When sending is complete, it's preferred to systematically clear the flags
that were set for that transfer. What could happen is that the to_forward
counter had caused the MSG_MORE flag to be set and BF_EXPECT_MORE not to
be cleared, resulting in this flag being unexpectedly maintained for next
round.

The code has taken extreme care of not doing this till now, but it's not
acceptable that the caller has to know these precise semantics. So let's
unconditionnally clear the flag instead.

For the sake of safety, this fix should be backported to 1.4.
2011-05-30 18:42:40 +02:00
Willy Tarreau
5c62092ca1 [MINOR] http: partially revert the chunking optimization for now
Commit 57f5c1 used to provide a nice improvement on chunked encoding since
it ensured that we did not set a PUSH flag for every chunk or buffer data
part of a chunked transfer.

Some applications appear to erroneously abuse HTTP chunking in order to
get interactive exchanges between a user agent and an origin server with
very small chunks. While it happens to work through haproxy, it's terribly
slow due to the latency added after passing each chunk to the system, who
could wait up to 200ms before pushing them onto the wire.

So we need an interactive mode for such usages. In the mean time, step back
on the optim, but not completely, so that we still keep the flag as long as
we know we're not finished with the current chunk.

This change should be backported to 1.4 too as the issue was discovered
with it.
2011-05-11 20:17:42 +02:00
Willy Tarreau
ae94d4df8f [MINOR] http: make the "HTTP 200" status code configurable.
This status code is used in response to requests matching "monitor-uri".
Some users need to adjust it to fit their needs (eg: make some strings
appear there). As it's already defined as a chunked string and used
exactly like other status codes, it makes sense to make it configurable
with the usual "errorfile", "errorloc", ...
2011-05-11 16:31:43 +02:00
Willy Tarreau
436d9ed808 [REORG] http: move HTTP error codes back to proto_http.h
This one was left isolated in its own file. It probably is a leftover
from the 1.2->1.3 split.
2011-05-11 16:31:43 +02:00
Willy Tarreau
027a85bb03 [MINOR] http: don't report the "haproxy" word on the monitoring response
Some people like to make the monitoring URL testable from unsafe locations.
Reporting haproxy's existence there can sometimes be problematic. This patch
should not be backported to 1.4 because it is possible, eventhough unlikely,
that some scripts rely on this word to appear there.
2011-05-11 16:31:43 +02:00
Cyril Bonté
7c51a732f7 [BUG] fix binary stick-tables
As reported by Lauri-Alo Adamson, version 1.5-dev6 doesn't support
stick-tables with a binary type.
This issue was introduced in the commit 4f92d32 where a line was erroneously
deleted, and is 1.5-specific.
2011-05-09 23:30:58 +02:00
Willy Tarreau
96dd079b49 [BUG] proto_tcp: fix address binding on remote source
Mark Brooks reported that commit 1b4b7c broke tproxy in 1.5-dev6. Nick
Chalk tracked the issue down to a missing address family setting in
tcp_bind_socket() which resulted in a failure to use get_addr_len().
This issue is 1.5-specific.
2011-04-19 07:20:57 +02:00
Willy Tarreau
787aed5078 [DOC] fix minor typo in the "dispatch" doc
Bradley Falzon reported a left-over of a copy-paste from the "disabled"
keyword in the "dispatch" section.
2011-04-15 06:45:37 +02:00
Willy Tarreau
a164fb5721 [BUG] checks: http-check expect could fail a check on multi-packet responses
Christopher Blencowe reported that the httpchk_expect() function was
lacking a test for incomplete responses : if the server sends only the
headers in the first packet and the body in a subsequent one, there is
a risk that the check fails without waiting for more data. A failure
rate of about 1% was reported.

This fix must be backported to 1.4.
2011-04-13 09:32:41 +02:00
Willy Tarreau
04df1125cf [RELEASE] Released version 1.5-dev6
Released version 1.5-dev6 with the following main changes :
    - [BUG] stream_sock: use get_addr_len() instead of sizeof() on sockaddr_storage
    - [BUG] TCP source tracking was broken with IPv6 changes
    - [BUG] stick-tables did not work when converting IPv6 to IPv4
    - [CRITICAL] fix risk of crash when dealing with space in response cookies
2011-04-08 00:56:41 +02:00
Willy Tarreau
1fc1f45618 [CRITICAL] fix risk of crash when dealing with space in response cookies
When doing fix 24581bae02 to correctly handle
response cookies, an unfortunate typo was inserted in the less likely code
path, resulting in a risk of crash when cookie-based persistence is enabled
and the server emits a cookie with several spaces around the equal sign.

This bug was noticed during a code backport. Its effects were never reported
because this situation is very unlikely to appear, but it can be provoked on
purpose by the server.

This patch must be backported to 1.4 versions which contain the fix above
(anything > 1.4.8), and to similar 1.3 versions > 1.3.25. 1.5-dev versions
after 1.5-dev2 are affected too.
2011-04-08 00:50:36 +02:00
Willy Tarreau
442452034e [BUG] stick-tables did not work when converting IPv6 to IPv4
A stick-table of type IPv6 would store a wrong IPv4 address as the
result of an IPv6 to IPv4 conversion. This bug was introduced in
1.5-dev5.
2011-04-07 10:53:30 +02:00
Willy Tarreau
c9f6011760 [BUG] TCP source tracking was broken with IPv6 changes
John Helliwell reported a bug when using TCP source address
tracking on Solaris. The bug was introduced in haproxy 1.5-dev5.
2011-04-07 10:53:25 +02:00
Willy Tarreau
1b4b7ce6dd [BUG] stream_sock: use get_addr_len() instead of sizeof() on sockaddr_storage
John Helliwell reported a runtime issue on Solaris since 1.5-dev5. Traces
show that connect() returns EINVAL, which means the socket length is not
appropriate for the family. Solaris does not like being called with sizeof
and needs the address family's size on sockaddr_storage.

The fix consists in adding a get_addr_len() function which returns the
socket's address length based on its family. Tests show that this works
for both IPv4 and IPv6 addresses.
2011-04-05 16:56:50 +02:00