[syslinux] tftp-hpa bug on aliased interface and recent kernels.

Jarrod Johnson jarrod.b.johnson+tf at gmail.com
Mon Jun 11 10:58:59 PDT 2012


So as of recent kernels, this change helps:
http://git.kernel.org/?p=network/tftp/tftp-hpa.git;a=commitdiff;h=c6d2c36b1a2b1986cab7aebb72d120fa118bdfeb

But there is still a flaw.  Notably, if tftpd is running with AF_UNSPEC (as
it will if ipv6 support is desired), myrecvfrom will fail to setsockopt to
get the data back on the first pass.

I'd guess the least disruptive change to get to be correct would be:
diff --git a/tftpd/recvfrom.c b/tftpd/recvfrom.c
index d050b80..fe233da 100644
--- a/tftpd/recvfrom.c
+++ b/tftpd/recvfrom.c
@@ -149,16 +149,16 @@ myrecvfrom(int s, void *buf, int len, unsigned int
flags,

     /* Try to enable getting the return address */
 #ifdef IP_RECVDSTADDR
-    if (from->sa_family == AF_INET)
+    if (from->sa_family == AF_INET || from->sa_family == AF_UNSPEC)
         setsockopt(s, IPPROTO_IP, IP_RECVDSTADDR, &on, sizeof(on));
 #endif
 #ifdef IP_PKTINFO
-    if (from->sa_family == AF_INET)
+    if (from->sa_family == AF_INET || from->sa_family == AF_UNSPEC)
         setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
 #endif
 #ifdef HAVE_IPV6
 #ifdef IPV6_RECVPKTINFO
-    if (from->sa_family == AF_INET6)
+    if (from->sa_family == AF_INET6 || from->sa_family == AF_UNSPEC)
         setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on));
 #endif
 #endif



More information about the Syslinux mailing list