]> git.kaiwu.me - haproxy.git/commit
MEDIUM: spoe: add the "on-switching-rules" event
authorBenedict Weis <benedict.weis01@sap.com>
Fri, 9 Oct 2026 09:18:54 +0000 (09:18 +0000)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 9 Oct 2026 11:47:12 +0000 (13:47 +0200)
commitc2913a001d60fbd9c58dc27aad9373c0e146001e
treed5edfe2bda51dd6f2b349be65a64b504b8901e68
parentb465a6b1e7cdb6dc5f3d858fcddf0f0e994558c0
MEDIUM: spoe: add the "on-switching-rules" event

Add a new SPOE event, "on-switching-rules", triggered on the frontend side
after the evaluation of "tcp-request content" rules but before the
"use_backend" switching rules. This lets a SPOA agent inspect the request
and influence backend selection (e.g. set a variable that a "use_backend"
rule then reads). The main use case is SNI-based routing in TCP mode.

The event is hooked on the AN_REQ_SWITCHING_RULES analyzer via the filter
pre-analyze callback, so it runs after tcp_inspect_request() (which
evaluates "tcp-request content" rules and honors "tcp-request
inspect-delay") and before process_switching_rules(). Its sample-fetch
validity checkpoint is SMP_VAL_FE_SET_BCK, matching the point at which
use_backend rules are evaluated. Like the other frontend events it is only
accepted for SPOE filters declared in a frontend or listen section.

Note that, in TCP mode, request data (such as req.ssl_sni) is only
guaranteed to be available at this event if a "tcp-request content" rule
combined with a "tcp-request inspect-delay" actually waits for it; with no
such rule the analyzers run at connection time and the event fires with no
request data buffered yet.

The event is documented in doc/SPOE.txt, both in the "event" directive list
and in the "Events & Messages" section. A functional reg-test
(reg-tests/spoe/switching_rules.vtc) drives it end to end with a minimal,
stdlib-only SPOA mock (spoa_mock.py), avoiding external dependencies: the
agent populates sess.spoe.backend_name from a NOTIFY and a "use_backend"
rule routes traffic accordingly.

This resolves GitHub issue #3220.

This is a new feature, no backport needed.

Co-authored-by: Alexander Stephan <alexander.stephan@sap.com>
doc/SPOE.txt
reg-tests/spoe/spoa_mock.py [new file with mode: 0644]
reg-tests/spoe/switching_rules.vtc [new file with mode: 0644]
src/flt_spoe.c