[sorry if you have received multiple copies of this email; facing 
problems in posting<br>to the list; big size etc ... ]<br><br><br>Attached
 is the modified patch after the feedback. It is also<br>pasted at the 
end of this email.<br>
<br>Following is the summary of the changes:<br><br>1. 
dnsmasq-2.57/dnsmasq.conf.<div id=":14c">example:<br>2. dnsmasq-2.57/man/dnsmasq.8<br>   
 added example and description for following version of dhcp-boot<br><br>   
 #dhcp-boot=/var/ftpd/pxelinux.0,boothost,tftp_server_name<br>
<br>3.<br>dnsmasq-2.57/src/dnsmasq.h<br>    added a new field 
&#39;tftp_sname&#39; in struct dhcp_boot<br>    for the tftp server name.<br><br>4.<br>dnsmasq-2.57/src/option.c<br>   
 added code to process the tftp_servername option.<br>
<br>5.<br>dnsmasq-2.57/src/rfc2131.c<br>    added code to call 
cache_find_by_name() to get an IP address<br>    of the tftp server 
given its name. cache_find_by_name()<br>    automatically returns these 
addresses in cycle.<br>
<br><br>tested with:<br><br>    dhcp-boot=pxelinux.0,test2,test2<br>in
 the dnsmasq.conf file<br><br>    --dhcp-boot=pxelinux.0,test2,test2<br>on
 the command line<br><br>    --dhcp-boot=pxelinux.0,,test2<br>on the 
command line.<br>
<br>In these examples test2 was considered as tftp server name and<br>so
 it was looked up in the cache and one ip address was returned.<br><br><br>Following
 are the diffs:<br><br>..........................................................................<br>
<br>diff -ru dnsmasq-2.57.origg/dnsmasq.conf.example 
dnsmasq-2.57/dnsmasq.conf.example<br>--- 
dnsmasq-2.57.origg/dnsmasq.conf.example    2011-02-17 
21:00:15.000000000 +0530<br>+++ dnsmasq-2.57/dnsmasq.conf.example   
 2011-06-21 18:45:45.000000000 +0530<br>
@@ -422,6 +422,14 @@<br> # Can fail with old PXE ROMS. Overridden by 
--pxe-service.<br> #dhcp-boot=/var/ftpd/pxelinux.0,boothost,192.168.0.3<br> <br>+#If
 there are multiple external tftp servers having a same name<br>+#(using
 /etc/hosts) then that name can be specified as the<br>
+#tftp_servername (the third option to dhcp-boot) and in that<br>+#case 
dnsmasq resolves this name and returns the resultant IP<br>+#addresses 
in round robin fasion. This facility can be used to<br>+#load balance 
the tftp load among a set of servers.<br>
+#dhcp-boot=/var/ftpd/pxelinux.0,boothost,tftp_server_name<br>+<br> #
 Set the limit on DHCP leases, the default is 150<br> #dhcp-lease-max=150<br> <br> #################################################################<br>
 <br>diff -ru dnsmasq-2.57.origg/man/dnsmasq.8 
dnsmasq-2.57/man/dnsmasq.8<br>--- dnsmasq-2.57.origg/man/dnsmasq.8   
 2011-02-17 21:00:15.000000000 +0530<br>+++ 
dnsmasq-2.57/man/dnsmasq.8    2011-06-21 18:47:03.000000000 +0530<br>
@@ -845,7 +845,7 @@<br> need broadcast replies set a flag in their 
requests so that this<br> happens automatically, some old BOOTP clients 
do not.<br> .TP<br>-.B \-M, --dhcp-boot=[tag:&lt;tag&gt;,]&lt;filename&gt;,[&lt;servername&gt;[,&lt;server
 address&gt;]]<br>
+.B \-M, --dhcp-boot=[tag:&lt;tag&gt;,]&lt;filename&gt;,[&lt;servername&gt;[,&lt;server
 address&gt;|&lt;tftp_servername&gt;]]<br> Set BOOTP options to be 
returned by the DHCP server. Server name and<br> address are optional: 
if not provided, the name is left empty, and the<br>
 address set to the address of the machine running dnsmasq. If dnsmasq<br>@@
 -854,6 +854,13 @@<br> ) then only the filename is required here to 
enable network booting.<br> If the optional tag(s) are given,<br> they 
must match for this configuration to be sent. <br>
+If there are multiple external tftp servers having a same name<br>+(using
 /etc/hosts) then that name can be specified as the<br>+tftp_servername 
