]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
9 years agoMINOR: connection: add a new flag CO_FL_PRIVATE
Willy Tarreau [Tue, 4 Aug 2015 17:24:13 +0000 (19:24 +0200)] 
MINOR: connection: add a new flag CO_FL_PRIVATE

This flag is set on an outgoing connection when this connection gets
some properties that must not be shared with other connections, such
as dynamic transparent source binding, SNI or a proxy protocol header,
or an authentication challenge from the server. This will be needed
later to implement connection reuse.

9 years agoMINOR: server: add a list of already used idle connections
Willy Tarreau [Wed, 5 Aug 2015 08:31:57 +0000 (10:31 +0200)] 
MINOR: server: add a list of already used idle connections

There's a difference with the other idle conns in that these new
ones have already been used and may be reused by other streams.

9 years agoMINOR: stream-int: make si_idle_conn() only accept valid connections
Willy Tarreau [Wed, 5 Aug 2015 09:08:30 +0000 (11:08 +0200)] 
MINOR: stream-int: make si_idle_conn() only accept valid connections

This function is now dedicated to idle connections only, which means
that it must not be used without any endpoint nor anything not a
connection. The connection remains attached to the stream interface.

9 years agoMEDIUM: stream-int: queue idle connections at the server
Willy Tarreau [Tue, 4 Aug 2015 17:00:17 +0000 (19:00 +0200)] 
MEDIUM: stream-int: queue idle connections at the server

Now we get a per-server list of all idle connections. That way we'll
be able to reclaim them upon shortage later.

9 years agoMINOR: connection: add a new list member in the connection struct
Willy Tarreau [Tue, 4 Aug 2015 15:25:58 +0000 (17:25 +0200)] 
MINOR: connection: add a new list member in the connection struct

This list member will be used to attach a connection to a list of
idle, reusable or queued connections. It's unused for now. Given
that it's not expected to be used more than a few times per session,
the member was put after the target, in the area starting at the
second cache line of the structure.

9 years agoMINOR: server: add a list of private idle connections
Willy Tarreau [Tue, 4 Aug 2015 15:19:06 +0000 (17:19 +0200)] 
MINOR: server: add a list of private idle connections

For now it's not populated but we have the list entry. It will carry
all idle connections that sessions don't want to share. They may be
used later to reclaim connections upon socket shortage for example.

9 years agoMINOR: stream-int: add new function si_detach_endpoint()
Willy Tarreau [Tue, 4 Aug 2015 18:44:05 +0000 (20:44 +0200)] 
MINOR: stream-int: add new function si_detach_endpoint()

This function only detaches the endpoint from the stream-int and
optionally returns the original pointer. This will be needed to
steal idle connections from other connections.

9 years agoMEDIUM: stream-int: simplify si_alloc_conn()
Willy Tarreau [Wed, 5 Aug 2015 19:47:23 +0000 (21:47 +0200)] 
MEDIUM: stream-int: simplify si_alloc_conn()

Since we now always call this function with the reuse parameter cleared,
let's simplify the function's logic as it cannot return the existing
connection anymore. The savings on this inline function are appreciable
(240 bytes) :

$ size haproxy.old haproxy.new
   text    data     bss     dec     hex filename
1020383   40816   36928 1098127  10c18f haproxy.old
1020143   40816   36928 1097887  10c09f haproxy.new

9 years agoMEDIUM: backend: don't call si_alloc_conn() when we reuse a valid connection
Willy Tarreau [Tue, 4 Aug 2015 17:45:36 +0000 (19:45 +0200)] 
MEDIUM: backend: don't call si_alloc_conn() when we reuse a valid connection

connect_server() already does most of the check that is done again in
si_alloc_conn(), so let's simply reuse the existing connection instead
of calling the function again. It will also simplify the connection
reuse.

Indeed, for reuse to be set, it also requires srv_conn to be valid. In the
end, the only situation where we have to release the existing connection
and allocate a new one is when reuse == 0.

9 years agoCLEANUP: backend: factor out objt_server() in connect_server()
Willy Tarreau [Tue, 4 Aug 2015 17:34:21 +0000 (19:34 +0200)] 
CLEANUP: backend: factor out objt_server() in connect_server()

objt_server() is called multiple times at various places while some
places already make use of srv for this. Let's move the call at the
top of the function and use it all over the place.

9 years agoDOC: resolve-prefer default value and default-server update
Baptiste Assmann [Tue, 4 Aug 2015 20:43:06 +0000 (22:43 +0200)] 
DOC: resolve-prefer default value and default-server update

By the code, resolve-prefer defaults to IPv6 and is also available in
the default-server directive.
These information were missing or wrong in the documentation.

9 years agoDOC: typos in tcp-check expect examples
Baptiste Assmann [Tue, 4 Aug 2015 08:12:18 +0000 (10:12 +0200)] 
DOC: typos in tcp-check expect examples

The match keyword 'string' was missing in a few tcp-check expect example
statements.

9 years agoDOC: typo in 'redirect', 302 code meaning
Baptiste Assmann [Mon, 3 Aug 2015 09:42:50 +0000 (11:42 +0200)] 
DOC: typo in 'redirect', 302 code meaning

302 means a temprary move, not a permanent one

9 years agoDOC/MINOR: fix OpenBSD versions where haproxy works
Daniel Jakots [Wed, 29 Jul 2015 06:03:08 +0000 (08:03 +0200)] 
DOC/MINOR: fix OpenBSD versions where haproxy works

9 years agoMINOR: stream: initialize the current_rule field to NULL on stream init
Remi Gacogne [Wed, 22 Jul 2015 15:10:58 +0000 (17:10 +0200)] 
MINOR: stream: initialize the current_rule field to NULL on stream init

Currently it is possible for the current_rule field to be evaluated before
being set, leading to valgrind complaining:

==16783== Conditional jump or move depends on uninitialised value(s)
==16783==    at 0x44E662: http_res_get_intercept_rule (proto_http.c:3730)
==16783==    by 0x44E662: http_process_res_common (proto_http.c:6528)
==16783==    by 0x4797B7: process_stream (stream.c:1851)
==16783==    by 0x414634: process_runnable_tasks (task.c:238)
==16783==    by 0x40B02F: run_poll_loop (haproxy.c:1528)
==16783==    by 0x407F25: main (haproxy.c:1887)

This was introduced by commit 152b81e7b2565862956af883820d4f79177d0651.

9 years agoBUILD: ssl: Allow building against libssl without SSLv3.
Jérémie Courrèges-Anglas [Sat, 25 Jul 2015 22:50:52 +0000 (16:50 -0600)] 
BUILD: ssl: Allow building against libssl without SSLv3.

If SSLv3 is explicitely requested but not available, warn the user and
bail out.

9 years agoBUILD: link with libdl if needed for Lua support
Vincent Bernat [Thu, 16 Jul 2015 18:52:51 +0000 (20:52 +0200)] 
BUILD: link with libdl if needed for Lua support

On platforms where the dl*() functions are not part of the libc, a
program linking Lua also needs to link to libdl.

Moreover, on platforms using a gold linker with the --as-needed flag,
the libdl library needs to be linked after linking Lua, otherwise, it
won't be marked as needed and will be discarded and its symbols won't be
present at the end of the linking phase.

Ubuntu enables the --as-needed flag by default. Other distributions may
advertise its use, like Gentoo.

9 years agoBUG/MEDIUM: mailer: DATA part must be terminated with <CRLF>.<CRLF>
Pieter Baauw [Wed, 22 Jul 2015 17:51:54 +0000 (19:51 +0200)] 
BUG/MEDIUM: mailer: DATA part must be terminated with <CRLF>.<CRLF>

The dot is send in the wrong place.
As defined in https://www.ietf.org/rfc/rfc2821.txt 'the character sequence "<CRLF>.<CRLF>" ends the mail text'

9 years ago[RELEASE] Released version 1.6-dev3 v1.6-dev3
Willy Tarreau [Wed, 22 Jul 2015 15:32:56 +0000 (17:32 +0200)] 
[RELEASE] Released version 1.6-dev3

