#include <import/ebtree-t.h>
#include <haproxy/api-t.h>
+#include <haproxy/guid-t.h>
#include <haproxy/obj_type-t.h>
#include <haproxy/quic_cc-t.h>
#include <haproxy/quic_sock-t.h>
char *arg; /* argument passed to "bind" for better error reporting */
char *file; /* file where the section appears */
int line; /* line where the section appears */
+ char *guid_prefix; /* prefix for listeners GUID */
+ size_t guid_idx; /* next index for listeners GUID generation */
char *rhttp_srvname; /* name of server when using "rhttp@" address */
int rhttp_nbconn; /* count of connections to initiate in parallel */
__decl_thread(HA_RWLOCK_T sni_lock); /* lock the SNI trees during add/del operations */
struct eb32_node id; /* place in the tree of used IDs */
} conf; /* config information */
+ struct guid_node guid; /* GUID global tree node */
+
struct li_per_thread *per_thr; /* per-thread fields (one per thread in the group) */
EXTRA_COUNTERS(extra_counters);
#include <haproxy/guid.h>
#include <import/ebistree.h>
+#include <haproxy/listener-t.h>
#include <haproxy/obj_type.h>
#include <haproxy/proxy.h>
#include <haproxy/server-t.h>
guid = &__objt_proxy(objt)->guid;
break;
+ case OBJ_TYPE_LISTENER:
+ guid = &__objt_listener(objt)->guid;
+ break;
+
case OBJ_TYPE_SERVER:
guid = &__objt_server(objt)->guid;
break;
{
char *msg = NULL;
struct proxy *px;
+ struct listener *l;
struct server *srv;
switch (obj_type(guid->obj_type)) {
px = __objt_proxy(guid->obj_type);
return memprintf(&msg, "%s %s", proxy_cap_str(px->cap), px->id);
+ case OBJ_TYPE_LISTENER:
+ l = __objt_listener(guid->obj_type);
+ return memprintf(&msg, "listener %s (%s:%d)",
+ l->bind_conf->frontend->id,
+ l->bind_conf->file, l->bind_conf->line);
+
case OBJ_TYPE_SERVER:
srv = __objt_server(guid->obj_type);
return memprintf(&msg, "server %s/%s", srv->proxy->id, srv->id);
#include <haproxy/freq_ctr.h>
#include <haproxy/frontend.h>
#include <haproxy/global.h>
+#include <haproxy/guid.h>
#include <haproxy/list.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
if (fd != -1)
l->rx.flags |= RX_F_INHERITED;
+ guid_init(&l->guid);
+
l->extra_counters = NULL;
HA_RWLOCK_INIT(&l->lock);
return cfgerr;
}
+/* Generate and insert unique GUID for each listeners of <bind_conf> instance
+ * if GUID prefix is defined.
+ *
+ * Returns 0 on success else non-zero.
+ */
+int bind_generate_guid(struct bind_conf *bind_conf)
+{
+ struct listener *l;
+ char *guid_err = NULL;
+
+ if (!bind_conf->guid_prefix)
+ return 0;
+
+ list_for_each_entry(l, &bind_conf->listeners, by_bind) {
+ if (bind_conf->guid_idx == (size_t)-1) {
+ ha_alert("[%s:%d] : error on GUID generation : Too many listeners.\n",
+ bind_conf->file, bind_conf->line);
+ return 1;
+ }
+
+ chunk_printf(&trash, "%s-%lld", bind_conf->guid_prefix,
+ (ullong)bind_conf->guid_idx);
+
+ if (guid_insert(&l->obj_type, b_head(&trash), &guid_err)) {
+ ha_alert("[%s:%d] : error on GUID generation : %s. "
+ "You may fix it by adjusting guid-prefix.\n",
+ bind_conf->file, bind_conf->line, guid_err);
+ ha_free(&guid_err);
+ return 1;
+ }
+
+ ++bind_conf->guid_idx;
+ }
+
+ return 0;
+}
+
/*
* Registers the bind keyword list <kwl> as a list of valid keywords for next
* parsing sessions.
#endif
LIST_INIT(&bind_conf->listeners);
+ bind_conf->guid_prefix = NULL;
+ bind_conf->guid_idx = 0;
+
bind_conf->rhttp_srvname = NULL;
return bind_conf;
return 0;
}
+/* parse the "guid-prefix" bind keyword */
+static int bind_parse_guid_prefix(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
+{
+ char *prefix = NULL;
+
+ if (!*args[cur_arg + 1]) {
+ memprintf(err, "'%s' : expects an argument", args[cur_arg]);
+ return ERR_ALERT | ERR_FATAL;
+ }
+
+ prefix = strdup(args[cur_arg + 1]);
+ if (!prefix) {
+ memprintf(err, "'%s' : out of memory", args[cur_arg]);
+ return ERR_ALERT | ERR_FATAL;
+ }
+
+ conf->guid_prefix = prefix;
+ return 0;
+}
+
/* parse the "id" bind keyword */
static int bind_parse_id(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
{
{ "accept-netscaler-cip", bind_parse_accept_netscaler_cip, 1, 0 }, /* enable NetScaler Client IP insertion protocol */
{ "accept-proxy", bind_parse_accept_proxy, 0, 0 }, /* enable PROXY protocol */
{ "backlog", bind_parse_backlog, 1, 0 }, /* set backlog of listening socket */
+ { "guid-prefix", bind_parse_guid_prefix, 1, 1 }, /* set guid of listening socket */
{ "id", bind_parse_id, 1, 1 }, /* set id of listening socket */
{ "maxconn", bind_parse_maxconn, 1, 0 }, /* set maxconn of listening socket */
{ "name", bind_parse_name, 1, 1 }, /* set name of listening socket */