All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: neigh: disallow state transition DELAY->STALE in neigh_update()
@ 2016-07-21 17:58 Chunhui He
  2016-07-22  7:20   ` Julian Anastasov
  0 siblings, 1 reply; 16+ messages in thread
From: Chunhui He @ 2016-07-21 17:58 UTC (permalink / raw)
  To: David S. Miller
  Cc: Chunhui He, David Ahern, Nicolas Dichtel, Roopa Prabhu,
	Robert Shearman, David Barroso, Martin Zhang, Rick Jones,
	Konstantin Khlebnikov, Eric Dumazet, Thomas Graf,
	Eric W. Biederman, YOSHIFUJI Hideaki, netdev, linux-kernel

If neigh entry was CONNECTED and address is not changed, and if new state is
STALE, entry state will not change. Because DELAY is not in CONNECTED, it's
possible to change state from DELAY to STALE.

That is bad. Consider a host in IPv4 nerwork, a neigh entry in STALE state
is referenced to send packets, so goes to DELAY state. If the entry is not
confirmed by upper layer, it goes to PROBE state, and sends ARP request.
The neigh host sends ARP reply, then the entry goes to REACHABLE state.
But the entry state may be reseted to STALE by broadcast ARP packets, before
the entry goes to PROBE state. So it's possible that the entry will never go
to REACHABLE state, without external confirmation.

In my case, the gateway refuses to send unicast packets to me, before it sees
my ARP request. So it's critical to enter REACHABLE state by sending ARP
request, but not by external confirmation.

This fixes neigh_update() not to change to STALE if old state is CONNECTED or
DELAY.

Signed-off-by: Chunhui He <hchunhui@mail.ustc.edu.cn>
---
 net/core/neighbour.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 510cd62..29429eb 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1152,7 +1152,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
 		} else {
 			if (lladdr == neigh->ha && new == NUD_STALE &&
 			    ((flags & NEIGH_UPDATE_F_WEAK_OVERRIDE) ||
-			     (old & NUD_CONNECTED))
+			     (old & (NUD_CONNECTED | NUD_DELAY)))
 			    )
 				new = old;
 		}
-- 
2.1.4

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

end of thread, other threads:[~2016-07-25 18:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-21 17:58 [PATCH] net: neigh: disallow state transition DELAY->STALE in neigh_update() Chunhui He
2016-07-22  7:20 ` Julian Anastasov
2016-07-22  7:20   ` Julian Anastasov
2016-07-22  9:41   ` Hannes Frederic Sowa
2016-07-22 12:47   ` Chunhui He
2016-07-23  6:17     ` Julian Anastasov
2016-07-23 11:24       ` Chunhui He
2016-07-23 14:09         ` Julian Anastasov
2016-07-23 14:09           ` Julian Anastasov
2016-07-23 16:52           ` Chunhui He
2016-07-23 19:09             ` Julian Anastasov
2016-07-25  7:52               ` Chunhui He
2016-07-25  5:20     ` YOSHIFUJI Hideaki/吉藤英明
2016-07-25  8:13       ` Chunhui He
2016-07-25 12:45         ` 吉藤英明
2016-07-25 18:57           ` Julian Anastasov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.