[U-Boot-Users] [Fwd: [PPCBoot-users] DHCP updating environment???]

Hi there,
I asked this quetsion before. But on the PPCBoot mailing list. So here again on the new list:
-------- Original Message -------- Subject: [PPCBoot-users] DHCP updating environment??? Date: Thu, 31 Oct 2002 16:46:47 +0100 From: Steven Scholz steven.scholz@imc-berlin.de To: PPCBoot ppcboot-users@lists.sourceforge.net
Hi folks,
is there a reason why BootpCopyNetParams() in bootp.c does _not_ setenv the ipaddr?
If I set autoload=n I want to use the dhcp command just to get the IP address from the server. But PPCBoot only sets the "bootfile" variable and nothing more!
Wouldn't it make sense to set all the params we got from the DHCP server? Well, at least the ones we're interessted in (see CONFIG_BOOTP_MASK).
Thanks,
Steven

In message 3DC7B80F.E41725BC@imc-berlin.de you wrote:
I asked this quetsion before. But on the PPCBoot mailing list.
I remember, and hoped somebody with a btter memory than mine would jump in.
is there a reason why BootpCopyNetParams() in bootp.c does _not_ setenv the ipaddr?
IIRC this was requested by one / some users with nobody else complaining about this. [But this discussion may have happned about 2 years ago, so I may be wrong.]
If I set autoload=n I want to use the dhcp command just to get the IP address from the server. But PPCBoot only sets the "bootfile" variable and nothing more!
No. With DHCP you cannot "just get the IP address"; you will always get what the DHCP server has to offer, and you default configuration will most certainly ask for more than just the IP address.
Wouldn't it make sense to set all the params we got from the DHCP server?
Maybe, maybe not. This depends on a lot of things.
For example: assume I manually set a parameter (maybe ipaddr, maybe gatewayip); in this case I probably want to make sure that my pre-set values take precedence over any DHCP supplied (additional) information. But then, I cannot simply implement some code which sets the params gotten via DHCP if they are not present in the environment - I think I remember there was an argument that in such a situation you would not be able to get rid of a faulty setting suppllied once by a misconfigured DHCP server.
Well, at least the ones we're interessted in (see CONFIG_BOOTP_MASK).
I understand what you mean, but I would like to hear more feedback from others...
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
is there a reason why BootpCopyNetParams() in bootp.c does _not_ setenv the ipaddr?
IIRC this was requested by one / some users with nobody else complaining about this. [But this discussion may have happned about 2 years ago, so I may be wrong.]
If I set autoload=n I want to use the dhcp command just to get the IP address from the server. But PPCBoot only sets the "bootfile" variable and nothing more!
No. With DHCP you cannot "just get the IP address"; you will always get what the DHCP server has to offer, and you default configuration will most certainly ask for more than just the IP address.
Wouldn't it make sense to set all the params we got from the DHCP server?
Maybe, maybe not. This depends on a lot of things.
For example: assume I manually set a parameter (maybe ipaddr, maybe gatewayip); in this case I probably want to make sure that my pre-set values take precedence over any DHCP supplied (additional) information. But then, I cannot simply implement some code which sets the params gotten via DHCP if they are not present in the environment
- I think I remember there was an argument that in such a situation
you would not be able to get rid of a faulty setting suppllied once by a misconfigured DHCP server.
Fair enough! That's why I mentioned CONFIG_BOOTP_MASK. This could be use to decide/filter which setting supplied by a DHCP server to use. If you have to deal with a faulty server and you don't want/can update PPCBoot, maybe we can introduce an environment variable like "dhcp_mask" ...
Well, at least the ones we're interessted in (see CONFIG_BOOTP_MASK).
I understand what you mean, but I would like to hear more feedback from others...
Yes please! :o)
Again: What's the use of setting autoload to "n"? I thought it's to get the settings from a DHCP server without immediately loading a file, so I can use the settings (IP, server ip etc) for something else, e.g. tftp'ing an FPGA file or ppcboot (ehm sorry U-Boot) image.
Thanks,
Steven

