mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-17 12:35:37 +00:00
MINOR: tools: remove the central test for "udp" in str2sa_range()
Now we only rely on dgram type associated with AF_INET/AF_INET6 to infer UDP4/UDP6. We still keep the hint based on PA_O_SOCKET_FD to detect that the caller is a listener though. It's still far from optimal but UDP remains rooted into the protocols and needs to be taken out first.
This commit is contained in:
parent
3baec249b1
commit
62a976cd44
27
src/tools.c
27
src/tools.c
@ -875,7 +875,6 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||||||
char *port1, *port2;
|
char *port1, *port2;
|
||||||
int portl, porth, porta;
|
int portl, porth, porta;
|
||||||
int abstract = 0;
|
int abstract = 0;
|
||||||
int is_udp = 0;
|
|
||||||
int new_fd = -1;
|
int new_fd = -1;
|
||||||
int sock_type, ctrl_type;
|
int sock_type, ctrl_type;
|
||||||
|
|
||||||
@ -933,19 +932,16 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||||||
str2 += 5;
|
str2 += 5;
|
||||||
ss.ss_family = AF_INET;
|
ss.ss_family = AF_INET;
|
||||||
sock_type = ctrl_type = SOCK_DGRAM;
|
sock_type = ctrl_type = SOCK_DGRAM;
|
||||||
is_udp = 1;
|
|
||||||
}
|
}
|
||||||
else if (strncmp(str2, "udp6@", 5) == 0) {
|
else if (strncmp(str2, "udp6@", 5) == 0) {
|
||||||
str2 += 5;
|
str2 += 5;
|
||||||
ss.ss_family = AF_INET6;
|
ss.ss_family = AF_INET6;
|
||||||
sock_type = ctrl_type = SOCK_DGRAM;
|
sock_type = ctrl_type = SOCK_DGRAM;
|
||||||
is_udp = 1;
|
|
||||||
}
|
}
|
||||||
else if (strncmp(str2, "udp@", 4) == 0) {
|
else if (strncmp(str2, "udp@", 4) == 0) {
|
||||||
str2 += 4;
|
str2 += 4;
|
||||||
ss.ss_family = AF_UNSPEC;
|
ss.ss_family = AF_UNSPEC;
|
||||||
sock_type = ctrl_type = SOCK_DGRAM;
|
sock_type = ctrl_type = SOCK_DGRAM;
|
||||||
is_udp = 1;
|
|
||||||
}
|
}
|
||||||
else if (strncmp(str2, "fd@", 3) == 0) {
|
else if (strncmp(str2, "fd@", 3) == 0) {
|
||||||
str2 += 3;
|
str2 += 3;
|
||||||
@ -1151,17 +1147,6 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_host_port(&ss, porta);
|
set_host_port(&ss, porta);
|
||||||
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)) {
|
if (ctrl_type == SOCK_STREAM && !(opts & PA_O_STREAM)) {
|
||||||
@ -1173,6 +1158,18 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts & PA_O_SOCKET_FD && sock_type == SOCK_DGRAM && ctrl_type == SOCK_DGRAM) {
|
||||||
|
/* 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 if (ss.ss_family == AF_INET)
|
||||||
|
ss.ss_family = AF_CUST_UDP4;
|
||||||
|
}
|
||||||
|
|
||||||
ret = &ss;
|
ret = &ss;
|
||||||
out:
|
out:
|
||||||
if (port)
|
if (port)
|
||||||
|
Loading…
Reference in New Issue
Block a user