MEDIUM: tools: make str2sa_range() only report AF_CUST_UDP on listeners

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.
This commit is contained in:
Willy Tarreau 2020-09-16 20:35:12 +02:00
parent e835bd8f91
commit 3baec249b1
3 changed files with 6 additions and 14 deletions

View 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",

View File

@ -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)

View 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)) {