]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: tools: rely on address family to detect ABNS sockets
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 24 Oct 2024 14:29:14 +0000 (16:29 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 29 Oct 2024 11:14:44 +0000 (12:14 +0100)
Following previous commit, in str2sa_range(), make use of address' family
which was just set to check if the socket is ABNS or not instead of
relying on an extra boolean to save this info.

src/tools.c

index a51a4ffdc5a67d6dfc8c5bbad668dbb3b82699b5..ec36a9d94203605f03b50d45bdcccbf9fe6b8016 100644 (file)
@@ -982,7 +982,6 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
        char *back, *str2;
        char *port1, *port2;
        int portl, porth, porta;
-       int abstract = 0;
        int new_fd = -1;
        enum proto_type proto_type = 0; // to shut gcc warning
        int ctrl_type = 0; // to shut gcc warning
@@ -1035,12 +1034,10 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
 
        if (strncmp(str2, "unix@", 5) == 0) {
                str2 += 5;
-               abstract = 0;
                ss.ss_family = AF_UNIX;
        }
        else if (strncmp(str2, "uxdg@", 5) == 0) {
                str2 += 5;
-               abstract = 0;
                ss.ss_family = AF_UNIX;
                proto_type = PROTO_TYPE_DGRAM;
                ctrl_type = SOCK_DGRAM;
@@ -1048,14 +1045,12 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
        }
        else if (strncmp(str2, "uxst@", 5) == 0) {
                str2 += 5;
-               abstract = 0;
                ss.ss_family = AF_UNIX;
                proto_type = PROTO_TYPE_STREAM;
                ctrl_type = SOCK_STREAM;
        }
        else if (strncmp(str2, "abns@", 5) == 0) {
                str2 += 5;
-               abstract = 1;
                ss.ss_family = AF_CUST_ABNS;
        }
        else if (strncmp(str2, "ip@", 3) == 0) {
@@ -1228,6 +1223,10 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
                int prefix_path_len;
                int max_path_len;
                int adr_len;
+               int abstract = 0;
+
+               if (ss.ss_family == AF_CUST_ABNS)
+                       abstract = 1;
 
                /* complete unix socket path name during startup or soft-restart is
                 * <unix_bind_prefix><path>.<pid>.<bak|tmp>