Skip to contentSkip to conversation

bootp: Fix bug in auto_load function

PATCH New Michal Simek 3 participants 5 messages Aug 31, 2011 – Sep 1, 2011 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bootp: Fix bug in auto_load function

Patch: "Put common autoload code into auto_load() function" (sha1: 093498669e77597635a24f326f11efeab213d394) is not simple code cleanup but code change which introduce new bug.

If autoload variable is not setup it worked as autoload=yes.

Currently if autoload is not setup dhcp sends request in forever loop.

There are two options how to fix it:
1. Move TftpStart() which is in this patch
2. Change functionality if autoload is not setup, set NetSate and ends.

@@ -165,7 +165,8 @@ static void auto_load(void)

                }
 #endif
        TftpStart();

- }
+ } else
+ NetState = NETLOOP_SUCCESS;
}

CC Eric B?nard <[email protected]>
CC Simon Glass <[email protected]>
---
 net/bootp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/bootp.c +1 -1
index 3db08ea..a003c42 100644
@@ -164,8 +164,8 @@ static void auto_load(void)
 			return;
 		}
 #endif
-	TftpStart();
 	}
+	TftpStart();
 }
 
 #if !defined(CONFIG_CMD_DHCP)
Signature · 1 line
1.5.5.6
#1 lore raw

PATCH 1/1 bootp: Fix bug in auto_load function

Hi Michal,

Quoted 8 lines · Michal Simek

Patch: "Put common autoload code into auto_load() function" (sha1: 093498669e77597635a24f326f11efeab213d394) is not simple code cleanup but code change which introduce new bug.

If autoload variable is not setup it worked as autoload=yes.

Currently if autoload is not setup dhcp sends request in forever loop.

Thanks for bring this up - there was some discussion at the time I remember. Also please excuse the verbatim code in this email but I want it to be clear.

The old code in v2011.03 is:

			/* Obey the 'autoload' setting */
			if ((s = getenv("autoload")) != NULL) {
				if (*s == 'n') {
					/*
					 * Just use BOOTP to configure system;
					 * Do not use TFTP to load the bootfile.
					 */
					NetState = NETLOOP_SUCCESS;
					return;
#if defined(CONFIG_CMD_NFS)
				} else if (strcmp(s, "NFS") == 0) {
					/*
					 * Use NFS to load the bootfile.
					 */
					NfsStart();
					return;
#endif
				}
			}
			TftpStart();
			return;

and

	if ((s = getenv("autoload")) != NULL) {
		if (*s == 'n') {
			/*
			 * Just use BOOTP to configure system;
			 * Do not use TFTP to load the bootfile.
			 */
			NetState = NETLOOP_SUCCESS;
			return;
#if defined(CONFIG_CMD_NFS)
		} else if (strcmp(s, "NFS") == 0) {
			/*
			 * Use NFS to load the bootfile.
			 */
			NfsStart();
			return;
#endif
		}
	}

	TftpStart();

These two sites were changed to a call to auto_load:

static void auto_load(void)

{
	const char *s = getenv("autoload");

	if (s != NULL) {
		if (*s == 'n') {
			/*
			 * Just use BOOTP to configure system;
			 * Do not use TFTP to load the bootfile.
			 */
			NetState = NETLOOP_SUCCESS;
			return;
		}
#if defined(CONFIG_CMD_NFS)
		if (strcmp(s, "NFS") == 0) {
			/*
			 * Use NFS to load the bootfile.
			 */
			NfsStart();
			return;
		}
#endif
	TftpStart();
	}
}

I don't see a change in the functionality here - I may be missing something so please can you explain?

#2 lore raw

PATCH 1/1 bootp: Fix bug in auto_load function

Hi,

2011/8/31 Simon Glass <[email protected]>

Quoted 96 lines

Hi Michal,

Quoted 8 lines · Michal Simek

Patch: "Put common autoload code into auto_load() function" (sha1: 093498669e77597635a24f326f11efeab213d394) is not simple code cleanup but code change which introduce new bug.

If autoload variable is not setup it worked as autoload=yes.

Currently if autoload is not setup dhcp sends request in forever loop.

Thanks for bring this up - there was some discussion at the time I remember. Also please excuse the verbatim code in this email but I want it to be clear.

The old code in v2011.03 is:

                       /* Obey the 'autoload' setting */
                       if ((s = getenv("autoload")) != NULL) {
                               if (*s == 'n') {
                                       /*
                                        * Just use BOOTP to configure
system;
                                        * Do not use TFTP to load the
bootfile.
                                        */
                                       NetState = NETLOOP_SUCCESS;
                                       return;
#if defined(CONFIG_CMD_NFS)
                               } else if (strcmp(s, "NFS") == 0) {
                                       /*
                                        * Use NFS to load the bootfile.
                                        */
                                       NfsStart();
                                       return;
#endif
                               }
                       }
                       TftpStart();
                       return;

and

       if ((s = getenv("autoload")) != NULL) {
               if (*s == 'n') {
                       /*
                        * Just use BOOTP to configure system;
                        * Do not use TFTP to load the bootfile.
                        */
                       NetState = NETLOOP_SUCCESS;
                       return;
#if defined(CONFIG_CMD_NFS)
               } else if (strcmp(s, "NFS") == 0) {
                       /*
                        * Use NFS to load the bootfile.
                        */
                       NfsStart();
                       return;
#endif
               }
       }

       TftpStart();

