]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server/event_hdl: add server_inetaddr struct to facilitate event data usage
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Dec 2023 15:18:39 +0000 (16:18 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 21 Dec 2023 13:22:26 +0000 (14:22 +0100)
event_hdl_cb_data_server_inetaddr struct had some anonymous structs
defined in it, making it impossible to pass as a function argument and
harder to maintain since changes must be performed at multiple places
at once. So instead we define a storage struct named server_inetaddr
that helps to save addr:port server information in INET context.

include/haproxy/server-t.h

index 1708bc62055484a004c5fc7dc30262141dce408c..7d1cc700b08b9a6f6d01ac29a4770b3b6871e1e0 100644 (file)
@@ -597,6 +597,18 @@ struct event_hdl_cb_data_server_check {
        } unsafe;
 };
 
+/* struct to store server address and port information in INET
+ * context
+ */
+struct server_inetaddr {
+       int family; /* AF_UNSPEC, AF_INET or AF_INET6 */
+       union {
+               struct in_addr v4;
+               struct in6_addr v6;
+       } addr; /* may hold v4 or v6 addr */
+       unsigned int svc_port;
+};
+
 /* data provided to EVENT_HDL_SUB_SERVER_INETADDR handlers through
  * event_hdl facility
  *
@@ -609,22 +621,8 @@ struct event_hdl_cb_data_server_inetaddr {
         */
        struct event_hdl_cb_data_server server;                 /* must be at the beginning */
        struct {
-               struct  {
-                       int family; /* AF_UNSPEC, AF_INET or AF_INET6 */
-                       union {
-                               struct in_addr v4;
-                               struct in6_addr v6;
-                       } addr; /* may hold v4 or v6 addr */
-                       unsigned int svc_port;
-               } prev;
-               struct {
-                       int family; /* AF_UNSPEC, AF_INET or AF_INET6 */
-                       union {
-                               struct in_addr v4;
-                               struct in6_addr v6;
-                       } addr; /* may hold v4 or v6 addr */
-                       unsigned int svc_port;
-               } next;
+               struct server_inetaddr prev;
+               struct server_inetaddr next;
                uint8_t purge_conn; /* set to 1 if the network change will force a connection cleanup */
        } safe;
        /* no unsafe data */