[Dnsmasq-discuss] Small dnsmasq 2.22 issue

Ron Frederick frederick@timeheart.net
Sat, 18 Jun 2005 09:08:27 -0700


I recently started the "dnsmasq" program as part of the OpenWRT distribution
on my Linksys WRT54GS wireless router. It replaced an ISC 'dhcpd' I was
running on a desktop Linux machine. However, I ran into one problem when I
switched over. I noticed that the DHCP OFFER responses were no longer
including the DHCP 'host-name' option. This option was included in DHCP ACK
responses to the same host later on, but it was missing from the initial
OFFER response. I have a Rio Digital Audio Receiver here which depends on
seeing the hostname in the OFFER response to boot properly. So, I took a
look at the source code to see if I could find the problem.

It turned out to be quite straightforward to fix it. All I had to do was
to change the call to do_req_options() in the OFFER case to pass 'hostname'
as an argument instead of NULL, just as is done later when sending the ACK.
I'm not sure if there was a specific reason why the hostname was omitted
from the OFFER response, but the ISC dhcpd does include it and as I
mentioned above my Rio seemed to require it.

Here's the patch I put together against version 2.22:

--- dnsmasq-2.22/src/rfc2131.c.orig     2005-03-26 01:24:37.000000000 -0800
+++ dnsmasq-2.22/src/rfc2131.c  2005-06-14 18:29:36.515458822 -0700
@@ -444,7 +444,7 @@
          p = option_put(p, end, OPTION_T2, 4, (time*7)/8);
        }
       p = do_req_options(context, p, end, req_options, daemon, 
-                        NULL, netid, subnet_addr);
+                        hostname, netid, subnet_addr);
       p = option_end(p, end, mess);
       
       log_packet("OFFER" , &mess->yiaddr, mess->chaddr, iface_name, NULL);

If this looks like a reasonable change, feel free to include it in the next
release. For now, it's working well for me.
--
Ron Frederick
frederick@timeheart.net