<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    I'm not sure about the actual patch, but the idea is a great one.&nbsp;&nbsp;
    I have two NSLU2's and a router all configured with dnsmasq to act
    as tftp servers.&nbsp;&nbsp; Normally, have just been relying on the race of
    which one wins the race when more than one is running at the same
    time, but that is almost always the router...&nbsp;&nbsp; I like your idea
    much better.<br>
    <br>
    Regards,<br>
    <br>
    Bill<br>
    <br>
    <br>
    On 06/18/2011 12:52 PM, Sushil Agrawal wrote:
    <blockquote cite="mid:SNT116-W261809BCC974C96232ADAEE76C0@phx.gbl"
      type="cite">
      <style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
      <div dir="ltr">
        <br>
        Hi All,<br>
        <br>
        The attached patch enables dnsmasq(8) to return the ip addresses<br>
        of multiple tftp servers (for pxe boot) having a single alias<br>
        name (thru the /etc/hosts) in round robin fashion.<br>
        <br>
        We have a virtual environment where there are some managed hosts<br>
        running kvm hypervisor and some &gt; 150&nbsp; virtual machines<br>
        carved out of these hosts. All these virtual machines are thin<br>
        clients which boot of the net using pxe. The arrangement is such<br>
        that all of these machines boot at the same time and in order to<br>
        balance the load on the tftp server, we planned to have multiple<br>
        tftp servers (on these managed hosts themselves) running.<br>
        <br>
        dnsmasq currently returns only one address for tftp server<br>
        which it finds in the dhcp-boot option in the dnsmasq.conf<br>
        file. Although there is a provision for specifying the<br>
        tftp server name there but it is not used. We made<br>
        use of this name as an alias for multiple tftp servers<br>
        (using /etc/hosts) and then return the resolved addresses<br>
        one by one in cycle.<br>
        <br>
        The function cache_find_by_name() already takes care<br>
        of all this and all we had to do was to just call<br>
        it in dhcp_reply() to get one address and return<br>
        that as tftp address.<br>
        <br>
        If the tftp server address is specified in the dhcp-boot<br>
        option then that address is returned always. If address<br>
        is not specified and name is specified then this cyclic<br>
        stuff is done. This solution is working for us and hope it<br>
        will be useful to others.<br>
        <br>
        <br>
        Following is the patch (also attached) based on<br>
        dnsmasq-2.57:<br>
        <br>
        ................................................................<br>
        <br>
        --- dnsmasq-2.57.origg/src/rfc2131.c&nbsp;&nbsp; &nbsp;2011-02-17
        21:00:15.000000000 +0530<br>
        +++ dnsmasq-2.57/src/rfc2131.c&nbsp;&nbsp; &nbsp;2011-06-18 17:48:59.000000000
        +0530<br>
        @@ -829,8 +829,23 @@<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and set discovery_control = 8 */<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; if (boot)<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; {<br>
        -&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (boot-&gt;next_server.s_addr)<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (boot-&gt;next_server.s_addr) {<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;mess-&gt;siaddr = boot-&gt;next_server;<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if (boot-&gt;sname) {<br>
        +<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/*<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; * If the pxe server name is given in the conf
        then<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; * cycle thru its addresses.<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; */<br>
        +<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct crec *crecp;<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;time_t now = dnsmasq_time();<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;crecp = cache_find_by_name(NULL,
        boot-&gt;sname, now,<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; F_DHCP | F_HOSTS);<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (crecp) {<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;mess-&gt;siaddr = *(struct
        in_addr*)&amp;crecp-&gt;addr;<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (boot-&gt;file)<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;strncpy((char *)mess-&gt;file, boot-&gt;file,
        sizeof(mess-&gt;file)-1);<br>
        @@ -2222,8 +2237,23 @@<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; strncpy((char *)mess-&gt;file, boot-&gt;file,
        sizeof(mess-&gt;file)-1);<br>
        &nbsp;&nbsp;&nbsp; &nbsp;}<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>
        -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (boot-&gt;next_server.s_addr)<br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (boot-&gt;next_server.s_addr) {<br>
        &nbsp;&nbsp;&nbsp; &nbsp;mess-&gt;siaddr = boot-&gt;next_server;<br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if (boot-&gt;sname) {<br>
        +<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/*<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; * If the pxe server name is given in the conf then<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; * cycle thru its addresses.<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; */<br>
        +<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;struct crec *crecp;<br>
        + &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;time_t now = dnsmasq_time();<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;crecp = cache_find_by_name(NULL, boot-&gt;sname, now,<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; F_DHCP | F_HOSTS);<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (crecp) {<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;mess-&gt;siaddr = *(struct
        in_addr*)&amp;crecp-&gt;addr;<br>
        +&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
        &nbsp;&nbsp;&nbsp;&nbsp; }<br>
        &nbsp;&nbsp; else<br>
        &nbsp;&nbsp;&nbsp;&nbsp; /* Use the values of the relevant options if no dhcp-boot
        given and<br>
        ................................................................<br>
        <br>
        Sushil.<br>
        <br>
        <br>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Dnsmasq-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk">Dnsmasq-discuss@lists.thekelleys.org.uk</a>
<a class="moz-txt-link-freetext" href="http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss">http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>