Released version 1.6-dev3 with the following main changes :
    - CLEANUP: sample: generalize sample_fetch_string() as sample_fetch_as_type()
    - MEDIUM: http: Add new 'set-src' option to http-request
    - DOC usesrc root privileges requirments
    - BUG/MINOR: dns: wrong time unit for some DNS default parameters
    - MINOR: proxy: bit field for proxy_find_best_match diff status
    - MINOR: server: new server flag: SRV_F_FORCED_ID
    - MINOR: server: server_find functions: id, name, best_match
    - DOC: dns: fix chapters syntax
    - BUILD/MINOR: tools: rename popcount to my_popcountl
    - BUILD: add netbsd TARGET
    - MEDIUM: 51Degrees code refactoring and cleanup
    - MEDIUM: 51d: add LRU-based cache on User-Agent string detection
    - DOC: add notes about the "51degrees-cache-size" parameter
    - BUG/MEDIUM: 51d: possible incorrect operations on smp->data.str.str
    - BUG/MAJOR: connection: fix TLV offset calculation for proxy protocol v2 parsing
    - MINOR: Add sample fetch to detect Supported Elliptic Curves Extension
    - BUG/MINOR: payload: Add volatile flag to smp_fetch_req_ssl_ec_ext
    - BUG/MINOR: lua: type error in the arguments wrapper
    - CLEANUP: vars: remove unused struct
    - BUG/MINOR: http/sample: gmtime/localtime can fail
    - MINOR: standard: add 64 bits conversion functions
    - MAJOR: sample: converts uint and sint in 64 bits signed integer
    - MAJOR: arg: converts uint and sint in sint
    - MEDIUM: sample: switch to saturated arithmetic
    - MINOR: vars: returns variable content
    - MEDIUM: vars/sample: operators can use variables as parameter
    - BUG/MINOR: ssl: fix smp_fetch_ssl_fc_session_id
    - BUILD/MINOR: lua: fix a harmless build warning
    - BUILD/MINOR: stats: fix build warning due to condition always true
    - BUG/MAJOR: lru: fix unconditional call to free due to unexpected semi-colon
    - BUG/MEDIUM: logs: fix improper systematic use of quotes with a few tags
    - BUILD/MINOR: lua: ensure that hlua_ctx_destroy is properly defined
    - BUG/MEDIUM: lru: fix possible memory leak when ->free() is used
    - MINOR: vars: make the accounting not depend on the stream
    - MEDIUM: vars: move the session variables to the session, not the stream
    - BUG/MEDIUM: vars: do not freeze the connection when the expression cannot be fetched
    - BUG/MAJOR: buffers: make the buffer_slow_realign() function respect output data
    - BUG/MAJOR: tcp: tcp rulesets were still broken
    - MINOR: stats: improve compression stats reporting
    - MINOR: ssl: make self-generated certs also work with raw IPv6 addresses
    - CLEANUP: ssl: make ssl_sock_generated_cert_serial() take a const
    - CLEANUP: ssl: make ssl_sock_generate_certificate() use ssl_sock_generated_cert_serial()
    - BUG/MINOR: log: missing some ARGC_* entries in fmt_directives()
    - MINOR: args: add new context for servers
    - MINOR: stream: maintain consistence between channel_forward and HTTP forward
    - MINOR: ssl: provide ia function to set the SNI extension on a connection
    - MEDIUM: ssl: add sni support on the server lines
    - CLEANUP: stream: remove a useless call to si_detach()
    - CLEANUP: stream-int: fix a few outdated comments about stream_int_register_handler()
    - CLEANUP: stream-int: remove stream_int_unregister_handler() and si_detach()
    - MINOR: stream-int: only use si_release_endpoint() to release a connection
    - MINOR: standard: provide htonll() and ntohll()
    - CLEANUP/MINOR: dns: dns_str_to_dn_label() only needs a const char
    - BUG/MAJOR: dns: fix the length of the string to be copied

9 years agoBUG/MAJOR: dns: fix the length of the string to be copied
Willy Tarreau [Wed, 22 Jul 2015 14:45:36 +0000 (16:45 +0200)] 
BUG/MAJOR: dns: fix the length of the string to be copied

Jan A. Bruder reported that some very specific hostnames on server
lines were causing haproxy to crash on startup. Given that hist
backtrace showed some heap corruption, it was obvious there was an
overflow somewhere. The bug in fact is a typo in dns_str_to_dn_label()
which mistakenly copies one extra byte from the host name into the
output value, thus effectively corrupting the structure.

The bug triggers while parsing the next server of similar length
after the corruption, which generally triggers at config time but
could theorically crash at any moment during runtime depending on
what malloc sizes are needed next. This is why it's tagged major.

No backport is needed, this bug was introduced in 1.6-dev2.

9 years agoCLEANUP/MINOR: dns: dns_str_to_dn_label() only needs a const char
Willy Tarreau [Wed, 22 Jul 2015 14:42:43 +0000 (16:42 +0200)] 
CLEANUP/MINOR: dns: dns_str_to_dn_label() only needs a const char

The string is an input, let's constify it.

9 years agoMEDIUM: vars/sample: operators can use variables as parameter
Thierry FOURNIER [Tue, 7 Jul 2015 19:10:16 +0000 (21:10 +0200)] 
MEDIUM: vars/sample: operators can use variables as parameter

This patch allow the existing operators to take a variable as parameter.
This is useful to add the content of two variables. This patch modify
the behavior of operators.

9 years agoMINOR: vars: returns variable content
Thierry FOURNIER [Tue, 7 Jul 2015 19:20:42 +0000 (21:20 +0200)] 
MINOR: vars: returns variable content

This patch copy the content of a variable in a sample. The function
returns 0 if the variable is not found.

9 years agoMEDIUM: sample: switch to saturated arithmetic
Thierry FOURNIER [Tue, 7 Jul 2015 23:10:21 +0000 (01:10 +0200)] 
MEDIUM: sample: switch to saturated arithmetic

This patch check calculus for overflow and returns capped values.
This permits to protect against integer overflow in certain operations
involving ratios, percentages, limits or anything. That can sometimes
be critically important with some operations (eg: content-length < X).

9 years agoMAJOR: arg: converts uint and sint in sint
Thierry FOURNIER [Mon, 20 Jul 2015 15:45:02 +0000 (17:45 +0200)] 
MAJOR: arg: converts uint and sint in sint

This patch removes the 32 bits unsigned integer and the 32 bit signed
integer. It replaces these types by a unique type 64 bit signed.

9 years agoMAJOR: sample: converts uint and sint in 64 bits signed integer
Thierry FOURNIER [Mon, 6 Jul 2015 21:43:03 +0000 (23:43 +0200)] 
MAJOR: sample: converts uint and sint in 64 bits signed integer

This patch removes the 32 bits unsigned integer and the 32 bit signed
integer. It replaces these types by a unique type 64 bit signed.

This makes easy the usage of integer and clarify signed and unsigned use.
With the previous version, signed and unsigned are used ones in place of
others, and sometimes the converter loose the sign. For example, divisions
are processed with "unsigned", if one entry is negative, the result is
wrong.

Note that the integer pattern matching and dotted version pattern matching
are already working with signed 64 bits integer values.

There is one user-visible change : the "uint()" and "sint()" sample fetch
functions which used to return a constant integer have been replaced with
a new more natural, unified "int()" function. These functions were only
introduced in the latest 1.6-dev2 so there's no impact on regular
deployments.

9 years agoMINOR: standard: provide htonll() and ntohll()
Willy Tarreau [Tue, 21 Jul 2015 21:47:18 +0000 (23:47 +0200)] 
MINOR: standard: provide htonll() and ntohll()

These are the 64-bit equivalent of htonl() and ntohl(). They're a bit
tricky in order to avoid expensive operations.

The principle consists in letting the compiler detect we're playing
with a union and simplify most or all operations. The asm-optimized
htonl() version involving bswap (x86) / rev (arm) / other is a single
operation on little endian, or a NOP on big-endian. In both cases,
this lets the compiler "see" that we're rebuilding a 64-bit word from
two 32-bit quantities that fit into a 32-bit register. In big endian,
the whole code is optimized out. In little endian, with a decent compiler,
a few bswap and 2 shifts are left, which is the minimum acceptable.

9 years agoMINOR: standard: add 64 bits conversion functions
Thierry FOURNIER [Mon, 6 Jul 2015 21:09:52 +0000 (23:09 +0200)] 
MINOR: standard: add 64 bits conversion functions

This patch adds 3 functions for 64 bit integer conversion.

 * lltoa_r : converts signed 64 bit integer to string
 * read_uint64 : converts from string to signed 64 bits integer with capping
 * read_int64 : converts from string to unsigned 64 bits integer with capping

9 years agoMINOR: server: server_find functions: id, name, best_match
Baptiste Assmann [Wed, 8 Jul 2015 20:03:56 +0000 (22:03 +0200)] 
MINOR: server: server_find functions: id, name, best_match

This patch introduces three new functions which can be used to find a
server in a farm using different server information:
- server unique id (srv->puid)
- server name
- find best match using either name or unique id

When performing best matching, the following applies:
 - use the server name first (if provided)
 - use the server id if provided
 in any case, the function can update the caller about mismatches
 encountered.

9 years agoMINOR: server: new server flag: SRV_F_FORCED_ID
Baptiste Assmann [Tue, 7 Jul 2015 20:02:20 +0000 (22:02 +0200)] 
MINOR: server: new server flag: SRV_F_FORCED_ID

This flag aims at reporting whether the server unique id (srv->puid) has
been forced by the administrator in HAProxy's configuration.
If not set, it means HAProxy has generated automatically the server's
unique id.

9 years agoMINOR: proxy: bit field for proxy_find_best_match diff status
Baptiste Assmann [Fri, 3 Jul 2015 09:03:33 +0000 (11:03 +0200)] 
MINOR: proxy: bit field for proxy_find_best_match diff status

function proxy_find_best_match can update the caller by updating an int
provided in argument.
For now, proxy_find_best_match hardcode bit values 0x01, 0x02 and 0x04,
which is not understandable when reading a code exploiting them.

This patch defines 3 macros with a more explicit wording, so further
reading of a code exploiting the magic bit values will be understandable
more easily.

9 years agoBUG/MINOR: http/sample: gmtime/localtime can fail
Thierry FOURNIER [Tue, 7 Jul 2015 22:15:20 +0000 (00:15 +0200)] 
BUG/MINOR: http/sample: gmtime/localtime can fail

The man said that gmtime() and localtime() can return a NULL value.
This is not tested. It appears that all the values of a 32 bit integer
are valid, but it is better to check the return of these functions.

However, if the integer move from 32 bits to 64 bits, some 64 values
can be unsupported.

9 years agoBUG/MINOR: payload: Add volatile flag to smp_fetch_req_ssl_ec_ext
Nenad Merdanovic [Wed, 15 Jul 2015 10:51:11 +0000 (12:51 +0200)] 
BUG/MINOR: payload: Add volatile flag to smp_fetch_req_ssl_ec_ext