In message 3DC7C327.2CA471E@imc-berlin.de you wrote:
Again: What's the use of setting autoload to "n"?
The doc says:
autoload
if set to "no" (any string beginning with 'n'), the rarpb, bootp or dhcp commands will just perform a configuration lookup from the BOOTP / DHCP server, but not try to load any image using TFTP.
I thought it's to get the settings from a DHCP server without immediately loading a file, so I can use the settings (IP, server ip etc) for something else, e.g. tftp'ing an FPGA file or ppcboot (ehm sorry U-Boot) image.
Seems you think right. Ummmm... why are you asking? Any problems with it?
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 3DC7C327.2CA471E@imc-berlin.de you wrote:
Again: What's the use of setting autoload to "n"?
The doc says:
autoload
if set to "no" (any string beginning with 'n'), the rarpb, bootp or dhcp commands will just perform a configuration lookup from the BOOTP / DHCP server, but not try to load any image using TFTP.
I thought it's to get the settings from a DHCP server without immediately loading a file, so I can use the settings (IP, server ip etc) for something else, e.g. tftp'ing an FPGA file or ppcboot (ehm sorry U-Boot) image.
Seems you think right. Ummmm... why are you asking? Any problems with it?
Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...
(Well not realy anoyed! Just curious why it is the way it is.)
I want to do something like "dhcp; tftp 100000 fpga.rbf".
Steven

In message 3DC7C8C5.6983A78@imc-berlin.de you wrote:
Seems you think right. Ummmm... why are you asking? Any problems with it?
Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...
(Well not realy anoyed! Just curious why it is the way it is.)
I want to do something like "dhcp; tftp 100000 fpga.rbf".
I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 3DC7C8C5.6983A78@imc-berlin.de you wrote:
Seems you think right. Ummmm... why are you asking? Any problems with it?
Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...
(Well not realy anoyed! Just curious why it is the way it is.)
I want to do something like "dhcp; tftp 100000 fpga.rbf".
I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.
Ok. Example (from real life):
After power on I have
loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F
A bootp results in: => bootp FEC ETHERNET configured BOOTP broadcast 1 DHCP client bound to address 10.0.9.161 ARP broadcast 1 TFTP from server 10.0.2.9; our IP address is 10.0.9.161 Filename 'pImage.DAB4K2'. Load address: 0x100000 Loading: ################################################################# ################################################################# ######## done Bytes transferred = 702439 (ab7e7 hex) => printenv loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F bootfile=pImage.DAB4K2 filesize=ab7e7 netmask=255.255.0.0 hostname=dab4k2_69383 rootpath=/opt/ELDK/ppc_8xx ipaddr=10.0.9.161 serverip=10.0.2.9
Fair enough! But let's do it again...
=> setenv autoload n => bootp FEC ETHERNET configured BOOTP broadcast 1 DHCP client bound to address 10.0.9.161 => printenv loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F autoload=n bootfile=pImage.DAB4K2
You see!?
Only "bootfile" gets set. So a following tftp brings
=> tftp 100000 pImage.DAB4K2 FEC ETHERNET configured *** ERROR: `serverip' not set
So I think BootpCopyNetParams() should get called regardless of autoload!
Steven

Steven Scholz wrote:
Wolfgang Denk wrote:
In message 3DC7C8C5.6983A78@imc-berlin.de you wrote:
Seems you think right. Ummmm... why are you asking? Any problems with it?
Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...
(Well not realy anoyed! Just curious why it is the way it is.)
I want to do something like "dhcp; tftp 100000 fpga.rbf".
I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.
Ok. Example (from real life):
After power on I have
loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F
A bootp results in: => bootp FEC ETHERNET configured BOOTP broadcast 1 DHCP client bound to address 10.0.9.161 ARP broadcast 1 TFTP from server 10.0.2.9; our IP address is 10.0.9.161 Filename 'pImage.DAB4K2'. Load address: 0x100000 Loading: ################################################################# ################################################################# ######## done Bytes transferred = 702439 (ab7e7 hex) => printenv loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F bootfile=pImage.DAB4K2 filesize=ab7e7 netmask=255.255.0.0 hostname=dab4k2_69383 rootpath=/opt/ELDK/ppc_8xx ipaddr=10.0.9.161 serverip=10.0.2.9
Fair enough! But let's do it again...
=> setenv autoload n => bootp FEC ETHERNET configured BOOTP broadcast 1 DHCP client bound to address 10.0.9.161 => printenv loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F autoload=n bootfile=pImage.DAB4K2
You see!?
Only "bootfile" gets set. So a following tftp brings
=> tftp 100000 pImage.DAB4K2 FEC ETHERNET configured *** ERROR: `serverip' not set
So I think BootpCopyNetParams() should get called regardless of autoload!
Sorry!!! BootpCopyNetParams() gets called regardless of autoload!
But
void BootpCopyNetParams(Bootp_t *bp) { NetCopyIP(&NetOurIP, &bp->bp_yiaddr); NetCopyIP(&NetServerIP, &bp->bp_siaddr); memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6); copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
debug ("Bootfile: %s\n", BootFile);
/* Propagate to environment: * don't delete exising entry when BOOTP / DHCP reply does * not contain a new value */ if (*BootFile) { setenv ("bootfile", BootFile); } }
So setenv is called only for bootfile. So should we call setenv for OurIP, ServerIp etc or should tftp check NetOurIP or bp->bp_yiaddr!?
Steven

