netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ping: ICMP error replies while errno < 0 is a hard error
@ 2016-06-07 12:05 Jason A. Donenfeld
  2016-06-08  1:53 ` YOSHIFUJI Hideaki
  0 siblings, 1 reply; 2+ messages in thread
From: Jason A. Donenfeld @ 2016-06-07 12:05 UTC (permalink / raw)
  To: netdev, hideaki; +Cc: Jason A. Donenfeld

There are some odd conditions in which a device will return an error for
sendto, while at the same time an ICMP error response is generated. In
this case, with the current code, the packet is retransmitted in a
flood, which is not what anybody wants. In fact, when these two
conditions occur, we want to treat the packet as a "hard local error"
and do the ordinary pause as before. The reasoning is that if we did
receive an ICMP error message, then the packet was transmitted, and so
it should be accounted for. But, since we also received an errno, this
should be reported to the user, as something is wonky with their network
interface.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 ping_common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/ping_common.c b/ping_common.c
index 6054a91..89c0463 100644
--- a/ping_common.c
+++ b/ping_common.c
@@ -567,9 +567,14 @@ resend:
 		return MININTERVAL;
 	} else {
 		if ((i=receive_error_msg()) > 0) {
-			/* An ICMP error arrived. */
-			tokens += interval;
-			return MININTERVAL;
+			/* An ICMP error arrived. In this case, we've received
+			 * an error from sendto(), but we've also received an
+			 * ICMP message, which means the packet did in fact
+			 * send in some capacity. So, in this odd case, report
+			 * the more specific errno as the error, and treat this
+			 * as a hard local error. */
+			i = 0;
+			goto hard_local_error;
 		}
 		/* Compatibility with old linuces. */
 		if (i == 0 && confirm_flag && errno == EINVAL) {
@@ -580,6 +585,7 @@ resend:
 			goto resend;
 	}
 
+hard_local_error:
 	/* Hard local error. Pretend we sent packet. */
 	advance_ntransmitted();
 
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-08  1:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-07 12:05 [PATCH] ping: ICMP error replies while errno < 0 is a hard error Jason A. Donenfeld
2016-06-08  1:53 ` YOSHIFUJI Hideaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).