This bug was introduced in 5fc7d7e. No backport to 1.5 needed.

Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
9 years agoMINOR: stream-int: only use si_release_endpoint() to release a connection
Willy Tarreau [Sun, 19 Jul 2015 17:14:10 +0000 (19:14 +0200)] 
MINOR: stream-int: only use si_release_endpoint() to release a connection

Change si_alloc_conn() to call si_release_endpoint() instead of
open-coding the connection releasing code when reuse is disabled.
This fuses the code with the one already dealing with applets, makes
it shorter and helps centralizing the connection freeing logic at a
single place.

9 years agoCLEANUP: stream-int: remove stream_int_unregister_handler() and si_detach()
Willy Tarreau [Sun, 19 Jul 2015 16:47:45 +0000 (18:47 +0200)] 
CLEANUP: stream-int: remove stream_int_unregister_handler() and si_detach()

The former was not used anymore and the latter was only used by the former.
They were only aliases to other existing functions anyway.

9 years agoCLEANUP: stream-int: fix a few outdated comments about stream_int_register_handler()
Willy Tarreau [Sun, 19 Jul 2015 16:46:30 +0000 (18:46 +0200)] 
CLEANUP: stream-int: fix a few outdated comments about stream_int_register_handler()

They were not updated after the infrastructure change.

9 years agoCLEANUP: stream: remove a useless call to si_detach()
Willy Tarreau [Sun, 19 Jul 2015 15:57:02 +0000 (17:57 +0200)] 
CLEANUP: stream: remove a useless call to si_detach()

It's pointless to call si_detach() after si_reset() since it does
nothing due to si->end being NULL.

9 years agoBUG/MINOR: dns: wrong time unit for some DNS default parameters
Baptiste Assmann [Tue, 14 Jul 2015 19:42:49 +0000 (21:42 +0200)] 
BUG/MINOR: dns: wrong time unit for some DNS default parameters

Madison May reported that the timeout applied by the default
configuration is inproperly set up.
This patch fix this:
 - hold valid default to 10s
 - timeout retry default to 1s

9 years agoDOC usesrc root privileges requirments
Baptiste Assmann [Fri, 17 Jul 2015 19:59:42 +0000 (21:59 +0200)] 
DOC usesrc root privileges requirments

The "usesrc" parameter of the source statement requires root privileges.

10 years agoCLEANUP: vars: remove unused struct
Thierry FOURNIER [Tue, 23 Jun 2015 20:11:04 +0000 (22:11 +0200)] 
CLEANUP: vars: remove unused struct