(the third option to dhcp-boot) and in that<br>+case dnsmasq resolves 
this name and returns the resultant IP<br>
+addresses in round robin fasion. This facility can be used to<br>+load 
balance the tftp load among a set of servers.<br>+#dhcp-boot=/var/ftpd/pxelinux.0,boothost,tftp_server_name<br> .TP<br> .B
 --pxe-service=[tag:&lt;tag&gt;,]&lt;CSA&gt;,&lt;menu 
text&gt;[,&lt;basename&gt;|&lt;bootservicetype&gt;][,&lt;server 
address&gt;]<br>
 Most uses of PXE boot-ROMS simply allow the PXE<br>diff -ru 
dnsmasq-2.57.origg/src/dnsmasq.h dnsmasq-2.57/src/dnsmasq.h<br>--- 
dnsmasq-2.57.origg/src/dnsmasq.h    2011-02-17 21:00:15.000000000 
+0530<br>+++ dnsmasq-2.57/src/dnsmasq.h    2011-06-21 13:59:07.000000000
 +0530<br>
@@ -519,7 +519,7 @@<br> #define DHOPT_RFC3925         2048<br> <br> struct
 dhcp_boot {<br>-  char *file, *sname;<br>+  char *file, *sname, 
*tftp_sname;<br>   struct in_addr next_server;<br>   struct dhcp_netid 
*netid;<br>
   struct dhcp_boot *next;<br>diff -ru dnsmasq-2.57.origg/src/option.c
 dnsmasq-2.57/src/option.c<br>--- dnsmasq-2.57.origg/src/option.c   
 2011-02-18 17:03:48.000000000 +0530<br>+++ dnsmasq-2.57/src/option.c   
 2011-06-21 16:46:31.000000000 +0530<br>
@@ -2218,7 +2218,7 @@<br>       option = &#39;?&#39;;<br>     else <br>       {<br>-   
     char *dhcp_file, *dhcp_sname = NULL;<br>+        char *dhcp_file, 
*dhcp_sname = NULL, *tftp_sname = NULL;<br>         struct in_addr 
dhcp_next_server;<br>
         comma = split(arg);<br>         dhcp_file = 
opt_string_alloc(arg);<br>@@ -2231,8 +2231,17 @@<br>         if (comma)<br>    
       {<br>             unhide_metas(comma);<br>-            if 
((dhcp_next_server.s_addr = inet_addr(comma)) == (in_addr_t)-1)<br>
-              option = &#39;?&#39;;<br>+            if 
((dhcp_next_server.s_addr = inet_addr(comma)) == (in_addr_t)-1) {<br>+<br>+   
           /*<br>+               * The user may have specified the tftp 
hostname here.<br>
+               * save it so that it can be resolved/looked up during<br>+   
            * actual dhcp_reply().<br>+               */    <br>+<br>+   
           tftp_sname = opt_string_alloc(comma);<br>+              
dhcp_next_server.s_addr = 0;<br>
+            }<br>           }<br>           }<br>         if (option !=
 &#39;?&#39;)<br>@@ -2240,6 +2249,7 @@<br>         struct dhcp_boot *new = 
opt_malloc(sizeof(struct dhcp_boot));<br>         new-&gt;file = 
dhcp_file;<br>
         new-&gt;sname = dhcp_sname;<br>+        new-&gt;tftp_sname = 
tftp_sname;<br>         new-&gt;next_server = dhcp_next_server;<br>     
    new-&gt;netid = id;<br>         new-&gt;next = 
daemon-&gt;boot_config;<br>diff -ru dnsmasq-2.57.origg/src/rfc2131.c
 dnsmasq-2.57/src/rfc2131.c<br>
--- dnsmasq-2.57.origg/src/rfc2131.c    2011-02-17 
21:00:15.000000000 +0530<br>+++ dnsmasq-2.57/src/rfc2131.c    2011-06-21
 16:25:52.000000000 +0530<br>@@ -829,8 +829,23 @@<br>              and 
set discovery_control = 8 */<br>
           if (boot)<br>             {<br>-              if 
(boot-&gt;next_server.s_addr)<br>+              if 
(boot-&gt;next_server.s_addr) {<br>             mess-&gt;siaddr = 
boot-&gt;next_server;<br>+              } else if (boot-&gt;tftp_sname) {<br>
+<br>+            /*<br>+             * If the tftp server name is given
 in the conf<br>+             * then cycle thru its addresses.<br>+    
         */<br>+<br>+            struct crec *crecp;<br>+            
time_t now = dnsmasq_time();<br>
+            crecp = cache_find_by_name(NULL, boot-&gt;tftp_sname,<br>+   
                        now, F_DHCP | F_HOSTS);<br>+            if 
(crecp) {<br>+                mess-&gt;siaddr = *(struct 
in_addr*)&amp;crecp-&gt;addr;<br>
+            }<br>+              }<br>               <br>               
if (boot-&gt;file)<br>             strncpy((char *)mess-&gt;file, 
boot-&gt;file, sizeof(mess-&gt;file)-1);<br>@@ -2222,8 +2237,23 @@<br>    
     strncpy((char *)mess-&gt;file, boot-&gt;file, 
sizeof(mess-&gt;file)-1);<br>
     }<br>       <br>-      if (boot-&gt;next_server.s_addr)<br>+      
if (boot-&gt;next_server.s_addr) {<br>     mess-&gt;siaddr = 
boot-&gt;next_server;<br>+      } else if (boot-&gt;tftp_sname) {<br>+<br>+   
 /*<br>+     * If the tftp server name is specified<br>
+     * then cycle thru its addresses.<br>+     */<br>+<br>+    struct 
crec *crecp;<br>+    time_t now = dnsmasq_time();<br>+    crecp = 
cache_find_by_name(NULL, boot-&gt;tftp_sname,<br>+                   
now, F_DHCP | F_HOSTS);<br>
+    if (crecp) {<br>+        mess-&gt;siaddr = *(struct 
in_addr*)&amp;crecp-&gt;addr;<br>+    }<br>+      }<br>     }<br>   else<br>    
 /* Use the values of the relevant options if no dhcp-boot given and<br>..........................................................................<br>
<br><br>cheers<br>Sushil.<br><br></div><br><div class="gmail_quote">On Tue, Jun 21, 2011 at 7:59 PM, Sushil Agrawal <span dir="ltr">&lt;<a href="mailto:sushil_agrawal@hotmail.com">sushil_agrawal@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



<div><div dir="ltr">
<br><br><div>&gt; Date: Mon, 20 Jun 2011 22:30:56 +0100<br>&gt; From: <a href="mailto:simon@thekelleys.org.uk" target="_blank">simon@thekelleys.org.uk</a><br>&gt; To: <a href="mailto:sushil_agrawal@hotmail.com" target="_blank">sushil_agrawal@hotmail.com</a><br>
&gt; CC: <a href="mailto:dnsmasq-discuss@lists.thekelleys.org.uk" target="_blank">dnsmasq-discuss@lists.thekelleys.org.uk</a><br>&gt; Subject: Re: [Dnsmasq-discuss] Enable dnsmasq to return addresses of multiple tftp servers in cycle<br>
&gt; <br>&gt; On 19/06/11 23:00, Sushil Agrawal wrote:<br>&gt; &gt;<br>&gt; &gt; Sure. I&#39;ll send the man page updates.<br>&gt; &gt;<br>&gt; &gt; Regarding the overloading of the server name parameter:<br>&gt; &gt; are you saying that we should have a version of the dhcp-boot option like:<br>
&gt; &gt;<br>&gt; &gt; dhcp-boot=/var/ftpd/pxelinux.0,boothost,boothost<br>&gt; &gt;<br>&gt; &gt; and take the second &#39;boothost&#39; (3rd parameter) to indicate that<br>&gt; &gt; it be resolved and a resultant address returned as a tftp<br>
&gt; &gt; server address ?<br>&gt; &gt;<br>&gt; <br>&gt; Exactly so. PXE doesn&#39;t use the &quot;server name&quot; field, but something else <br>&gt; might, (BOOTP does) so it would be nice to be able to specify if <br>
&gt; independently of the TFTP server.<br>&gt; <br>&gt; In an ideal world, the order of the arguments to dhcp-boot would be<br>&gt; filename, server address, servername<br>&gt; <br>&gt; but that mistake was made long ago and were stuck with it.<br>
&gt; <br>&gt; <br>&gt; Cheers,<br>&gt; <br>&gt; Simon.<br></div></div></div></blockquote></div>