mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/6] net: arp_request: do not retry endlessly
Date: Wed,  4 Apr 2012 18:04:42 +0200	[thread overview]
Message-ID: <1333555484-32635-5-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1333555484-32635-1-git-send-email-w.sang@pengutronix.de>

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

  parent reply	other threads:[~2012-04-04 16:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` [PATCH 3/6] net: tftp: check for error when retrying Wolfram Sang
2012-04-04 16:04 ` Wolfram Sang [this message]
2012-04-04 16:04 ` [PATCH 5/6] net: tftp: do not retry endlessly 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1333555484-32635-5-git-send-email-w.sang@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox