Skip to contentSkip to conversation

DHCP: fix dhcp command parameters overwrite issue

PATCH New Bo Shen 2 participants 4 messages May 3, 2012 – May 4, 2012 Networking

lore
Share & tools
lore

Bo Shen

author
#0 lore raw

PATCH 1/1 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.

---
 common/cmd_net.c |    1 +
 net/bootp.c      |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
common/cmd_net.c +1 -0
index 65f32bc..9b1e650 100644
@@ -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;
 
net/bootp.c +2 -1
index 9e32476..df9f5eb 100644
@@ -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);
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 DHCP: fix dhcp command parameters overwrite issue

Dear Bo Shen,

Quoted 4 lines · In message <[email protected]> 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

Signature · 4 lines
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 at denx.de
Memories of you remind me of you.                   - Karl Lehenbauer
author
#2 lore raw

PATCH 1/1 DHCP: fix dhcp command parameters overwrite issue

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 ???

Quoted 37 lines

Dear Bo Shen,

In message <[email protected]<javascript:;>>

Quoted 4 lines · you

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 at denx.de<javascript:;>
Memories of you remind me of you. - Karl Lehenbauer

#3 lore raw

PATCH 1/1 DHCP: fix dhcp command parameters overwrite issue

Dear voice shen,

please do not top post / full quote. Please read
http://www.netmeister.org/news/learn2quote.html

Quoted 8 lines · In message <CAArQUwmcOCQQQmswdtE7xWa+F940GjK+54uJuDb1W8aPbZ7BgQ@mail.gmail.com>…

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.

Quoted 2 lines

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.

Quoted 2 lines

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

Signature · 5 lines
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 at denx.de
The human mind  ordinarily  operates  at  only  ten  percent  of  its
capacity. The rest is overhead for the operating system.