Commit Graph

1878 Commits

Author SHA1 Message Date
Willy Tarreau
57f5c12c04 [OPTIM] http: don't send each chunk in a separate packet
When forwarding chunk-encoded data, each chunk gets a TCP PUSH flag when
going onto the wire simply because the send() function does not know that
some data remain after it (next chunk). Now we set the BF_EXPECT_MORE flag
on the buffer if the chunk size is not null. That way we can reduce the
number of packets sent, which is particularly noticeable when forwarding
compressed data, especially as it requires less ACKs from the client.
2010-12-02 00:39:33 +01:00
Willy Tarreau
342b11c4d4 [BUG] http: do not re-enable the PROXY analyser on keep-alive
The PROXY analyser is connection-oriented and must only be set once. When
an HTTP transaction is done, we must not re-enable it.
2010-11-29 07:32:02 +01:00
Willy Tarreau
65ce3918af [DOC] update roadmap file 2010-11-29 07:32:02 +01:00
Willy Tarreau
798a39cdc9 [MEDIUM] hash: add support for an 'avalanche' hash-type
When the number of servers is a multiple of the size of the input set,
map-based hash can be inefficient. This typically happens with 64
servers when doing URI hashing. The "avalanche" hash-type applies an
avalanche hash before performing a map lookup in order to smooth the
distribution. The result is slightly less smooth than the map for small
numbers of servers, but still better than the consistent hashing.
2010-11-29 07:28:16 +01:00
Willy Tarreau
4c14eaa0d4 [CLEANUP] hash: move the avalanche hash code globally available
We'll use this hash at other places, let's make it globally available.
The function has also been renamed because its "chash_hash" name was
not appropriate.
2010-11-29 07:28:16 +01:00
Willy Tarreau
3c9a3fb0b8 [BUILD] add -fno-strict-aliasing to fix warnings with gcc >= 4.4
Gcc 4.4 enables strict aliasing by default, resuling in complaints
when casting struct sockaddr_storage to sockaddr_in. Not only doing
this does not provide any noticeable performance improvement, it also
presents a risk of strange bugs even when the compiler does not emit
a warning, so let's disable this optimization !
2010-11-28 08:57:53 +01:00
Willy Tarreau
a5899aaad5 [BUILD] add the CPU=native and ARCH=32/64 build options
Hank A. Paulson suggested to add CPU=native to optimize the code for
the build machine. This makes sense in a lot of situations. Since it
is often possible to have both 32 and 64 bits supported on recent
systems, the ARCH=32 and ARCH=64 build options were also added.
2010-11-28 07:49:59 +01:00
Willy Tarreau
26db59ea6b [BUG] http: correctly update the header list when removing two consecutive headers
When a header is removed, the previous header's next pointer is updated
to reflect the next of the current header. However, when cycling through
the loop, we update the prev pointer to point to the deleted header, which
means that if we delete another header, it's the deleted header's next
pointer that will be updated, leaving the deleted header in the list with
a null length, which is forbidden.

We must just not update the prev pointer after a removal.

This bug was present when either "reqdel" and "rspdel" removed two consecutive
headers. It could also occur when removing cookies in either requests or
responses, but since headers were the last header processing, the issue
remained unnoticed.

Issue reported by Hank A. Paulson.

This fix must be ported to 1.4 and possibly 1.3.
2010-11-28 07:06:23 +01:00
Willy Tarreau
b810554f8f [CRITICAL] cookies: mixing cookies in indirect mode and appsession can crash the process
Cookies in indirect mode are removed from the cookie header. Three pointers
ought to be updated when appsession cookies are processed next, but were not.
The result is that a memcpy() can be called with a negative value causing the
process to crash. It is not sure whether this can be remotely exploited or not.
(cherry picked from commit c5f3749aa3ccfdebc4992854ea79823d26f66213)
2010-11-28 07:06:22 +01:00
Willy Tarreau
77eb9b8a2d [BUG] appsession: fix possible double free in case of out of memory
In out of memory conditions, the ->destroy function would free all
possibly allocated pools from the current appsession, including those
that were not yet allocated nor assigned, which used to point to a
previous allocation, obviously resulting in a segfault.
(cherry picked from commit 75eae485921d3a6ce197915c769673834ecbfa5c)
2010-11-19 13:25:11 +01:00
Willy Tarreau
f70fc75296 [BUG] capture: do not capture a cookie if there is no memory left
In case of out of memory, it was possible to write to a null pointer
when capturing response cookies due to a missing "else" block. The
request handling was fine though.
(cherry picked from commit 62e3604d7dd27741c0b4c9e27d9e7c73495dfc32)
2010-11-19 13:25:11 +01:00
Willy Tarreau
e79c3b24fb [BUG] debug: report the correct poller list in verbose mode
When running with -vv or -V -d, the list of usable polling systems
is reported. The final selection did not take into account the
possible failures during the tests, which is misleading and could
make one think that a non-working poller will be used, while it is
not the case. Fix that to really report the correct ones.
(cherry picked from commit 6d0e354e0171f08b7b3868ad2882c3663bd068a7)
2010-11-19 13:25:10 +01:00
Cyril Bonté
1f5848a460 [CLEANUP] unix sockets : move create_uxst_socket() in uxst_bind_listener()
The code of create_uxst_socket() is moved in uxst_bind_listener() so that we
don't need to pass a lot of parameters, as it was only called there.
2010-11-14 17:21:44 +01:00
Cyril Bonté
e4cbbe2a0e [MINOR] unix sockets : inherits the backlog size from the listener
Since unix sockets are supported for bind, the default backlog size was not
enough to accept the traffic. The size is now inherited from the listener
to behave like the tcp listeners.

