]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: protocol: support a generic way to call getsockopt() on a connection
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Dec 2025 15:54:15 +0000 (16:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Dec 2025 17:38:51 +0000 (18:38 +0100)
commit6d995e59e9ff96b141107ed3241023018697c3f0
treebca803b42075a6dce2b5a50e82d3bdbea874aca1
parent44c67a08dd769291d8107f4522cf95b7dd314c22
MINOR: protocol: support a generic way to call getsockopt() on a connection

It's regularly needed to call getsockopt() on a connection, but each
time the calling code has to do all the job by itself. This commit adds
a "get_opt()" callback on the protocol struct, that directly calls
getsockopt() on the connection's FD. A generic implementation for
standard sockets is provided, though QUIC would likely require a
different approach, or maybe a mapping. Due to the overlap between
IP/TCP/socket option values, it is necessary for the caller to indicate
both the level and the option. An abstraction of the level could be
done, but the caller would nonetheless have to know the optname, which
is generally defined in the same include files. So for now we'll
consider that this callback is only for very specific use.

The levels and optnames are purposely passed as signed ints so that it
is possible to further extend the API by using negative levels for
internal namespaces.
include/haproxy/protocol-t.h
include/haproxy/sock.h
src/sock.c