Jarrod Johnson
2012-Jun-11 17:58 UTC
[syslinux] tftp-hpa bug on aliased interface and recent kernels.
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
H. Peter Anvin
2012-Jun-11 22:36 UTC
[syslinux] tftp-hpa bug on aliased interface and recent kernels.
On 06/11/2012 10:58 AM, Jarrod Johnson wrote:> 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:Why AF_UNSPEC for IPv6? Typically one would just use AF_INET6 and handle the inbound connections using the ::/96 compatibility addreses, or did someone break that? -hpa