MINOR: proxy: implement GUID support
Implement proxy identiciation through GUID. As such, a guid_node member is inserted into proxy structure. A proxy keyword "guid" is defined to allow user to fix its value.
This commit is contained in:
parent
1009ca4160
commit
da754b4533
@ -4902,6 +4902,7 @@ error-log-format X X X -
|
||||
force-persist - - X X
|
||||
filter - X X X
|
||||
fullconn X - X X
|
||||
guid - X X X
|
||||
hash-balance-factor X - X X
|
||||
hash-key X - X X
|
||||
hash-type X - X X
|
||||
@ -6666,6 +6667,14 @@ fullconn <conns>
|
||||
See also : "maxconn", "server"
|
||||
|
||||
|
||||
guid <string>
|
||||
Specify a case-sensitive global unique ID for this proxy. This must be unique
|
||||
accross all haproxy configuration on every object types. Format is left
|
||||
unspecified to allow the user to select its naming policy. The only
|
||||
restriction is its length which cannot be greater than 127 characters. All
|
||||
alphanumerical values and '.', ':', '-' and '_' characters are valid.
|
||||
|
||||
|
||||
hash-balance-factor <factor>
|
||||
Specify the balancing factor for bounded-load consistent hashing
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <haproxy/compression-t.h>
|
||||
#include <haproxy/counters-t.h>
|
||||
#include <haproxy/freq_ctr-t.h>
|
||||
#include <haproxy/guid-t.h>
|
||||
#include <haproxy/obj_type-t.h>
|
||||
#include <haproxy/queue-t.h>
|
||||
#include <haproxy/server-t.h>
|
||||
@ -457,6 +458,8 @@ struct proxy {
|
||||
*/
|
||||
struct list filter_configs; /* list of the filters that are declared on this proxy */
|
||||
|
||||
struct guid_node guid; /* GUID global tree node */
|
||||
|
||||
EXTRA_COUNTERS(extra_counters_fe);
|
||||
EXTRA_COUNTERS(extra_counters_be);
|
||||
};
|
||||
|
12
src/guid.c
12
src/guid.c
@ -2,6 +2,7 @@
|
||||
|
||||
#include <import/ebistree.h>
|
||||
#include <haproxy/obj_type.h>
|
||||
#include <haproxy/proxy.h>
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
/* GUID global tree */
|
||||
@ -40,6 +41,10 @@ int guid_insert(enum obj_type *objt, const char *uid, char **errmsg)
|
||||
}
|
||||
|
||||
switch (obj_type(objt)) {
|
||||
case OBJ_TYPE_PROXY:
|
||||
guid = &__objt_proxy(objt)->guid;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* No guid support for this objtype. */
|
||||
ABORT_NOW();
|
||||
@ -103,7 +108,14 @@ struct guid_node *guid_lookup(const char *uid)
|
||||
*/
|
||||
char *guid_name(const struct guid_node *guid)
|
||||
{
|
||||
char *msg = NULL;
|
||||
struct proxy *px;
|
||||
|
||||
switch (obj_type(guid->obj_type)) {
|
||||
case OBJ_TYPE_PROXY:
|
||||
px = __objt_proxy(guid->obj_type);
|
||||
return memprintf(&msg, "%s %s", proxy_cap_str(px->cap), px->id);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
33
src/proxy.c
33
src/proxy.c
@ -29,6 +29,7 @@
|
||||
#include <haproxy/fd.h>
|
||||
#include <haproxy/filters.h>
|
||||
#include <haproxy/global.h>
|
||||
#include <haproxy/guid.h>
|
||||
#include <haproxy/http_ana.h>
|
||||
#include <haproxy/http_htx.h>
|
||||
#include <haproxy/http_ext.h>
|
||||
@ -232,6 +233,8 @@ void free_proxy(struct proxy *p)
|
||||
free_acl_cond(cond);
|
||||
}
|
||||
|
||||
guid_remove(&p->guid);
|
||||
|
||||
EXTRA_COUNTERS_FREE(p->extra_counters_fe);
|
||||
EXTRA_COUNTERS_FREE(p->extra_counters_be);
|
||||
|
||||
@ -1010,6 +1013,33 @@ static int proxy_parse_tcpka_intvl(char **args, int section, struct proxy *proxy
|
||||
}
|
||||
#endif
|
||||
|
||||
static int proxy_parse_guid(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
const char *guid;
|
||||
char *guid_err = NULL;
|
||||
|
||||
if (curpx->cap & PR_CAP_DEF) {
|
||||
ha_alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, line, args[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!*args[1]) {
|
||||
memprintf(err, "'%s' : expects an argument", args[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
guid = args[1];
|
||||
if (guid_insert(&curpx->obj_type, guid, &guid_err)) {
|
||||
memprintf(err, "'%s': %s", args[0], guid_err);
|
||||
ha_free(&guid_err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function inserts proxy <px> into the tree of known proxies (regular
|
||||
* ones or defaults depending on px->cap & PR_CAP_DEF). The proxy's name is
|
||||
* used as the storing key so it must already have been initialized.
|
||||
@ -1348,6 +1378,8 @@ void init_new_proxy(struct proxy *p)
|
||||
/* Default to only allow L4 retries */
|
||||
p->retry_type = PR_RE_CONN_FAILED;
|
||||
|
||||
guid_init(&p->guid);
|
||||
|
||||
p->extra_counters_fe = NULL;
|
||||
p->extra_counters_be = NULL;
|
||||
|
||||
@ -2569,6 +2601,7 @@ static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_LISTEN, "clitcpka-intvl", proxy_parse_tcpka_intvl },
|
||||
{ CFG_LISTEN, "srvtcpka-intvl", proxy_parse_tcpka_intvl },
|
||||
#endif
|
||||
{ CFG_LISTEN, "guid", proxy_parse_guid },
|
||||
{ 0, NULL, NULL },
|
||||
}};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user