BUG/MINOR: dev/udp: properly preset the rx address size

addrlen was not preset to sizeof(addr) on rx, resulting in the address
often not being filled and response packets not always flowing back.

Let's also consistently use "addr" in the bind call (it points to
frt_addr there but it's a bit confusing).

(cherry picked from commit 3ff9610356)
Signed-off-by: Willy Tarreau <w@1wt.eu>
This commit is contained in:
Willy Tarreau 2022-08-31 08:55:12 +02:00
parent e3a7a98032
commit ca596b3f52

View File

@ -193,7 +193,7 @@ int create_udp_listener(struct sockaddr_storage *addr, struct errmsg *err)
goto fail;
}
#endif
if (bind(fd, (struct sockaddr *)&frt_addr, addr->ss_family == AF_INET6 ?
if (bind(fd, (struct sockaddr *)addr, addr->ss_family == AF_INET6 ?
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)) == -1) {
err->len = snprintf(err->msg, err->size, "bind(): '%s'", strerror(errno));
goto fail;
@ -297,6 +297,7 @@ int handle_frt(int fd, struct pollfd *pfd, struct conn *conns, int nbconn)
pktbuf = history[history_idx].buf;
}
addrlen = sizeof(addr);
ret = recvfrom(fd, pktbuf, MAXPKTSIZE, MSG_DONTWAIT | MSG_NOSIGNAL,
(struct sockaddr *)&addr, &addrlen);