MEDIUM: stick-table: Stop handling stick-tables as proxies.
This patch adds the support for the "table" line parsing in "peers" sections
to declare stick-table in such sections. This also prevents the user from having
to declare dummy backends sections with a unique stick-table inside.
Even if still supported, this usage will become deprecated.
To do so, the ->table member of proxy struct which is a stktable struct is replaced
by a pointer to a stktable struct allocated at parsing time in src/cfgparse-listen.c
for the dummy stick-table backends and in src/cfgparse.c for "peers" sections.
This has an impact on the code for stick-table sample converters and on the stickiness
rules parsers which first store the name of the dummy before resolving the rules.
This patch replaces proxy_tbl_by_name() calls by stktable_find_by_name() calls
to lookup for stick-tables stored in "stktable_by_name" ebtree at parsing time.
There is only one remaining place where proxy_tbl_by_name() is used: src/hlua.c.
At several places in the code we relied on the fact that ->size member of stick-table
was equal to zero to consider the stick-table was present by not configured,
this do not make sense anymore as ->table member of struct proxyis fow now on a pointer.
These tests are replaced by a test on ->table value itself.
In "peers" section we do not have to temporary store the name of the section the
stick-table are attached to because this name is obviously already known just after
having entered this "peers" section.
About the CLI stick-table I/O handler, the pointer to proxy struct is replaced by
a pointer to a stktable struct.
diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h
index 962c95a..3010d81 100644
--- a/include/proto/stick_table.h
+++ b/include/proto/stick_table.h
@@ -28,9 +28,13 @@
#include <common/time.h>
#include <types/stick_table.h>
+extern struct stktable *stktables_list;
+
#define stktable_data_size(type) (sizeof(((union stktable_data*)0)->type))
#define stktable_data_cast(ptr, type) ((union stktable_data*)(ptr))->type
+void stktable_store_name(struct stktable *t);
+struct stktable *stktable_find_by_name(const char *name);
struct stksess *stksess_new(struct stktable *t, struct stktable_key *key);
void stksess_setkey(struct stktable *t, struct stksess *ts, struct stktable_key *key);
void stksess_free(struct stktable *t, struct stksess *ts);
diff --git a/include/types/applet.h b/include/types/applet.h
index 4786b31..b7b297c 100644
--- a/include/types/applet.h
+++ b/include/types/applet.h
@@ -144,7 +144,7 @@
} errors;
struct {
void *target; /* table we want to dump, or NULL for all */
- struct proxy *proxy; /* table being currently dumped (first if NULL) */
+ struct stktable *t; /* table being currently dumped (first if NULL) */
struct stksess *entry; /* last entry we were trying to dump (or first if NULL) */
long long value; /* value to compare against */
signed char data_type; /* type of data to compare, or -1 if none */
diff --git a/include/types/arg.h b/include/types/arg.h
index 6580c15..a9778f2 100644
--- a/include/types/arg.h
+++ b/include/types/arg.h
@@ -30,6 +30,7 @@
#include <types/vars.h>
#include <types/protocol_buffers.h>
+#include <types/stick_table.h>
/* encoding of each arg type : up to 31 types are supported */
#define ARGT_BITS 5
@@ -99,6 +100,7 @@
struct in6_addr ipv6;
struct proxy *prx; /* used for fe, be, tables */
struct server *srv;
+ struct stktable *t;
struct userlist *usr;
struct map_descriptor *map;
struct my_regex *reg;
diff --git a/include/types/hlua.h b/include/types/hlua.h
index f9709bb..36554e2 100644
--- a/include/types/hlua.h
+++ b/include/types/hlua.h
@@ -11,6 +11,7 @@
#include <types/proto_http.h>
#include <types/proxy.h>
#include <types/server.h>
+#include <types/stick_table.h>
#define CLASS_CORE "Core"
#define CLASS_TXN "TXN"
diff --git a/include/types/proxy.h b/include/types/proxy.h
index dababea..f6d2634 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -416,7 +416,7 @@
struct fe_counters fe_counters; /* frontend statistics counters */
struct list listener_queue; /* list of the temporarily limited listeners because of lack of a proxy resource */
- struct stktable table; /* table for storing sticking streams */
+ struct stktable *table; /* table for storing sticking streams */
struct task *task; /* the associated task, mandatory to manage rate limiting, stopping and resource shortage, NULL if disabled */
struct list tcpcheck_rules; /* tcp-check send / expect rules */
diff --git a/include/types/stick_table.h b/include/types/stick_table.h
index a6a4a49..ff9546c 100644
--- a/include/types/stick_table.h
+++ b/include/types/stick_table.h
@@ -152,6 +152,7 @@
const char *file; /* The file where the stick-table is declared. */
int line; /* The line in this <file> the stick-table is declared. */
} conf;
+ struct ebpt_node name; /* Stick-table are lookup by name here. */
struct eb_root keys; /* head of sticky session tree */
struct eb_root exps; /* head of sticky session expiration tree */
struct eb_root updates; /* head of sticky updates sequence tree */