This also affects the "stats socket" backlog, which is now determined by
"stats maxconn".
2010-11-14 17:21:31 +01:00
Willy Tarreau
48d84c10b5 [OPTIM] linux: add support for bypassing libc to force using vsyscalls
Some distros' libc are built for CPUs earlier than i686 and as such do
not offer support for Linux kernel's faster vsyscalls. This code adds
a new build option USE_VSYSCALLS to bypass libc for most commonly used
system calls. A net gain of about 10% can be observed with this change
alone.

It only works when /proc/sys/abi/vsyscall32 equals exactly 2. When it's
set to 1, the VDSO is randomized and cannot be used.
2010-11-14 17:09:33 +01:00
Willy Tarreau
b695a6e5fa [BUILD] pattern: use 'int' instead of 'int32_t'
Ross West reported that int32_t breaks compilation on FreeBSD. Since an
int is 32-bit on all supported platforms and we already rely on that,
change the type.
2010-11-14 14:24:27 +01:00
Willy Tarreau
0a6b1fda03 [DOC] update ROADMAP file
move what was done and add a few collected wishes.
2010-11-14 14:23:22 +01:00
Willy Tarreau
442e8349f1 [RELEASE] Released version 1.5-dev3
Released version 1.5-dev3 with the following main changes :
    - [DOC] fix http-request documentation
    - [MEDIUM] enable/disable servers from the stats web interface
    - [MEDIUM] stats: add an admin level
    - [DOC] stats: document the "stats admin" statement
    - [MINOR] startup: print the proxy socket which caused an error
    - [CLEANUP] Remove unneeded chars allocation
    - [MINOR] config: detect options not supported due to compilation options
    - [MINOR] Add pattern's fetchs payload and payload_lv
    - [MINOR] frontend: improve accept-proxy header parsing
    - [MINOR] frontend: add tcpv6 support on accept-proxy bind
    - [MEDIUM] Enhance message errors management on binds
    - [MINOR] Manage unix socket source field on logs
    - [MINOR] Manage unix socket source field on session dump on sock stats
    - [MINOR] Support of unix listener sockets for debug and log event messages on frontend.c
    - [MINOR] Add some tests on sockets family for port remapping and mode transparent.
    - [MINOR] Manage socket type unix for some logs
    - [MINOR] Enhance controls of socket's family on acls and pattern fetch
    - [MINOR] Support listener's sockets unix on http logs.
    - [MEDIUM] Add supports of bind on unix sockets.
    - [BUG] stick table purge failure if size less than 255
    - [BUG] stick table entries expire on counters updates/read or show table, even if there is no "expire" parameter
    - [MEDIUM] Implement tcp inspect response rules
    - [DOC] tcp-response content and inspect
    - [MINOR] new acls fetch req_ssl_hello_type and rep_ssl_hello_type
    - [DOC] acls rep_ssl_hello and req_ssl_hello
    - [MEDIUM] Create new protected pattern types CONSTSTRING and CONSTDATA to force memcpy if data from protected areas need to be manipulated.
    - [DOC] new type binary in stick-table
    - [DOC] stick store-response and new patterns payload and payload_lv
    - [MINOR] Manage all types (ip, integer, string, binary) on cli "show table" command
    - [MEDIUM] Create updates tree on stick table to manage sync.
    - [MAJOR] Add new files src/peer.c, include/proto/peers.h and include/types/peers.h for sync stick table management
    - [MEDIUM] Manage peers section parsing and stick table registration on peers.
    - [MEDIUM] Manage soft stop on peers proxy
    - [DOC] add documentation for peers section
    - [MINOR] checks: add support for LDAPv3 health checks
    - [MINOR] add better support to "mysql-check"
    - [BUG] Restore info about available active/backup servers
    - [CONTRIB] Update haproxy.pl
    - [CONTRIB] Update Cacti Tempates
    - [CONTRIB] add templates for Cacti.
    - [BUG] http: don't consider commas as a header delimitor within quotes
    - [MINOR] support a global jobs counter
    - [DOC] add a summary about cookie incompatibilities between specs and browsers
    - [DOC] fix description of cookie "insert" and "indirect" modes
    - [MEDIUM] http: fix space handling in the request cookie parser
    - [MEDIUM] http: fix space handling in the response cookie parser
    - [DOC] fix typo in the queue() definition (backend, not frontend)
    - [BUG] deinit: unbind listeners before freeing them
    - [BUG] stream_interface: only call si->release when both dirs are closed
    - [MEDIUM] buffers: rework the functions to exchange between SI and buffers
    - [DOC] fix typo in the avg_queue() and be_conn() definition (backend, not frontend)
    - [MINOR] halog: add '-tc' to sort by termination codes
    - [MINOR] halog: skip non-traffic logs for -st and -tc
    - [BUG] stream_sock: cleanly disable the listener in case of resource shortage
    - [BUILD] stream_sock: previous fix lacked the #include, causing a warning.
    - [DOC] bind option is "defer-accept", not "defer_accept"
    - [DOC] missing index entry for http-check send-state
    - [DOC] tcp-request inspect-delay is for backends too
    - [BUG] ebtree: string_equal_bits() could return garbage on identical strings
    - [BUG] stream_sock: try to flush any extra pending request data after a POST
    - [BUILD] proto_http: eliminate some build warnings with gcc-2.95
    - [MEDIUM] make it possible to combine http-pretend-keepalived with httpclose
    - [MEDIUM] tcp-request : don't wait for inspect-delay to expire when the buffer is full
    - [MEDIUM] checks: add support for HTTP contents lookup
    - [TESTS] add test-check-expect to test various http-check methods
    - [MINOR] global: add "tune.chksize" to change the default check buffer size
    - [MINOR] cookie: add options "maxidle" and "maxlife"
    - [MEDIUM] cookie: support client cookies with some contents appended to their value
    - [MINOR] http: make some room in the transaction flags to extend cookies
    - [MINOR] cookie: add the expired (E) and old (O) flags for request cookies
    - [MEDIUM] cookie: reassign set-cookie status flags to store more states
    - [MINOR] add encode/decode function for 30-bit integers from/to base64
    - [MEDIUM] cookie: check for maxidle and maxlife for incoming dated cookies
    - [MEDIUM] cookie: set the date in the cookie if needed
    - [DOC] document the cookie maxidle and maxlife parameters
    - [BUG] checks: don't log backend down for all zero-weight servers
    - [MEDIUM] checks: set server state to one state from failure when leaving maintenance
    - [BUG] config: report correct keywords for "observe"
    - [MINOR] checks: ensure that we can inherit binary checks from the defaults section
    - [MINOR] acl: add the http_req_first match
    - [DOC] fix typos about bind-process syntax
    - [BUG] cookie: correctly unset default cookie parameters
    - [MINOR] cookie: add support for the "preserve" option
    - [BUG] ebtree: fix duplicate strings insertion
    - [CONTRIB] halog: report per-url counts, errors and times
    - [CONTRIB] halog: minor speed improvement in timer parser
    - [MINOR] buffers: add a new request analyser flag for PROXY mode
    - [MINOR] listener: add the "accept-proxy" option to the "bind" keyword
    - [MINOR] standard: add read_uint() to parse a delimited unsigned integer
    - [MINOR] standard: change arg type from const char* to char*
    - [MINOR] frontend: add a new analyser to parse a proxied connection
    - [MEDIUM] session: call the frontend_decode_proxy analyser on proxied connections
    - [DOC] add the proxy protocol's specifications
    - [DOC] document the 'accept-proxy' bind option
    - [MINOR] cfgparse: report support of <path> for the 'bind' statements
    - [DOC] add references to unix socket handling
    - [MINOR] move MAXPATHLEN definition to compat.h
    - [MEDIUM] unix sockets: cleanup the error reporting path
    - [BUG] session: don't stop forwarding of data upon last packet
    - [CLEANUP] accept: replace some inappropriate Alert() calls with send_log()
    - [BUILD] peers: shut a printf format warning (key_size is a size_t)
    - [BUG] accept: don't close twice upon error
    - [OPTIM] session: don't recheck analysers when buffer flags have not changed
    - [OPTIM] stream_sock: don't clear FDs that are already cleared
    - [BUG] proto_tcp: potential bug on pattern fetch dst and dport
