* [PATCH 1/6] net: ping: send PING packets with 1-second interval
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
@ 2012-04-04 16:04 ` Wolfram Sang
2012-04-04 16:04 ` [PATCH 2/6] net: ping: remove unneeded initialization Wolfram Sang
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2012-04-04 16:04 UTC (permalink / raw)
To: barebox
Like standard ping does by default.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
net/ping.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/net/ping.c b/net/ping.c
index b90e5af..0e8a0dc 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -88,7 +88,8 @@ static int do_ping(int argc, char *argv[])
net_poll();
- if (is_timeout(ping_start, 10 * SECOND)) {
+ if (is_timeout(ping_start, SECOND)) {
+ /* No answer, send another packet */
ping_start = get_time_ns();
ret = ping_send();
if (ret)
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/6] net: ping: remove unneeded initialization
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
2012-04-04 16:04 ` [PATCH 1/6] net: ping: send PING packets with 1-second interval Wolfram Sang
@ 2012-04-04 16:04 ` Wolfram Sang
2012-04-04 16:04 ` [PATCH 3/6] net: tftp: check for error when retrying Wolfram Sang
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2012-04-04 16:04 UTC (permalink / raw)
To: barebox
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
net/ping.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/ping.c b/net/ping.c
index 0e8a0dc..4aa10f8 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -55,7 +55,7 @@ static void ping_handler(void *ctx, char *pkt, unsigned len)
static int do_ping(int argc, char *argv[])
{
int ret;
- uint64_t ping_start = 0;
+ uint64_t ping_start;
if (argc < 2)
return COMMAND_ERROR_USAGE;
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/6] net: tftp: check for error when retrying
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
2012-04-04 16:04 ` [PATCH 1/6] net: ping: send PING packets with 1-second interval Wolfram Sang
2012-04-04 16:04 ` [PATCH 2/6] net: ping: remove unneeded initialization Wolfram Sang
@ 2012-04-04 16:04 ` Wolfram Sang
2012-04-04 16:04 ` [PATCH 4/6] net: arp_request: do not retry endlessly Wolfram Sang
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2012-04-04 16:04 UTC (permalink / raw)
To: barebox
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
net/tftp.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index 45ac7ad..243ad0a 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -345,7 +345,9 @@ static int do_tftpb(int argc, char *argv[])
net_poll();
if (is_timeout(tftp_timer_start, SECOND)) {
show_progress(-1);
- tftp_send();
+ tftp_err = tftp_send();
+ if (tftp_err)
+ goto out_unreg;
}
}
out_unreg:
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/6] net: arp_request: do not retry endlessly
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
` (2 preceding siblings ...)
2012-04-04 16:04 ` [PATCH 3/6] net: tftp: check for error when retrying Wolfram Sang
@ 2012-04-04 16:04 ` Wolfram Sang
2012-04-04 16:04 ` [PATCH 5/6] net: tftp: " Wolfram Sang
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2012-04-04 16:04 UTC (permalink / raw)
To: barebox
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
include/net.h | 2 ++
net/net.c | 5 +++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/net.h b/include/net.h
index 0ebe198..3f2187e 100644
--- a/include/net.h
+++ b/include/net.h
@@ -21,6 +21,8 @@
#include <led.h>
#include <asm/byteorder.h> /* for nton* / ntoh* stuff */
+/* How often do we retry to send packages */
+#define PKT_NUM_RETRIES 4
/* The number of receive packet buffers */
#define PKTBUFSRX 4
diff --git a/net/net.c b/net/net.c
index 39db75e..046ddd4 100644
--- a/net/net.c
+++ b/net/net.c
@@ -223,6 +223,7 @@ static int arp_request(IPaddr_t dest, unsigned char *ether)
uint64_t arp_start;
static char *arp_packet;
struct ethernet *et;
+ unsigned retries = 0;
if (!arp_packet) {
arp_packet = net_alloc_packet();
@@ -277,8 +278,12 @@ static int arp_request(IPaddr_t dest, unsigned char *ether)
printf("T ");
arp_start = get_time_ns();
eth_send(arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
+ retries++;
}
+ if (retries > PKT_NUM_RETRIES)
+ return -ETIMEDOUT;
+
net_poll();
}
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/6] net: tftp: do not retry endlessly
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
` (3 preceding siblings ...)
2012-04-04 16:04 ` [PATCH 4/6] net: arp_request: do not retry endlessly Wolfram Sang
@ 2012-04-04 16:04 ` Wolfram Sang
2012-04-04 16:04 ` [PATCH 6/6] net: ping: " Wolfram Sang
2012-04-05 6:56 ` [PATCH 0/6] net: minor cleanups & avoid endless retries Sascha Hauer
6 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2012-04-04 16:04 UTC (permalink / raw)
To: barebox
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
net/tftp.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index 243ad0a..fc33c94 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -39,6 +39,7 @@ static unsigned int tftp_last_block; /* last packet sequence number received */
static int tftp_state;
static uint64_t tftp_timer_start;
static int tftp_err;
+static unsigned tftp_retries;
#define STATE_RRQ 1
#define STATE_WRQ 2
@@ -106,6 +107,7 @@ static int tftp_send(void)
}
tftp_last_block = tftp_block;
+ tftp_retries = 0;
s = (uint16_t *)pkt;
*s++ = htons(TFTP_DATA);
*s++ = htons(tftp_block);
@@ -231,6 +233,7 @@ static void tftp_handler(void *ctx, char *packet, unsigned len)
break;
tftp_last_block = tftp_block;
+ tftp_retries = 0;
if (!(tftp_block % 10))
tftp_size++;
@@ -278,6 +281,7 @@ static int do_tftpb(int argc, char *argv[])
do_tftp_push(0);
tftp_last_block = 0;
tftp_size = 0;
+ tftp_retries = 0;
while((opt = getopt(argc, argv, "p")) > 0) {
switch(opt) {
@@ -348,6 +352,12 @@ static int do_tftpb(int argc, char *argv[])
tftp_err = tftp_send();
if (tftp_err)
goto out_unreg;
+ tftp_retries++;
+ }
+
+ if (tftp_retries > PKT_NUM_RETRIES) {
+ tftp_err = -ETIMEDOUT;
+ break;
}
}
out_unreg:
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6/6] net: ping: do not retry endlessly
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
` (4 preceding siblings ...)
2012-04-04 16:04 ` [PATCH 5/6] net: tftp: " Wolfram Sang
@ 2012-04-04 16:04 ` Wolfram Sang
2012-04-05 6:56 ` [PATCH 0/6] net: minor cleanups & avoid endless retries Sascha Hauer
6 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2012-04-04 16:04 UTC (permalink / raw)
To: barebox
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
net/ping.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/net/ping.c b/net/ping.c
index 4aa10f8..bc6cf2e 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -56,6 +56,7 @@ static int do_ping(int argc, char *argv[])
{
int ret;
uint64_t ping_start;
+ unsigned retries = 0;
if (argc < 2)
return COMMAND_ERROR_USAGE;
@@ -94,6 +95,12 @@ static int do_ping(int argc, char *argv[])
ret = ping_send();
if (ret)
goto out_unreg;
+ retries++;
+ }
+
+ if (retries > PKT_NUM_RETRIES) {
+ ret = -ETIMEDOUT;
+ goto out_unreg;
}
}
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/6] net: minor cleanups & avoid endless retries
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
` (5 preceding siblings ...)
2012-04-04 16:04 ` [PATCH 6/6] net: ping: " Wolfram Sang
@ 2012-04-05 6:56 ` Sascha Hauer
6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2012-04-05 6:56 UTC (permalink / raw)
To: Wolfram Sang; +Cc: barebox
On Wed, Apr 04, 2012 at 06:04:38PM +0200, Wolfram Sang wrote:
> For scripted update scenarios, endless retries on commands like ping or tftp is
> unwanted. Use a retry now and timeout. Apply minor cleanups found on the way.
>
> Wolfram Sang (6):
> net: ping: send PING packets with 1-second interval
> net: ping: remove unneeded initialization
> net: tftp: check for error when retrying
> net: arp_request: do not retry endlessly
> net: tftp: do not retry endlessly
> net: ping: do not retry endlessly
Applied, thanks.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread