neigh: Better handling of transition to NUD_PROBE state
Erik Kline [Wed, 2 Dec 2015 10:01:20 +0000 (15:01 +0530)]
[1] When entering NUD_PROBE state via neigh_update(), perhaps received
from userspace, correctly (re)initialize the probes count to zero.

This is useful for forcing revalidation of a neighbor (for example
if the host is attempting to do DNA [IPv4 4436, IPv6 6059]).

[2] Notify listeners when a neighbor goes into NUD_PROBE state.

By sending notifications on entry to NUD_PROBE state listeners get
more timely warnings of imminent connectivity issues.

The current notifications on entry to NUD_STALE have somewhat
limited usefulness: NUD_STALE is a perfectly normal state, as is
NUD_DELAY, whereas notifications on entry to NUD_FAILURE come after
a neighbor reachability problem has been confirmed (typically after
three probes).

Bug 200154120

Change-Id: I3ee05ab3489173824d38a4b3790bcf0840e0dc40
Signed-off-by: Erik Kline <ek@google.com>
Acked-By: Lorenzo Colitti <lorenzo@google.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: kraghavender <kraghavender@nvidia.com>
Reviewed-on: http://git-master/r/840347
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-by: Om Prakash Singh <omp@nvidia.com>
Tested-by: Om Prakash Singh <omp@nvidia.com>
Reviewed-by: Dhiren Parmar <dparmar@nvidia.com>

net/core/neighbour.c

index b49e8ba..cdd7716 100644 (file)
@@ -928,6 +928,7 @@ static void neigh_timer_handler(unsigned long arg)
                        neigh->nud_state = NUD_PROBE;
                        neigh->updated = jiffies;
                        atomic_set(&neigh->probes, 0);
+                       notify = 1;
                        next = now + neigh->parms->retrans_time;
                }
        } else {
@@ -1155,6 +1156,8 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
 
        if (new != old) {
                neigh_del_timer(neigh);
+               if (new & NUD_PROBE)
+                       atomic_set(&neigh->probes, 0);
                if (new & NUD_IN_TIMER)
                        neigh_add_timer(neigh, (jiffies +
                                                ((new & NUD_REACHABLE) ?