2010-11-11 23:29:35 +01:00
Willy Tarreau
11f49408f2 [OPTIM] stream_sock: don't clear FDs that are already cleared
We can on average two calls to __fd_clr() per session by avoiding to
call it unnecessarily.
2010-11-11 23:08:17 +01:00
Willy Tarreau
2f976e18b8 [OPTIM] session: don't recheck analysers when buffer flags have not changed
Analysers were re-evaluated when some flags were still present in the
buffers, even if they had not changed since previous pass, resulting
in a waste of CPU cycles.

Ensuring that the flags have changed has saved some useless calls :

  function            min calls per session (before -> after)

  http_request_forward_body       5 -> 4
  http_response_forward_body      3 -> 2
  http_sync_req_state            10 -> 8
  http_sync_res_state             8 -> 6
  http_resync_states              8 -> 6
2010-11-11 14:28:47 +01:00
Willy Tarreau
abe8ea5c1d [BUG] accept: don't close twice upon error
The stream_sock's accept() used to close the FD upon error, but this
was also sometimes performed by the frontend's accept() called via the
session's accept(). Those interlaced calls were also responsible for the
spaghetti-looking error unrolling code in session.c and stream_sock.c.

Now the frontend must not close the FD anymore, the session is responsible
for that. It also takes care of just closing the FD or also removing from
the FD lists, depending on its state. The socket-level accept() does not
have to care about that anymore.
2010-11-11 11:05:20 +01:00
Willy Tarreau
bd55e3167b [BUILD] peers: shut a printf format warning (key_size is a size_t)
Also fix a few misleading comments.
2010-11-11 11:05:04 +01:00
Willy Tarreau
fffe1325df [CLEANUP] accept: replace some inappropriate Alert() calls with send_log()
Some Alert() messages were remaining in the accept() path, which they
would have no chance to be detected. Remove some of them (the impossible
ones) and replace the relevant ones with send_log() so that the admin
has a chance to catch them.
2010-11-11 09:51:38 +01:00
Emeric Brun
f099e7906d [DOC] add documentation for peers section 2010-11-11 09:29:08 +01:00
Emeric Brun
5a8c0a9f52 [MEDIUM] Manage soft stop on peers proxy 2010-11-11 09:29:08 +01:00
Emeric Brun
32da3c40db [MEDIUM] Manage peers section parsing and stick table registration on peers. 2010-11-11 09:29:08 +01:00
Emeric Brun
2b920a1af1 [MAJOR] Add new files src/peer.c, include/proto/peers.h and include/types/peers.h for sync stick table management
Add cmdline option -L to configure local peer name
2010-11-11 09:29:08 +01:00
Emeric Brun
85e77c7f0d [MEDIUM] Create updates tree on stick table to manage sync. 2010-11-11 09:29:08 +01:00
Emeric Brun
1e029aa965 [MINOR] Manage all types (ip, integer, string, binary) on cli "show table" command 2010-11-11 09:29:07 +01:00
Emeric Brun
6a1cefacad [DOC] stick store-response and new patterns payload and payload_lv 2010-11-11 09:29:07 +01:00
Emeric
f2d7caedd1 [MINOR] Add pattern's fetchs payload and payload_lv 2010-11-11 09:29:07 +01:00
Emeric Brun
7c6b82ee43 [DOC] new type binary in stick-table 2010-11-11 09:29:07 +01:00
Emeric Brun
485479d8e9 [MEDIUM] Create new protected pattern types CONSTSTRING and CONSTDATA to force memcpy if data from protected areas need to be manipulated.
Enhance pattern convs and fetch argument parsing, now fetchs and convs callbacks used typed args.
Add more details on error messages on parsing pattern expression function.
Update existing pattern convs and fetchs to new proto.
Create stick table key type "binary".
Manage Truncation and padding if pattern's fetch-converted result don't match table key size.
2010-11-11 09:29:07 +01:00
Emeric Brun
392d1d8b89 [DOC] acls rep_ssl_hello and req_ssl_hello 2010-11-11 09:29:01 +01:00
Emeric Brun
38e7176961 [MINOR] new acls fetch req_ssl_hello_type and rep_ssl_hello_type 2010-11-11 09:28:55 +01:00
Emeric Brun
0a3b67fbd4 [DOC] tcp-response content and inspect 2010-11-11 09:28:48 +01:00
Emeric Brun
97679e7901 [MEDIUM] Implement tcp inspect response rules 2010-11-11 09:28:18 +01:00
Emeric Brun
c89a57284a [BUG] stick table entries expire on counters updates/read or show table, even if there is no "expire" parameter 2010-11-11 09:28:18 +01:00
Emeric Brun
fbce6d0215 [BUG] stick table purge failure if size less than 255
If table size is lower than 256, we can't force to purge old entries.
This patch should be backported to 1.4.
2010-11-11 09:28:18 +01:00
Willy Tarreau
da4d9fe5a4 [BUG] session: don't stop forwarding of data upon last packet
If a read shutdown is encountered on the first packet of a connection
right after the data and the last analyser is unplugged at the same
time, then that last data chunk may never be forwarded. In practice,
right now it cannot happen on requests due to the way they're scheduled,
nor can it happen on responses due to the way their analysers work.

