[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
'tftp_sname' 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:<tag>,]<filename>,[<servername>[,<server
address>]]<br>
+.B \-M, --dhcp-boot=[tag:<tag>,]<filename>,[<servername>[,<server
address>|<tftp_servername>]]<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:<tag>,]<CSA>,<menu
text>[,<basename>|<bootservicetype>][,<server
address>]<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 = '?';<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 = '?';<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 !=
'?')<br>@@ -2240,6 +2249,7 @@<br> struct dhcp_boot *new =
opt_malloc(sizeof(struct dhcp_boot));<br> new->file =
dhcp_file;<br>
new->sname = dhcp_sname;<br>+ new->tftp_sname =
tftp_sname;<br> new->next_server = dhcp_next_server;<br>
new->netid = id;<br> new->next =
daemon->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->next_server.s_addr)<br>+ if
(boot->next_server.s_addr) {<br> mess->siaddr =
boot->next_server;<br>+ } else if (boot->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->tftp_sname,<br>+
now, F_DHCP | F_HOSTS);<br>+ if
(crecp) {<br>+ mess->siaddr = *(struct
in_addr*)&crecp->addr;<br>
+ }<br>+ }<br> <br>
if (boot->file)<br> strncpy((char *)mess->file,
boot->file, sizeof(mess->file)-1);<br>@@ -2222,8 +2237,23 @@<br>
strncpy((char *)mess->file, boot->file,
sizeof(mess->file)-1);<br>
}<br> <br>- if (boot->next_server.s_addr)<br>+
if (boot->next_server.s_addr) {<br> mess->siaddr =
boot->next_server;<br>+ } else if (boot->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->tftp_sname,<br>+
now, F_DHCP | F_HOSTS);<br>
+ if (crecp) {<br>+ mess->siaddr = *(struct
in_addr*)&crecp->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"><<a href="mailto:sushil_agrawal@hotmail.com">sushil_agrawal@hotmail.com</a>></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>> Date: Mon, 20 Jun 2011 22:30:56 +0100<br>> From: <a href="mailto:simon@thekelleys.org.uk" target="_blank">simon@thekelleys.org.uk</a><br>> To: <a href="mailto:sushil_agrawal@hotmail.com" target="_blank">sushil_agrawal@hotmail.com</a><br>
> CC: <a href="mailto:dnsmasq-discuss@lists.thekelleys.org.uk" target="_blank">dnsmasq-discuss@lists.thekelleys.org.uk</a><br>> Subject: Re: [Dnsmasq-discuss] Enable dnsmasq to return addresses of multiple tftp servers in cycle<br>
> <br>> On 19/06/11 23:00, Sushil Agrawal wrote:<br>> ><br>> > Sure. I'll send the man page updates.<br>> ><br>> > Regarding the overloading of the server name parameter:<br>> > 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) to indicate that<br>> > it be resolved and a resultant address returned as a tftp<br>
> > server address ?<br>> ><br>> <br>> Exactly so. PXE doesn't use the "server name" field, but something else <br>> might, (BOOTP does) so it would be nice to be able to specify if <br>
> independently of the TFTP server.<br>> <br>> In an ideal world, the order of the arguments to dhcp-boot would be<br>> filename, server address, servername<br>> <br>> but that mistake was made long ago and were stuck with it.<br>
> <br>> <br>> Cheers,<br>> <br>> Simon.<br></div></div></div></blockquote></div>