<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<br>Sure. I'll send the man page updates.<br><br>Regarding the overloading of the server name parameter:<br>&nbsp;&nbsp;&nbsp; are you saying that we should have a version of the dhcp-boot option like:<br><br>dhcp-boot=/var/ftpd/pxelinux.0,boothost,boothost<br><br>and take the second 'boothost' (3rd parameter)&nbsp; to indicate that<br>it be resolved and a resultant address returned as a tftp<br>server address ?<br><br>cheers<br>Sushil.<br><br><br>&gt; Subject: Re: [Dnsmasq-discuss] Enable dnsmasq to return addresses of multiple        tftp servers in cycle<br><div>&gt; From: simon@thekelleys.org.uk<br>&gt; Date: Sat, 18 Jun 2011 22:44:25 +0100<br>&gt; To: sushil_agrawal@hotmail.com; dnsmasq-discuss@lists.thekelleys.org.uk<br>&gt; <br>&gt; Sushil Agrawal &lt;sushil_agrawal@hotmail.com&gt; wrote:<br>&gt; <br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;Hi All,<br>&gt; &gt;<br>&gt; &gt;The attached patch enables dnsmasq(8) to return the ip addresses<br>&gt; &gt;of multiple tftp servers (for pxe boot) having a single alias<br>&gt; &gt;name (thru the /etc/hosts) in round robin fashion.<br>&gt; &gt;<br>&gt; &gt;We have a virtual environment where there are some managed hosts<br>&gt; &gt;running kvm hypervisor and some &gt; 150  virtual machines<br>&gt; &gt;carved out of these hosts. All these virtual machines are thin<br>&gt; &gt;clients which boot of the net using pxe. The arrangement is such<br>&gt; &gt;that all of these machines boot at the same time and in order to<br>&gt; &gt;balance the load on the tftp server, we planned to have multiple<br>&gt; &gt;tftp servers (on these managed hosts themselves) running.<br>&gt; &gt;<br>&gt; &gt;dnsmasq currently returns only one address for tftp server<br>&gt; &gt;which it finds in the dhcp-boot option in the dnsmasq.conf<br>&gt; &gt;file. Although there is a provision for specifying the<br>&gt; &gt;tftp server name there but it is not used. We made<br>&gt; &gt;use of this name as an alias for multiple tftp servers<br>&gt; &gt;(using /etc/hosts) and then return the resolved addresses<br>&gt; &gt;one by one in cycle.<br>&gt; &gt;<br>&gt; &gt;The function cache_find_by_name() already takes care<br>&gt; &gt;of all this and all we had to do was to just call<br>&gt; &gt;it in dhcp_reply() to get one address and return<br>&gt; &gt;that as tftp address.<br>&gt; &gt;<br>&gt; &gt;If the tftp server address is specified in the dhcp-boot<br>&gt; &gt;option then that address is returned always. If address<br>&gt; &gt;is not specified and name is specified then this cyclic<br>&gt; &gt;stuff is done. This solution is working for us and hope it<br>&gt; &gt;will be useful to others.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;Following is the patch (also attached) based on<br>&gt; &gt;dnsmasq-2.57:<br>&gt; &gt;<br>&gt; &gt;................................................................<br>&gt; &gt;<br>&gt; &gt;--- dnsmasq-2.57.origg/src/rfc2131.c    2011-02-17 21:00:15.000000000<br>&gt; &gt;+0530<br>&gt; &gt;+++ dnsmasq-2.57/src/rfc2131.c    2011-06-18 17:48:59.000000000 +0530<br>&gt; &gt;@@ -829,8 +829,23 @@<br>&gt; &gt;              and set discovery_control = 8 */<br>&gt; &gt;           if (boot)<br>&gt; &gt;             {<br>&gt; &gt;-              if (boot-&gt;next_server.s_addr)<br>&gt; &gt;+              if (boot-&gt;next_server.s_addr) {<br>&gt; &gt;             mess-&gt;siaddr = boot-&gt;next_server;<br>&gt; &gt;+              } else if (boot-&gt;sname) {<br>&gt; &gt;+<br>&gt; &gt;+                /*<br>&gt; &gt;+                 * If the pxe server name is given in the conf then<br>&gt; &gt;+                 * cycle thru its addresses.<br>&gt; &gt;+                 */<br>&gt; &gt;+<br>&gt; &gt;+                struct crec *crecp;<br>&gt; &gt;+                time_t now = dnsmasq_time();<br>&gt; &gt;+                crecp = cache_find_by_name(NULL, boot-&gt;sname, now,<br>&gt; &gt;+                               F_DHCP | F_HOSTS);<br>&gt; &gt;+                if (crecp) {<br>&gt; &gt;+                    mess-&gt;siaddr = *(struct in_addr*)&amp;crecp-&gt;addr;<br>&gt; &gt;+                }<br>&gt; &gt;+              }<br>&gt; &gt;               <br>&gt; &gt;               if (boot-&gt;file)<br>&gt; &gt;         strncpy((char *)mess-&gt;file, boot-&gt;file, sizeof(mess-&gt;file)-1);<br>&gt; &gt;@@ -2222,8 +2237,23 @@<br>&gt; &gt;         strncpy((char *)mess-&gt;file, boot-&gt;file, sizeof(mess-&gt;file)-1);<br>&gt; &gt;     }<br>&gt; &gt;       <br>&gt; &gt;-      if (boot-&gt;next_server.s_addr)<br>&gt; &gt;+      if (boot-&gt;next_server.s_addr) {<br>&gt; &gt;     mess-&gt;siaddr = boot-&gt;next_server;<br>&gt; &gt;+      } else if (boot-&gt;sname) {<br>&gt; &gt;+<br>&gt; &gt;+        /*<br>&gt; &gt;+         * If the pxe server name is given in the conf then<br>&gt; &gt;+         * cycle thru its addresses.<br>&gt; &gt;+         */<br>&gt; &gt;+<br>&gt; &gt;+        struct crec *crecp;<br>&gt; &gt;+          time_t now = dnsmasq_time();<br>&gt; &gt;+        crecp = cache_find_by_name(NULL, boot-&gt;sname, now,<br>&gt; &gt;+                       F_DHCP | F_HOSTS);<br>&gt; &gt;+        if (crecp) {<br>&gt; &gt;+            mess-&gt;siaddr = *(struct in_addr*)&amp;crecp-&gt;addr;<br>&gt; &gt;+        }<br>&gt; &gt;+      }<br>&gt; &gt;     }<br>&gt; &gt;   else<br>&gt; &gt;    /* Use the values of the relevant options if no dhcp-boot given and<br>&gt; &gt;................................................................<br>&gt; &gt;<br>&gt; &gt;Sushil.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;                                               _______________________________________________<br>&gt; &gt;Dnsmasq-discuss mailing list<br>&gt; &gt;Dnsmasq-discuss@lists.thekelleys.org.uk<br>&gt; &gt;http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss<br>&gt; <br>&gt; This looks like a great idea, but overloading the server name parameter is not correct. That can be used for other things. The correct way to do this is to check if a name is supplied instead of an address in dhcp-boot and act accordingly. That will need some code in options.c and elaboration of the dhcp boot data structure. <br>&gt; <br>&gt; A general observation for patch submitters. I'm much more likely to look kindly on a patch if it includes documentation, ie a patch to the man page.<br>&gt; <br>&gt; I'm away from home at the moment, so further action on this may have to wait until next week.<br>&gt; <br>&gt; Cheers, <br>&gt; <br>&gt; Simon.<br></div>                                               </div></body>
</html>