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.
diff --git a/src/tools.c b/src/tools.c
index 473de79..0f0bbae 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -875,7 +875,6 @@
char *port1, *port2;
int portl, porth, porta;
int abstract = 0;
- int is_udp = 0;
int new_fd = -1;
int sock_type, ctrl_type;
@@ -933,19 +932,16 @@
str2 += 5;
ss.ss_family = AF_INET;
sock_type = ctrl_type = SOCK_DGRAM;
- is_udp = 1;
}
else if (strncmp(str2, "udp6@", 5) == 0) {
str2 += 5;
ss.ss_family = AF_INET6;
sock_type = ctrl_type = SOCK_DGRAM;
- is_udp = 1;
}
else if (strncmp(str2, "udp@", 4) == 0) {
str2 += 4;
ss.ss_family = AF_UNSPEC;
sock_type = ctrl_type = SOCK_DGRAM;
- is_udp = 1;
}
else if (strncmp(str2, "fd@", 3) == 0) {
str2 += 3;
@@ -1151,17 +1147,6 @@
}
}
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)) {
@@ -1173,6 +1158,18 @@
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;
out:
if (port)