But this behaviour has been observed with new response analysers being
developped.

The reason is that when the read shutdown is encountered and an analyser
is present, data cannot be forwarded but the BF_SHUTW_NOW flag is set.
After that, the analyser gets called and unplugs itself, hoping that
process_session() will automatically forward the data. This does not
happen due to BF_SHUTW_NOW.

Simply removing the test on this flag is not enough because then aborted
requests still get forwarded, due to the forwarding code undoing the
abort.

The solution here consists in checking BF_SHUTR_NOW instead of BF_SHUTW_NOW.
BF_SHUTR_NOW is only set on aborts and remains set until ->shutr() is called.
This is enough to catch recent aborts but not prevent forwarding in other
cases. Maybe a new special buffer flag "BF_ABORT" might be desirable in the
future.

This patch does not need to be backported because older versions don't
have the analyser which make the problem appear.
2010-11-11 09:26:29 +01:00
Cyril Bonté
62846b2674 [MINOR] config: detect options not supported due to compilation options
Some options depends on the target architecture or compilation options.
When such an option is used on a compiled version that doesn't support it,
it's probably better to identify it as an unsupported option due to
compilation options instead of an unknown option.

Edit: better check on the empty capability than on the option bits. -Willy
2010-11-11 09:26:28 +01:00
Cyril Bonté
acd7d63ff9 [CLEANUP] Remove unneeded chars allocation
Some arrays used to log addresses add some more bytes for ports but this space
is never used.
2010-11-11 09:26:28 +01:00
Willy Tarreau
b40dc94a9a [MEDIUM] unix sockets: cleanup the error reporting path
There were a lot of snprintf() everywhere in the UNIX bind code. Now we
proceed as for tcp and indicate the socket path at the end between square
brackets. The code is smaller and more readable.
2010-11-11 09:26:28 +01:00
Cyril Bonté
43ba1b331c [MINOR] startup: print the proxy socket which caused an error
Add the address and port to the error message of the proxy socket that caused
the error. This can be helpful when several listening addresses are used in a
proxy.

