]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: protocol: add a flags field to store info about protocols
authorWilly Tarreau <w@1wt.eu>
Sat, 22 Apr 2023 13:02:35 +0000 (15:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 23 Apr 2023 07:46:15 +0000 (09:46 +0200)
We'll use these flags to know if some protocols are supported, and if
so, with what options/extensions. Reuseport will move there for example.
Two functions were added to globally set/clear a flag.

include/haproxy/protocol-t.h
include/haproxy/protocol.h
src/protocol.c

index 0419191ada4449e9d20df8f4b742871d24ca6edf..aa8aa662c448f866367c7bbf86bf92582e0216f7 100644 (file)
@@ -127,7 +127,7 @@ struct protocol {
        /* default I/O handler */
        void (*default_iocb)(int fd);                   /* generic I/O handler (typically accept callback) */
 
-       /* 4-byte hole here on 64-bit machines */
+       uint flags;                                     /* flags describing protocol support (PROTO_F_*) */
        uint nb_receivers;                              /* number of receivers (under proto_lock) */
        struct list receivers;                          /* list of receivers using this protocol (under proto_lock) */
        struct list list;                               /* list of registered protocols (under proto_lock) */
index 05bba78d968018b1942f795ce8d5941aed8b1ee8..5c0871aec7b8e7ad58a2a1644c34f2e5c666cbc6 100644 (file)
@@ -38,6 +38,12 @@ void protocol_register(struct protocol *proto);
  */
 void protocol_unregister(struct protocol *proto);
 
+/* clears flag <flag> on all protocols. */
+void protocol_clrf_all(uint flag);
+
+/* sets flag <flag> on all protocols. */
+void protocol_setf_all(uint flag);
+
 /* binds all listeners of all registered protocols. Returns a composition
  * of ERR_NONE, ERR_RETRYABLE, ERR_FATAL, ERR_ABORT.
  */
index c627d5c73493fa3567aaba8e828d88eecfc3ad6e..7cc96743680345881da77b29e637d09515f0808b 100644 (file)
@@ -61,6 +61,28 @@ void protocol_unregister(struct protocol *proto)
        HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock);
 }
 
+/* clears flag <flag> on all protocols. */
+void protocol_clrf_all(uint flag)
+{
+       struct protocol *proto;
+
+       HA_SPIN_LOCK(PROTO_LOCK, &proto_lock);
+       list_for_each_entry(proto, &protocols, list)
+               proto->flags &= ~flag;
+       HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock);
+}
+
+/* sets flag <flag> on all protocols. */
+void protocol_setf_all(uint flag)
+{
+       struct protocol *proto;
+
+       HA_SPIN_LOCK(PROTO_LOCK, &proto_lock);
+       list_for_each_entry(proto, &protocols, list)
+               proto->flags |= flag;
+       HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock);
+}
+
 /* binds all listeners of all registered protocols. Returns a composition
  * of ERR_NONE, ERR_RETRYABLE, ERR_FATAL.
  */