Commit graph

1183 commits

Author SHA1 Message Date
Willy Tarreau
eadbab9081 [RELEASE] Released version 1.3.23
Released version 1.3.23 with the following main changes :
    - [MINOR] server tracking: don't care about the tracked server's mode
    - [MEDIUM] appsession: add the "request-learn" option
    - [BUG] Configuration parser bug when escaping characters
    - [BUG] appsession: possible memory leak in case of out of memory condition
    - [MINOR] config: don't accept 'appsession' in defaults section
    - [CLEANUP] Keep in sync "defaults" support between documentation and code
    - [BUILD] warning ultoa_r returns char *
    - [CLEANUP] format '%d' expects type 'int', but argument 5 has type 'long int'
    - [BUG] config: fix erroneous check on cookie domain names, again
    - [DOC] trivial fix for man page
    - [BUG] config: fix wrong handling of too large argument count
    - [BUG] config: disable 'option httplog' on TCP proxies
    - [BUG] config: fix erroneous check on cookie domain names
    - [BUG] config: cookie domain was ignored in defaults sections
    - [MINOR] config: support passing multiple "domain" statements to cookies
    - [BUG] x-original-to: name was not set in default instance
    - [BUG] config: fix error message when config file is not found
    - [MINOR] config: don't report error on all subsequent files on failure
    - [BUILD] Makefile: make without arch-specific optimizations
    - [BUG] halog: fix segfault in case of empty log in PCT mode
    - [CLEANUP] second fix for the printf format warning
    - [BUG] check_post: limit analysis to the buffer length
    - [MINOR] http: typos on several unlikely() around header insertion
    - [CLEANUP] buffers: wrong size calculation for displaced data
    - [MINOR] config: option forceclose is valid in frontends too
    - [BUG] http: fix cookie parser to support spaces and commas in values
    - [MINOR] config: some options were missing for "redirect"
    - [BUILD] appsession did not build anymore under gcc-2.95 (cherry picked from commit 1fac75385a)
    - [MINOR] http: fix double slash prefix with server redirect
    - [MINOR] http redirect: add the ability to append a '/' to the URL
    - [MINOR] config: indicate that timeout appsession should not be used
    - [DOC] remove several trailing spaces
    - [CLEANUP] stream_sock: MSG_NOSIGNAL is only for send(), not recv()
    - [BUG] check: we must not check for error before reading a response
    - [CLEANUP] buffers: remove remains of wrong obsolete length check
    - [CLEANUP] http_server_error() must not purge a previous pending response
    - [MEDIUM] add the "force-persist" statement to force persistence on down servers
    - [MINOR] http: logs must report persistent connections to down servers
    - [MINOR] buffer_replace2 must never change the ->w entry
    - [MINOR] buffers: buffer_insert_line2 must not change the ->w entry
    - [MEDIUM] checks: make the HTTP check code add the CRLF itself
    - [MEDIUM] checks: add the server's status in the checks
    - [DOC] add some build info about the AIX platform
    - [CLEANUP] config: do not allocate an empty argument for rsp* keywords
2010-01-28 23:34:16 +01:00
Willy Tarreau
f33e55af06 [CLEANUP] config: do not allocate an empty argument for rsp* keywords
This was a harmless copy-paste typo. Empty parameters are strduped
and passed to chain_regex(). This was spotted and fixed in 1.4
commit ade5ec430d.
2010-01-28 23:17:16 +01:00
Willy Tarreau
e41914c77e [DOC] add some build info about the AIX platform 2010-01-28 23:17:15 +01:00
Willy Tarreau
db214364d0 [MEDIUM] checks: add the server's status in the checks
Now a server can check the contents of the header X-Haproxy-Server-State
to know how haproxy sees it. The same values as those reported in the stats
are provided :
  - up/down status + check counts
  - throttle
  - weight vs backend weight
  - active sessions vs backend sessions
  - queue length
  - haproxy node name
