Commit Graph

1232 Commits

Author SHA1 Message Date
Thierry FOURNIER
85c6c97830 MINOR: action: add reference to the original keywork matched for the called parser.
This is usefull because the keyword can contains some condifiguration
data set while the keyword registration.
2015-09-23 21:44:23 +02:00
Thierry FOURNIER
7ea160cb5f MINOR: action: add private configuration
This private configuration pointer is used for storing some configuration
data associated the keyword, So many keywords can use the same parse
function, and this one can use a discriminator.
2015-09-23 21:44:23 +02:00
Willy Tarreau
f7ead61388 BUG/MINOR: args: add name for ARGT_VAR
Commit 4834bc7 ("MEDIUM: vars: adds support of variables") introduced
ARGT_VAR but forgot to put it in the names array. No backport needed.
2015-09-21 20:57:12 +02:00
James Rosewell
10790964b0 MINOR: global: Added new fields for 51Degrees device detection
Added support for version 3.2 of 51Degrees C library.

Added fields to store HTTP header names important to device detection
other than User-Agent.

Included a pool of worksets for use with Pattern device detection.
2015-09-21 12:10:41 +02:00
Baptiste Assmann
e11cfcd2c9 MINOR: config: new backend directives: load-server-state-from-file and server-state-file-name
This directive gives HAProxy the ability to use the either the global
server-state-file directive or a local one using server-state-file-name to
load server states.
The state can be saved right before the reload by the init script, using
the "show servers state" command on the stats socket redirecting output into
a file.
2015-09-19 17:05:28 +02:00
Baptiste Assmann
e0882263e0 MINOR: config: new global section directive: server-state-file
This new global section directive is used to store the path to the file
where HAProxy will be able to retrieve server states across reloads.

The file pointed by this path is used to store a file which can contains
state of all servers from all backends.
2015-09-19 17:05:27 +02:00
Baptiste Assmann
6bc89366bb MINOR: config: new global directive server-state-base
This new global directive can be used to provide a base directory where
all the server state files could be loaded.
If a server state file name starts with a slash '/', then this directive
must not be applied.
2015-09-19 17:05:26 +02:00
Baptiste Assmann
2828946cb5 MINOR: cli: new stats socket command: show servers state
new command 'show servers state' which dumps all variable parameters
of a server during an HAProxy process life.
Purpose is to dump current server state at current run time in order to
read them right after the reload.

The format of the output is versionned and we support version 1 for now.
2015-09-19 16:52:46 +02:00
Baptiste Assmann
41472f4d98 MINOR: server: Macro definition for server-state
Introduces a few new macros used by server state save and application accros reloads:
- currently used state server file format version
- currently used state server file header fields
- MIN and MAX value for version number
- maximum number of fields that could be found in a server-state file
- an arbitrary state-file max line length
2015-09-19 11:34:41 +02:00
Baptiste Assmann
54a4730c65 BUG/MAJOR: can't enable a server through the stat socket
When a server is disabled in the configuration using the "disabled"
keyword, a single flag is positionned: SRV_ADMF_CMAINT (use to be
SRV_ADMF_FMAINT)..
That said, when providing the first version of this code, we also
changed the SRV_ADMF_MAINT mask to match any of the possible MAINT
cases: SRV_ADMF_FMAINT, SRV_ADMF_IMAINT, SRV_ADMF_CMAINT

Since SRV_ADMF_CMAINT is never (and is not supposed to be) altered at
run time, once a server has this flag set up, it can never ever be
enabled again using the stats socket.

In order to fix this, we should:
- consider SRV_ADMF_CMAINT as a simple flag to report the state in the
  old configuration file (will be used after a reload to deduce the
  state of the server in a new running process)
- enabling both SRV_ADMF_CMAINT and SRV_ADMF_FMAINT when the keyword
  "disabled" is in use in the configuration
- update the mask SRV_ADMF_MAINT as it was before, to only match
  SRV_ADMF_FMAINT and SRV_ADMF_IMAINT.

The following patch perform the changes above.
It allows fixing the regression without breaking the way the up coming
feature (seamless server state accross reloads) is going to work.