These two sites were changed to a call to auto_load:

static void auto_load(void)

{
       const char *s = getenv("autoload");

       if (s != NULL) {
               if (*s == 'n') {
                       /*
                        * Just use BOOTP to configure system;
                        * Do not use TFTP to load the bootfile.
                        */
                       NetState = NETLOOP_SUCCESS;
                       return;
               }
#if defined(CONFIG_CMD_NFS)
               if (strcmp(s, "NFS") == 0) {
                       /*
                        * Use NFS to load the bootfile.
                        */
                       NfsStart();
                       return;
               }
#endif
       TftpStart();
       }
}
Quoted 3 lines

I don't see a change in the functionality here - I may be missing something so please can you explain?

just look at TftpStart(); position in new and old code.
In new code is inside if (s != NULL) { } part in old not which change
behavior.

Just do simple test run
set autoload
dhcp

on my system it loops forever.

Quoted 4 lines

From my experience U-Boot has always performed an autoload unless you 'setenv autoload n', even if the variable is not set. From the README:

Quoted 9 lines

autoload - if set to "no" (any string beginning with 'n'),
"bootp" will just load perform a lookup of the configuration from the BOOTP server, but not try to load any image using TFTP

which suggests that this is the correct behavior (i.e. it defaults to autoload=yes)

I am fine with that that if autoload var is not set it means autoload=yes.

Quoted 56 lines
Quoted 27 lines

There are two options how to fix it:
1. Move TftpStart() which is in this patch
2. Change functionality if autoload is not setup, set NetSate and ends.

(quoted diff) +2 -1
@@ -165,7 +165,8 @@ static void auto_load(void)
               }
 #endif
       TftpStart();
-       }
+       } else
+               NetState = NETLOOP_SUCCESS;
 }
 
CC Eric B?nard <[email protected]>
CC Simon Glass <[email protected]>
---
 net/bootp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/bootp.c +0 -0
index 3db08ea..a003c42 100644

net/bootp.c static void auto_load(void) · line 169

Quoted 7 lines
net/bootp.c +1 -1
@@ -164,8 +164,8 @@ static void auto_load(void)
                       return;
               }
 #endif
-       TftpStart();
       }
+       TftpStart();
 }

Isn't this the opposite of the patch you want? I think you want to move TftpStart() inside the loop, like this:

static void auto_load(void)

{
       const char *s = getenv("autoload");

       if (s != NULL) {
               if (*s == 'n') {
                       /*
                        * Just use BOOTP to configure system;
                        * Do not use TFTP to load the bootfile.
                        */
                       NetState = NETLOOP_SUCCESS;
                       return;
               }
#if defined(CONFIG_CMD_NFS)
               if (strcmp(s, "NFS") == 0) {
                       /*
                        * Use NFS to load the bootfile.
Quoted 9 lines
                        */
                       NfsStart();
                       return;
               TftpStart();
               }
#endif
       }
}

Definitely this one - where TftpStart is not even called.

Michal

#3 lore raw

PATCH 1/1 bootp: Fix bug in auto_load function

In reply to Michal Simek

Dear Michal Simek,

Quoted 5 lines · In message <[email protected]> you wrote:

Patch: "Put common autoload code into auto_load() function" (sha1: 093498669e77597635a24f326f11efeab213d394) is not simple code cleanup but code change which introduce new bug.

If autoload variable is not setup it worked as autoload=yes.

Yes, and this is intentionally, because it's what poople expect when they run the "dhcpboot" command.

Quoted 2 lines

Currently if autoload is not setup dhcp sends request in forever loop.

That's not correct. Only until a DHCP server provides the needed configurationinformation so TFTP gets started.

Quoted 3 lines

There are two options how to fix it:
1. Move TftpStart() which is in this patch
2. Change functionality if autoload is not setup, set NetSate and ends.

That would change behavious in a way that is not wanted.

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
Status quo. Latin for "the mess we're in."
#4 lore raw

PATCH 1/1 bootp: Fix bug in auto_load function

Hi,

Quoted 11 lines · Wolfgang Denk

Dear Michal Simek,

Quoted 5 lines · In message <[email protected]> you wrote:

Patch: "Put common autoload code into auto_load() function" (sha1: 093498669e77597635a24f326f11efeab213d394) is not simple code cleanup but code change which introduce new bug.

If autoload variable is not setup it worked as autoload=yes.

Yes, and this is intentionally, because it's what poople expect when they run the "dhcpboot" command.

ok.

Quoted 6 lines
Quoted 3 lines

Currently if autoload is not setup dhcp sends request in forever loop.

That's not correct. Only until a DHCP server provides the needed configurationinformation so TFTP gets started.

That's what I get/see on my platforms.

Quoted 6 lines
Quoted 4 lines

There are two options how to fix it:
1. Move TftpStart() which is in this patch
2. Change functionality if autoload is not setup, set NetSate and ends.

That would change behavious in a way that is not wanted.

Agree that point 2 change behavior. Point 1 just fix c&p error.

Regards,
Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian