Commit Graph

6047 Commits

Author SHA1 Message Date
Willy Tarreau
30fd4bd844 BUG/MEDIUM: ssl: properly reset the reused_sess during a forced handshake
We have a bug when SSL reuse is disabled on the server side : we reset
the context but do not set it to NULL, causing a multiple free of the
same entry. It seems like this bug cannot appear as-is with the current
code (or the conditions to get it are not obvious) but it did definitely
strike when trying to fix another bug with the SNI which forced a new
handshake.

This fix should be backported to 1.7, 1.6 and 1.5.
2016-12-22 21:54:21 +01:00
Willy Tarreau
368780334c MEDIUM: compression: move the zlib-specific stuff from global.h to compression.c
This finishes to clean up the zlib-specific parts. It also unbreaks recent
commit b97c6fb ("CLEANUP: compression: use the build options list to report
the algos") which broke USE_ZLIB due to MAXWBITS not being defined anymore
in haproxy.c.
2016-12-22 20:00:46 +01:00
Willy Tarreau
14e36a101c MEDIUM: cfgparse: move ssl-dh-param-file parsing to ssl_sock
This one was missing an arg count check which was added in the operation.
2016-12-21 23:39:26 +01:00
Willy Tarreau
f22e9683e9 MINOR: cfgparse: move parsing of ssl-default-{bind,server}-ciphers to ssl_sock
These ones are pretty similar, just an strdup. Contrary to ca-base
and crt-base they support being changed.
2016-12-21 23:39:26 +01:00
Willy Tarreau
0bea58d641 MEDIUM: cfgparse: move maxsslconn parsing to ssl_sock
This one simply reuses the existing integer parser. It implicitly
adds a control against negative numbers.
2016-12-21 23:39:26 +01:00
Willy Tarreau
9ceda384e9 MEDIUM: cfgparse: move all tune.ssl.* keywords to ssl_sock
The following keywords were still parsed in cfgparse and were moved
to ssl_sock to remove some #ifdefs :

"tune.ssl.cachesize", "tune.ssl.default-dh-param", "tune.ssl.force-private-cache",
"tune.ssl.lifetime", "tune.ssl.maxrecord", "tune.ssl.ssl-ctx-cache-size".

It's worth mentionning that some of them used to have incorrect sign
checks possibly resulting in some negative values being used. All of
them are now checked for being positive.
2016-12-21 23:39:26 +01:00
Willy Tarreau
8c3b0fd273 MINOR: cfgparse: move parsing of "ca-base" and "crt-base" to ssl_sock
This removes 2 #ifdefs and makes the code much cleaner. The controls
are still there and the two parsers have been merged into a single
function ssl_parse_global_ca_crt_base().

It's worth noting that there's still a check to prevent a change when
the value was already specified. This test seems useless and possibly
counter-productive, it may have to be revisited later, but for now it
was implemented identically.
2016-12-21 23:39:26 +01:00
Willy Tarreau
ece9b07c71 MINOR: cfgparse: add two new functions to check arguments count
We already had alertif_too_many_args{,_idx}(), but these ones are
specifically designed for use in cfgparse. Outside of it we're
trying to avoid calling Alert() all the time so we need an
equivalent using a pointer to an error message.

These new functions called too_many_args{,_idx)() do exactly this.
They don't take the file name nor the line number which they have
no use for but instead they take an optional pointer to an error
message and the pointer to the error code is optional as well.
With (NULL, NULL) they'll simply check the validity and return a
verdict. They are quite convenient for use in isolated keyword
parsers.

These two new functions as well as the previous ones have all been
exported.
2016-12-21 23:39:26 +01:00
Willy Tarreau
bee9dde31f CLEANUP: da: move global settings out of the global section
We replaced global.deviceatlas with global_deviceatlas since there's no need
to store all this into the global section. This removes the last #ifdefs,
and now the code is 100% self-contained in da.c. The file da.h was now
removed because it was only used to load dac.h, which is more easily
loaded directly from da.c. It provides another good example of how to
integrate code in the future without touching the core parts.
2016-12-21 21:30:54 +01:00
Willy Tarreau
b7a671477f CLEANUP: 51d: move global settings out of the global section
We replaced global._51degrees with global_51degrees since there's no need
to store all this into the global section. This removes the last #ifdefs,
and now the code is 100% self-contained in 51d.c. The file 51d.h was now
removed because it was only used to load 51Degrees.h, which is more easily
loaded from 51d.c. It provides a good example of how to integrate code in
the future without touching the core parts.
2016-12-21 21:30:54 +01:00
Willy Tarreau
350c1c6886 CLEANUP: wurfl: move global settings out of the global section
We replaced global.wurfl with global_wurfl since there's no need to store
all this into the global section. This removes the last #ifdefs, and now
the code is 100% self-contained in wurfl.c. It provides a good example of
how to integrate code in the future without touching the core parts.
2016-12-21 21:30:54 +01:00
Willy Tarreau
b149eedd5a CLEANUP: da: register the deinitialization function
deinit_deviceatlas() is not called anymore from haproxy.c, removing 2
still includes other parts of the Deviceatlas library so it was not
touched.
2016-12-21 21:30:54 +01:00
Willy Tarreau
7ac4c20509 CLEANUP: 51d: register the deinitialization function
deinit_51degrees() is not called anymore from haproxy.c, removing
2 #ifdefs and one include. The function was made static. The include
file still includes 51Degrees.h which is needed by global.h and 51d.c
so it was not touched beyond this last function removal.
2016-12-21 21:30:54 +01:00
Willy Tarreau
800f93f375 CLEANUP: wurfl: register the deinit function via the dedicated list
By registering the deinit function we avoid another #ifdef in haproxy.c.
The ha_wurfl_deinit() function has been made static and unexported. Now
proto/wurfl.h is totally empty, the code being self-contained in wurfl.c,
so the useless .h has been removed.
2016-12-21 21:30:54 +01:00
Willy Tarreau
05554e6bf1 MINOR: haproxy: add a registration for post-deinit functions
The 3 device detection engines stop at the same place in deinit()
with the usual #ifdefs. Similar to the other functions we can have
some late deinitialization functions. These functions do not return
anything however so we have to use a different type.
2016-12-21 21:30:54 +01:00
Willy Tarreau
876054df96 CLEANUP: da: make use of the late init registration code
Instead of having a #ifdef in the main init code we now use the registered
init functions. Doing so also enables error checking as errors were previously
reported as alerts but ignored. Also they were incorrect as the 'status'
variable was hidden by a second one and was always reporting DA_SYS (which
is apparently an error) in every case including the case where no file was
loaded. The init_deviceatlas() function was unexported since it's not used
outside of this place anymore.
2016-12-21 21:30:54 +01:00
Willy Tarreau
9f3f2549fb CLEANUP: 51d: make use of the late init registration
This removes some #ifdefs from the main haproxy code path. Function
init_51degrees() now returns ERR_* instead of exit(1) on error, and
this function was made static and is not exported anymore.
2016-12-21 21:30:54 +01:00
Willy Tarreau
dc2ed47163 CLEANUP: wurfl: make use of the late init registration
This removes some #ifdefs from the main haproxy code path and enables
error checking. The current code only makes use of warnings even for
some errors that look serious. While this choice is questionnable, it
has been kept as-is, and only the return codes were adapted to ERR_WARN
to at least report that some warnings were emitted. ha_wurfl_init() was
unexported as it's not needed anymore.
2016-12-21 21:30:54 +01:00
Willy Tarreau
64bca599d9 CLEANUP: filters: use the function registration to initialize all proxies
Function flt_init() was called in the main init code path, now we move
it to the list of initializers and we can unexport flt_init().
2016-12-21 21:30:54 +01:00
Willy Tarreau
865c5148e6 CLEANUP: checks: make use of the post-init registration to start checks
Instead of calling the checks directly from the init code, we now
register the start_checks() function to be run at this point. This
also allows to unexport the check init function and to remove one
include from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
e694573fa0 MINOR: haproxy: add a registration for post-check functions
There's a significant amount of late initialization calls which are
performed after the point where we exit in check mode. These calls
are used to allocate resource and perform certain slow operations.
Let's have a way to register some functions which need to be called
there instead of having this multitude of #ifdef in the init path.
2016-12-21 21:30:54 +01:00
Willy Tarreau
e8692b41e5 CLEANUP: auth: use the build options list to report its support
This removes 1 #ifdef from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
b97c6fb59e CLEANUP: compression: use the build options list to report the algos
This removes 2 #ifdef, an include, an ugly construct and a wild "extern"
declaration from haproxy.c. The message indicating that compression is
*not* enabled is not there anymore.
2016-12-21 21:30:54 +01:00
Willy Tarreau
c2c0b61274 CLEANUP: ssl: use the build options list to report the SSL details
This removes 7 #ifdef from haproxy.c. The message indicating that
openssl is *not* enabled is not there anymore.
2016-12-21 21:30:54 +01:00
Willy Tarreau
7a9ac6dac6 CLEANUP: regex: use the build options list to report the regex type
This removes 3 #ifdef from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
bb57d94a96 CLEANUP: lua: use the build options list to report it
This removes 1 #ifdef from haproxy.c. The "build without" version
is not reported anymore now.
2016-12-21 21:30:54 +01:00
Willy Tarreau
ba96291600 CLEANUP: tcp: use the build options list to report transparent modes
This removes 6 #ifdef from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
dba5002c4c CLEANUP: namespaces: use the build options list to report it
This removes one #ifdef from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
3dd483e727 CLEANUP: da: use the build options list to report it
This removes one #ifdef from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
b5e58d6ba1 CLEANUP: 51d: use the build options list to report it
This removes one #ifdef from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
770042d3c6 CLEANUP: wurfl: use the build options list to report it
This removes one #ifdef from haproxy.c.
2016-12-21 21:30:54 +01:00
Willy Tarreau
cdb737e5a2 MINOR: haproxy: add a registration for build options
Many extensions now report some build options to ease debugging, but
this is now being done at the expense of code maintainability. Let's
provide a registration function to do this so that we can start to
remove most of the #ifdefs from haproxy.c (18 currently just for a
single function).
2016-12-21 21:30:54 +01:00
Willy Tarreau
1b5af7cd42 CLEANUP: haproxy: statify unexported functions
haproxy.c is a real mess. Let's start to clean it up by declaring static
all functions which are not exported (ie almost all of them).
2016-12-21 18:19:57 +01:00
Thierry FOURNIER
2c8b54e7be MEDIUM: lua: remove Lua struct from session, and allocate it with memory pools
This patch use memory pools for allocating the Lua struct. This
save 128B of memory in the session if the Lua is unused.
2016-12-21 15:24:56 +01:00
Thierry FOURNIER
1be34152da BUG/MINOR: lua: memleak when Lua/cli fails
If the memory allocator fails, it return a bad code, and the execution
continue. If the Lua/cli initializer fails, the allocated struct is not
released.
2016-12-21 15:24:35 +01:00
Thierry FOURNIER
33558c4a3f BUG/MINOR: lua: bad return code
If the lua/cli fails during initialization, it returns an ok
status, an the execution continue. This will probably occur a
segfault.