2010-01-28 23:17:08 +01:00
Willy Tarreau
91caa6fe50 [MEDIUM] checks: make the HTTP check code add the CRLF itself
Currently we cannot easily add headers nor anything to HTTP checks
because the requests are pre-formatted with the last CRLF. Make the
check code add the CRLF itself so that we can later add useful info.
(cherry picked from commit e9d8788fdd)
2010-01-28 23:16:59 +01:00
Cyril Bonté
197538f56e [CLEANUP] Keep in sync "defaults" support between documentation and code
Hi Willy,

I've made a quick pass on the "defaults" column in the Proxy keywords matrix (chapter 4.1. in the documentation).
This patch resyncs the code and the documentation. I let you decide if some keywords that still work in the "defaults" section should be forbidden.

- default_backend : in the matrix, "defaults" was not supported but the keyword details say it is.
Tests also shows it works, then I've updated the matrix.

- capture cookie : in the keyword details, we can read `It is not possible to specify a capture in a "defaults" section.'.
Ok, even if the tests worked, I've added an alert in the configuration parser (as it is for capture request/response header).

- description : not supported in "defaults", I added an alert in the parser.
I've also noticed that this keyword doesn't appear in the documentation.
There's one "description" entry, but for the "global" section, which is for a different use (the patch doesn't update the documentation).

- grace : even if this is maybe useless, it works in "defaults". Documentation is updated.
- redirect : alert is added in the parser.
- rsprep : alert added in the parser.

--
Cyril Bonté

(cherry picked from commit 99ed327d62)
2010-01-28 23:16:58 +01:00
Willy Tarreau
1bade0eae1 [MINOR] buffers: buffer_insert_line2 must not change the ->w entry
Krzysztof Oledzki reported that 1.4-dev7 would regularly crash
on an apparently very common workload. The cores he provided
showed some inter-buffer data corruption, exactly similar to
what was fixed by the following recent commit :

bbfa7938bd [BUG] buffer_replace2 must never change the ->w entry

In fact, it was buffer_insert_line2() which was still modifying the
->w pointer, causing issues with pipelined responses in keep-alive
mode if some headers were to be added.

The bug requires a remote client, a near server, large server buffers
and small client buffers to be reproduced, with response header
insertion. Still, it's surprizing that it did not trigger earlier.

Now after 100k pipelined requests it did not trigger anymore.

Note: 1.3 is not affected by this issue since it does not support
keep-alive, but better fix this silly bug anyway.

(cherry picked from commit c5bbe53f6f)
2010-01-28 23:16:58 +01:00
Willy Tarreau
c65cbb7095 [MINOR] buffer_replace2 must never change the ->w entry
This function is used to move data which is located between ->w and ->r,
so it must not touch ->w, otherwise it will displace pending data which
is before the one we're actually overwriting. The issue arose in 1.4 with
some pipelined responses which cause some part of the previous one to
be chopped off when removing the connection: close header, thus
corrupting last response and shifting next one. Those are detected
in the logs because the next response will be a 502 with flags PH.

Note that this does not affect 1.3, still this is a bug that's better
fixed than blindly copy-pasted and woken up again.

(cherry picked from commit bbfa7938bd)
2010-01-28 23:16:58 +01:00
Willy Tarreau
857d0c3d0c [MINOR] http: logs must report persistent connections to down servers
When using "option persist" or "force-persist", we want to know from the
logs if the cookie referenced a valid server or a down server. Till here
the flag reported a valid server even if the server was down, which is
misleading. Now we correctly report that the requested server was down.
We can typically see "--DI" when using "option persist" with redispatch,
ad "SCDN" when using force-persist on a down server.
(cherry picked from commit 2a6d88dafe)
2010-01-28 23:16:57 +01:00
Willy Tarreau
59f50cce06 [MEDIUM] add the "force-persist" statement to force persistence on down servers
This is used to force access to down servers for some requests. This
is useful when validating that a change on a server correctly works
before enabling the server again.

(cherry picked from commit 4de9149f87)
2010-01-28 23:16:57 +01:00
Willy Tarreau
32efff0c67 [CLEANUP] http_server_error() must not purge a previous pending response
This can cause parts of responses to be truncated in case of
pipelined requests if the second request generates an error
before the first request is completely flushed.

(cherry picked from commit d5fd51c75b)
2010-01-28 23:16:50 +01:00
Willy Tarreau
b23d838c30 [CLEANUP] buffers: remove remains of wrong obsolete length check
A check was performed in buffer_replace2() to compare buffer
length with its read pointer. This has been wrong for a long
time, though it only has an impact when dealing with keep-alive
requests/responses. In theory this should be backported but
the check has no impact without keep-alive.
(cherry picked from commit 43a7e6620b)
2010-01-28 23:16:39 +01:00
Willy Tarreau
4623b0e5c4 [BUG] check: we must not check for error before reading a response
We can receive data with a notification of socket error. But we
must not check for the error before reading the data, because it
may be an asynchronous error notification that we check too early
while the response we're waiting for is available. If there is an
error, recv() will get it.

This should help with servers that close very fast after the response
and should also slightly lower the CPU usage during very fast checks
on massive amounts of servers since we eliminate one system call.

This should probably be backported to 1.3.

(cherry picked from commit a5aa1c86a5)
2010-01-28 23:16:37 +01:00
Willy Tarreau
014c4bcf19 [CLEANUP] stream_sock: MSG_NOSIGNAL is only for send(), not recv()
We must not set this flag on recv(), it's not used, it's just for
send().
(cherry picked from commit fc1daaf497)
2010-01-28 23:16:37 +01:00
Willy Tarreau
a1a5950226 [DOC] remove several trailing spaces 2010-01-28 23:16:37 +01:00
Willy Tarreau
e032a767b0 [MINOR] config: indicate that timeout appsession should not be used 2010-01-28 23:16:37 +01:00
Cyril Bonté
f2432b0c80 [MINOR] config: don't accept 'appsession' in defaults section
Maybe appsession should be forbidden in the 'defaults' section as it
will not work in the backends.
(cherry picked from commit 3b7a369baa)
2010-01-28 23:16:37 +01:00
Cyril Bonté
1b81667094 [BUG] appsession: possible memory leak in case of out of memory condition
I've tried to follow all the pool_alloc2/pool_free2 calls in the code
to track memory leaks. I've found one which only happens when there's
already no more memory when allocating a new appsession cookie.

(cherry picked from commit 41689c22da)
2010-01-28 23:16:37 +01:00
Willy Tarreau
11c77a39b7 [MINOR] http redirect: add the ability to append a '/' to the URL
Sometimes it can be desired to return a location which is the same
as the request with a slash appended when there was not one in the
request. A typical use of this is for sending a 301 so that people
don't reference links without the trailing slash. The name of the
new option is "append-slash" and it can be used on "redirect"
statements in prefix mode.

(cherry picked from commit 81e3b4f48d)
2010-01-28 23:16:37 +01:00
Willy Tarreau
cd2ae4f342 [MINOR] http: fix double slash prefix with server redirect
When using server redirection, it is possible to specify a path
consisting of only one slash. While this is discouraged (risk of
loop) it may sometimes be useful combined with content switching.
The prefixing of a '/' then causes two slashes to be returned in
the response. So we now do as with the other redirects, don't
prepend a slash if it's alone.
(cherry picked from commit dcb75c4a83)
2010-01-28 23:16:36 +01:00
Willy Tarreau
1df8a6a684 [BUILD] appsession did not build anymore under gcc-2.95
(cherry picked from commit 1fac75385a)
2010-01-28 23:16:36 +01:00
Emeric Brun
1e01b78aff [BUILD] warning ultoa_r returns char *
ultoa_r modifies its output, it returns a char *.
(cherry picked from commit 3a7fce5383)
2010-01-28 23:16:36 +01:00
Willy Tarreau
ceb33a0e68 [MINOR] config: some options were missing for "redirect"
Those options were missing in the parser error message :
  set-cookie, clear-cookie, drop-query
(cherry picked from commit 963abc33a2)
2010-01-28 23:16:36 +01:00
Willy Tarreau
bb6e777da9 [BUG] http: fix cookie parser to support spaces and commas in values
The cookie parser could be fooled by spaces or commas in cookie names
and values, causing the persistence cookie not to be matched if located
just after such a cookie. Now spaces found in values are considered as
part of the value, and spaces, commas and semi-colons found in values
or names, are skipped till next cookie name.

This fix must be backported to 1.3.
(cherry picked from commit 305ae85957)
2010-01-28 23:16:36 +01:00
Willy Tarreau
15c24da81e [MINOR] config: option forceclose is valid in frontends too
This option was disabled for frontends in the configuration because
it was useless in its initial implementation, though it was still
checked in the code. Let's officially enable it now.
(cherry picked from commit a31e5dff36)
2010-01-28 23:16:35 +01:00
Willy Tarreau
c04b83edaf [CLEANUP] buffers: wrong size calculation for displaced data
This error was triggered by requests not starting at the beginning
of the buffer. It cannot happen with earlier versions though it might
be a good idea to fix it anyway.
(cherry picked from commit 019fd5bc93)
2010-01-28 23:16:27 +01:00
Willy Tarreau
80b085003a [MINOR] http: typos on several unlikely() around header insertion
In many places where we perform header insertion, an error control
is performed but due to a mistake, it cannot match any error :

   if (unlikely(error) < 0)
instead of
   if (unlikely(error < 0))

This prevents error 400 responses from being sent when the buffer is
full due to many header additions. This must be backported to 1.3.
(cherry picked from commit 58cc872848)
2010-01-28 23:16:17 +01:00
Willy Tarreau
6179630e0f [BUG] check_post: limit analysis to the buffer length
If "balance url_param XXX check_post" is used, we must bound the
number of bytes analysed to the buffer's length.
(cherry picked from commit dc8017ced6)
2010-01-28 23:15:21 +01:00
Krzysztof Piotr Oledzki
39ece3d0f9 [BUG] config: fix erroneous check on cookie domain names, again
The previous check was correct: the RFC states that it is required
to have a domain-name which contained a dot AND began with a dot.
However, currently some (all?) browsers do not obey this specification,
so such configuration might work.

This patch reverts 3d8fbb6658 but
changes the check from FATAL to WARNING and extends the message.
(cherry picked from commit 1a8bea9390)
2010-01-28 23:15:19 +01:00
Willy Tarreau
5203a0b055 [CLEANUP] second fix for the printf format warning
Fix 500b8f0349 fixed the patch for the 64 bit
case but caused the opposite type issue to appear on 32 bit platforms. Cast
the difference and be done with it since gcc does not agree on type carrying
the difference between two pointers on 32 and 64 bit platforms.
(cherry picked from commit 3ccf94efd9)
2010-01-28 23:15:09 +01:00
Krzysztof Piotr Oledzki
8a4d7dd743 [CLEANUP] format '%d' expects type 'int', but argument 5 has type 'long int'
src/cfgparse.c: In function 'readcfgfile':
src/cfgparse.c:4087: warning: format '%d' expects type 'int', but argument 5 has type 'long int'
(cherry picked from commit 500b8f0349)
2010-01-28 23:14:30 +01:00
Willy Tarreau
fe362fe476 [BUG] halog: fix segfault in case of empty log in PCT mode 2010-01-28 10:03:42 +01:00
Willy Tarreau
f0e0d65abb [BUILD] Makefile: make without arch-specific optimizations 2010-01-28 10:03:42 +01:00
Willy Tarreau
e3a93ff814 [MINOR] config: don't report error on all subsequent files on failure
Cyril Bonté found that when an error is detected in one config file, it
is also reported in all other ones, which is wrong. The fix obviously
consists in checking the return code from readcfgfile() and not the
accumulator.
(cherry picked from commit 25a67fae3e)
2009-12-15 21:50:18 +01:00
Cyril Bonté
97c8d9e1a5 [BUG] Configuration parser bug when escaping characters
Today I was testing headers manipulation but I met a bug with my first test.
To reproduce it, add for example this line :

    rspadd Cache-Control:\ max-age=1500

Check the response header, it will provide :

Cache-Control: max-age=15000 <= the last character is duplicated

This only happens when we use backslashes on the last line of the
configuration file, without returning to the line.

Also if the last line is like :
  rspadd Cache-Control:\ max-age=1500\

the last backslash causes a segfault.

This is not due to rspadd but to a more general bug in cfgparse.c :
...
if (skip) {
        memmove(line + 1, line + 1 + skip, end - (line + skip + 1));
        end -= skip;
}
...

should be :
...
if (skip) {
        memmove(line + 1, line + 1 + skip, end - (line + skip));
        end -= skip;
}
...

I've reproduced it with haproxy 1.3.22 and the last 1.4 snapshot.
(cherry picked from commit dd1b01d027)
2009-12-06 13:47:34 +01:00
Willy Tarreau
d289240085 [BUG] config: fix error message when config file is not found
Cameron Simpson reported an annoying case where haproxy simply reports
"Error(s) found in configuration file" when the file is not found or
not readable.

Fortunately the parsing function still returns -1 in case of open
error, so we're able to detect the issue from the caller and report
the corresponding errno message.
(cherry picked from commit c438242878)
2009-12-06 13:21:18 +01:00
Willy Tarreau
f175a6d6b1 [BUG] x-original-to: name was not set in default instance
This resulted in an empty header name when option originalto
was declared in a default sections.
(cherry picked from commit b86db34fe0)
2009-12-06 13:21:03 +01:00
Alex Williams
37fc94dc42 [MINOR] server tracking: don't care about the tracked server's mode
Right now, an HTTP server cannot track a TCP server and vice-versa.
This patch enables proxy tracking without relying on the proxy's mode
(tcp/http/health). It only requires a matching proxy name to exist. The
original function was renamed to findproxy_mode().

(cherry picked from commit 96532db923)
2009-12-06 13:20:08 +01:00
Willy Tarreau
950245ca2b [MINOR] config: support passing multiple "domain" statements to cookies
In some environments it is not possible to rely on any wildcard for a
domain name (eg: .com, .net, .fr...) so it is required to send multiple
domain extensions. (Un)fortunately the syntax check on the domain name
prevented that from being done the dirty way. So let's just build a
domain list when multiple domains are passed on the same line.
2009-12-03 23:28:34 +01:00
Willy Tarreau
baf78c8e03 [BUG] config: cookie domain was ignored in defaults sections
Since cookie can appear in a defaults section, the domain extension
must be supported there as well.
2009-12-03 23:23:28 +01:00
Willy Tarreau
a1e107fc13 [BUG] config: fix erroneous check on cookie domain names
It was a OR instead of a AND, so it was required to have a cookie
name which contained a dot AND began with a dot.
2009-12-03 23:10:56 +01:00
Willy Tarreau
5f0bd6537f [BUG] config: disable 'option httplog' on TCP proxies
Gabriel Sosa reported that logs were appearing with BADREQ when
'option httplog' was used with a TCP proxy (eg: inherited via a
default instance). This patch detects it and falls back to tcplog
after emitting a warning.
2009-11-09 21:27:51 +01:00
Willy Tarreau
3b39c1446b [BUG] config: fix wrong handling of too large argument count
Holger Just reported that running ACLs with too many args caused
a segfault during config parsing. This is caused by a wrong test
on argument count. In case of too many arguments on a config line,
the last one was not correctly zeroed. This is now done and we
report the error indicating what part had been truncated.
2009-11-09 21:16:53 +01:00
Cyril Bonté
7433c2a4b3 [MEDIUM] appsession: add the "request-learn" option
This patch has 2 goals :

1. I wanted to test the appsession feature with a small PHP code,
using PHPSESSID. The problem is that when PHP gets an unknown session
id, it creates a new one with this ID. So, when sending an unknown
session to PHP, persistance is broken : haproxy won't see any new
cookie in the response and will never attach this session to a
specific server.

This also happens when you restart haproxy : the internal hash becomes
empty and all sessions loose their persistance (load balancing the
requests on all backend servers, creating a new session on each one).
For a user, it's like the service is unusable.

The patch modifies the code to make haproxy also learn the persistance
from the client : if no session is sent from the server, then the
session id found in the client part (using the URI or the client cookie)
is used to associated the server that gave the response.

As it's probably not a feature usable in all cases, I added an option
to enable it (by default it's disabled). The syntax of appsession becomes :

  appsession <cookie> len <length> timeout <holdtime> [request-learn]

This helps haproxy repair the persistance (with the risk of losing its
session at the next request, as the user will probably not be load
balanced to the same server the first time).

2. This patch also tries to reduce the memory usage.
Here is a little example to explain the current behaviour :
- Take a Tomcat server where /session.jsp is valid.
- Send a request using a cookie with an unknown value AND a path
  parameter with another unknown value :

  curl -b "JSESSIONID=12345678901234567890123456789012" http://<haproxy>/session.jsp;jsessionid=00000000000000000000000000000001

(I know, it's unexpected to have a request like that on a live service)
Here, haproxy finds the URI session ID and stores it in its internal
hash (with no server associated). But it also finds the cookie session
ID and stores it again.

- As a result, session.jsp sends a new session ID also stored in the
  internal hash, with a server associated.

=> For 1 request, haproxy has stored 3 entries, with only 1 which will be usable

The patch modifies the behaviour to store only 1 entry (maximum).

Similar patch was merged in 1.4 with commit ID bf47aeb946.
2009-10-18 11:58:53 +02:00
Michael Shuler
95f1d3eaf3 [DOC] trivial fix for man page
I'm working on helping Arnaud update haproxy in Debian, and one of the
package build warnings I received was about "hyphen where a minus sign
was intended" in the man page - details:
http://lintian.debian.org/tags/hyphen-used-as-minus-sign.html

Patch included in my 1.3.20 Debian package is attached.

(cherry picked from commit 35928e84e2)
2009-10-14 21:13:32 +02:00
Willy Tarreau
a2e01e90df [RELEASE] Released version 1.3.22
Released version 1.3.22 with the following main changes :
    - [BUG] unix socket: don't try to dereference frontend/backends
    - [MINOR] unix socket: report the socket path in case of bind error
    - [CONTRIB] halog: support searching by response time
    - [DOC] add a reminder about obsolete documents
2009-10-14 20:43:22 +02:00
Willy Tarreau
7b4652e599 [DOC] add a reminder about obsolete documents
haproxy-en.txt and haproxy-fr.txt are outdated but people still refer to
them quite often, generally causing a useless waste of time.
(cherry picked from commit a080eca533)
2009-10-14 20:40:55 +02:00
Willy Tarreau
e3039cc361 [CONTRIB] halog: support searching by response time
Also support inverting search criteria when specified uppercase
(cherry picked from commit 5bdfd968ed)
2009-10-14 20:40:54 +02:00
Willy Tarreau
336708878c [MINOR] unix socket: report the socket path in case of bind error
When an error occurs during binding of the stats unix socket, messages
are far from clear for the user !
(cherry picked from commit 5d53634f36)
2009-10-14 20:40:41 +02:00
Willy Tarreau
8087c66b3c [BUG] unix socket: don't try to dereference frontend/backends
John Lauro reported a new crash on 1.3.21 due to a dereferencing bug
of the frontend which does not have any frontend. The bug was introduced
by commit a3e0e0767f.
2009-10-14 15:25:37 +02:00