aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/udp_io.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libbb/udp_io.c b/libbb/udp_io.c
index a32af9bd2..6e3ef484e 100644
--- a/libbb/udp_io.c
+++ b/libbb/udp_io.c
@@ -70,7 +70,13 @@ send_to_from(int fd, void *buf, size_t len, int flags,
70 msg.msg_flags = flags; 70 msg.msg_flags = flags;
71 71
72 cmsgptr = CMSG_FIRSTHDR(&msg); 72 cmsgptr = CMSG_FIRSTHDR(&msg);
73 if (to->sa_family == AF_INET && from->sa_family == AF_INET) { 73 /*
74 * Users report that to->sa_family can be AF_INET6 too,
75 * if "to" was acquired by recv_from_to(). IOW: recv_from_to()
76 * was seen showing IPv6 "from" even when the destination
77 * of received packet (our local address) was IPv4.
78 */
79 if (/* to->sa_family == AF_INET && */ from->sa_family == AF_INET) {
74 struct in_pktinfo *pktptr; 80 struct in_pktinfo *pktptr;
75 cmsgptr->cmsg_level = IPPROTO_IP; 81 cmsgptr->cmsg_level = IPPROTO_IP;
76 cmsgptr->cmsg_type = IP_PKTINFO; 82 cmsgptr->cmsg_type = IP_PKTINFO;
@@ -86,7 +92,7 @@ send_to_from(int fd, void *buf, size_t len, int flags,
86 pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr; 92 pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr;
87 } 93 }
88# if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) 94# if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
89 else if (to->sa_family == AF_INET6 && from->sa_family == AF_INET6) { 95 else if (/* to->sa_family == AF_INET6 && */ from->sa_family == AF_INET6) {
90 struct in6_pktinfo *pktptr; 96 struct in6_pktinfo *pktptr;
91 cmsgptr->cmsg_level = IPPROTO_IPV6; 97 cmsgptr->cmsg_level = IPPROTO_IPV6;
92 cmsgptr->cmsg_type = IPV6_PKTINFO; 98 cmsgptr->cmsg_type = IPV6_PKTINFO;