Hello,

I have found that tftp functionality no longer works since 2.56 (client hangs), at least on FreeBSD (checked on 9-CURRENT amd64).

A patch is included bellow, it shouldn't harm other OSes. (tested on Linux)

Here is the regression, between 2.55 and 2.56 versions, still present in 2.57:

Server output:
[root@tic ~/dnsmasq-2.55]# ./src/dnsmasq -d --enable-tftp
dnsmasq: started, version 2.55 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt no-DBus no-I18N DHCP TFTP
dnsmasq-tftp: TFTP enabled
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 212.27.40.240#53
dnsmasq: read /etc/hosts - 4 addresses
dnsmasq-tftp: file /a not found

Client output:
tftp> get a
Got ERROR packet: file /a not found
Error code 256: file /a not found
tftp>

Server output:
[root@tic ~/dnsmasq-2.56]# ./src/dnsmasq -d --enable-tftp
dnsmasq: started, version 2.56 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt no-DBus no-I18N DHCP TFTP
dnsmasq-tftp: TFTP enabled
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 212.27.40.240#53
dnsmasq: read /etc/hosts - 4 addresses

Client output:
tftp> get a
Try 1, didn't receive answer from remote.
Try 2, didn't receive answer from remote.
Try 3, didn't receive answer from remote.
(...) and so on, until timeout

Fix: http://loicp.eu/patchs/dnsmasq/tftp.c.diff

--- tftp.c.orig 2011-07-19 00:16:39.000000000 +0200
+++ tftp.c      2011-07-19 00:16:49.000000000 +0200
@@ -260,7 +260,7 @@
   /* if we have a nailed-down range, iterate until we find a free one. */
   while (1)
     {
-      if (bind(transfer->sockfd, &addr.sa, sizeof(addr)) == -1 ||
+      if (bind(transfer->sockfd, &addr.sa, sizeof(addr.sa)) == -1 ||
 #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
setsockopt(transfer->sockfd, SOL_IP, IP_MTU_DISCOVER, &mtuflag, sizeof(mtuflag)) == -1 ||
 #endif


bind() returned -1, it seems not correctly catched, but I'm not sure how to fix that.

Please keep up the good work, Dnsmasq is excellent :)

Best regards,
Loïc Pefferkorn

Reply via email to