Thiw patch should be backported in 1.7
2016-12-21 15:24:24 +01:00
Thierry FOURNIER
4e7c708612 BUG/MINOR: lua: memory leak executing tasks
The struct hlua isn't freed when the task is complete.

This patch should be backported in 1.6 and 1.7
2016-12-21 15:24:09 +01:00
Christopher Faulet
33834b15dc BUG/MINOR: Fix the sending function in Lua's cosocket
This is a regression from the commit a73e59b690.

When data are sent from a cosocket, the action is done in the context of the
applet running a lua stack and not in the context of the applet owning the
cosocket. So we must take care, explicitly, that this last applet have a buffer
(the req buffer of the cosocket).

This patch must be backported in 1.7
2016-12-21 15:22:08 +01:00
Marcin Deranek
6e413ed1ed DOC: fix small typo in fe_id (backend instead of frontend)
Needs to be backported to 1.7 and 1.6 at least.
2016-12-21 15:21:28 +01:00
Thierry FOURNIER
3b0a6d480b MINOR/DOC: lua: just precise one thing
In the case of applet, the Lua context is taken from session
when we get the private values. This patch just update comments
associated to this action because it is not obvious.
2016-12-17 14:27:30 +01:00
Willy Tarreau
5cd60670a6 CONTRIB: tcploop: add limits.h to fix build issue with some compilers
Just got this while cross-compiling :

