Commit 3c172c4fdbbb5858fae38478d6399be4a16be3fc

Authored by Michael Zaidman
Committed by Ben Warren
1 parent b11f664f52

NetLoop initialization bug

The patch fixes the bug of partial initialization of global network
parameters.

Upon u-boot's start up the first ping command causes a failure of the
consequent TFTP command. It happens in the recently added mechanism of
the NetLoop initialization where initialization of global network
parameters is separated in the NetInitLoop routine which is called per
env_id change. Thus, ping request will initialize the network parameters
necessary for ping operation only, afterwards the env_changed_id will be
set to the env_id that will prevent all following initialization requests
from other protocols.
The problem is that the initialized by ping subset of network parameters
is not sufficient for other protocols and particularly for TFTP which
requires the NetServerIp also.

Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>

Showing 1 changed file with 4 additions and 59 deletions Side-by-side Diff

... ... @@ -285,68 +285,16 @@
285 285 int env_id = get_env_id ();
286 286  
287 287 /* update only when the environment has changed */
288   - if (env_changed_id == env_id)
289   - return 0;
290   -
291   - switch (protocol) {
292   -#if defined(CONFIG_CMD_NFS)
293   - case NFS:
294   -#endif
295   -#if defined(CONFIG_CMD_PING)
296   - case PING:
297   -#endif
298   -#if defined(CONFIG_CMD_SNTP)
299   - case SNTP:
300   -#endif
301   - case NETCONS:
302   - case TFTP:
  288 + if (env_changed_id != env_id) {
303 289 NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
304 290 NetOurGatewayIP = getenv_IPaddr ("gatewayip");
305 291 NetOurSubnetMask= getenv_IPaddr ("netmask");
306   - NetOurVLAN = getenv_VLAN("vlan");
307   - NetOurNativeVLAN = getenv_VLAN("nvlan");
308   -
309   - switch (protocol) {
310   -#if defined(CONFIG_CMD_NFS)
311   - case NFS:
312   -#endif
313   - case NETCONS:
314   - case TFTP:
315   - NetServerIP = getenv_IPaddr ("serverip");
316   - break;
317   -#if defined(CONFIG_CMD_PING)
318   - case PING:
319   - /* nothing */
320   - break;
321   -#endif
322   -#if defined(CONFIG_CMD_SNTP)
323   - case SNTP:
324   - /* nothing */
325   - break;
326   -#endif
327   - default:
328   - break;
329   - }
330   -
331   - break;
332   - case BOOTP:
333   - case RARP:
334   - /*
335   - * initialize our IP addr to 0 in order to accept ANY
336   - * IP addr assigned to us by the BOOTP / RARP server
337   - */
338   - NetOurIP = 0;
339 292 NetServerIP = getenv_IPaddr ("serverip");
340   - NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */
341 293 NetOurNativeVLAN = getenv_VLAN("nvlan");
342   - case CDP:
343   - NetOurVLAN = getenv_VLAN("vlan"); /* VLANs must be read */
344   - NetOurNativeVLAN = getenv_VLAN("nvlan");
345   - break;
346   - default:
347   - break;
  294 + NetOurVLAN = getenv_VLAN("vlan");
  295 + env_changed_id = env_id;
348 296 }
349   - env_changed_id = env_id;
  297 +
350 298 return 0;
351 299 }
352 300  
353 301  
... ... @@ -440,10 +388,7 @@
440 388  
441 389 #if defined(CONFIG_CMD_DHCP)
442 390 case DHCP:
443   - /* Start with a clean slate... */
444 391 BootpTry = 0;
445   - NetOurIP = 0;
446   - NetServerIP = getenv_IPaddr ("serverip");
447 392 DhcpRequest(); /* Basically same as BOOTP */
448 393 break;
449 394 #endif