Note: this is 1.6-only, no backport needed.
2015-09-18 12:38:23 +02:00
Thierry FOURNIER
007ff4ce0f MINOR: build: missing header
Regex header file is missing in types/action.h

Repported by Conrad Hoffmann

I cannot build the current dev's master HEAD (ec3c37d) because of this error:

> In file included from include/proto/proto_http.h:26:0,
>                  from src/stick_table.c:26:
> include/types/action.h:102:20: error: field ‘re’ has incomplete type
>     struct my_regex re;    /* used by replace-header and replace-value */
>                     ^
> Makefile:771: recipe for target 'src/stick_table.o' failed
> make: *** [src/stick_table.o] Error 1

The struct act_rule defined in action.h includes a full struct my_regex
without #include-ing regex.h. Both gcc 5.2.0 and clang 3.6.2 do not allow this.
2015-09-11 17:34:56 +02:00
Thierry FOURNIER
ec3c37db3b CLEANUP: actions: missplaced includes
The include of action.h are misplaced.
2015-09-10 21:17:04 +02:00
Baptiste Assmann
0453a1dd45 MINOR: dns: new flag to report that no IP can be found in a DNS response packet
Some DNS response may be valid from a protocol point of view but may not
contain any IP addresses.
This patch gives a new flag to the function dns_get_ip_from_response to
report such case.
It's up to the upper layer to decide what to do with this information.
2015-09-10 15:42:55 +02:00
Baptiste Assmann
96972bcd36 MINOR: dns: no expected DNS record type found
Some DNS responses may be valid from a protocol point of view, but may
not contain any information considered as interested by the requester..
Purpose of the flag DNS_RESP_NO_EXPECTED_RECORD introduced by this patch is
to allow reporting such situation.

When this happens, a new DNS query is sent with a new query type.

For now, the function only expect A and AAAA query types which is enough
to cover current cases.
In a next future, it will be up to the caller to tell the function which
query types are expected.
2015-09-10 15:41:53 +02:00
Baptiste Assmann
0df5d9669a MINOR: dns: New DNS response analysis code: DNS_RESP_TRUNCATED
This patch introduces a new internal response state about the analysis
of a DNS response received by a server.
It is dedicated to report to above layer that the response is
'truncated'.
2015-09-08 14:58:07 +02:00
Baptiste Assmann
6cdea9359b MINOR: dns: dns_nameserver structure update: new counter for truncated response
This patch updates the dns_nameserver structure to integrate a counter
dedicated to 'truncated' response sent by servers.
Such response are important to track, since HAProxy is supposed to
replay its request.
2015-09-08 14:57:28 +02:00
Baptiste Assmann
042d0a1f8c MINOR: dns: new bitmasks to use against DNS flags
Current DNS client code implementation doesn't take care of response
flags setup by the server.
This patch introduces a couple of bitmasks one can use to retrieve the
truncated flag and the reply code available in the 2-bytes flag field.
2015-09-08 12:14:03 +02:00
Baptiste Assmann
189363e35a MINOR: dns: dns_resolution structure update: time_t to unsigned int
3 variables of the dns_resolution structure are set to 'time_t' type.
Since they are all set by 'now_ms' and used as 'ticks' in HAProxy's
internal, it is safer to set them to the same type than now_ms:
'unsigned int'.
2015-09-08 10:50:17 +02:00
Willy Tarreau
b7ce424be2 BUG/MINOR: http: remove stupid HTTP_METH_NONE entry
When converting the "method" fetch to a string, we used to get an empty
string if the first character was not an upper case. This was caused by
the lookup function which returns HTTP_METH_NONE when a lookup is not
possible, and this method being mapped to an empty string in the array.

This is a totally stupid mechanism, there's no reason for having the
result depend on the first char. In fact the message parser already
checks that the syntax matches an HTTP token so we can only land there
with a valid token, hence only HTTP_METH_OTHER should be returned.

This fix should be backported to all actively supported branches.
2015-09-03 17:15:21 +02:00
Thierry FOURNIER
42148735bc MEDIUM: actions: remove ACTION_STOP
Before this patch, two type of custom actions exists: ACT_ACTION_CONT and
ACT_ACTION_STOP. ACT_ACTION_CONT is a non terminal action and ACT_ACTION_STOP is
a terminal action.

Note that ACT_ACTION_STOP is not used in HAProxy.

This patch remove this behavior. Only type type of custom action exists, and it
is called ACT_CUSTOM. Now, the custion action can return a code indicating the
required behavior. ACT_RET_CONT wants that HAProxy continue the current rule
list evaluation, and ACT_RET_STOP wants that HAPRoxy stops the the current rule
list evaluation.
2015-09-02 18:36:38 +02:00
Thierry FOURNIER
35d70efc33 MINOR: http: Action for manipulating the returned status code.
This patch is inspired by Bowen Ni's proposal and it is based on his first
implementation:

   With Lua integration in HAProxy 1.6, one can change the request method,
   path, uri, header, response header etc except response line.
   I'd like to contribute the following methods to allow modification of the
   response line.

   [...]

   There are two new keywords in 'http-response' that allows you to rewrite
   them in the native HAProxy config. There are also two new APIs in Lua that
   allows you to do the same rewriting in your Lua script.

   Example:
   Use it in HAProxy config:
   *http-response set-code 404*
   Or use it in Lua script:
   *txn.http:res_set_reason("Redirect")*

I dont take the full patch because the manipulation of the "reason" is useless.
standard reason are associated with each returned code, and unknown code can
take generic reason.

So, this patch can set the status code, and the reason is automatically adapted.
2015-08-27 14:29:44 +02:00
Thierry FOURNIER
0a99b89531 MINOR: lua: add core.done() function
This function immediately give back the control to HAProxy core.
2015-08-27 11:27:29 +02:00
Willy Tarreau
29fbe51490 MAJOR: tproxy: remove support for cttproxy
This was the first transparent proxy technology supported by haproxy
circa 2005 but it was obsoleted in 2007 by Tproxy 4.0 which removed a
lot of the earlier versions' shortcomings and was finally merged into
the kernel. Since nobody has been using cttproxy for many years now
and nobody has even just tried to compile the files, it's time to
remove it. The doc was updated as well.
2015-08-20 19:35:14 +02:00
Thierry FOURNIER
e0627bdae0 MINOR: stick-tables: Add GPC0 actions
This patch adds access to GPC0 through http and tcp actions
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
236657b5e0 MINOR: stick-tables: Add GPT0 access
This patch adds acces to GPT0. The access can be done with http and
tcp actions, and through a converter.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
3cf1111eb3 MEDIUM: stick-tables: Add GPT0 in the stick tables
This patch adds GPT0 (General Purpose Tag 0). It is useful for storing
a simple state.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
7e25df3f17 MAJOR: stick-tables: remove key storage from the key struct
Now, the key struct only points to the storage provided by the
sample as input.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
5d24ebc3d7 MEDIUM: stick-tables: use the sample type names
This patch removes the special stick tables types names and
use the standard sample type names. This avoid the maintainance
of two types and remove the switch/case for matching a sample
type for each stick table type.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
bc8c404449 MAJOR: stick-tables: use sample types in place of dedicated types
This patch is the first step for sample integration. Actually
the stick tables uses her own data type, and some converters
must be called to convert sample type to stick-tables types.

This patch removes the stick-table types and replace it by
the sample types. This prevent:
 - Maintenance of two types of converters
 - reduce the code using the samples converters
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
afa80496db MEDIUM: actions: Normalize the return code of the configuration parsers
This patch normalize the return code of the configuration parsers. Before
these changes, the tcp action parser returned -1 if fail and 0 for the
succes. The http action returned 0 if fail and 1 if succes.

The normalisation does:
 - ACT_RET_PRS_OK for succes
 - ACT_RET_PRS_ERR for failure
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
322a124867 MINOR: actions: mutualise the action keyword lookup
Each (http|tcp)-(request|response) action use the same method
for looking up the action keyword during the cofiguration parsing.