Edit: since we now also support unix sockets (which already report their
      path), better move the address reporting to proto_tcp.c by analogy.
      -Willy
2010-11-11 09:26:28 +01:00
Willy Tarreau
17f449b214 [MINOR] move MAXPATHLEN definition to compat.h
MAXPATHLEN may be used at other places, it's unconvenient to have it
redefined in a few files. Also, since checking it requires including
sys/param.h, some versions of it cause a macro declaration conflict
with MIN/MAX which are defined in tools.h. The solution consists in
including sys/param.h in both files so that we ensure it's loaded
before the macros are defined and MAXPATHLEN is checked.
2010-11-11 09:21:53 +01:00
Willy Tarreau
ceb24bc7b4 [DOC] add references to unix socket handling
UNIX listening sockets have some additional options and may log slightly
differently.
2010-11-09 15:59:42 +01:00
Willy Tarreau
d55c3feca6 [MINOR] cfgparse: report support of <path> for the 'bind' statements
"bind" now supports unix sockets, so report that in the error message.
2010-11-09 15:59:42 +01:00
Emeric Brun
ed76092e10 [MEDIUM] Add supports of bind on unix sockets. 2010-11-09 15:59:42 +01:00
Emeric Brun
5bd86a8ff5 [MINOR] Support listener's sockets unix on http logs.
Enhance controls of sockets family on X-Forwarded-For and X-Original-To insert
2010-11-09 15:59:42 +01:00
Emeric Brun
f769f51af6 [MINOR] Enhance controls of socket's family on acls and pattern fetch 2010-11-09 15:59:42 +01:00