Steven Scholz wrote:
Steven Scholz wrote:
Wolfgang Denk wrote:
In message 3DC7C8C5.6983A78@imc-berlin.de you wrote:
Seems you think right. Ummmm... why are you asking? Any problems with it?
Well, I am a bit anoyed because everytime I do a dhcp to get the settings for a tftp I have to wait until pImage gets loaded...
(Well not realy anoyed! Just curious why it is the way it is.)
I want to do something like "dhcp; tftp 100000 fpga.rbf".
I don't get you. Do you mean that setting "autoload" to "no" does NOT work with DHCP? From the code I think it should work.
Ok. Example (from real life):
After power on I have
loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F
A bootp results in: => bootp FEC ETHERNET configured BOOTP broadcast 1 DHCP client bound to address 10.0.9.161 ARP broadcast 1 TFTP from server 10.0.2.9; our IP address is 10.0.9.161 Filename 'pImage.DAB4K2'. Load address: 0x100000 Loading: ################################################################# ################################################################# ######## done Bytes transferred = 702439 (ab7e7 hex) => printenv loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F bootfile=pImage.DAB4K2 filesize=ab7e7 netmask=255.255.0.0 hostname=dab4k2_69383 rootpath=/opt/ELDK/ppc_8xx ipaddr=10.0.9.161 serverip=10.0.2.9
Fair enough! But let's do it again...
=> setenv autoload n => bootp FEC ETHERNET configured BOOTP broadcast 1 DHCP client bound to address 10.0.9.161 => printenv loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F autoload=n bootfile=pImage.DAB4K2
You see!?
Only "bootfile" gets set. So a following tftp brings
=> tftp 100000 pImage.DAB4K2 FEC ETHERNET configured *** ERROR: `serverip' not set
So I think BootpCopyNetParams() should get called regardless of autoload!
Sorry!!! BootpCopyNetParams() gets called regardless of autoload!
But
void BootpCopyNetParams(Bootp_t *bp) { NetCopyIP(&NetOurIP, &bp->bp_yiaddr); NetCopyIP(&NetServerIP, &bp->bp_siaddr); memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6); copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
debug ("Bootfile: %s\n", BootFile); /* Propagate to environment: * don't delete exising entry when BOOTP / DHCP reply does * not contain a new value */ if (*BootFile) { setenv ("bootfile", BootFile); }
}
So setenv is called only for bootfile. So should we call setenv for OurIP, ServerIp etc or should tftp check NetOurIP or bp->bp_yiaddr!?
I should realy read more before start writing! ;-)
netbootp_update_env() is what I need! When I call netbootp_update_env() from within the DHCPHandler when autoload == n then I get what I need...
=> setenv autoload n => dhcp FEC ETHERNET configured BOOTP broadcast 0 DHCP client bound to address 10.0.9.161 => printenv loadaddr=0x100000 serial#=69383 ethaddr=00:A0:33:01:07:0F autoload=n bootfile=pImage.DAB4K2 netmask=255.255.0.0 hostname=dab4k2_69383 rootpath=/opt/ELDK/ppc_8xx ipaddr=10.0.9.161 serverip=10.0.2.9
What do you think?
Steven

In message 3DC7E754.AAB01A23@imc-berlin.de you wrote:
What do you think?
To _me_ this makes sense. Please send me a patch.
If there is no protest from anybody else it'll make it into CVS within a couple of hours.
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 3DC7E754.AAB01A23@imc-berlin.de you wrote:
What do you think?
To _me_ this makes sense. Please send me a patch.
If there is no protest from anybody else it'll make it into CVS within a couple of hours.
Dear Wolfgang,
1. I can't send patches for U-Boot yet. 2. All I have right now is a nasty hack that works for me (since my DHCP server is configured well) 3. Before we put something like that into CVS we (not just you and me) should discuss a way to deal with misconfigured dhcp servers because this changes the behaviour of boards that actually have autoload=n. (There's only one board with #define CFG_AUTOLOAD "n" in the PPCBoot CVS -> GENIETV)
Is it enough to have a right CONFIG_BOOTP_MASK? So only the "interessting" NetOurXXX variables are effected!?
Steven
participants (2)
-
Steven Scholz
-
Wolfgang Denk