[U-Boot] [PATCH] DHCP: fix dhcp command parameters overwrite issue

when using dhcp command with parameters as usage message, if DHCP server response contains bootfilename, it will overwrite the dhcp command parameters. So the dhcp command parameters can not be used.
Using this patch to fix it.
Signed-off-by: Bo Shen voice.shen@gmail.com --- common/cmd_net.c | 1 + net/bootp.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/cmd_net.c b/common/cmd_net.c index 65f32bc..9b1e650 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -221,6 +221,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
case 3: load_addr = simple_strtoul(argv[1], NULL, 16); copy_filename (BootFile, argv[2], sizeof(BootFile)); + setenv ("bootfile", BootFile);
break;
diff --git a/net/bootp.c b/net/bootp.c index 9e32476..df9f5eb 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -116,7 +116,8 @@ static void BootpCopyNetParams(Bootp_t *bp) memcpy (NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6); #endif if (strlen(bp->bp_file) > 0) - copy_filename (BootFile, bp->bp_file, sizeof(BootFile)); + if (!getenv("bootfile")) + copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
debug("Bootfile: %s\n", BootFile);

Dear Bo Shen,
In message 1336036915-6422-1-git-send-email-voice.shen@gmail.com you wrote:
when using dhcp command with parameters as usage message, if DHCP server response contains bootfilename, it will overwrite the dhcp command parameters. So the dhcp command parameters can not be used.
This behaviour is not a bug, it is intentional. If the DHCP server returns any network configuration parameters, thise shall take precedence over any user-defined (default-) settings.
If you want to ignore the boot filename returned by the DHCP server, you can do so: set autoload to no, use DHCP to get the (rest of) the network configuration, and then use tftp to download the boot file of your choice. Similar for any other network parameters returned by the DHCP server.
We had a similar discussion not so long ago; please see here for reference: http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/129689/focus=129987
Thanks for your patch, but we will not apply it, as the current behaviour is correct (or at least as intended).
Best regards,
Wolfgang Denk

Hi Wolfgang, Thank you very much.
But, I have a question. The different DHCP server configuration will cause different result. Please take following information as a reference. case 1: DHCP server response include bootfilename, the parameters of the dhcp can not be used. case 2: DHCP server response exclude bootfilename, the parameters of the dhcp can be used.
So, for dhcp command, we prefer to use the parameters get from DHCP server while not user-defined. Am I right? If I am right, this will confuse the user who does not know about the DHCP server configuration.
Thanks again.
在 2012年5月4日星期五,Wolfgang Denk 写道:
Dear Bo Shen,
In message <1336036915-6422-1-git-send-email-voice.shen@gmail.comjavascript:;> you wrote:
when using dhcp command with parameters as usage message, if DHCP server response contains bootfilename, it will overwrite the dhcp command parameters. So the dhcp command parameters can not be used.
This behaviour is not a bug, it is intentional. If the DHCP server returns any network configuration parameters, thise shall take precedence over any user-defined (default-) settings.
If you want to ignore the boot filename returned by the DHCP server, you can do so: set autoload to no, use DHCP to get the (rest of) the network configuration, and then use tftp to download the boot file of your choice. Similar for any other network parameters returned by the DHCP server.
We had a similar discussion not so long ago; please see here for reference: http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/129689/focus=129987
Thanks for your patch, but we will not apply it, as the current behaviour is correct (or at least as intended).
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.dejavascript:; Memories of you remind me of you. - Karl Lehenbauer

Dear voice shen,
please do not top post / full quote. Please read http://www.netmeister.org/news/learn2quote.html
In message CAArQUwmcOCQQQmswdtE7xWa+F940GjK+54uJuDb1W8aPbZ7BgQ@mail.gmail.com you wrote:
But, I have a question. The different DHCP server configuration will cause different result. Please take following information as a reference. case 1: DHCP server response include bootfilename, the parameters of the dhcp can not be used. case 2: DHCP server response exclude bootfilename, the parameters of the dhcp can be used.
Correct. If the DHCP server returns different information, then the result will be different. If it provides a boot file name, this one will be used. If not, the default (here: the arg) will be used.
So, for dhcp command, we prefer to use the parameters get from DHCP server while not user-defined. Am I right?
I explained this several times before. See my previous message, and the link to the other thread.
If I am right, this will confuse the user who does not know about the DHCP server configuration.
I don't see what should be confusing here. Either we use the values returned by the DHCP server, or, in case the DHCP server returns none, we use the default value. What is confusing about this?
Best regards,
Wolfgang Denk
participants (3)
-
Bo Shen
-
voice shen
-
Wolfgang Denk