The commit "MEDIUM: vars: move the session variables to the session, not the stream" (ebcd4844e82a4198ea5d98fe491a46267da1d1ec")
moves the variables from the stream to the session. It forgot to remove
the stream definition of the "vars_sess".

10 years agoBUG/MINOR: lua: type error in the arguments wrapper
Thierry FOURNIER [Mon, 6 Jul 2015 22:41:29 +0000 (00:41 +0200)] 
BUG/MINOR: lua: type error in the arguments wrapper

The expected arguments time and size are returned as int. This patch
fix this bug and returns the expected type.

10 years agoMEDIUM: ssl: add sni support on the server lines
Willy Tarreau [Thu, 9 Jul 2015 09:40:25 +0000 (11:40 +0200)] 
MEDIUM: ssl: add sni support on the server lines

The new "sni" server directive takes a sample fetch expression and
uses its return value as a hostname sent as the TLS SNI extension.
A typical use case consists in forwarding the front connection's SNI
value to the server in a bridged HTTPS forwarder :

   sni ssl_fc_sni

10 years agoMINOR: ssl: provide ia function to set the SNI extension on a connection
Willy Tarreau [Fri, 10 Jul 2015 09:33:32 +0000 (11:33 +0200)] 
MINOR: ssl: provide ia function to set the SNI extension on a connection

ssl_sock_set_servername() is used to set the SNI hostname on an
outgoing connection. This function comes from code originally
provided by Christopher Faulet of Qualys.

10 years agoMINOR: stream: maintain consistence between channel_forward and HTTP forward
Willy Tarreau [Thu, 9 Jul 2015 16:38:57 +0000 (18:38 +0200)] 
MINOR: stream: maintain consistence between channel_forward and HTTP forward

When the HTTP forwarder is used, it resets msg->sov so that we know that
the parsing pointer has advanced by exactly (msg->eoh + msg->eol - msg->sov)
bytes which may have to be rewound in case we want to perform an HTTP fetch
after forwarding has started (eg: upon connect).

But when the backend is in TCP mode, there may be no HTTP forwarding
analyser installed, still we may want to perform these HTTP fetches in
case we have already ensured at the TCP layer that we have a properly
parsed HTTP transaction.

In order to solve this, we reset msg->sov before doing a channel_forward()
so that we can still compute http_rewind() on the pending data. That ensures
the buffer is always rewindable even in mixed TCP+HTTP mode.

10 years agoMINOR: args: add new context for servers
Willy Tarreau [Thu, 9 Jul 2015 09:39:33 +0000 (11:39 +0200)] 
MINOR: args: add new context for servers

We'll have to support fetch expressions and args on server lines for
"usesrc", "usedst", "sni", etc...

10 years agoBUG/MINOR: log: missing some ARGC_* entries in fmt_directives()
Willy Tarreau [Thu, 9 Jul 2015 09:20:00 +0000 (11:20 +0200)] 
BUG/MINOR: log: missing some ARGC_* entries in fmt_directives()

ARGC_CAP was not added to fmt_directives() which is used to format
error messages when failing to parse log format expressions. The
whole switch/case has been reorganized to match the declaration
order making it easier to spot missing values. The default is not
the "log" directive anymore but "undefined" asking to report the
bug.

Backport to 1.5 is not strictly needed but is desirable at least
for code sanity.

10 years agoMINOR: Add sample fetch to detect Supported Elliptic Curves Extension
Nenad Merdanovic [Tue, 7 Jul 2015 20:00:17 +0000 (22:00 +0200)] 
MINOR: Add sample fetch to detect Supported Elliptic Curves Extension

Clients that support ECC cipher suites SHOULD send the specified extension
within the SSL ClientHello message according to RFC4492, section 5.1. We
can use this extension to chain-proxy requests so that, on the same IP
address, a ECC compatible clients gets an EC certificate and a non-ECC
compatible client gets a regular RSA certificate. The main advantage of this
approach compared to the one presented by Dave Zhu on the mailing list
is that we can make it work with OpenSSL versions before 1.0.2.

Example:
frontend ssl-relay
        mode tcp
        bind 0.0.0.0:443
        use_backend ssl-ecc if { req.ssl_ec_ext 1 }
        default_backend ssl-rsa

backend ssl-ecc
        mode tcp
        server ecc unix@/var/run/haproxy_ssl_ecc.sock send-proxy-v2 check

backend ssl-rsa
        mode tcp
        server rsa unix@/var/run/haproxy_ssl_rsa.sock send-proxy-v2 check

listen  all-ssl
        bind unix@/var/run/haproxy_ssl_ecc.sock accept-proxy ssl crt /usr/local/haproxy/ecc.foo.com.pem user nobody
        bind unix@/var/run/haproxy_ssl_rsa.sock accept-proxy ssl crt /usr/local/haproxy/www.foo.com.pem user nobody

Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
10 years agoCLEANUP: ssl: make ssl_sock_generate_certificate() use ssl_sock_generated_cert_serial()
Willy Tarreau [Tue, 7 Jul 2015 16:09:34 +0000 (18:09 +0200)] 
CLEANUP: ssl: make ssl_sock_generate_certificate() use ssl_sock_generated_cert_serial()

It saves from open-coding the hashing method. Instead all serial
generation is done in a single function.

10 years agoCLEANUP: ssl: make ssl_sock_generated_cert_serial() take a const
Willy Tarreau [Tue, 7 Jul 2015 16:09:15 +0000 (18:09 +0200)] 
CLEANUP: ssl: make ssl_sock_generated_cert_serial() take a const

It doesn't modify the input.

10 years agoMINOR: ssl: make self-generated certs also work with raw IPv6 addresses
Willy Tarreau [Tue, 7 Jul 2015 16:04:38 +0000 (18:04 +0200)] 
MINOR: ssl: make self-generated certs also work with raw IPv6 addresses

The current method of retrieving the incoming connection's destination
address to hash it is not compatible with IPv6 nor the proxy protocol
because it directly tries to get an IPv4 address from the socket. Instead
we must ask the connection. This is only used when no SNI is provided.

10 years agoBUG/MEDIUM: 51d: possible incorrect operations on smp->data.str.str
Dragan Dosen [Tue, 7 Jul 2015 14:10:43 +0000 (16:10 +0200)] 
BUG/MEDIUM: 51d: possible incorrect operations on smp->data.str.str

In src/51d.c, the function _51d_conv(), a final '\0' is added into
smp->data.str.str, which can cause a problem if the SMP_F_CONST flag is
set in smp->flags or if smp->data.str.size is not available.

This patch adds a check on smp->flags and smp->data.str.size, and copies
the smp->data.str.str to another buffer by using smp_dup(). If necessary,
the "const" flag is set after device detection. Also, this patch removes
the unnecessary call to chunk_reset() on temp argument.

10 years agoMEDIUM: http: Add new 'set-src' option to http-request
Adis Nezirovic [Mon, 6 Jul 2015 13:44:30 +0000 (15:44 +0200)] 
MEDIUM: http: Add new 'set-src' option to http-request

This option enables overriding source IP address in a HTTP request. It is
useful when we want to set custom source IP (e.g. front proxy rewrites address,
but provides the correct one in headers) or we wan't to mask source IP address
for privacy or compliance.

It acts on any expression which produces correct IP address.

10 years agoCLEANUP: sample: generalize sample_fetch_string() as sample_fetch_as_type()
Adis Nezirovic [Mon, 6 Jul 2015 13:41:02 +0000 (15:41 +0200)] 
CLEANUP: sample: generalize sample_fetch_string() as sample_fetch_as_type()

This modification makes possible to use sample_fetch_string() in more places,
where we might need to fetch sample values which are not plain strings. This
way we don't need to fetch string, and convert it into another type afterwards.

When using aliased types, the caller should explicitly check which exact type
was returned (e.g. SMP_T_IPV4 or SMP_T_IPV6 for SMP_T_ADDR).

All usages of sample_fetch_string() are converted to use new function.

10 years agoMINOR: stats: improve compression stats reporting
Willy Tarreau [Sat, 4 Jul 2015 12:35:15 +0000 (14:35 +0200)] 
MINOR: stats: improve compression stats reporting

Compression stats were not easy to read and could be confusing because
the saving ratio could be taken for global savings while it was only
relative to compressible input. Let's make that a bit clearer using
the new tooltips with a bit more details and also report the effective
ratio over all output bytes.

10 years agoBUG/MAJOR: tcp: tcp rulesets were still broken
Willy Tarreau [Sat, 4 Jul 2015 09:36:30 +0000 (11:36 +0200)] 
BUG/MAJOR: tcp: tcp rulesets were still broken

Commit cc87a11 ("MEDIUM: tcp: add register keyword system.") broke the
TCP ruleset by merging custom rules and accept. It was fixed a first time
by commit e91ffd0 ("BUG/MAJOR: tcp: only call registered actions when
they're registered") but the accept action still didn't work anymore
and was causing the matching rule to simply be ignored.

Since the code introduced a very fragile behaviour by not even mentionning
that accept and custom were silently merged, let's fix this once for all by
adding an explicit check for the accept action. Nevertheless, as previously
mentionned, the action should be changed so that custom is the only action
and the continue vs break indication directly comes from the callee.

No backport is needed, this bug only affects 1.6-dev.

10 years agoDOC: dns: fix chapters syntax
Cyril Bonté [Thu, 2 Jul 2015 20:45:32 +0000 (22:45 +0200)] 
DOC: dns: fix chapters syntax

All chapters in the configuration documentation used to follow this syntax :
<chapter number>. <title>
-------------------------

The new chapters introduced to document the dns resolution didn't provide the
dot character after the chapter number, which breaks the parsing for the HTML
converter. Instead of adding new conditions in the converter, we can align the
chapters with this syntax.

10 years agoBUG/MAJOR: connection: fix TLV offset calculation for proxy protocol v2 parsing
KOVACS Krisztian [Fri, 3 Jul 2015 12:09:10 +0000 (14:09 +0200)] 
BUG/MAJOR: connection: fix TLV offset calculation for proxy protocol v2 parsing

Until now, the code assumed that it can get the offset to the first TLV
header just by subtracting the length of the TLV part from the length of
the complete buffer. However, if the buffer contains actual data after
the header, this computation is flawed and leads to haproxy trying to
parse TLV headers from the proxied data.

This change fixes this by making sure that the offset to the first TLV
header is calculated based from the start of the buffer -- simply by
adding the size of the proxy protocol v2 header plus the address
family-dependent size of the address information block.

10 years agoBUG/MAJOR: buffers: make the buffer_slow_realign() function respect output data
Willy Tarreau [Thu, 2 Jul 2015 10:50:23 +0000 (12:50 +0200)] 
BUG/MAJOR: buffers: make the buffer_slow_realign() function respect output data

The function buffer_slow_realign() was initially designed for requests
only and did not consider pending outgoing data. This causes a problem
when called on responses where data remain in the buffer, which may
happen with pipelined requests when the client is slow to read data.

The user-visible effect is that if less than <maxrewrite> bytes are
present in the buffer from a previous response and these bytes cross
the <maxrewrite> boundary close to the end of the buffer, then a new
response will cause a realign and will destroy these pending data and
move the pointer to what's believed to contain pending output data.
Thus the client receives the crap that lies in the buffer instead of
the original output bytes.

This new implementation now properly realigns everything including the
outgoing data which are moved to the end of the buffer while the input
data are moved to the beginning.

This implementation still uses a buffer-to-buffer copy which is not
optimal in terms of performance and which should be replaced by a
buffer switch later.

Prior to this patch, the following script would return different hashes
on each round when run from a 100 Mbps-connected machine :

  i=0
  while usleep 100000; do
    echo round $((i++))
    set -- $(nc6 0 8001 < 1kreq5k.txt | grep -v '^[0-9A-Z]' | md5sum)
    if [ "$1" != "3861afbb6566cd48740ce01edc426020" ]; then echo $1;break;fi
  done

The file contains 1000 times this request with "Connection: close" on the
last one :

  GET /?s=5k&R=1 HTTP/1.1

The config is very simple :

  global
        tune.bufsize 16384
        tune.maxrewrite 8192

  defaults
        mode http
        timeout client 10s
        timeout server 5s
        timeout connect 3s

  listen px
        bind :8001
        option http-server-close
        server s1 127.0.0.1:8000

And httpterm-1.7.2 is used as the server on port 8000.

After the fix, 1 million requests were sent and all returned the same
contents.

Many thanks to Charlie Smurthwaite of atechmedia.com for his precious
help on this issue, which would not have been diagnosed without his
very detailed traces and numerous tests.

The patch must be backported to 1.5 which is where the bug was introduced.

10 years agoBUILD: add netbsd TARGET
David Carlier [Thu, 2 Jul 2015 06:58:22 +0000 (06:58 +0000)] 
BUILD: add netbsd TARGET

For now it's the same as openbsd.

10 years agoBUILD/MINOR: tools: rename popcount to my_popcountl
David Carlier [Thu, 2 Jul 2015 07:00:17 +0000 (07:00 +0000)] 
BUILD/MINOR: tools: rename popcount to my_popcountl

This is in order to avoid conflicting with NetBSD popcount* functions
since 6.x release, the final l to mentions the argument is a long like
NetBSD does.

This patch could be backported to 1.5 to fix the build issue there as well.

10 years agoDOC: add notes about the "51degrees-cache-size" parameter
Dragan Dosen [Mon, 29 Jun 2015 14:43:27 +0000 (16:43 +0200)] 
DOC: add notes about the "51degrees-cache-size" parameter

10 years agoMEDIUM: 51d: add LRU-based cache on User-Agent string detection
Dragan Dosen [Mon, 29 Jun 2015 14:43:26 +0000 (16:43 +0200)] 
MEDIUM: 51d: add LRU-based cache on User-Agent string detection

This cache is used by 51d converter. The input User-Agent string, the
converter args and a random seed are used as a hashing key. The cached
entries contains a pointer to the resulting string for specific
User-Agent string detection.

The cache size can be tuned using 51degrees-cache-size parameter.

10 years agoMEDIUM: 51Degrees code refactoring and cleanup
Dragan Dosen [Mon, 29 Jun 2015 14:43:25 +0000 (16:43 +0200)] 
MEDIUM: 51Degrees code refactoring and cleanup

Moved 51Degrees code from src/haproxy.c, src/sample.c and src/cfgparse.c
into a separate files src/51d.c and include/import/51d.h.

Added two new functions init_51degrees() and deinit_51degrees(), updated
Makefile and other code reorganizations related to 51Degrees.

10 years agoBUG/MEDIUM: vars: do not freeze the connection when the expression cannot be fetched
Willy Tarreau [Tue, 23 Jun 2015 13:17:33 +0000 (15:17 +0200)] 
BUG/MEDIUM: vars: do not freeze the connection when the expression cannot be fetched

Commit 4834bc7 ("MEDIUM: vars: adds support of variables") brought a bug.
Setting a variable from an expression that doesn't resolve infinitely
blocks the processing.

The internal actions API must be changed to let the caller pass the various
flags regarding the state of the analysis (SMP_OPT_FINAL).

For now we only fix the issue by making the action_store() function always
return 1 to prevent any blocking.

No backport is needed.

10 years agoMEDIUM: vars: move the session variables to the session, not the stream
Willy Tarreau [Fri, 19 Jun 2015 09:59:02 +0000 (11:59 +0200)] 
MEDIUM: vars: move the session variables to the session, not the stream

It's important that the session-wide variables are in the session and not
in the stream.

10 years agoMINOR: vars: make the accounting not depend on the stream
Willy Tarreau [Fri, 19 Jun 2015 09:21:56 +0000 (11:21 +0200)] 
MINOR: vars: make the accounting not depend on the stream

We'll need to move the session variables to the session. For this, the
accounting must not depend on the stream. Instead we pass the pointers
to the different lists.

10 years agoBUG/MEDIUM: lru: fix possible memory leak when ->free() is used
Willy Tarreau [Wed, 17 Jun 2015 18:33:30 +0000 (20:33 +0200)] 
BUG/MEDIUM: lru: fix possible memory leak when ->free() is used

Commit 7810ad7 ("BUG/MAJOR: lru: fix unconditional call to free due to
unexpected semi-colon") was not enough, it happens that the free() is
not performed at the right place because if the evicted node is recycled,
we must also release its data before it gets overwritten.

No backport is needed.

10 years agoBUILD/MINOR: lua: ensure that hlua_ctx_destroy is properly defined
Willy Tarreau [Wed, 17 Jun 2015 18:18:54 +0000 (20:18 +0200)] 
BUILD/MINOR: lua: ensure that hlua_ctx_destroy is properly defined

When Lua is disabled, the alternate functions must have the same
prototype as the original ones, otherwise we get such warnings :

src/stream.c:278:27: warning: too many arguments in call to 'hlua_ctx_destroy'
        hlua_ctx_destroy(&s->hlua);
        ~~~~~~~~~~~~~~~~         ^
No backport is needed.

10 years agoBUG/MEDIUM: logs: fix improper systematic use of quotes with a few tags
Willy Tarreau [Wed, 17 Jun 2015 17:58:02 +0000 (19:58 +0200)] 
BUG/MEDIUM: logs: fix improper systematic use of quotes with a few tags

Dmitry Sivachenko reported the following build warning using Clang, which
is a real bug :

  src/log.c:1538:22: warning: use of logical '&&' with constant operand
        [-Wconstant-logical-operand]
                                  if (tmp->options && LOG_OPT_QUOTE)
                                                   ^  ~~~~~~~~~~~~~
The effect is that recent log tags related to HTTP method, path, uri,
query have a bug making them always use quotes.

This bug was introduced in 1.6-dev2 with commit 0ebc55f ("MEDIUM: logs:
Add HTTP request-line log format directives"), so no backport is needed.

10 years agoBUG/MAJOR: lru: fix unconditional call to free due to unexpected semi-colon
Willy Tarreau [Wed, 17 Jun 2015 17:53:03 +0000 (19:53 +0200)] 
BUG/MAJOR: lru: fix unconditional call to free due to unexpected semi-colon

Dmitry Sivachenko reported the following build warning using Clang, which
is a real bug :

  src/lru.c:133:32: warning: if statement has empty body [-Wempty-body]
                                  if (old->data && old->free);
                                                             ^
It results in calling old->free(old->data) even when old->free is NULL,
hence crashing on cached patterns.

The same bug appears a few lines below in lru64_destroy() :

  src/lru.c:195:33: warning: if statement has empty body [-Wempty-body]
                          if (elem->data && elem->free);
                                                       ^
Both were introduced in 1.6-dev2 with commit f90ac55 ("MINOR: lru: Add the
possibility to free data when an item is removed"), so no backport is needed.

10 years agoBUILD/MINOR: stats: fix build warning due to condition always true
Willy Tarreau [Wed, 17 Jun 2015 17:49:52 +0000 (19:49 +0200)] 
BUILD/MINOR: stats: fix build warning due to condition always true

Dmitry Sivachenko reported the following harmless build warning using Clang :

  src/dumpstats.c:5196:48: warning: address of array 'strm_li(sess)->proto->name'
        will always evaluate to 'true' [-Wpointer-bool-conversion]
    ...strm_li(sess) && strm_li(sess)->proto->name ? strm_li(sess)->proto->nam...
                     ~~ ~~~~~~~~~~~~~~~~~~~~~~^~~~
proto->name cannot be null here as it's the protocol name which is stored
directly in the structure.

The same case is present in 1.5 though the code changed.

10 years agoBUILD/MINOR: lua: fix a harmless build warning
Willy Tarreau [Wed, 17 Jun 2015 17:43:49 +0000 (19:43 +0200)] 
BUILD/MINOR: lua: fix a harmless build warning

Dmitry Sivachenko reported the following build warning using Clang,
though it's harmless :

  src/hlua.c:1911:13: warning: variable '_socket_info_expanded_form' is not needed
        and will not be emitted [-Wunneeded-internal-declaration]
  static char _socket_info_expanded_form[] = SOCKET_INFO_EXPANDED_FORM;
              ^
Indeed, the variable is not used except to compute a sizeof which is
taken from the string it is initialized from. It probably is a leftover
after various code refactorings. Let's get rid of it now since it's not
used anymore.

No backport is needed.

10 years agoBUG/MINOR: ssl: fix smp_fetch_ssl_fc_session_id
Willy Tarreau [Wed, 17 Jun 2015 16:34:14 +0000 (18:34 +0200)] 
BUG/MINOR: ssl: fix smp_fetch_ssl_fc_session_id

Dmitry Sivachenko reported the following build warning using Clang
which is a real bug :

src/ssl_sock.c:4104:44: warning: address of 'smp->data.str.len' will always
      evaluate to 'true' [-Wpointer-bool-conversion]
        if (!smp->data.str.str || !&smp->data.str.len)

The impact is very low however, it will return an empty session_id
instead of no session id when none is found.

The fix should be backported to 1.5.

10 years ago[RELEASE] Released version 1.6-dev2 v1.6-dev2
Willy Tarreau [Wed, 17 Jun 2015 13:53:25 +0000 (15:53 +0200)] 
[RELEASE] Released version 1.6-dev2

Released version 1.6-dev2 with the following main changes :
    - BUG/MINOR: ssl: Display correct filename in error message
    - MEDIUM: logs: Add HTTP request-line log format directives
    - BUG/MEDIUM: check: tcpcheck regression introduced by e16c1b3f
    - BUG/MINOR: check: fix tcpcheck error message
    - MINOR: use an int instead of calling tcpcheck_get_step_id
    - MINOR: tcpcheck_rule structure update
    - MINOR: include comment in tcpcheck error log
    - DOC: tcpcheck comment documentation
    - MEDIUM: server: add support for changing a server's address
    - MEDIUM: server: change server ip address from stats socket
    - MEDIUM: protocol: add minimalist UDP protocol client
    - MEDIUM: dns: implement a DNS resolver
    - MAJOR: server: add DNS-based server name resolution
    - DOC: server name resolution + proto DNS
    - MINOR: dns: add DNS statistics
    - MEDIUM: http: configurable http result codes for http-request deny
    - BUILD: Compile clean when debug options defined
    - MINOR: lru: Add the possibility to free data when an item is removed
    - MINOR: lru: Add lru64_lookup function
    - MEDIUM: ssl: Add options to forge SSL certificates
    - MINOR: ssl: Export functions to manipulate generated certificates
    - MEDIUM: config: add DeviceAtlas global keywords
    - MEDIUM: global: add the DeviceAtlas required elements to struct global
    - MEDIUM: sample: add the da-csv converter
    - MEDIUM: init: DeviceAtlas initialization
    - BUILD: Makefile: add options to build with DeviceAtlas
    - DOC: README: explain how to build with DeviceAtlas
    - BUG/MEDIUM: http: fix the url_param fetch
    - BUG/MEDIUM: init: segfault if global._51d_property_names is not initialized
    - MAJOR: peers: peers protocol version 2.0
    - MINOR: peers: avoid re-scheduling of pending stick-table's updates still not pushed.
    - MEDIUM: peers: re-schedule stick-table's entry for sync when data is modified.
    - MEDIUM: peers: support of any stick-table data-types for sync
    - BUG/MAJOR: sample: regression on sample cast to stick table types.
    - CLEANUP: deinit: remove codes for cleaning p->block_rules
    - DOC: Fix L4TOUT typo in documentation
    - DOC: set-log-level in Logging section preamble
    - BUG/MEDIUM: compat: fix segfault on FreeBSD
    - MEDIUM: check: include server address and port in the send-state header
    - MEDIUM: backend: Allow redispatch on retry intervals
    - MINOR: Add TLS ticket keys reference and use it in the listener struct
    - MEDIUM: Add support for updating TLS ticket keys via socket
    - DOC: Document new socket commands "show tls-keys" and "set ssl tls-key"
    - MINOR: Add sample fetch which identifies if the SSL session has been resumed
    - DOC: Update doc about weight, act and bck fields in the statistics
    - BUG/MEDIUM: ssl: fix tune.ssl.default-dh-param value being overwritten
    - MINOR: ssl: add a destructor to free allocated SSL ressources
    - MEDIUM: ssl: add the possibility to use a global DH parameters file
    - MEDIUM: ssl: replace standards DH groups with custom ones
    - MEDIUM: stats: Add enum srv_stats_state
    - MEDIUM: stats: Separate server state and colour in stats
    - MEDIUM: stats: Only report drain state in stats if server has SRV_ADMF_DRAIN set
    - MEDIUM: stats: Differentiate between DRAIN and DRAIN (agent)
    - MEDIUM: Lower priority of email alerts for log-health-checks messages
    - MEDIUM: Send email alerts when servers are marked as UP or enter the drain state
    - MEDIUM: Document when email-alerts are sent
    - BUG/MEDIUM: lua: bad argument number in analyser and in error message
    - MEDIUM: lua: automatically converts strings in proxy, tables, server and ip
    - BUG/MINOR: utf8: remove compilator warning
    - MEDIUM: map: uses HAProxy facilities to store default value
    - BUG/MINOR: lua: error in detection of mandatory arguments
    - BUG/MINOR: lua: set current proxy as default value if it is possible
    - BUG/MEDIUM: http: the action set-{method|path|query|uri} doesn't run.
    - BUG/MEDIUM: lua: undetected infinite loop
    - BUG/MAJOR: http: don't read past buffer's end in http_replace_value
    - BUG/MEDIUM: http: the function "(req|res)-replace-value" doesn't respect the HTTP syntax
    - MEDIUM/CLEANUP: http: rewrite and lighten http_transform_header() prototype
    - BUILD: lua: it miss the '-ldl' directive
    - MEDIUM: http: allows 'R' and 'S' in the protocol alphabet
    - MINOR: http: split the function http_action_set_req_line() in two parts
    - MINOR: http: split http_transform_header() function in two parts.
    - MINOR: http: export function inet_set_tos()
    - MINOR: lua: txn: add function set_(loglevel|tos|mark)
    - MINOR: lua: create and register HTTP class
    - DOC: lua: fix some typos
    - MINOR: lua: add log functions
    - BUG/MINOR: lua: Fix SSL initialisation
    - DOC: lua: some fixes
    - MINOR: lua: (req|res)_get_headers return more than one header value
    - MINOR: lua: map system integration in Lua
    - BUG/MEDIUM: http: functions set-{path,query,method,uri} breaks the HTTP parser
    - MINOR: sample: add url_dec converter
    - MEDIUM: sample: fill the struct sample with the session, proxy and stream pointers
    - MEDIUM: sample change the prototype of sample-fetches and converters functions
    - MINOR: sample: fill the struct sample with the options.
    - MEDIUM: sample: change the prototype of sample-fetches functions
    - MINOR: http: split the url_param in two parts
    - CLEANUP: http: bad indentation
    - MINOR: http: add body_param fetch
    - MEDIUM: http: url-encoded parsing function can run throught wrapped buffer
    - DOC: http: req.body_param documentation
    - MINOR: proxy: custom capture declaration
    - MINOR: capture: add two "capture" converters
    - MEDIUM: capture: Allow capture with slot identifier
    - MINOR: http: add array of generic pointers in http_res_rules
    - MEDIUM: capture: adds http-response capture
    - MINOR: common: escape CSV strings
    - MEDIUM: stats: escape some strings in the CSV dump
    - MINOR: tcp: add custom actions that can continue tcp-(request|response) processing
    - MINOR: lua: Lua tcp action are not final action
    - DOC: lua: schematics about lua socket organization
    - BUG/MINOR: debug: display (null) in place of "meth"
    - DOC: mention the "lua action" in documentation
    - MINOR: standard: add function that converts signed int to a string
    - BUG/MINOR: sample: wrong conversion of signed values
    - MEDIUM: sample: Add type any
    - MINOR: debug: add a special converter which display its input sample content.
    - MINOR: tcp: increase the opaque data array
    - MINOR: tcp/http/conf: extends the keyword registration options
    - MINOR: build: fix build dependency
    - MEDIUM: vars: adds support of variables
    - MINOR: vars: adds get and set functions
    - MINOR: lua: Variable access
    - MINOR: samples: add samples which returns constants
    - BUG/MINOR: vars/compil: fix some warnings
    - BUILD: add 51degrees options to makefile.
    - MINOR: global: add several 51Degrees members to global
    - MINOR: config: add 51Degrees config parsing.
    - MINOR: init: add 51Degrees initialisation code
    - MEDIUM: sample: add fiftyone_degrees converter.
    - MEDIUM: deinit: add cleanup for 51Degrees to deinit
    - MEDIUM: sample: add trie support to 51Degrees
    - DOC: add 51Degrees notes to configuration.txt.
    - DOC: add build indications for 51Degrees to README.
    - MEDIUM: cfgparse: introduce weak and strong quoting
    - BUG/MEDIUM: cfgparse: incorrect memmove in quotes management
    - MINOR: cfgparse: remove line size limitation
    - MEDIUM: cfgparse: expand environment variables
    - BUG/MINOR: cfgparse: fix typo in 'option httplog' error message
    - BUG/MEDIUM: cfgparse: segfault when userlist is misused
    - CLEANUP: cfgparse: remove reference to 'ruleset' section
    - MEDIUM: cfgparse: check section maximum number of arguments
    - MEDIUM: cfgparse: max arguments check in the global section
    - MEDIUM: cfgparse: check max arguments in the proxies sections
    - CLEANUP: stream-int: remove a redundant clearing of the linger_risk flag
    - MINOR: connection: make conn_sock_shutw() actually perform the shutdown() call
    - MINOR: stream-int: use conn_sock_shutw() to shutdown a connection
    - MINOR: connection: perform the call to xprt->shutw() in conn_data_shutw()
    - MEDIUM: stream-int: replace xprt->shutw calls with conn_data_shutw()
    - MINOR: checks: use conn_data_shutw_hard() instead of call via xprt
    - MINOR: connection: implement conn_sock_send()
    - MEDIUM: stream-int: make conn_si_send_proxy() use conn_sock_send()
    - MEDIUM: connection: make conn_drain() perform more controls
    - REORG: connection: move conn_drain() to connection.c and rename it
    - CLEANUP: stream-int: remove inclusion of fd.h that is not used anymore
    - MEDIUM: channel: don't always set CF_WAKE_WRITE on bi_put*
    - CLEANUP: lua: don't use si_ic/si_oc on known stream-ints
    - BUG/MEDIUM: peers: correctly configure the client timeout
    - MINOR: peers: centralize configuration of the peers frontend
    - MINOR: proxy: store the default target into the frontend's configuration
    - MEDIUM: stats: use frontend_accept() as the accept function
    - MEDIUM: peers: use frontend_accept() instead of peer_accept()
    - CLEANUP: listeners: remove unused timeout
    - MEDIUM: listener: store the default target per listener
    - BUILD: fix automatic inclusion of libdl.
    - MEDIUM: lua: implement a simple memory allocator
    - MEDIUM: compression: postpone buffer adjustments after compression
    - MEDIUM: compression: don't send leading zeroes with chunk size
    - BUG/MINOR: compression: consider the expansion factor in init
    - MINOR: http: check the algo name "identity" instead of the function pointer
    - CLEANUP: compression: statify all algo-specific functions
    - MEDIUM: compression: add a distinction between UA- and config- algorithms
    - MEDIUM: compression: add new "raw-deflate" compression algorithm
    - MEDIUM: compression: split deflate_flush() into flush and finish
    - CLEANUP: compression: remove unused reset functions
    - MAJOR: compression: integrate support for libslz
    - BUG/MEDIUM: http: hdr_cnt would not count any header when called without name
    - BUG/MAJOR: http: null-terminate the http actions keywords list
    - CLEANUP: lua: remove the unused hlua_sleep memory pool
    - BUG/MAJOR: lua: use correct object size when initializing a new converter
    - CLEANUP: lua: remove hard-coded sizeof() in object creations and mallocs
    - CLEANUP: lua: fix confusing local variable naming in hlua_txn_new()
    - CLEANUP: hlua: stop using variable name "s" alternately for hlua_txn and hlua_smp
    - CLEANUP: lua: get rid of the last "*ht" for struct hlua_txn.
    - CLEANUP: lua: rename last occurrences of "*s" to "*htxn" for hlua_txn
    - CLEANUP: lua: rename variable "sc" for struct hlua_smp
    - CLEANUP: lua: get rid of the last two "*hs" for hlua_smp
    - REORG/MAJOR: session: rename the "session" entity to "stream"
    - REORG/MEDIUM: stream: rename stream flags from SN_* to SF_*
    - MINOR: session: start to reintroduce struct session
    - MEDIUM: stream: allocate the session when a stream is created
    - MEDIUM: stream: move the listener's pointer to the session
    - MEDIUM: stream: move the frontend's pointer to the session
    - MINOR: session: add a pointer to the session's origin
    - MEDIUM: session: use the pointer to the origin instead of s->si[0].end
    - CLEANUP: sample: remove useless tests in fetch functions for l4 != NULL
    - MEDIUM: http: move header captures from http_txn to struct stream
    - MINOR: http: create a dedicated pool for http_txn
    - MAJOR: http: move http_txn out of struct stream
    - MAJOR: sample: don't pass l7 anymore to sample fetch functions
    - CLEANUP: lua: remove unused hlua_smp->l7 and hlua_txn->l7
    - MEDIUM: http: remove the now useless http_txn from {req/res} rules
    - CLEANUP: lua: don't pass http_txn anymore to hlua_request_act_wrapper()
    - MAJOR: sample: pass a pointer to the session to each sample fetch function
    - MINOR: stream: provide a few helpers to retrieve frontend, listener and origin
    - CLEANUP: stream: don't set ->target to the incoming connection anymore
    - MINOR: stream: move session initialization before the stream's
    - MINOR: session: store the session's accept date
    - MINOR: session: don't rely on s->logs.logwait in embryonic sessions
    - MINOR: session: implement session_free() and use it everywhere
    - MINOR: session: add stick counters to the struct session
    - REORG: stktable: move the stkctr_* functions from stream to sticktable
    - MEDIUM: streams: support looking up stkctr in the session
    - MEDIUM: session: update the session's stick counters upon session_free()
    - MEDIUM: proto_tcp: track the session's counters in the connection ruleset
    - MAJOR: tcp: make tcp_exec_req_rules() only rely on the session
    - MEDIUM: stream: don't call stream_store_counters() in kill_mini_session() nor session_accept()
    - MEDIUM: stream: move all the session-specific stuff of stream_accept() earlier
    - MAJOR: stream: don't initialize the stream anymore in stream_accept
    - MEDIUM: session: remove the task pointer from the session
    - REORG: session: move the session parts out of stream.c
    - MINOR: stream-int: make appctx_new() take the applet in argument
    - MEDIUM: peers: move the appctx initialization earlier
    - MINOR: session: introduce session_new()
    - MINOR: session: make use of session_new() when creating a new session
    - MINOR: peers: make use of session_new() when creating a new session
    - MEDIUM: peers: initialize the task before the stream
    - MINOR: session: set the CO_FL_CONNECTED flag on the connection once ready
    - CLEANUP: stream.c: do not re-attach the connection to the stream
    - MEDIUM: stream: isolate connection-specific initialization code
    - MEDIUM: stream: also accept appctx as origin in stream_accept_session()
    - MEDIUM: peers: make use of stream_accept_session()
    - MEDIUM: frontend: make ->accept only return +/-1
    - MEDIUM: stream: return the stream upon accept()
    - MEDIUM: frontend: move some stream initialisation to stream_new()
    - MEDIUM: frontend: move the fd-specific settings to session_accept_fd()
    - MEDIUM: frontend: don't restrict frontend_accept() to connections anymore
    - MEDIUM: frontend: move some remaining stream settings to stream_new()
    - CLEANUP: frontend: remove one useless local variable
    - MEDIUM: stream: don't rely on the session's listener anymore in stream_new()
    - MEDIUM: lua: make use of stream_new() to create an outgoing connection
    - MINOR: lua: minor cleanup in hlua_socket_new()
    - MINOR: lua: no need for setting timeouts / conn_retries in hlua_socket_new()
    - MINOR: peers: no need for setting timeouts / conn_retries in peer_session_create()
    - CLEANUP: stream-int: swap stream-int and appctx declarations
    - CLEANUP: namespaces: fix protection against multiple inclusions
    - MINOR: session: maintain the session count stats in the session, not the stream
    - MEDIUM: session: adjust the connection flags before stream_new()
    - MINOR: stream: pass the pointer to the origin explicitly to stream_new()
    - CLEANUP: poll: move the conditions for waiting out of the poll functions
    - BUG/MEDIUM: listener: don't report an error when resuming unbound listeners
    - BUG/MEDIUM: init: don't limit cpu-map to the first 32 processes only
    - BUG/MAJOR: tcp/http: fix current_rule assignment when restarting over a ruleset
    - BUG/MEDIUM: stream-int: always reset si->ops when si->end is nullified
    - DOC: update the entities diagrams
    - BUG/MEDIUM: http: properly retrieve the front connection
    - MINOR: applet: add a new "owner" pointer in the appctx
    - MEDIUM: applet: make the applet not depend on a stream interface anymore
    - REORG: applet: move the applet definitions out of stream_interface
    - CLEANUP: applet: rename struct si_applet to applet
    - REORG: stream-int: create si_applet_ops dedicated to applets
    - MEDIUM: applet: add basic support for an applet run queue
    - MEDIUM: applet: implement a run queue for active appctx
    - MEDIUM: stream-int: add a new function si_applet_done()
    - MAJOR: applet: now call si_applet_done() instead of si_update() in I/O handlers
    - MAJOR: stream: use a regular ->update for all stream interfaces
    - MEDIUM: dumpstats: don't unregister the applet anymore
    - MEDIUM: applet: centralize the call to si_applet_done() in the I/O handler
    - MAJOR: stream: do not allocate request buffers anymore when the left side is an applet
    - MINOR: stream-int: add two flags to indicate an applet's wishes regarding I/O
    - MEDIUM: applet: make the applets only use si_applet_{cant|want|stop}_{get|put}
    - MEDIUM: stream-int: pause the appctx if the task is woken up
    - BUG/MAJOR: tcp: only call registered actions when they're registered
    - BUG/MEDIUM: peers: fix applet scheduling
    - BUG/MEDIUM: peers: recent applet changes broke peers updates scheduling
    - MINOR: tools: provide an rdtsc() function for time comparisons
    - IMPORT: lru: import simple ebtree-based LRU functions
    - IMPORT: hash: import xxhash-r39
    - MEDIUM: pattern: add a revision to all pattern expressions
    - MAJOR: pattern: add LRU-based cache on pattern matching
    - BUG/MEDIUM: http: remove content-length from chunked messages
    - DOC: http: update the comments about the rules for determining transfer-length
    - BUG/MEDIUM: http: do not restrict parsing of transfer-encoding to HTTP/1.1
    - BUG/MEDIUM: http: incorrect transfer-coding in the request is a bad request
    - BUG/MEDIUM: http: remove content-length form responses with bad transfer-encoding
    - MEDIUM: http: restrict the HTTP version token to 1 digit as per RFC7230
    - MEDIUM: http: disable support for HTTP/0.9 by default
    - MEDIUM: http: add option-ignore-probes to get rid of the floods of 408
    - BUG/MINOR: config: clear proxy->table.peers.p for disabled proxies
    - MEDIUM: init: don't stop proxies in parent process when exiting
    - MINOR: stick-table: don't attach to peers in stopped state
    - MEDIUM: config: initialize stick-tables after peers, not before
    - MEDIUM: peers: add the ability to disable a peers section
    - MINOR: peers: store the pointer to the signal handler
    - MEDIUM: peers: unregister peers that were never started
    - MEDIUM: config: propagate the table's process list to the peers sections
    - MEDIUM: init: stop any peers section not bound to the correct process
    - MEDIUM: config: validate that peers sections are bound to exactly one process
    - MAJOR: peers: allow peers section to be used with nbproc > 1
    - DOC: relax the peers restriction to single-process
    - DOC: document option http-ignore-probes
    - DOC: fix the comments about the meaning of msg->sol in HTTP
    - BUG/MEDIUM: http: wait for the exact amount of body bytes in wait_for_request_body
    - BUG/MAJOR: http: prevent risk of reading past end with balance url_param
    - MEDIUM: stream: move HTTP request body analyser before process_common
    - MEDIUM: http: add a new option http-buffer-request
    - MEDIUM: http: provide 3 fetches for the body
    - DOC: update the doc on the proxy protocol
    - BUILD: pattern: fix build warnings introduced in the LRU cache
    - BUG/MEDIUM: stats: properly initialize the scope before dumping stats
    - CLEANUP: config: fix misleading information in error message.
    - MINOR: config: report the number of processes using a peers section in the error case
    - BUG/MEDIUM: config: properly compute the default number of processes for a proxy
    - MEDIUM: http: add new "capture" action for http-request
    - BUG/MEDIUM: http: fix the http-request capture parser
    - BUG/MEDIUM: http: don't forward client shutdown without NOLINGER except for tunnels
    - BUILD/MINOR: ssl: fix build failure introduced by recent patch
    - BUG/MAJOR: check: fix breakage of inverted tcp-check rules
    - CLEANUP: checks: fix double usage of cur / current_step in tcp-checks
    - BUG/MEDIUM: checks: do not dereference head of a tcp-check at the end
    - CLEANUP: checks: simplify the loop processing of tcp-checks
    - BUG/MAJOR: checks: always check for end of list before proceeding
    - BUG/MEDIUM: checks: do not dereference a list as a tcpcheck struct
    - BUG/MAJOR: checks: break infinite loops when tcp-checks starts with comment
    - MEDIUM: http: make url_param iterate over multiple occurrences
    - BUG/MEDIUM: peers: apply a random reconnection timeout
    - MEDIUM: config: reject invalid config with name duplicates
    - MEDIUM: config: reject conflicts in table names
    - CLEANUP: proxy: make the proxy lookup functions more user-friendly
    - MINOR: proxy: simply ignore duplicates in proxy name lookups
    - MINOR: config: don't open-code proxy name lookups
    - MEDIUM: config: clarify the conflicting modes detection for backend rules
    - CLEANUP: proxy: remove now unused function findproxy_mode()
    - MEDIUM: stick-table: remove the now duplicate find_stktable() function
    - MAJOR: config: remove the deprecated reqsetbe / reqisetbe actions
    - MINOR: proxy: add a new function proxy_find_by_id()
    - MINOR: proxy: add a flag to memorize that the proxy's ID was forced
    - MEDIUM: proxy: add a new proxy_find_best_match() function
    - CLEANUP: http: explicitly reference request in http_apply_redirect_rules()
    - MINOR: http: prepare support for parsing redirect actions on responses
    - MEDIUM: http: implement http-response redirect rules
    - MEDIUM: http: no need to close the request on redirect if data was parsed
    - BUG/MEDIUM: http: fix body processing for the stats applet
    - BUG/MINOR: da: fix log-level comparison to emove annoying warning
    - CLEANUP: global: remove one ifdef USE_DEVICEATLAS
    - CLEANUP: da: move the converter registration to da.c
    - CLEANUP: da: register the config keywords in da.c
    - CLEANUP: adjust the envelope name in da.h to reflect the file name
    - CLEANUP: da: remove ifdef USE_DEVICEATLAS from da.c
    - BUILD: make 51D easier to build by defaulting to 51DEGREES_SRC
    - BUILD: fix build warning when not using 51degrees
    - BUILD: make DeviceAtlas easier to build by defaulting to DEVICEATLAS_SRC
    - BUILD: ssl: fix recent build breakage on older SSL libs

10 years agoBUILD: ssl: fix recent build breakage on older SSL libs
Willy Tarreau [Wed, 17 Jun 2015 13:48:26 +0000 (15:48 +0200)] 
BUILD: ssl: fix recent build breakage on older SSL libs

Commit 31af49d ("MEDIUM: ssl: Add options to forge SSL certificates")
introduced some dependencies on SSL_CTRL_SET_TLSEXT_HOSTNAME for which
a few checks were missing, breaking the build on openssl 0.9.8.

10 years agoBUG/MINOR: vars/compil: fix some warnings
Thierry FOURNIER [Tue, 16 Jun 2015 21:52:47 +0000 (23:52 +0200)] 
BUG/MINOR: vars/compil: fix some warnings

A switch case doesn't have default entry, and the compilator sends
a warning about uninitilized var.

   warning: 'vars' may be used uninitialized in this function [-Wmaybe-uninitialized]

10 years agoBUG/MAJOR: sample: regression on sample cast to stick table types.
Emeric Brun [Tue, 16 Jun 2015 16:26:17 +0000 (18:26 +0200)] 
BUG/MAJOR: sample: regression on sample cast to stick table types.

This regression was introduce by commit
9c627e84b2 (MEDIUM: sample: Add type any)

New sample type 'any' was not handled in the matrix used to cast
to stick-tables types.

10 years agoMEDIUM: peers: support of any stick-table data-types for sync
Emeric Brun [Thu, 11 Jun 2015 16:25:54 +0000 (18:25 +0200)] 
MEDIUM: peers: support of any stick-table data-types for sync

It is possible to propagate entries of any data-types in stick-tables between
several haproxy instances over TCP connections in a multi-master fashion. Each
instance pushes its local updates and insertions to remote peers. The pushed
values overwrite remote ones without aggregation. Interrupted exchanges are
automatically detected and recovered from the last known point.

10 years agoMEDIUM: peers: re-schedule stick-table's entry for sync when data is modified.
Emeric Brun [Mon, 15 Jun 2015 16:29:57 +0000 (18:29 +0200)] 
MEDIUM: peers: re-schedule stick-table's entry for sync when data is modified.

This was correctly done for data of type 'serverid' but it is now
necessary for all stick-tables data-types if we want to perform their
sync.

10 years agoMINOR: peers: avoid re-scheduling of pending stick-table's updates still not pushed.
Emeric Brun [Mon, 15 Jun 2015 15:23:30 +0000 (17:23 +0200)] 
MINOR: peers: avoid re-scheduling of pending stick-table's updates still not pushed.

10 years agoMINOR: samples: add samples which returns constants
Thierry FOURNIER [Sat, 6 Jun 2015 17:30:17 +0000 (19:30 +0200)] 
MINOR: samples: add samples which returns constants

This patch adds sample which returns constants values. This is useful
for intialising variables.

10 years agoMINOR: lua: Variable access
Thierry FOURNIER [Mon, 8 Jun 2015 11:05:33 +0000 (13:05 +0200)] 
MINOR: lua: Variable access

This patch adds two Lua function for using HAPRoxy's
vraibles. The function are stored in the TXN class,
and her name is "set_var" and "get_var".

10 years agoMINOR: vars: adds get and set functions
Thierry FOURNIER [Tue, 9 Jun 2015 10:27:17 +0000 (12:27 +0200)] 
MINOR: vars: adds get and set functions

This patch adds two functions used for variable acces using the
variable full name. If the variable doesn't exists in the variable
pool name, it is created.

10 years agoMEDIUM: vars: adds support of variables
Thierry FOURNIER [Sat, 6 Jun 2015 17:29:07 +0000 (19:29 +0200)] 
MEDIUM: vars: adds support of variables

This patch adds support of variables during the processing of each stream. The
variables scope can be set as 'session', 'transaction', 'request' or 'response'.
The variable type is the type returned by the assignment expression. The type
can change while the processing.

The allocated memory can be controlled for each scope and each request, and for
the global process.

10 years agoMINOR: build: fix build dependency
Thierry FOURNIER [Tue, 9 Jun 2015 13:49:44 +0000 (15:49 +0200)] 
MINOR: build: fix build dependency

fix include dependency. The header file sample.h don't need to known
the content of the struct arg, so I remove the include, and replace
it by a simple pointer declaration.

This prevent an include dependecy issue with the next patch.

10 years agoMINOR: tcp/http/conf: extends the keyword registration options
Thierry FOURNIER [Thu, 4 Jun 2015 09:44:06 +0000 (11:44 +0200)] 
MINOR: tcp/http/conf: extends the keyword registration options

This patch permits to register a new keyword with the keyword "tcp-request content"
'tcp-request connection", tcp-response content", http-request" and "http-response"
which is identified only by matching the start of the keyword.

for example, we register the keyword "set-var" with the option "match_pfx"
and the configuration keyword "set-var(var_name)" matchs this entry.

10 years agoMINOR: tcp: increase the opaque data array
Thierry FOURNIER [Wed, 3 Jun 2015 17:32:04 +0000 (19:32 +0200)] 
MINOR: tcp: increase the opaque data array

This patch increase the opaque data array for the tcp_rules.
It is used by the "store" action (next commited) which deal
with variables.

10 years agoMINOR: debug: add a special converter which display its input sample content.
Thierry FOURNIER [Thu, 7 May 2015 13:46:29 +0000 (15:46 +0200)] 
MINOR: debug: add a special converter which display its input sample content.

This converter displays its input sample type and content. It is useful
for debugging some complex configurations.

10 years agoMEDIUM: sample: Add type any
Thierry FOURNIER [Wed, 3 Jun 2015 18:12:35 +0000 (20:12 +0200)] 
MEDIUM: sample: Add type any

This type is used to accept any type of sample as input, and prevent
any automatic "cast". It runs like the type "ADDR" which accept the
type "IPV4" and "IPV6".

10 years agoBUG/MINOR: sample: wrong conversion of signed values
Thierry FOURNIER [Sat, 6 Jun 2015 17:16:52 +0000 (19:16 +0200)] 
BUG/MINOR: sample: wrong conversion of signed values

The signed values are casted as unsigned before conversion. This patch
use the good converters according with the sample type.

Note: it depends on previous patch to parse signed ints.

10 years agoMINOR: standard: add function that converts signed int to a string
Thierry FOURNIER [Sat, 6 Jun 2015 17:14:59 +0000 (19:14 +0200)] 
MINOR: standard: add function that converts signed int to a string

This function is the same as "ultoa_r", but it takes a signed value
as input.

10 years agoDOC: mention the "lua action" in documentation
Thierry FOURNIER [Thu, 4 Jun 2015 10:23:41 +0000 (12:23 +0200)] 
DOC: mention the "lua action" in documentation

Fix some precision about lua.

10 years agoMINOR: dns: add DNS statistics
Baptiste Assmann [Sat, 16 May 2015 22:33:24 +0000 (00:33 +0200)] 
MINOR: dns: add DNS statistics

add a new command on the stats socket to print a DNS resolvers section
(including per server) statistics: "show stats resolvers <id>"

10 years agoDOC: server name resolution + proto DNS
Baptiste Assmann [Mon, 13 Apr 2015 22:28:47 +0000 (00:28 +0200)] 
DOC: server name resolution + proto DNS

10 years agoMAJOR: server: add DNS-based server name resolution
Baptiste Assmann [Mon, 13 Apr 2015 23:15:08 +0000 (01:15 +0200)] 
MAJOR: server: add DNS-based server name resolution

Relies on the DNS protocol freshly implemented in HAProxy.
It performs a server IP addr resolution based on a server hostname.

10 years agoMEDIUM: dns: implement a DNS resolver
Baptiste Assmann [Mon, 13 Apr 2015 21:40:55 +0000 (23:40 +0200)] 
MEDIUM: dns: implement a DNS resolver

Implementation of a DNS client in HAProxy to perform name resolution to
IP addresses.

It relies on the freshly created UDP client to perform the DNS
resolution. For now, all UDP socket calls are performed in the
DNS layer, but this might change later when the protocols are
extended to be more suited to datagram mode.

A new section called 'resolvers' is introduced thanks to this patch. It
is used to describe DNS servers IP address and also many parameters.

10 years agoMEDIUM: protocol: add minimalist UDP protocol client
Baptiste Assmann [Mon, 13 Apr 2015 21:08:16 +0000 (23:08 +0200)] 
MEDIUM: protocol: add minimalist UDP protocol client

Basic introduction of a UDP layer in HAProxy. It can be used as a
client only and manages UDP exchanges with servers.

It can't be used to load-balance UDP protocols, but only used by
internal features such as DNS resolution.

10 years agoMEDIUM: server: change server ip address from stats socket
Baptiste Assmann [Mon, 13 Apr 2015 20:54:33 +0000 (22:54 +0200)] 
MEDIUM: server: change server ip address from stats socket

New command available on the stats socket to change a server addr using
the command "set server <backend>/<server> addr <ip4|ip6>"

10 years agoMEDIUM: server: add support for changing a server's address
Baptiste Assmann [Mon, 13 Apr 2015 23:13:07 +0000 (01:13 +0200)] 
MEDIUM: server: add support for changing a server's address

Ability to change a server IP address during HAProxy run time.
For now this is provided via function update_server_addr() which
currently is not called.

A log is emitted on each change. For now we do it inconditionally,
but later we'll want to do it only on certain circumstances, which
explains why the logging block is enclosed in if(1).

10 years agoBUG/MEDIUM: compat: fix segfault on FreeBSD
Joris Dedieu [Fri, 12 Jun 2015 23:05:11 +0000 (01:05 +0200)] 
BUG/MEDIUM: compat: fix segfault on FreeBSD

Since commit 65d805fd witch removes standard.h from compat.h some
values were not properly set on FreeBSD. This caused a segfault
at startup when smp_resolve_args is called.

As FreeBSD have IP_BINDANY, CONFIG_HAP_TRANSPARENT is define. This
cause struct conn_src to be extended with some fields. The size of
this structure was incorrect. Including netinet/in.h fix this issue.

While diving in code preprocessing, I found that limits.h was require
to properly set MAX_HOSTNAME_LEN, ULONG_MAX, USHRT_MAX and others
system limits on FreeBSD.