Willy Tarreau [Fri, 31 Aug 2012 15:43:29 +0000 (17:43 +0200)]
MAJOR: connection: make the PROXY decoder a handshake handler
The PROXY protocol is now decoded in the connection before other
handshakes. This means that it may be extracted from a TCP stream
before SSL is decoded from this stream.
Willy Tarreau [Fri, 31 Aug 2012 14:01:23 +0000 (16:01 +0200)]
MAJOR: session: introduce embryonic sessions
When an incoming connection request is accepted, a connection
structure is needed to store its state. However we don't want to
fully initialize a session until the data layer is about to be
ready.
As long as the connection is physically stored into the session,
it's not easy to split both allocations.
As such, we only initialize the minimum requirements of a session,
which results in what we call an embryonic session. Then once the
data layer is ready, we can complete the function's initialization.
Doing so avoids buffers allocation and ensures that a session only
sees ready connections.
The frontend's client timeout is used as the handshake timeout. It
is likely that another timeout will be used in the future.
Willy Tarreau [Fri, 31 Aug 2012 11:54:11 +0000 (13:54 +0200)]
MEDIUM: connection: add an ->init function to data layer
SSL need to initialize the data layer before proceeding with data. At
the moment, this data layer is automatically initialized from itself,
which will not be possible once we extract connection from sessions
since we'll only create the data layer once the handshake is finished.
So let's have the application layer initialize the data layer before
using it.
Willy Tarreau [Thu, 30 Aug 2012 20:59:48 +0000 (22:59 +0200)]
MINOR: tcp: replace tcp_src_to_stktable_key with addr_to_stktable_key
Make it more obvious that this function does not depend on any knowledge
of the session. This is important to plan for TCP rules that can run on
connection without any initialized session yet.
Willy Tarreau [Thu, 30 Aug 2012 20:23:13 +0000 (22:23 +0200)]
MEDIUM: proto_tcp: remove any dependence on stream_interface
The last uses of the stream interfaces were in tcp_connect_server() and
could easily and more appropriately be moved to its callers, si_connect()
and connect_server(), making a lot more sense.
Now the function should theorically be usable for health checks.
It also appears more obvious that the file is split into two distinct
parts :
- the protocol layer used at the connection level
- the tcp analysers executing tcp-* rules and their samples/acls.
Willy Tarreau [Thu, 30 Aug 2012 19:23:53 +0000 (21:23 +0200)]
MEDIUM: stream_interface: remove CAP_SPLTCP/CAP_SPLICE flags
These ones are implicitly handled by the connection's data layer, no need
to rely on them anymore and reaching them maintains undesired dependences
on stream-interface.
Willy Tarreau [Thu, 30 Aug 2012 19:11:38 +0000 (21:11 +0200)]
MAJOR: connection: move the addr field from the stream_interface
We need to have the source and destination addresses in the connection.
They were lying in the stream interface so let's move them. The flags
SI_FL_FROM_SET and SI_FL_TO_SET have been moved as well.
It's worth noting that tcp_connect_server() almost does not use the
stream interface anymore except for a few flags.
It has been identified that once we detach the connection from the SI,
it will probably be needed to keep a copy of the server-side addresses
in the SI just for logging purposes. This has not been implemented right
now though.
Willy Tarreau [Thu, 30 Aug 2012 13:49:18 +0000 (15:49 +0200)]
REORG: connection: move the target pointer from si to connection
The target is per connection and is directly used by the connection, so
we need it there. It's not needed anymore in the SI however.
Willy Tarreau [Mon, 27 Aug 2012 22:06:31 +0000 (00:06 +0200)]
CLEANUP: channel: use "channel" instead of "buffer" in function names
This is a massive rename of most functions which should make use of the
word "channel" instead of the word "buffer" in their names.
In concerns the following ones (new names) :
unsigned long long channel_forward(struct channel *buf, unsigned long long bytes);
static inline void channel_init(struct channel *buf)
static inline int channel_input_closed(struct channel *buf)
static inline int channel_output_closed(struct channel *buf)
static inline void channel_check_timeouts(struct channel *b)
static inline void channel_erase(struct channel *buf)
static inline void channel_shutr_now(struct channel *buf)
static inline void channel_shutw_now(struct channel *buf)
static inline void channel_abort(struct channel *buf)
static inline void channel_stop_hijacker(struct channel *buf)
static inline void channel_auto_connect(struct channel *buf)
static inline void channel_dont_connect(struct channel *buf)
static inline void channel_auto_close(struct channel *buf)
static inline void channel_dont_close(struct channel *buf)
static inline void channel_auto_read(struct channel *buf)
static inline void channel_dont_read(struct channel *buf)
unsigned long long channel_forward(struct channel *buf, unsigned long long bytes)
Some functions provided by channel.[ch] have kept their "buffer" name because
they are really designed to act on the buffer according to some information
gathered from the channel. They have been moved together to the same place in
the file for better readability but they were not changed at all.
The "buffer" memory pool was also renamed "channel".
Willy Tarreau [Mon, 27 Aug 2012 21:14:58 +0000 (23:14 +0200)]
CLEANUP: channel: usr CF_/CHN_ prefixes instead of BF_/BUF_
Get rid of these confusing BF_* flags. Now channel naming should clearly
be used everywhere appropriate.
No code was changed, only a renaming was performed. The comments about
channel operations was updated.
Willy Tarreau [Mon, 27 Aug 2012 20:08:00 +0000 (22:08 +0200)]
REORG: channel: move buffer_{replace,insert_line}* to buffer.{c,h}
These functions do not depend on the channel flags anymore thus they're
much better suited to be used on plain buffers. Move them from channel
to buffer.
Willy Tarreau [Mon, 27 Aug 2012 18:53:34 +0000 (20:53 +0200)]
MAJOR: channel: remove the BF_FULL flag
This is similar to the recent removal of BF_OUT_EMPTY. This flag was very
problematic because it relies on permanently changing information such as the
to_forward value, so it had to be updated upon every change to the buffers.
Previous patch already got rid of its users.
One part of the change is sensible : the flag was also part of BF_MASK_STATIC,
which is used by process_session() to rescan all analysers in case the flag's
status changes. At first glance, none of the analysers seems to change its
mind base on this flag when it is subject to change, so it seems fine not to
add variation checks here. Otherwise it's possible that checking the buffer's
input and output is more reliable than checking the flag's replacement.
Willy Tarreau [Mon, 27 Aug 2012 18:46:07 +0000 (20:46 +0200)]
MAJOR: channel: stop relying on BF_FULL to take action
This flag is quite complex to get right and updating it everywhere is a
major pain, especially since the buffer/channel split. This is the first
step of getting rid of it. Instead now it's dynamically computed whenever
needed.
Willy Tarreau [Mon, 27 Aug 2012 17:51:36 +0000 (19:51 +0200)]
MINOR: buffer: provide a new buffer_full() function
This one only focuses on the input part of the buffer and is dedicated
to analysers.
Willy Tarreau [Mon, 27 Aug 2012 16:54:20 +0000 (18:54 +0200)]
MINOR: channel: rename bi_full to channel_full as it checks the whole channel
Since the function takes care of the forward count and involves more than
buffer knowledge, rename it.
Willy Tarreau [Fri, 24 Aug 2012 20:56:11 +0000 (22:56 +0200)]
REORG: buffer: move buffer_flush, b_adv and b_rew to buffer.h
These one now operate over real buffers, not channels anymore.
Willy Tarreau [Fri, 24 Aug 2012 20:40:29 +0000 (22:40 +0200)]
MAJOR: channel: remove the BF_OUT_EMPTY flag
This flag was very problematic because it was composite in that both changes
to the pipe or to the buffer had to cause this flag to be updated, which is
not always simple (eg: there may not even be a channel attached to a buffer
at all).
There were not that many users of this flags, mostly setters. So the flag got
replaced with a macro which reports whether the channel is empty or not, by
checking both the pipe and the buffer.
One part of the change is sensible : the flag was also part of BF_MASK_STATIC,
which is used by process_session() to rescan all analysers in case the flag's
status changes. At first glance, none of the analysers seems to change its
mind base on this flag when it is subject to change, so it seems fine not to
add variation checks here. Otherwise it's possible that checking the buffer's
output size is more useful than checking the flag's replacement.
Willy Tarreau [Fri, 24 Aug 2012 17:22:53 +0000 (19:22 +0200)]
REORG: buffers: split buffers into chunk,buffer,channel
Many parts of the channel definition still make use of the "buffer" word.
Willy Tarreau [Fri, 24 Aug 2012 16:12:41 +0000 (18:12 +0200)]
CLEANUP: connection: split sock_ops into data_ops, app_cp and si_ops
Some parts of the sock_ops structure were only used by the stream
interface and have been moved into si_ops. Some of them were callbacks
to the stream interface from the connection and have been moved into
app_cp as they're the application seen from the connection (later,
health-checks will need to use them). The rest has moved to data_ops.
Normally at this point the connection could live without knowing about
stream interfaces at all.
Willy Tarreau [Fri, 24 Aug 2012 11:02:24 +0000 (13:02 +0200)]
MEDIUM: stream-interface: don't remove WAIT_DATA when a handshake is in progress
This doesn't make sense and will only require that it's enabled again.
Willy Tarreau [Fri, 24 Aug 2012 10:53:56 +0000 (12:53 +0200)]
MAJOR: stream-interface: fix splice not to call chk_snd by itself
In recent splice fixes we made splice call chk_snd, but this was due
to inappropriate checks in conn_notify_si() which prevented the chk_snd()
call from being performed. Now that this has been fixed, remove this
duplicate code.
Willy Tarreau [Fri, 24 Aug 2012 10:52:22 +0000 (12:52 +0200)]
MAJOR: stream-interface: don't commit polling changes in every callback
It's more efficient to centralize polling changes, which is already done
in the connection handler. So now all I/O callbacks just change flags and
rely on the connection handler for the commit. The special case of the
send loop is handled by the chk_snd() function which does an update at
the end.
Willy Tarreau [Fri, 24 Aug 2012 10:14:49 +0000 (12:14 +0200)]
MEDIUM: proxy-proto: don't use buffer flags in conn_si_send_proxy()
These ones should only be handled by the stream interface at the end
of the handshake now. Similarly a number of information are now taken
at the connection level rather than at the data level (eg: shutdown).
Fast polling updates have been used instead of slow ones since the
function is only called by the connection handler.
Willy Tarreau [Fri, 24 Aug 2012 10:12:53 +0000 (12:12 +0200)]
MAJOR: stream-interface: make conn_notify_si() more robust
This function was relying on the result of file descriptor polling
which is inappropriate as it may be subject to race conditions during
handshakes. Make it more robust by relying solely on buffer activity.
Willy Tarreau [Thu, 23 Aug 2012 22:46:52 +0000 (00:46 +0200)]
MAJOR: stream-interface: restore splicing mechanism
The splicing is now provided by the data-layer rcv_pipe/snd_pipe functions
which in turn are called by the stream interface's recv and send callbacks.
The presence of the rcv_pipe/snd_pipe functions is used to attest support
for splicing at the data layer. It looks like the stream-interface's
SI_FL_CAP_SPLICE flag does not make sense anymore as it's used as a proxy
for the pointers above.
It also appears that we call chk_snd() from the recv callback and then
try to call it again in update_conn(). It is very likely that this last
function will progressively slip into the recv/send callbacks in order
to avoid duplicate check code.
The code works right now with and without splicing. Only raw_sock provides
support for it and it is automatically selected when the various splice
options are set. However it looks like splice-auto doesn't enable it, which
possibly means that the streamer detection code does not work anymore, or
that it's only called at a time where it's too late to enable splicing (in
process_session).
Willy Tarreau [Tue, 21 Aug 2012 16:22:06 +0000 (18:22 +0200)]
MAJOR: connection: split the send call into connection and stream interface
Similar to what was done on the receive path, the data layer now provides
only an snd_buf() callback that is iterated over by the stream interface's
si_conn_send_loop() function.
The data layer now has no knowledge about channels nor stream interfaces.
The splice() code still need to be ported as it currently is disabled.
Willy Tarreau [Mon, 20 Aug 2012 19:41:06 +0000 (21:41 +0200)]
REORG: stream-interface: move sock_raw_read() to si_conn_recv_cb()
The recv function is now generic and is usable to iterate any connection-to-buf
reading function from a stream interface. So let's move it to stream-interface.
Willy Tarreau [Mon, 20 Aug 2012 18:27:59 +0000 (20:27 +0200)]
MINOR: stream-interface: add an rcv_buf callback to sock_ops
This one is to be used by the read I/O handlers.
Willy Tarreau [Mon, 20 Aug 2012 18:21:01 +0000 (20:21 +0200)]
MAJOR: raw_sock: temporarily disable splicing
It's too hard to convert splicing to connection+buf for now, so let's disable
it in order to make progress.
Willy Tarreau [Mon, 20 Aug 2012 15:30:32 +0000 (17:30 +0200)]
MAJOR: raw_sock: extract raw_sock_to_buf() from raw_sock_read()
This is the start of the stream connection iterator which calls the
data-layer reader. This still looks a bit tricky but is OK. Splicing
is not handled at all at the moment.
Willy Tarreau [Mon, 20 Aug 2012 15:01:35 +0000 (17:01 +0200)]
REORG: sock_raw: rename the files raw_sock*
The "raw_sock" prefix will be more convenient for naming functions as
it will be prefixed with the data layer and suffixed with the data
direction. So let's rename the files now to avoid any further confusion.
The #include directive was also removed from a number of files which do
not need it anymore.
Willy Tarreau [Mon, 20 Aug 2012 14:55:48 +0000 (16:55 +0200)]
MINOR: connection: provide conn_{data|sock}_{read0|shutw} functions
These functions are used to report unidirectional shutdown and to disable
polling in the related direction.
Willy Tarreau [Mon, 2 Jul 2012 15:01:20 +0000 (17:01 +0200)]
REORG/MAJOR: extract "struct buffer" from "struct channel"
At the moment, the struct is still embedded into the struct channel, but
all the functions have been updated to use struct buffer only when possible,
otherwise struct channel. Some functions would likely need to be splitted
between a buffer-layer primitive and a channel-layer function.
Later the buffer should become a pointer in the struct buffer, but doing so
requires a few changes to the buffer allocation calls.
Willy Tarreau [Mon, 2 Jul 2012 13:11:27 +0000 (15:11 +0200)]
REORG/MAJOR: use "struct channel" instead of "struct buffer"
This is a massive rename. We'll then split channel and buffer.
This change needs a lot of cleanups. At many locations, the parameter
or variable is still called "buf" which will become ambiguous. Also,
the "struct channel" is still defined in buffers.h.
Willy Tarreau [Mon, 20 Aug 2012 13:38:41 +0000 (15:38 +0200)]
MEDIUM: stream-interface: provide a generic stream_sock_read0() function
This function is used by the data layer when a zero has been read over a
connection. At the moment it only handles sockets and nothing else. Once
the complete split is done between buffers and stream interfaces, it should
become possible to work regardless on the connection type.
Willy Tarreau [Mon, 20 Aug 2012 13:09:53 +0000 (15:09 +0200)]
MEDIUM: stream-interface: provide a generic si_conn_send_cb callback
The connection send() callback is supposed to be generic for a
stream-interface, and consists in calling the lower layer snd_buf
function. Move this function to the stream interface and remove
the sock-raw and sock-ssl clones.
Willy Tarreau [Mon, 20 Aug 2012 13:01:10 +0000 (15:01 +0200)]
MEDIUM: stream-interface: provide a generic stream_int_chk_snd_conn() function
This one can be used by both sock_raw and sock_ssl instead of each having their own.
Willy Tarreau [Mon, 20 Aug 2012 12:02:10 +0000 (14:02 +0200)]
MEDIUM: stream-interface: add a snd_buf() callback to sock_ops
This callback is used to send data from the buffer to the socket. It is
the old write_loop() call of the data layer which is used both by the
->write() callback and the ->chk_snd() function. The reason for having
it as a pointer is that it's the only remaining part which causes the
write and chk_snd() functions to be different between raw and ssl.
Willy Tarreau [Mon, 20 Aug 2012 10:38:36 +0000 (12:38 +0200)]
MEDIUM: stream-interface: offer a generic chk_rcv function for connections
sock_raw and sock_ssl use a pretty generic chk_rcv function, so let's move
this function to the stream_interface and remove specific functions. Later
we might have a single chk_rcv function.
Willy Tarreau [Mon, 20 Aug 2012 10:06:26 +0000 (12:06 +0200)]
MEDIUM: stream_interface: offer a generic function for connection updates
We need to have a generic function to be called by upper layers when buffer
flags have been updated (the si->update function). At the moment, both sock_raw
and sock_ssl had their own which basically was a copy-paste. Since these
functions are only used to update stream interface flags, it is logical to
have them handled by the stream interface code.
This allowed us to remove the stream_interface-specific update function from
sock_raw and sock_ssl which now use the generic code.
The stream_sock_update_conn callback has also been more appropriately renamed
conn_notify_si() since it's meant to be called by lower layers to notify the
SI and possibly upper layers about incoming changes.
Willy Tarreau [Fri, 17 Aug 2012 21:55:05 +0000 (23:55 +0200)]
MINOR: fd: get rid of FD_WAIT_*
These flags were used to ease a transition which has been completed,
so they're not needed anymore. Get rid of them.
Willy Tarreau [Fri, 17 Aug 2012 21:53:56 +0000 (23:53 +0200)]
MEDIUM: checks: don't use FD_WAIT_* anymore
make use of fd_poll_* instead in preparation for a later adoption by the
connection subsystem.
Willy Tarreau [Thu, 9 Aug 2012 12:45:22 +0000 (14:45 +0200)]
MAJOR: make use of conn_{data|sock}_{poll|stop|want}* in connection handlers
This is a second attempt at getting rid of FD_WAIT_*. Now the situation is
much better since native I/O handlers can directly manipulate the FD using
fd_{poll|want|stop}_* and the connection handlers manipulate connection-level
flags using the conn_{data|sock}_* equivalent.
Proceeding this way ensures that the connection flags always reflect the
reality even after data<->handshake switches.
Willy Tarreau [Fri, 17 Aug 2012 15:33:53 +0000 (17:33 +0200)]
MEDIUM: connection: make use of the new polling functions
Now the connection handler, the handshake callbacks and the I/O callbacks
make use of the connection-layer polling functions to enable or disable
polling on a file descriptor.
Some changes still need to be done to avoid using the FD_WAIT_* constants.
Willy Tarreau [Fri, 17 Aug 2012 09:55:04 +0000 (11:55 +0200)]
MEDIUM: connection: add definitions for dual polling mechanisms
The conflicts we're facing with polling is that handshake handlers have
precedence over data handlers and may change the polling requirements
regardless of what is expected by the data layer. This causes issues
such as missed events.
The real need is to have three polling levels :
- the "current" one, which is effective at any moment
- the data one, which reflects what the data layer asks for
- the sock one, which reflects what the socket layer asks for
Depending on whether a handshake is in progress or not, either one of the
last two will replace the current one, and the change will be propagated
to the lower layers.
At the moment, the shutdown status is not considered, and only handshakes
are used to decide which layer to chose. This will probably change.
Willy Tarreau [Thu, 9 Aug 2012 10:14:03 +0000 (12:14 +0200)]
MEDIUM: fd: add fd_poll_{recv,send} for use when explicit polling is required
The old EV_FD_SET() macro was confusing, as it would enable receipt but there
was no way to indicate that EAGAIN was received, hence the recently added
FD_WAIT_* flags. They're not enough as we're still facing a conflict between
EV_FD_* and FD_WAIT_*. So let's offer I/O functions what they need to explicitly
request polling.
Willy Tarreau [Thu, 9 Aug 2012 10:11:58 +0000 (12:11 +0200)]
MAJOR: fd: replace all EV_FD_* macros with new fd_*_* inline calls
These functions have a more explicity meaning and will offer provisions
for explicit polling.
EV_FD_ISSET() has been left for now as it is still in use in checks.
Willy Tarreau [Mon, 6 Aug 2012 17:31:45 +0000 (19:31 +0200)]
MAJOR: stream_int: use a common stream_int_shut*() functions regardless of the data layer
Up to now, we had to use a shutr/shutw interface per data layer, which
basically means 3 distinct functions when we include SSL :
- generic stream_interface
- sock_raw
- sock_ssl
With this change, the code located in the stream_interface manages all the
stream_interface and buffer updates, and calls the data layer hooks when
needed.
At the moment, the socket layer hook had been implicitly considered as
being a regular socket, so the si_shut*() functions call the normal
shutdown() and EV_FD_CLR() functions on the fd if a socket layer is
defined. This may change in the future. The stream_int_shut*()
functions don't call EV_FD_CLR() so that they can later be embedded
in lower layers.
Thus, the si->data->shutr() is not called anymore and si->data->shutw()
is called to close the data layer only (eg: only for SSL).
Proceeding like this is very important because it's the only way to be
able not to rely on these functions when called from the connection
handlers, and call the data layers' instead.
Willy Tarreau [Mon, 6 Aug 2012 15:00:18 +0000 (17:00 +0200)]
MEDIUM: sock_raw: introduce a read0 callback that is different from shutr
This one is supposed to be called by the lower layer upon receiving a shutr
notification, which is different from the call performed by the upper layer.
Specifically, this function will ultimately not call EV_FD_* but will just
manipulate event flags instead. The function also does not call shutw anymore
and instead performs the necessary work.
Splitting it into si-specific part and data-specific parts will not be easy.
Willy Tarreau [Mon, 6 Aug 2012 13:06:49 +0000 (15:06 +0200)]
REORG: connection: replace si_data_close() with conn_data_close()
This close function only applies to connection-specific parts and
the stream-interface entry may soon disappear. Move this to the
connection instead.
Willy Tarreau [Mon, 6 Aug 2012 10:23:51 +0000 (12:23 +0200)]
MINOR: sock_raw: move calls to si_data_close upper
Some users of si_data_close() need to have the fd still open,
so we must move the call before fd_delete().
Willy Tarreau [Mon, 30 Jul 2012 12:29:35 +0000 (14:29 +0200)]
MEDIUM: fd: remove the EV_FD_COND_* primitives
These primitives were initially introduced so that callers were able to
conditionally set/disable polling on a file descriptor and check in return
what the state was. It's been long since we last had an "if" on this, and
all pollers' functions were the same for cond_* and their systematic
counter parts, except that this required a check and a specific return
value that are not always necessary.
So let's simplify the FD API by removing this now unused distinction and
by making all specific functions return void.
Willy Tarreau [Thu, 12 Jul 2012 13:32:13 +0000 (15:32 +0200)]
MAJOR: connection: call data layer handshakes from the handler
Handshakes is not called anymore from the data handlers, they're only
called from the connection handler when their flag is set.
Also, this move has uncovered an issue with the stream interface notifier :
it doesn't consider the FD_WAIT_* flags possibly set by the handshake
handlers. This will result in a stuck handshake when no data is in the
output buffer. In order to cover this, for now we'll perform the EV_FD_SET
in the SSL handshake function, but this needs to be addressed separately
from the stream interface operations.
Willy Tarreau [Mon, 23 Jul 2012 18:05:00 +0000 (20:05 +0200)]
MINOR: rearrange tcp_connect_probe() and fix wrong return codes
Sometimes we returned the need for polling while it was not needed. Remove
some of the spaghetti in the function.
Willy Tarreau [Mon, 23 Jul 2012 17:45:44 +0000 (19:45 +0200)]
MAJOR: connection: add a new CO_FL_CONNECTED flag
This new flag is used to indicate that the connection was already
connected. It can be used by I/O handlers to know that a connection
has just completed. It is used by stream_sock_update_conn(), allowing
the sock_opt handlers not to manipulate the SI timeout nor the
BF_WRITE_NULL flag anymore.
Willy Tarreau [Mon, 23 Jul 2012 17:19:51 +0000 (19:19 +0200)]
MEDIUM: stream_interface: centralize the SI_FL_ERR management
It's better to have only stream_sock_update_conn() handle the conversion
of the CO_FL_ERROR flag to SI_FL_ERR than having it in each and every I/O
callback.
Willy Tarreau [Mon, 23 Jul 2012 16:53:03 +0000 (18:53 +0200)]
MEDIUM: stream_interface: pass connection instead of fd in sock_ops
The sock_ops I/O callbacks made use of an FD till now. This has become
inappropriate and the struct connection is much more useful. It also
fixes the race condition introduced by previous change.
Willy Tarreau [Mon, 23 Jul 2012 16:24:25 +0000 (18:24 +0200)]
MAJOR: remove the stream interface and task management code from sock_*
The socket data layer code must only focus on moving data between a
socket and a buffer. We need a special stream interface handler to
update the stream interface and the file descriptor status.
At the moment the code works but suffers from a race condition caused
by its API : the read/write callbacks still make use of the fd instead
of using the connection. And when a double shutdown is performed, a call
to ->write() after ->read() processed an error results in dereferencing
a NULL fdtab[]->owner. This is only a temporary issue which doesn't need
to be fixed now since this will automatically go away when the functions
change to use the connection instead.
Willy Tarreau [Fri, 6 Jul 2012 14:02:29 +0000 (16:02 +0200)]
CLEANUP: remove the now unused fdtab direct I/O callbacks
They were all left to NULL since last commit so we can safely remove them
all now and remove the temporary dual polling logic in pollers.
Willy Tarreau [Mon, 23 Jul 2012 13:07:23 +0000 (15:07 +0200)]
MAJOR: tcp: remove the specific I/O callbacks for TCP connection probes
Use a single tcp_connect_probe() instead of tcp_connect_write() and
tcp_connect_read(). We call this one only when no data layer function
have been processed, so this is a fallback to test for completion of
a connection attempt.
With this done, we don't have the need for any direct I/O callback
anymore.
The function still relies on ->write() to wake the stream interface up,
so it's not finished.
Willy Tarreau [Fri, 6 Jul 2012 15:12:34 +0000 (17:12 +0200)]
MEDIUM: connection: extract the send_proxy callback from proto_tcp
This handshake handler must be independant, so move it away from
proto_tcp. It has a dedicated connection flag. It is tested before
I/O handlers and automatically removes the CO_FL_WAIT_L4_CONN flag
upon success.
It also sets the BF_WRITE_NULL flag on the stream interface and
stops the SI timeout. However it does not perform the task_wakeup(),
and relies on the data handler to do so for now. The SI wakeup will
have to be moved elsewhere anyway.
Willy Tarreau [Mon, 23 Jul 2012 10:14:26 +0000 (12:14 +0200)]
MEDIUM: connection: remove the FD_POLL_* flags only once
It's inappropriate to remove FD_POLL_IN and FD_POLL_OUT in the IO callback
handlers, first because they shouldn't care about this, and second because
it will make it harder to chain multiple callers.
So let's flush these flags only once for all in the connection handler.
Right now, the HUP and ERR flags are still flushed in each IO handler to
avoid multiple calls. This will probably have to be fixed later.
Willy Tarreau [Fri, 6 Jul 2012 12:54:49 +0000 (14:54 +0200)]
MINOR: fd: make fdtab->owner a connection and not a stream_interface anymore
It is more convenient with a connection here and will abstract stream_interface
more easily.
Willy Tarreau [Fri, 6 Jul 2012 12:29:45 +0000 (14:29 +0200)]
MAJOR: connection: replace direct I/O callbacks with the connection callback
Almost all direct I/O callbacks have been changed to use the connection
callback instead. Only the TCP connection validation remains.
Willy Tarreau [Fri, 6 Jul 2012 12:13:49 +0000 (14:13 +0200)]
MINOR: connection: add a handler for fd-based connections
This connection handler will be used as an I/O handler for events
detected on a file descriptor. It is not used yet.
Willy Tarreau [Fri, 6 Jul 2012 10:25:58 +0000 (12:25 +0200)]
MEDIUM: protocols: use the generic I/O callback for accept callbacks
This one is used only on read events, and it was easy to convert to
use the new I/O callback.
Willy Tarreau [Fri, 6 Jul 2012 10:00:49 +0000 (12:00 +0200)]
MEDIUM: checks: make use of fdtab->iocb instead of cb[]
Use the single I/O callback to handle the checks. This should soon be
replaced by the common connection handler.
Willy Tarreau [Fri, 6 Jul 2012 09:44:28 +0000 (11:44 +0200)]
MEDIUM: polling: prepare to call the iocb() function when defined.
We will need this to centralize I/O callbacks. Nobody sets it right
now so the code should have no impact.
Willy Tarreau [Fri, 6 Jul 2012 08:53:51 +0000 (10:53 +0200)]
MINOR: fd: add a new I/O handler to fdtab
This one will eventually replace both cb[] handlers. At the moment it
is not used yet.
Willy Tarreau [Fri, 6 Jul 2012 08:17:53 +0000 (10:17 +0200)]
MAJOR: get rid of fdtab[].state and use connection->flags instead
fdtab[].state was only used to know whether a connection was in progress
or an error was encountered. Instead we now use connection->flags to store
a flag for both. This way, connection management will be able to update the
connection status on I/O.
Willy Tarreau [Fri, 6 Jul 2012 07:52:14 +0000 (09:52 +0200)]
MINOR: connection: add flags to the connection struct
We're doing this to take over fdtab[].state.
Willy Tarreau [Fri, 6 Jul 2012 07:40:59 +0000 (09:40 +0200)]
REORG/MINOR: checks: put a struct connection into the server
This will be used to handle the connection state once it goes away from fdtab.
There is no functional change at the moment.
Willy Tarreau [Fri, 6 Jul 2012 07:47:57 +0000 (09:47 +0200)]
REORG/MINOR: connection: move declaration to its own include file
This way we don't depend on stream_interface anymore.
Willy Tarreau [Thu, 5 Jul 2012 21:36:42 +0000 (23:36 +0200)]
REORG/MEDIUM: fd: get rid of FD_STLISTEN
This state was only used so that ev_sepoll did not match FD_STERROR, which
changed in previous patch. We can now safely remove this state.
Willy Tarreau [Thu, 5 Jul 2012 21:33:51 +0000 (23:33 +0200)]
REORG/MEDIUM: fd: remove checks for FD_STERROR in ev_sepoll
This test is present only in this poller as an optimization, but this
optimization adds some complexity to remove fdtab[].state. Let's get
rid of it for now.
Willy Tarreau [Thu, 5 Jul 2012 21:19:22 +0000 (23:19 +0200)]
REORG/MEDIUM: fd: remove FD_STCLOSE from struct fdtab
In an attempt to get rid of fdtab[].state, and to move the relevant
parts to the connection struct, we remove the FD_STCLOSE state which
can easily be deduced from the <owner> pointer as there is a 1:1 match.
Jamie Gloudon [Sat, 25 Aug 2012 04:18:33 +0000 (00:18 -0400)]
DOC: fix name for "option independant-streams"
The correct spelling is "independent", not "independant". This patch
fixes the doc and the configuration parser to accept the correct form.
The config parser still allows the old naming for backwards compatibility.
Jamie Gloudon [Sat, 25 Aug 2012 04:18:33 +0000 (00:18 -0400)]
DOC: Typos cleanup
I came across a couple of typos in configuration.txt and made this patch.
Also, there is an inconsistency between using the word analys/ze in
configuration.txt as well. However, I did not provide a patch for that.
-- Jamie Gloudon
[wt: won't fix the us/uk language mistakes, they'll always exist anyway]
Willy Tarreau [Wed, 6 Jun 2012 23:03:16 +0000 (01:03 +0200)]
MEDIUM: stats/cli: add support for "set table key" to enter values
This is used to enter values for stick tables. The most likely usage
is to set gpc0 for a specific IP address in order to block traffic
for abusers without having to reload. Since all data types are
supported, other usages are possible (eg: replace a users's assigned
server).
Willy Tarreau [Wed, 6 Jun 2012 21:37:08 +0000 (23:37 +0200)]
MINOR: stats/cli: add plans to support more stick-table actions
Right now we only support show/clear on a table. In order to introduce
the "set" keyword we need to get rid of the "show" boolean arg. There
is no functional change up to this commit.
Willy Tarreau [Thu, 30 Aug 2012 20:52:28 +0000 (22:52 +0200)]
BUG: stktable: tcp_src_to_stktable_key() must return NULL on invalid families
Source addresses of non-TCP families were not correctly handled by
tcp_src_to_stktable_key() as it forgot to return NULL and instead left
the previous value in the stick-table buffer.
This bug is 1.5-specific and was introduced by commit
4f92d320 in 1.5-dev6
so it does not need any backport.
William Lallemand [Thu, 9 Aug 2012 14:41:35 +0000 (16:41 +0200)]
BUG/MINOR: to_log erased with unique-id-format
curproxy->to_log was reset to LW_INIT when using unique-id-format,
so logs looked like option logasap
Willy Tarreau [Tue, 31 Jul 2012 05:51:48 +0000 (07:51 +0200)]
MINOR: http: add the urlp_val ACL match
It's derived from other urlp_* matches, but there was no way to check for
an integer value and it seems like it's significantly used.
Willy Tarreau [Fri, 6 Jul 2012 09:16:01 +0000 (11:16 +0200)]
BUG/MINOR: polling: some events were not set in various pollers
fdtab[].ev was only set in ev_sepoll. Unfortunately, some I/O handling
functions now rely on this, so depending on the polling mechanism, some
useless operations might have been performed, such as performing a useless
recv() when a HUP was reported.
This is a very old issue, the flags were only added to the fdtab and not
propagated into any poller. Then they were used in ev_sepoll which needed
them for the cache. It is unsure whether a backport to 1.4 is appropriate
or not.
Willy Tarreau [Mon, 23 Jul 2012 08:55:43 +0000 (10:55 +0200)]
BUG/MINOR: tarpit: fix condition to return the HTTP 500 message
Commit
fa7e1025 (1.3.16-rc1) introduced a minor bug by comparing req->flags
with BF_READ_ERROR instead of checking for the bit. The result is that the
error message is always returned even in case of client error. This has no
real impact but this must be fixed.
It may be backported to 1.4 and 1.3.
David du Colombier [Fri, 13 Jul 2012 12:34:59 +0000 (14:34 +0200)]
MINOR: IPv6 support for transparent proxy
Set socket option IPV6_TRANSPARENT on binding
to enable transparent proxy on IPv6.
This option is available from Linux 2.6.37.
Willy Tarreau [Mon, 18 Jun 2012 18:01:30 +0000 (20:01 +0200)]
OPTIM: i386: make use of kernel-mode-linux when available
If haproxy is built with support for USE_VSYSCALL_DLSYM, it's very
easy to check for KML availability. So let's enable it. Tests show
a small overall performance improvement around 1%. Other tests show
that the syscall overhead is divided by 4 on a Geode LX using this
method.
Willy Tarreau [Sun, 29 Apr 2012 13:39:40 +0000 (15:39 +0200)]
MEDIUM: pattern: add the "base" sample fetch method
This one returns the concatenation of the first Host header entry with
the path. It can make content-switching rules easier, help with fighting
DDoS on certain URLs and improve shared caches efficiency.
Willy Tarreau [Sun, 29 Apr 2012 07:28:50 +0000 (09:28 +0200)]
MINOR: replace acl_fetch_{path,url}* with smp_fetch_*
Doing so allows us to support sticking on URL, URL's IP, URL's port and
path.
Both fetch functions should be improved to support an optional depth
allowing to stick to a server depending on just a few directory
components. This would help with portals, some prefetch-capable
caches and with outgoing connections using multiple internet links.
Vincent Bernat [Wed, 27 Jun 2012 15:18:30 +0000 (17:18 +0200)]
DOC: specify the default value for maxconn in the context of a proxy
Default value for maxconn in the context of a proxy is 2000 and is
unrelated to any other value (like global ulimit-n or global
maxconn). Without an explicit a user may think that the default value
is either no limit or equal to the global maxconn value.
Willy Tarreau [Fri, 15 Jun 2012 06:02:34 +0000 (08:02 +0200)]
BUG/MINOR: ACL implicit arguments must be created with unresolved flag
Commit 496aa0 fixed a design issue by adding an "unresolved" flag to the
ACL arguments. Unfortunately this unresolved flag was not set when building
the fake argument some ACL need when using an implicit argument pointing to
the local proxy.
Special thanks to Michael Kearey who reported the issue with a reproducer
and the commit introducing the bug.
Willy Tarreau [Tue, 12 Jun 2012 07:16:56 +0000 (09:16 +0200)]
OPTIM: halog: improve cold-cache behaviour when loading a file
Using posix_fadvise() it is possible to tell the system that we're
going to read a whole file at once. The kernel then doubles the
read-ahead size for this file. On Linux with an SSD, this has improved
cold-cache performance by around 20%. Hot-cache is not affected at all.
Willy Tarreau [Tue, 12 Jun 2012 06:52:22 +0000 (08:52 +0200)]
OPTIM: halog: make use of memchr() on platforms which provide a fast one
glibc-2.11 on x86_64 provides a machine-specific memchr() which is faster
than the generic C implementation by around 40%, so let's make it possible
to use it instead of the hand-coded version.
Willy Tarreau [Tue, 12 Jun 2012 05:59:16 +0000 (07:59 +0200)]
CLEANUP: halog: make clean should also remove .o files
Willy Tarreau [Sat, 9 Jun 2012 13:43:36 +0000 (15:43 +0200)]
BUG/MEDIUM: ebtree: ebmb_insert() must not call cmp_bits on full-length matches
Otherwise we end up comparing the byte past the end, resulting
in duplicate values still being inserted into the tree even if
undesired.
This generally has low impact, though it can sometimes cause one new entry
to be added next to an existing one for stick tables, preventing the results
from being merged.
(cherry picked from commit
12e54ac493a91bb02064568f410592c2700d3933)
Willy Tarreau [Sat, 9 Jun 2012 07:44:03 +0000 (09:44 +0200)]
MINOR: halog: use the more recent dual-mode fgets2 implementation
This version implements both 32 and 64 bit versions at once, it
avoids the need to have two separate output files. It also improves
efficiency on i386 platforms by adding a little bit of assembly where
gcc isn't efficient.
Willy Tarreau [Fri, 8 Jun 2012 20:57:36 +0000 (22:57 +0200)]
MEDIUM: fd/si: move peeraddr from struct fdinfo to struct connection
The destination address is purely a connection thing and not an fd thing.
It's also likely that later the address will be stored into the connection
and linked to by the SI.
struct fdinfo only keeps the pointer to the port range and the local port
for now. All of this also needs to move to the connection but before this
the release of the port range must move from fd_delete() to a new function
dedicated to the connection.
Willy Tarreau [Wed, 6 Jun 2012 14:15:03 +0000 (16:15 +0200)]
BUILD: add an AIX 5.2 (and later) target.
It's always a real pain to build on AIX and I constantly lose my flags,
so let's store them once for all in the Makefile.
Willy Tarreau [Wed, 6 Jun 2012 14:07:00 +0000 (16:07 +0200)]
BUG/MAJOR: cookie prefix doesn't support cookie-less servers
Commit
827aee91 merged in 1.5-dev5 introduced a regression causing
the srv pointer to be tested twice instead of srv then srv->cookie.
The result is that if a server has no cookie in prefix mode, haproxy
will crash when trying to modify it.
Such a config is very unlikely to happen, except maybe with a backup
server, which would cause haproxy to die with the last server in the
farm.
No backport is needed, only 1.5-dev was affected.
Willy Tarreau [Sun, 3 Jun 2012 22:43:45 +0000 (00:43 +0200)]
[RELEASE] Released version 1.5-dev11
Released version 1.5-dev11 with the following main changes :
- BUG/MEDIUM: option forwardfor if-none doesn't work with some configurations
- BUG/MAJOR: trash must always be the size of a buffer
- DOC: fix minor regex example issue and improve doc on stats
- MINOR: stream_interface: add a pointer to the listener for TARG_TYPE_CLIENT
- MEDIUM: protocol: add a pointer to struct sock_ops to the listener struct
- MINOR: checks: add on-marked-up option
- MINOR: balance uri: added 'whole' parameter to include query string in hash calculation
- MEDIUM: stream_interface: remove the si->init
- MINOR: buffers: add a rewind function
- BUG/MAJOR: fix regression on content-based hashing and http-send-name-header
- MAJOR: http: stop using msg->sol outside the parsers
- CLEANUP: http: make it more obvious that msg->som is always null outside of chunks
- MEDIUM: http: get rid of msg->som which is not used anymore
- MEDIUM: http: msg->sov and msg->sol will never wrap
- BUG/MAJOR: checks: don't call set_server_status_* when no LB algo is set
- BUG/MINOR: stop connect timeout when connect succeeds
- REORG: move the send-proxy code to tcp_connect_write()
- REORG/MINOR: session: detect the TCP monitor checks at the protocol accept
- MINOR: stream_interface: introduce a new "struct connection" type
- REORG/MINOR: stream_interface: move si->fd to struct connection
- REORG/MEDIUM: stream_interface: move applet->state and private to connection
- MINOR: stream_interface: add a data channel close function
- MEDIUM: stream_interface: call si_data_close() before releasing the si
- MINOR: peers: use the socket layer operations from the peer instead of sock_raw
- BUG/MINOR: checks: expire on timeout.check if smaller than timeout.connect
- MINOR: add a new function call tracer for debugging purposes
- BUG/MINOR: perform_http_redirect also needs to rewind the buffer
- BUG/MAJOR: b_rew() must pass a signed offset to b_ptr()
- BUG/MEDIUM: register peer sync handler in the proper order
- BUG/MEDIUM: buffers: fix bi_putchr() to correctly advance the pointer
- BUG/MINOR: fix option httplog validation with TCP frontends
- BUG/MINOR: log: don't report logformat errors in backends
- REORG/MINOR: use dedicated proxy flags for the cookie handling
- BUG/MINOR: config: do not report twice the incompatibility between cookie and non-http
- MINOR: http: add support for "httponly" and "secure" cookie attributes
- BUG/MEDIUM: ensure that unresolved arguments are freed exactly once
- BUG/MINOR: commit
196729ef used wrong condition resulting in freeing constants
- MEDIUM: stats: add support for soft stop/soft start in the admin interface
- MEDIUM: stats: add the ability to kill sessions from the admin interface
- BUILD: add support for linux kernels >= 2.6.28