From: Christopher Faulet Date: Fri, 25 Jul 2025 13:40:29 +0000 (+0200) Subject: MINOR: applet: Add support for flags on applets with a flag about the new API X-Git-Tag: v3.3-dev4~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=337768656b8ef60c938c6f5d6e94a111aa9dff02;p=thirdparty%2Fhaproxy.git MINOR: applet: Add support for flags on applets with a flag about the new API A new field was added in the applet structure to be able to set flags on the applets The first one is related to the new API. APPLET_FL_NEW_API is set for applets based on the new API. It was set on all HAProxy's applets. --- diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index 42240a9d6..33e6f5a73 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -2144,6 +2144,7 @@ static void promex_appctx_handle_io(struct appctx *appctx) struct applet promex_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .init = promex_appctx_init, .release = promex_appctx_release, diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index 9c0eac9e3..adeb9da12 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -81,9 +81,12 @@ static forceinline char *appctx_show_flags(char *buf, size_t len, const char *de #undef _ } +#define APPLET_FL_NEW_API 0x00000001 /* Set if the applet is based on the new API (using applet's buffers) */ + /* Applet descriptor */ struct applet { enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */ + unsigned int flags; /* APPLET_FL_* flags */ /* 3 unused bytes here */ char *name; /* applet's name to report in logs */ int (*init)(struct appctx *); /* callback to init resources, may be NULL. diff --git a/src/cache.c b/src/cache.c index 04dfe7af1..c4f2a5cf4 100644 --- a/src/cache.c +++ b/src/cache.c @@ -3139,6 +3139,7 @@ INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions); struct applet http_cache_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = http_cache_io_handler, .rcv_buf = appctx_htx_rcv_buf, diff --git a/src/cli.c b/src/cli.c index 13e8a34ed..6ca73059d 100644 --- a/src/cli.c +++ b/src/cli.c @@ -3899,6 +3899,7 @@ error: static struct applet cli_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = cli_io_handler, .rcv_buf = appctx_raw_rcv_buf, @@ -3909,6 +3910,7 @@ static struct applet cli_applet = { /* master CLI */ static struct applet mcli_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = cli_io_handler, .rcv_buf = appctx_raw_rcv_buf, diff --git a/src/dns.c b/src/dns.c index 9c36b598e..bb4ffc6d8 100644 --- a/src/dns.c +++ b/src/dns.c @@ -952,6 +952,7 @@ static void dns_session_release(struct appctx *appctx) /* DNS tcp session applet */ static struct applet dns_session_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = dns_session_io_handler, .rcv_buf = appctx_raw_rcv_buf, diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 6810008f2..3a42076cf 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -538,6 +538,7 @@ static void spoe_handle_appctx(struct appctx *appctx) struct applet spoe_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = spoe_handle_appctx, .init = spoe_init_appctx, diff --git a/src/hlua.c b/src/hlua.c index 32cf20ff8..314c5e20d 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -3437,6 +3437,7 @@ static int hlua_socket_getsockname(struct lua_State *L) /* This struct define the applet. */ static struct applet update_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", .fct = hlua_socket_handler, .rcv_buf = appctx_raw_rcv_buf, @@ -11610,6 +11611,7 @@ static enum act_parse_ret action_register_service_http(const char **args, int *c /* Add applet pointer in the rule. */ rule->applet.obj_type = OBJ_TYPE_APPLET; + rule->applet.flags = APPLET_FL_NEW_API; rule->applet.name = fcn->name; rule->applet.init = hlua_applet_http_init; rule->applet.rcv_buf = appctx_htx_rcv_buf; @@ -11797,6 +11799,7 @@ static enum act_parse_ret action_register_service_tcp(const char **args, int *cu /* Add applet pointer in the rule. */ rule->applet.obj_type = OBJ_TYPE_APPLET; + rule->applet.flags = APPLET_FL_NEW_API; rule->applet.name = fcn->name; rule->applet.init = hlua_applet_tcp_init; rule->applet.rcv_buf = appctx_raw_rcv_buf; diff --git a/src/http_client.c b/src/http_client.c index 4a3524b5d..33490bae9 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -1019,6 +1019,7 @@ void httpclient_applet_release(struct appctx *appctx) /* HTTP client applet */ static struct applet httpclient_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", .fct = httpclient_applet_io_handler, .rcv_buf = appctx_htx_rcv_buf, diff --git a/src/log.c b/src/log.c index b5d85b9b3..3eca3c154 100644 --- a/src/log.c +++ b/src/log.c @@ -5967,6 +5967,7 @@ out: static struct applet syslog_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = syslog_io_handler, .rcv_buf = appctx_raw_rcv_buf, diff --git a/src/peers.c b/src/peers.c index 88e5cf50e..e116e2fdd 100644 --- a/src/peers.c +++ b/src/peers.c @@ -3228,6 +3228,7 @@ out: static struct applet peer_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = peer_io_handler, .rcv_buf = appctx_raw_rcv_buf, diff --git a/src/sink.c b/src/sink.c index ce948ff00..22e5a3636 100644 --- a/src/sink.c +++ b/src/sink.c @@ -600,6 +600,7 @@ static void sink_forward_session_release(struct appctx *appctx) static struct applet sink_forward_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = sink_forward_io_handler, .rcv_buf = appctx_raw_rcv_buf, @@ -610,6 +611,7 @@ static struct applet sink_forward_applet = { static struct applet sink_forward_oc_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = sink_forward_oc_io_handler, .rcv_buf = appctx_raw_rcv_buf, diff --git a/src/stats-html.c b/src/stats-html.c index 045af0857..cd93630f6 100644 --- a/src/stats-html.c +++ b/src/stats-html.c @@ -2103,6 +2103,7 @@ static void http_stats_release(struct appctx *appctx) struct applet http_stats_applet = { .obj_type = OBJ_TYPE_APPLET, + .flags = APPLET_FL_NEW_API, .name = "", /* used for logging */ .fct = http_stats_io_handler, .rcv_buf = appctx_htx_rcv_buf,