Commit 67b96e87da1b84660fa1e5b78cc760246d116814
Committed by
Ben Warren
1 parent
fcffb680e7
Exists in
master
and in
54 other branches
Repair the 'netretry=once' option.
'netretry = once' does the same as 'netretry = yes', because it is not stored when it was tried once. Signed-off-by: Remy Bohmer <linux@bohmer.net> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Showing 1 changed file with 24 additions and 8 deletions Side-by-side Diff
net/net.c
... | ... | @@ -197,6 +197,8 @@ |
197 | 197 | |
198 | 198 | static int net_check_prereq (proto_t protocol); |
199 | 199 | |
200 | +static int NetTryCount; | |
201 | + | |
200 | 202 | /**********************************************************************/ |
201 | 203 | |
202 | 204 | IPaddr_t NetArpWaitPacketIP; |
... | ... | @@ -320,6 +322,7 @@ |
320 | 322 | NetArpWaitReplyIP = 0; |
321 | 323 | NetArpWaitTxPacket = NULL; |
322 | 324 | NetTxPacket = NULL; |
325 | + NetTryCount = 1; | |
323 | 326 | |
324 | 327 | if (!NetTxPacket) { |
325 | 328 | int i; |
326 | 329 | |
327 | 330 | |
... | ... | @@ -558,17 +561,30 @@ |
558 | 561 | void NetStartAgain (void) |
559 | 562 | { |
560 | 563 | char *nretry; |
561 | - int noretry = 0, once = 0; | |
564 | + int retry_forever = 0; | |
565 | + unsigned long retrycnt = 0; | |
562 | 566 | |
563 | - if ((nretry = getenv ("netretry")) != NULL) { | |
564 | - noretry = (strcmp (nretry, "no") == 0); | |
565 | - once = (strcmp (nretry, "once") == 0); | |
566 | - } | |
567 | - if (noretry) { | |
568 | - eth_halt (); | |
567 | + nretry = getenv("netretry"); | |
568 | + if (nretry) { | |
569 | + if (!strcmp(nretry, "yes")) | |
570 | + retry_forever = 1; | |
571 | + else if (!strcmp(nretry, "no")) | |
572 | + retrycnt = 0; | |
573 | + else if (!strcmp(nretry, "once")) | |
574 | + retrycnt = 1; | |
575 | + else | |
576 | + retrycnt = simple_strtoul(nretry, NULL, 0); | |
577 | + } else | |
578 | + retry_forever = 1; | |
579 | + | |
580 | + if ((!retry_forever) && (NetTryCount >= retrycnt)) { | |
581 | + eth_halt(); | |
569 | 582 | NetState = NETLOOP_FAIL; |
570 | 583 | return; |
571 | 584 | } |
585 | + | |
586 | + NetTryCount++; | |
587 | + | |
572 | 588 | #ifndef CONFIG_NET_MULTI |
573 | 589 | NetSetTimeout (10000UL, startAgainTimeout); |
574 | 590 | NetSetHandler (startAgainHandler); |
... | ... | @@ -580,7 +596,7 @@ |
580 | 596 | eth_init (gd->bd); |
581 | 597 | if (NetRestartWrap) { |
582 | 598 | NetRestartWrap = 0; |
583 | - if (NetDevExists && !once) { | |
599 | + if (NetDevExists) { | |
584 | 600 | NetSetTimeout (10000UL, startAgainTimeout); |
585 | 601 | NetSetHandler (startAgainHandler); |
586 | 602 | } else { |