This patch mutualize the code.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
c2bb050f7f MINOR: proto_tcp: proto_tcp.h is now useles
After removing the keyword register from types/proto_tcp.h, the header
file remains empty. This patch remove it
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
36481b8667 MEDIUM: actions: Merge (http|tcp)-(request|reponse) keywords structs
This patch merges the conguration keyword struct. Each declared configuration
keyword struct are similar with the others. This patch simplify the code.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
24ff6c6fce MEDIUM: actions: Add standard return code for the action API
Action function can return 3 status:
 - error if the action encounter fatal error (like out of memory)
 - yield if the action must terminate his work later
 - continue in other cases
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
0ea5c7fafa MINOR: actions: change actions names
For performances considerations, some actions are not processed by remote
function. They are directly processed by the function. Some of these actions
does the same things but for different processing part (request / response).

This patch give the same name for the same actions, and change the normalization
of the other actions names.

This patch is ONLY a rename, it doesn't modify the code.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
91f6ba0f2c MINOR: actions: Declare all the embedded actions in the same header file
This patch group the action name in one file. Some action are called
many times and need an action embedded in the action caller. The main
goal is to have only one header file grouping all definitions.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
22e49011b1 MINOR: actions: remove the mark indicating the last entry in enum
This mark permit to detect if the action tag is over the allowed range.
 - Normally, this case doesn't appear
 - If it appears, it is processed by ded fault case of the switch
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
5563e4b469 MINOR: actions: add "from" information
This struct member is used to specify who is the rule caller. It permits
to use one function for differents callers.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
d0d65aeab6 MEDIUM: capture: Move the capture configuration storage in the union
This patch moves the capture configuration struct (capture_prm) in the main
"arg" union. This reduce the size of the struct.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
5ec63e008d MEDIUM: track-sc: Move the track-sc configuration storage in the union
This patch moves the track-sc configuration struct (track_ctr_prm) in the main
"arg" union. This reduce the size od the struct.
2015-08-20 17:13:47 +02:00
Thierry FOURNIER
e209797ef0 MINOR: proto_http: replace generic opaque types by real used types in "http_capture" by id
This patch removes the generic opaque type for storing the configuration of the
action "http_capture" by id.
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
32b15003fe MINOR: proto_http: replace generic opaque types by real used types in "http_capture"
This patch removes the generic opaque type for storing the configuration of the
action "http_capture"".
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
8855a92d8c MINOR: proto_http: replace generic opaque types by real used types for the actions on thr request line
This patch removes the generic opaque type for storing the configuration of the
action "set-method", "set-path", "set-query" and "set-uri".
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
a002dc9df8 MINOR: proto_http: use an "expr" type in place of generic opaque type.
This patch removes the generic opaque type for storing the configuration of the
acion "set-src" (HTTP_REQ_ACT_SET_SRC), and use the dedicated type "struct expr"
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
f8c1dcea01 MINOR: vars: use the vars types as argument in place of opaque type
The (http|tcp)-(request|response) action rules use common
opaque type. For the HAProxy embbedded feature, types are know,
it better to add this types in the action union and use it.
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
231ef1d99c MINOR: lua: use the hlua_rule type in place of opaque type
The (http|tcp)-(request|response) action rules use common
opaque type. For the HAProxy embbedded feature, types are know,
it better to add this types in the action union and use it.
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
7677f400f5 MINOR: actions: Remove the data opaque pointer
This patch removes the "data" opaque pointer and replace it by the generic
opaque pointer "p[0]".
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
a28a9429b2 MEDIUM: actions: Merge (http|tcp)-(request|reponse) action structs
This patch is the first of a serie which merge all the action structs. The
function "tcp-request content", "tcp-response-content", "http-request" and
"http-response" have the same values and the same process for some defined
actions, but the struct and the prototype of the declared function are
different.

This patch try to unify all of these entries.
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
7d4335c935 MEDIUM: pattern/map: Maps can returns various types
A map can store and return various types as output. The only one example is the
IPv4 and IPv6 types. The previous patch remove the type from the sample storage
struct and use the conoverter output type, expecting that all entries of the
map have the same type.

This will be wrong when the maps will support both IPv4 and IPv6 as output.
2015-08-20 17:13:46 +02:00
Thierry FOURNIER
136f9d34a9 MINOR: samples: rename union from "data" to "u"
The union name "data" is a little bit heavy while we read the source
code because we can read "data.data.sint". The rename from "data" to "u"
makes the read easiest like "data.u.sint".
2015-08-20 17:13:46 +02:00