tcploop.c: In function 'tcp_recv':
tcploop.c:444:48: error: 'INT_MAX' undeclared (first use in this function)
tcploop.c:444:48: note: each undeclared identifier is reported only once for each function it appears in
2016-12-17 14:27:30 +01:00
Willy Tarreau
f5f26e824a MINOR: appctx/cli: remove the "tlskeys" entry from the appctx union
This one now migrates to the general purpose cli.p0 for the ref pointer,
cli.i0 for the dump_all flag and cli.i1 for the dump_keys_index. A few
comments were added.

The applet.h file doesn't depend on openssl anymore. It's worth noting
that the previous dependency was accidental and only used to work because
all files including this one used to have openssl included prior to
loading this file.
2016-12-16 19:40:14 +01:00
Willy Tarreau
3c92f2aca4 MINOR: appctx/cli: remove the "server_state" entry from the appctx union
This one now migrates to the general purpose cli.p0 for the proxy pointer,
cli.p1 for the server pointer, and cli.i0 for the proxy's instance if only
one has to be dumped.
2016-12-16 19:40:14 +01:00
Willy Tarreau
777b560d04 MINOR: appctx/cli: remove the "dns" entry from the appctx union
This one now migrates to the general purpose cli.p0.
2016-12-16 19:40:14 +01:00
Willy Tarreau
608ea5921a MINOR: appctx/cli: remove the "be" entry from the appctx union
This one now migrates to the general purpose cli.p0. The parsing
function was removed since it was only used to set the pointer to
NULL.
2016-12-16 19:40:14 +01:00
Willy Tarreau
f6710f8811 MINOR: appctx/cli: remove the env entry from the appctx union
This one now migrates to the general purpose cli.p0.
2016-12-16 19:40:14 +01:00
Willy Tarreau
3af9d832e8 MINOR: appctx/cli: remove the cli_socket entry from the appctx union
This one now migrates to the general purpose cli.p0.
2016-12-16 19:40:13 +01:00
Willy Tarreau
a2d5872297 MINOR: cli: add two general purpose pointers and integers in the CLI struct
Most of the keywords don't need to have their own entry in the appctx
union, they just need to reuse some generic pointers like we've been
used to do in the appctx with st{0,1,2}. This patch adds p0, p1, i0, i1
and initializes them to zero before calling the parser. This way some
of the simplest existing keywords will be able to disappear from the
union.

It's worth noting that this is an extension to what was initially
attempted via the "private" member that I removed a few patches ago by
not understanding how it was supposed to be used. Here the fact that
we share the same union will force us to be stricter: the code either
uses the general purpose variables or it uses its own fields but not
both.
2016-12-16 19:40:13 +01:00
Willy Tarreau
d25fc79d72 CLEANUP: stats: move a misplaced stats context initialization
This is a leftover from the cleanup campaign, the stats scope was still
initialized by the CLI instead of being initialized by the stats keyword
parsers. This should probably be backported to 1.7 to make the code more
consistent.
2016-12-16 19:40:13 +01:00
Willy Tarreau
ebec3519b0 CLEANUP: applet: group all CLI contexts together
The appctx storage became a real mess along the years. It now contains
mostly CLI-specific parts that share the same storage as the "cli" part
which in fact only contains the fields needed to pass an error message
to the caller, and it also has room a few other regular applets which
may become more and more common.

This first patch moves the parts around in the union so that all
standard applet parts are grouped together and the CLI-specific ones
are grouped together. It also adds a few comments to indicate what
certain parts are used for since it's sometimes a bit confusing.
2016-12-16 19:40:13 +01:00