]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: tools: make str2sa_range() only report AF_CUST_UDP on listeners
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 18:35:12 +0000 (20:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 20:08:08 +0000 (22:08 +0200)
For now only listeners can make use of AF_CUST_UDP and it requires hacks
in the DNS and logsrv code to remap it to AF_INET. Make str2sa_range()
smarter by detecting that it's called for a listener and only set these
protocol families for listeners. This way we can get rid of the hacks.

src/cfgparse.c
src/log.c
src/tools.c

index 392a2bd1aebbf1f1f313ca10e1a2c493887d42b7..fa546d3d3adca8640b95b444ed4aec55c0ae6f6b 100644 (file)
@@ -984,12 +984,6 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
-               /* handle nicely the case where "udp@" is forced */
-               if (sk->ss_family == AF_CUST_UDP4)
-                       sk->ss_family = AF_INET;
-               else if (sk->ss_family == AF_CUST_UDP6)
-                       sk->ss_family = AF_INET6;
-
                proto = protocol_by_family(sk->ss_family);
                if (!proto) {
                        ha_alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n",
index a0898aadce0fe0eb383695503714cdf79c3d6f74..8e4606af3c26ff99423d99099e8f9e9c0f95d9e4 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1028,12 +1028,6 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
                logsrv->type = LOG_TARGET_FD;
        logsrv->addr = *sk;
 
-       /* handle nicely the case where "udp@" is forced */
-       if (sk->ss_family == AF_CUST_UDP4)
-               sk->ss_family = AF_INET;
-       else if (sk->ss_family == AF_CUST_UDP6)
-               sk->ss_family = AF_INET6;
-
        if (sk->ss_family == AF_INET || sk->ss_family == AF_INET6) {
                logsrv->addr = *sk;
                if (!port1)
index 0c4366408b7e0d8c4aef64ce494179eb7bc72f7e..473de79df9b71ad36fd38bea11233c6384694784 100644 (file)
@@ -1151,13 +1151,17 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
                        }
                }
                set_host_port(&ss, porta);
-               if (is_udp) {
+               if (is_udp && opts & PA_O_SOCKET_FD) {
+                       /* FIXME: for now UDP is still its own family. However some UDP clients
+                        * (logs, dns) use AF_INET and are not aware of AF_CUST_UDP*. Since we
+                        * only want this mapping for listeners and they are the only ones
+                        * setting PA_O_SOCKET_FD, for now we condition this mapping to this.
+                        */
                        if (ss.ss_family == AF_INET6)
                                ss.ss_family = AF_CUST_UDP6;
                        else
                                ss.ss_family = AF_CUST_UDP4;
                }
-
        }
 
        if (ctrl_type == SOCK_STREAM && !(opts & PA_O_STREAM)) {