The native userspace tunnel neighbor cache extends a complete entry's
lifetime whenever it is used.  An idle entry is instead removed when
its aging timer expires.  The first packet after removal is dropped
while OVS resolves the neighbor again.

Refresh complete entries before they expire while keeping the cached
MAC usable.  Start up to three retransmission intervals before expiration,
capped at half the aging interval, and retry at the retransmission
interval while the entry remains valid.  The cap prevents immediate
repeated probes when aging and retransmission intervals are equal.
Unanswered entries still expire at their original deadline.

Check the cache deadline in the ofproto run loop and scan the table
when an event is due.  Send ARP or Neighbor Discovery requests
through the bridge pipeline outside the neighbor mutex.  Refresh learned
entries on their original interface to preserve policy-routing context.
For a gateway outside the interface prefix, reuse the local address
from learning if it is still assigned to that interface.  For manual
entries, prefer a direct route or use the sole eligible bridge port.
Defer probes during flow restoration and keep aging entries.  Show
entries being refreshed in tnl/neigh/show.

Process each snooped neighbor reply in userspace so identical replies
renew the entry even when they match a cached datapath flow.

Renew the aging deadline on neighbor learning, rather than cache lookup.
Remove the now-unused XC_TNL_NEIGH statistics bookkeeping.  Cold entries,
flushed entries, and entries lost on restart still require resolution
and can drop their triggering packet.

Add IPv4 and IPv6 tests covering proactive refresh, retries, actual tunnel
forwarding while refresh is pending and after renewal, and expiration
without a reply.  Also cover equal timers, source-based routing with two
VTEPs, and learned and manual entries on a non-local tunnel endpoint.
Verify that a changed neighbor MAC invalidates existing datapath actions
and that unanswered expiration invalidates them even with ongoing traffic.

Assisted-by: GPT-6, OpenAI Codex
Signed-off-by: Tim Rozet <[email protected]>
---
v5:
- Refresh off-prefix gateways with the local address from learning when
  that address is still assigned to the learned interface.
- Prefer a direct, unmarked route for a fresh manual entry. Fall back to
  a single eligible port on its bridge and skip ambiguous probes.
- Continue aging during flow restoration and send pending probes once
  the datapath is ready.  Retry failed receive setup without skipping
  tunnel maintenance or repeatedly logging the same error.
- Preserve retry spacing across timer writes and measure a changed
  retransmit interval from the previous attempt.
- Exercise IPv4 and IPv6 routed gateways, VLAN selection, restoration,
  and timer changes. Wait for the final datapath drop before checking
  that an expired MAC was not used.  Capture gateway probes across the
  route change so an early request is counted.

v4 review:
https://github.com/trozet/ovs/pull/7#pullrequestreview-5968078367

v4:
- Move cache maintenance and refresh to the ofproto run and wait loops.
  Share ARP/ND packet injection with cold resolution while preserving
  translation limits (Eelco).
- Tidy entry initialization and refresh queue locking, relax timer
  atomics, widen the retry calculation, and skip empty-table wakeups
  (Eelco). Keep release/acquire on publication of a newly learned MAC.
- Show REFRESHING in tnl/neigh/show and use grep -q in the tunnel
  tests (Mike).
- Process repeated ARP replies and Neighbor Advertisements even when
  a datapath flow matches. Test that they renew the cached entry.
- Cover loss of the learned port when another port can reach the same
  subnet. Keep the cached MAC until expiry and retry on the learned
  interface to preserve the original VLAN.

v3 review:
https://mail.openvswitch.org/pipermail/ovs-dev/2026-October/437534.html
https://mail.openvswitch.org/pipermail/ovs-dev/2026-November/438134.html

v3:
- Replace stale-entry retention with proactive ARP/ND refresh.
- Schedule up to three probes before expiration, retaining the
  cached MAC while awaiting a reply.
- Preserve the learned interface for policy-routed tunnels.
- Remove obsolete neighbor lookup statistics bookkeeping.
- Test cached datapath forwarding after MAC changes and invalidate
  cached actions on unanswered expiration, addressing Eelco's concern.
- Freeze test clocks and avoid immediate wakeups for queued probes.

Previous discussion:
https://mail.openvswitch.org/pipermail/ovs-dev/2026-September/436265.html

 lib/dpif-netdev.c                  |   2 -
 lib/tnl-neigh-cache.c              | 294 ++++++++++++++++++++++-------
 lib/tnl-neigh-cache.h              |   9 +-
 ofproto/ofproto-dpif-xlate-cache.c |  11 --
 ofproto/ofproto-dpif-xlate-cache.h |   5 -
 ofproto/ofproto-dpif-xlate.c       | 205 ++++++++++++++------
 ofproto/ofproto-dpif-xlate.h       |   1 +
 ofproto/ofproto-dpif.c             |  30 +--
 ofproto/ofproto-tnl-unixctl.man    |  12 +-
 tests/tunnel-push-pop-ipv6.at      | 133 ++++++++++++-
 tests/tunnel-push-pop.at           | 277 ++++++++++++++++++++++++++-
 11 files changed, 810 insertions(+), 169 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 4151ea056..edf6df48f 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -82,7 +82,6 @@
 #include "smap.h"
 #include "sset.h"
 #include "timeval.h"
-#include "tnl-neigh-cache.h"
 #include "tnl-ports.h"
 #include "unixctl.h"
 #include "util.h"
@@ -5915,7 +5914,6 @@ dpif_netdev_run(struct dpif *dpif)
     }
     ovs_rwlock_unlock(&dp->port_rwlock);
 
-    tnl_neigh_cache_run();
     tnl_port_map_run();
     new_tnl_seq = seq_read(tnl_conf_seq);
 
diff --git a/lib/tnl-neigh-cache.c b/lib/tnl-neigh-cache.c
index fbefc3d51..481d28f81 100644
--- a/lib/tnl-neigh-cache.c
+++ b/lib/tnl-neigh-cache.c
@@ -33,6 +33,7 @@
 #include "flow.h"
 #include "netdev.h"
 #include "ovs-atomic.h"
+#include "openvswitch/list.h"
 #include "ovs-thread.h"
 #include "packets.h"
 #include "openvswitch/poll-loop.h"
@@ -51,17 +52,24 @@
 
 struct tnl_neigh_entry {
     struct cmap_node cmap_node;
+    struct ovs_list refresh_node;
     struct in6_addr ip;
+    struct in6_addr local_ip;   /* Local address seen on the learned port. */
     struct eth_addr mac;
     atomic_llong expires;       /* Expiration time in ms. */
+    long long last_attempt;     /* LLONG_MIN until a probe is dequeued. */
     char br_name[IFNAMSIZ];
+    char dev_name[IFNAMSIZ];    /* IP interface used to learn the neighbor. */
     atomic_bool complete;
 };
 
 static struct cmap table = CMAP_INITIALIZER;
 static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
+static struct ovs_list refresh_list OVS_GUARDED_BY(mutex)
+    = OVS_LIST_INITIALIZER(&refresh_list);
 static atomic_uint32_t neigh_aging;
 static atomic_uint32_t neigh_retrans_time;
+static atomic_llong next_event;
 
 static uint32_t
 tnl_neigh_hash(const struct in6_addr *ip)
@@ -74,7 +82,7 @@ tnl_neigh_expired(struct tnl_neigh_entry *neigh)
 {
     long long expires;
 
-    atomic_read_explicit(&neigh->expires, &expires, memory_order_acquire);
+    atomic_read_relaxed(&neigh->expires, &expires);
 
     return expires <= time_msec();
 }
@@ -84,7 +92,7 @@ tnl_neigh_get_aging(void)
 {
     unsigned int aging;
 
-    atomic_read_explicit(&neigh_aging, &aging, memory_order_acquire);
+    atomic_read_relaxed(&neigh_aging, &aging);
     return aging;
 }
 
@@ -93,11 +101,31 @@ tnl_neigh_get_retrans_time(void)
 {
     unsigned int retrans_time;
 
-    atomic_read_explicit(&neigh_retrans_time, &retrans_time,
-                         memory_order_acquire);
+    atomic_read_relaxed(&neigh_retrans_time, &retrans_time);
     return retrans_time;
 }
 
+static void
+tnl_neigh_schedule(long long deadline)
+    OVS_REQUIRES(mutex)
+{
+    long long next;
+
+    atomic_read_relaxed(&next_event, &next);
+    if (deadline < next) {
+        atomic_store_relaxed(&next_event, deadline);
+    }
+}
+
+static long long
+tnl_neigh_refresh_window(uint32_t retrans_time)
+{
+    /* Leave time for two retries when the intervals permit, but always give
+     * a learned entry at least half its lifetime before probing again,
+     * including when aging == retrans. */
+    return MIN(3LL * retrans_time, tnl_neigh_get_aging() / 2);
+}
+
 static bool
 tnl_neigh_is_complete(struct tnl_neigh_entry *neigh)
 {
@@ -120,12 +148,6 @@ tnl_neigh_lookup__(const char br_name[IFNAMSIZ], const 
struct in6_addr *dst)
                 return NULL;
             }
 
-            if (tnl_neigh_is_complete(neigh)) {
-                atomic_store_explicit(&neigh->expires,
-                                      time_msec() + tnl_neigh_get_aging(),
-                                      memory_order_release);
-            }
-
             return neigh;
         }
     }
@@ -136,6 +158,7 @@ static void
 tnl_neigh_set_partial(const char name[IFNAMSIZ], const struct in6_addr *dst)
 {
     ovs_mutex_lock(&mutex);
+    long long expires = time_msec() + tnl_neigh_get_retrans_time();
     struct tnl_neigh_entry *neigh = tnl_neigh_lookup__(name, dst);
     if (neigh) {
         /* Entry inserted before lock taken. */
@@ -146,11 +169,15 @@ tnl_neigh_set_partial(const char name[IFNAMSIZ], const 
struct in6_addr *dst)
     neigh = xmalloc(sizeof *neigh);
 
     neigh->ip = *dst;
+    neigh->local_ip = in6addr_any;
     atomic_store_relaxed(&neigh->complete, false);
-    atomic_store_relaxed(&neigh->expires,
-                         time_msec() + tnl_neigh_get_retrans_time());
+    atomic_store_relaxed(&neigh->expires, expires);
+    neigh->last_attempt = LLONG_MIN;
     ovs_strlcpy(neigh->br_name, name, sizeof neigh->br_name);
+    neigh->dev_name[0] = '\0';
+    ovs_list_init(&neigh->refresh_node);
     cmap_insert(&table, &neigh->cmap_node, tnl_neigh_hash(&neigh->ip));
+    tnl_neigh_schedule(expires);
 
     ovs_mutex_unlock(&mutex);
     seq_change(tnl_conf_seq);
@@ -185,67 +212,90 @@ neigh_entry_free(struct tnl_neigh_entry *neigh)
     free(neigh);
 }
 
+static void
+tnl_neigh_cancel_refresh(struct tnl_neigh_entry *neigh)
+    OVS_REQUIRES(mutex)
+{
+    if (!ovs_list_is_empty(&neigh->refresh_node)) {
+        ovs_list_remove(&neigh->refresh_node);
+        ovs_list_init(&neigh->refresh_node);
+    }
+}
+
 static void
 tnl_neigh_delete(struct tnl_neigh_entry *neigh)
+    OVS_REQUIRES(mutex)
 {
     uint32_t hash = tnl_neigh_hash(&neigh->ip);
+
+    tnl_neigh_cancel_refresh(neigh);
     cmap_remove(&table, &neigh->cmap_node, hash);
     ovsrcu_postpone(neigh_entry_free, neigh);
 }
 
 void
-tnl_neigh_set(const char name[IFNAMSIZ], const struct in6_addr *dst,
-              const struct eth_addr mac)
+tnl_neigh_set(const char name[IFNAMSIZ], const char dev_name[IFNAMSIZ],
+              const struct in6_addr *dst, const struct eth_addr mac,
+              const struct in6_addr *local_ip)
 {
     ovs_mutex_lock(&mutex);
+    long long expires = time_msec() + tnl_neigh_get_aging();
     struct tnl_neigh_entry *neigh = tnl_neigh_lookup__(name, dst);
-    bool insert = true;
+    bool complete = neigh && tnl_neigh_is_complete(neigh);
 
-    if (neigh) {
-        if (!tnl_neigh_is_complete(neigh)) {
-            insert = false;
-        } else if (eth_addr_equals(neigh->mac, mac)) {
-            atomic_store_relaxed(&neigh->expires,
-                                 time_msec() + tnl_neigh_get_aging());
-            ovs_mutex_unlock(&mutex);
-            return;
-        } else {
-            tnl_neigh_delete(neigh);
-        }
+    /* An unsolicited update may lack a local unicast address.  Keep the
+     * previous one only if it belongs to the same learned interface. */
+    struct in6_addr src = local_ip ? *local_ip : in6addr_any;
+    if (!local_ip && neigh && dev_name && !strcmp(dev_name, neigh->dev_name)) {
+        src = neigh->local_ip;
     }
 
+    if (complete && !eth_addr_equals(neigh->mac, mac)) {
+        tnl_neigh_delete(neigh);
+        neigh = NULL;
+        complete = false;
+    }
+
+    bool insert = !neigh;
     if (insert) {
         neigh = xmalloc(sizeof *neigh);
-
         neigh->ip = *dst;
         ovs_strlcpy(neigh->br_name, name, sizeof neigh->br_name);
+        neigh->dev_name[0] = '\0';
+        neigh->local_ip = in6addr_any;
+        ovs_list_init(&neigh->refresh_node);
+    } else {
+        tnl_neigh_cancel_refresh(neigh);
     }
 
-    neigh->mac = mac;
-    atomic_store_explicit(&neigh->expires,
-                          time_msec() + tnl_neigh_get_aging(),
-                          memory_order_release);
-    atomic_store_explicit(&neigh->complete, true, memory_order_release);
-
-    if (insert) {
-        cmap_insert(&table, &neigh->cmap_node, tnl_neigh_hash(&neigh->ip));
+    if (dev_name && dev_name[0]) {
+        ovs_strlcpy(neigh->dev_name, dev_name, sizeof neigh->dev_name);
+        neigh->local_ip = src;
+    }
+    atomic_store_relaxed(&neigh->expires, expires);
+    neigh->last_attempt = LLONG_MIN;
+    long long window = tnl_neigh_refresh_window(tnl_neigh_get_retrans_time());
+    tnl_neigh_schedule(expires - window);
+
+    if (!complete) {
+        neigh->mac = mac;
+        /* Lockless readers can use the MAC once they see a complete entry. */
+        atomic_store_explicit(&neigh->complete, true, memory_order_release);
+        if (insert) {
+            cmap_insert(&table, &neigh->cmap_node, tnl_neigh_hash(dst));
+        }
     }
-
     ovs_mutex_unlock(&mutex);
-    seq_change(tnl_conf_seq);
-}
 
-static void
-tnl_arp_set(const char name[IFNAMSIZ], ovs_be32 dst,
-            const struct eth_addr mac)
-{
-    struct in6_addr dst6 = in6_addr_mapped_ipv4(dst);
-    tnl_neigh_set(name, &dst6, mac);
+    if (!complete) {
+        seq_change(tnl_conf_seq);
+    }
 }
 
 static int
 tnl_arp_snoop(const struct flow *flow, struct flow_wildcards *wc,
-              const char name[IFNAMSIZ], bool allow_update)
+              const char name[IFNAMSIZ], const char dev_name[IFNAMSIZ],
+              bool allow_update)
 {
     /* Snoop normal ARP replies and gratuitous ARP requests/replies only */
     if (!is_arp(flow)
@@ -258,14 +308,19 @@ tnl_arp_snoop(const struct flow *flow, struct 
flow_wildcards *wc,
     memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src);
 
     if (allow_update) {
-        tnl_arp_set(name, flow->nw_src, flow->arp_sha);
+        struct in6_addr dst = in6_addr_mapped_ipv4(flow->nw_src);
+        struct in6_addr local_ip = in6_addr_mapped_ipv4(flow->nw_dst);
+
+        tnl_neigh_set(name, dev_name, &dst, flow->arp_sha,
+                      flow->nw_src == flow->nw_dst ? NULL : &local_ip);
     }
     return 0;
 }
 
 static int
 tnl_nd_snoop(const struct flow *flow, struct flow_wildcards *wc,
-             const char name[IFNAMSIZ], bool allow_update)
+             const char name[IFNAMSIZ], const char dev_name[IFNAMSIZ],
+             bool allow_update)
 {
     if (!is_nd(flow, wc) || flow->tp_src != htons(ND_NEIGHBOR_ADVERT)) {
         return EINVAL;
@@ -285,36 +340,70 @@ tnl_nd_snoop(const struct flow *flow, struct 
flow_wildcards *wc,
     memset(&wc->masks.nd_target, 0xff, sizeof wc->masks.nd_target);
 
     if (allow_update) {
-        tnl_neigh_set(name, &flow->nd_target, flow->arp_tha);
+        tnl_neigh_set(name, dev_name, &flow->nd_target, flow->arp_tha,
+                      ipv6_addr_is_multicast(&flow->ipv6_dst)
+                      ? NULL : &flow->ipv6_dst);
     }
     return 0;
 }
 
 int
 tnl_neigh_snoop(const struct flow *flow, struct flow_wildcards *wc,
-                const char name[IFNAMSIZ], bool allow_update)
+                const char name[IFNAMSIZ], const char dev_name[IFNAMSIZ],
+                bool allow_update)
 {
     int res;
-    res = tnl_arp_snoop(flow, wc, name, allow_update);
+    res = tnl_arp_snoop(flow, wc, name, dev_name, allow_update);
     if (res != EINVAL) {
         return res;
     }
-    return tnl_nd_snoop(flow, wc, name, allow_update);
+    return tnl_nd_snoop(flow, wc, name, dev_name, allow_update);
 }
 
 void
 tnl_neigh_cache_run(void)
 {
     struct tnl_neigh_entry *neigh;
+    long long wakeup = LLONG_MAX;
+    long long now = time_msec();
+    long long scheduled;
+    long long refresh_window;
+    uint32_t retrans_time;
     bool changed = false;
 
+    atomic_read_relaxed(&next_event, &scheduled);
+    if (scheduled > now) {
+        return;
+    }
+
     ovs_mutex_lock(&mutex);
+    retrans_time = tnl_neigh_get_retrans_time();
+    refresh_window = tnl_neigh_refresh_window(retrans_time);
     CMAP_FOR_EACH(neigh, cmap_node, &table) {
-        if (tnl_neigh_expired(neigh)) {
+        long long expires;
+
+        atomic_read_relaxed(&neigh->expires, &expires);
+        if (expires <= now) {
             tnl_neigh_delete(neigh);
             changed = true;
+            continue;
+        }
+
+        if (tnl_neigh_is_complete(neigh) && retrans_time
+            && ovs_list_is_empty(&neigh->refresh_node)) {
+            long long probe_at = neigh->last_attempt == LLONG_MIN
+                                 ? expires - refresh_window
+                                 : neigh->last_attempt + retrans_time;
+
+            if (probe_at <= now) {
+                ovs_list_push_back(&refresh_list, &neigh->refresh_node);
+            } else {
+                expires = MIN(expires, probe_at);
+            }
         }
+        wakeup = MIN(wakeup, expires);
     }
+    atomic_store_relaxed(&next_event, wakeup);
     ovs_mutex_unlock(&mutex);
 
     if (changed) {
@@ -322,6 +411,52 @@ tnl_neigh_cache_run(void)
     }
 }
 
+/* Dequeues a probe with the interface and local address from learning.
+ * Returns false if no refresh is pending. */
+bool
+tnl_neigh_get_refresh(char br_name[IFNAMSIZ], char dev_name[IFNAMSIZ],
+                      struct in6_addr *dst, struct in6_addr *local_ip)
+    OVS_EXCLUDED(mutex)
+{
+    struct tnl_neigh_entry *neigh;
+    bool found = false;
+
+    ovs_mutex_lock(&mutex);
+    while (!ovs_list_is_empty(&refresh_list)) {
+        neigh = CONTAINER_OF(ovs_list_pop_front(&refresh_list),
+                             struct tnl_neigh_entry, refresh_node);
+        ovs_list_init(&neigh->refresh_node);
+        if (tnl_neigh_expired(neigh)) {
+            continue;
+        }
+
+        /* Space retries from the attempt, even if the probe waited in the
+         * queue or the learned interface is temporarily unavailable. */
+        neigh->last_attempt = time_msec();
+        tnl_neigh_schedule(neigh->last_attempt + tnl_neigh_get_retrans_time());
+        ovs_strlcpy(br_name, neigh->br_name, IFNAMSIZ);
+        ovs_strlcpy(dev_name, neigh->dev_name, IFNAMSIZ);
+        *dst = neigh->ip;
+        *local_ip = neigh->local_ip;
+        found = true;
+        break;
+    }
+    ovs_mutex_unlock(&mutex);
+
+    return found;
+}
+
+void
+tnl_neigh_cache_wait(void)
+{
+    long long wakeup;
+
+    atomic_read_relaxed(&next_event, &wakeup);
+    if (wakeup != LLONG_MAX) {
+        poll_timer_wait_until(wakeup);
+    }
+}
+
 void
 tnl_neigh_flush(const char br_name[IFNAMSIZ])
 {
@@ -392,17 +527,25 @@ tnl_neigh_cache_aging(struct unixctl_conn *conn, int argc,
         return;
     }
 
-    atomic_store_explicit(&neigh_aging, aging, memory_order_release);
-    new_exp = time_msec() + aging;
+    if (aging == tnl_neigh_get_aging()) {
+        unixctl_command_reply(conn, "OK");
+        return;
+    }
 
+    ovs_mutex_lock(&mutex);
+    atomic_store_relaxed(&neigh_aging, aging);
+    new_exp = time_msec() + aging;
     CMAP_FOR_EACH (neigh, cmap_node, &table) {
-        atomic_read_explicit(&neigh->expires, &curr_exp,
-                             memory_order_acquire);
+        atomic_read_relaxed(&neigh->expires, &curr_exp);
         if (new_exp < curr_exp) {
-            atomic_store_explicit(&neigh->expires, new_exp,
-                                  memory_order_release);
+            atomic_store_relaxed(&neigh->expires, new_exp);
         }
+        tnl_neigh_cancel_refresh(neigh);
     }
+    if (!cmap_is_empty(&table)) {
+        tnl_neigh_schedule(time_msec());
+    }
+    ovs_mutex_unlock(&mutex);
 
     unixctl_command_reply(conn, "OK");
 }
@@ -434,21 +577,28 @@ tnl_neigh_cache_retrans_time(struct unixctl_conn *conn, 
int argc,
         return;
     }
 
-    atomic_store_explicit(&neigh_retrans_time, retrans_time,
-                          memory_order_release);
-    new_exp = time_msec() + retrans_time;
+    if (retrans_time == tnl_neigh_get_retrans_time()) {
+        unixctl_command_reply(conn, "OK");
+        return;
+    }
 
+    ovs_mutex_lock(&mutex);
+    atomic_store_relaxed(&neigh_retrans_time, retrans_time);
+    new_exp = time_msec() + retrans_time;
     CMAP_FOR_EACH (neigh, cmap_node, &table) {
-        if (tnl_neigh_is_complete(neigh)) {
-            continue;
+        atomic_read_relaxed(&neigh->expires, &curr_exp);
+        if (!tnl_neigh_is_complete(neigh) && new_exp < curr_exp) {
+            atomic_store_relaxed(&neigh->expires, new_exp);
         }
-        atomic_read_explicit(&neigh->expires, &curr_exp,
-                             memory_order_acquire);
-        if (new_exp < curr_exp) {
-            atomic_store_explicit(&neigh->expires, new_exp,
-                                  memory_order_release);
+        tnl_neigh_cancel_refresh(neigh);
+        if (!retrans_time) {
+            neigh->last_attempt = LLONG_MIN;
         }
     }
+    if (!cmap_is_empty(&table)) {
+        tnl_neigh_schedule(time_msec());
+    }
+    ovs_mutex_unlock(&mutex);
 
     unixctl_command_reply(conn, "OK");
 }
@@ -488,7 +638,7 @@ tnl_neigh_cache_add(struct unixctl_conn *conn, int argc 
OVS_UNUSED,
         return;
     }
 
-    tnl_neigh_set(br_name, &ip6, mac);
+    tnl_neigh_set(br_name, NULL, &ip6, mac, NULL);
     unixctl_command_reply(conn, "OK");
 }
 
@@ -519,7 +669,10 @@ tnl_neigh_cache_show(struct unixctl_conn *conn, int argc 
OVS_UNUSED,
                           neigh->br_name);
         }
         if (tnl_neigh_expired(neigh)) {
-            ds_put_format(&ds, " STALE");
+            ds_put_cstr(&ds, " STALE");
+        } else if (neigh->last_attempt != LLONG_MIN
+                   || !ovs_list_is_empty(&neigh->refresh_node)) {
+            ds_put_cstr(&ds, " REFRESHING");
         }
         ds_put_char(&ds, '\n');
 
@@ -534,6 +687,7 @@ tnl_neigh_cache_init(void)
 {
     atomic_init(&neigh_aging, NEIGH_ENTRY_DEFAULT_IDLE_TIME_MS);
     atomic_init(&neigh_retrans_time, NEIGH_ENTRY_LOOKUP_RETRANS_TIME);
+    atomic_init(&next_event, LLONG_MAX);
     unixctl_command_register("tnl/arp/show", "", 0, 0,
                              tnl_neigh_cache_show, NULL);
     unixctl_command_register("tnl/arp/set", "BRIDGE IP MAC", 3, 3,
diff --git a/lib/tnl-neigh-cache.h b/lib/tnl-neigh-cache.h
index e16155b4d..3cfca88eb 100644
--- a/lib/tnl-neigh-cache.h
+++ b/lib/tnl-neigh-cache.h
@@ -32,13 +32,18 @@
 #include "util.h"
 
 int tnl_neigh_snoop(const struct flow *flow, struct flow_wildcards *wc,
+                    const char br_name[IFNAMSIZ],
                     const char dev_name[IFNAMSIZ], bool allow_update);
-void tnl_neigh_set(const char name[IFNAMSIZ], const struct in6_addr *dst,
-                   const struct eth_addr mac);
+void tnl_neigh_set(const char name[IFNAMSIZ], const char dev_name[IFNAMSIZ],
+                   const struct in6_addr *dst, const struct eth_addr mac,
+                   const struct in6_addr *local_ip);
 int tnl_neigh_lookup(const char dev_name[IFNAMSIZ], const struct in6_addr *dst,
                      struct eth_addr *mac, bool insert_partial);
 void tnl_neigh_cache_init(void);
 void tnl_neigh_cache_run(void);
+bool tnl_neigh_get_refresh(char br_name[IFNAMSIZ], char dev_name[IFNAMSIZ],
+                           struct in6_addr *dst, struct in6_addr *local_ip);
+void tnl_neigh_cache_wait(void);
 void tnl_neigh_flush(const char dev_name[IFNAMSIZ]);
 
 #endif
diff --git a/ofproto/ofproto-dpif-xlate-cache.c 
b/ofproto/ofproto-dpif-xlate-cache.c
index cb37e2462..ac170fba4 100644
--- a/ofproto/ofproto-dpif-xlate-cache.c
+++ b/ofproto/ofproto-dpif-xlate-cache.c
@@ -43,7 +43,6 @@
 #include "openvswitch/vlog.h"
 #include "ovs-router.h"
 #include "packets.h"
-#include "tnl-neigh-cache.h"
 #include "util.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_xlate_cache);
@@ -92,8 +91,6 @@ void
 xlate_push_stats_entry(struct xc_entry *entry,
                        struct dpif_flow_stats *stats, bool offloaded)
 {
-    struct eth_addr dmac;
-
     switch (entry->type) {
     case XC_TABLE:
         ofproto_dpif_credit_table_stats(entry->table.ofproto,
@@ -149,11 +146,6 @@ xlate_push_stats_entry(struct xc_entry *entry,
         group_dpif_credit_stats(entry->group.group, entry->group.bucket,
                                 stats);
         break;
-    case XC_TNL_NEIGH:
-        /* Lookup neighbor to avoid timeout. */
-        tnl_neigh_lookup(entry->tnl_neigh_cache.br_name,
-                         &entry->tnl_neigh_cache.d_ipv6, &dmac, false);
-        break;
     case XC_TUNNEL_HEADER:
         if (entry->tunnel_hdr.operation == ADD) {
             stats->n_bytes += stats->n_packets * entry->tunnel_hdr.hdr_size;
@@ -241,8 +233,6 @@ xlate_cache_clear_entry(struct xc_entry *entry)
     case XC_GROUP:
         ofproto_group_unref(&entry->group.group->up);
         break;
-    case XC_TNL_NEIGH:
-        break;
     case XC_TUNNEL_HEADER:
         break;
     default:
@@ -348,7 +338,6 @@ xlate_xcache_format(struct ds *s, const struct xlate_cache 
*xcache)
         case XC_LEARN:
         case XC_NORMAL:
         case XC_FIN_TIMEOUT:
-        case XC_TNL_NEIGH:
         case XC_TUNNEL_HEADER:
             break;
         }
diff --git a/ofproto/ofproto-dpif-xlate-cache.h 
b/ofproto/ofproto-dpif-xlate-cache.h
index e701734d7..adcd6856f 100644
--- a/ofproto/ofproto-dpif-xlate-cache.h
+++ b/ofproto/ofproto-dpif-xlate-cache.h
@@ -51,7 +51,6 @@ enum xc_type {
     XC_NORMAL,
     XC_FIN_TIMEOUT,      /* Calls back to ofproto. */
     XC_GROUP,
-    XC_TNL_NEIGH,
     XC_TUNNEL_HEADER,
 };
 
@@ -111,10 +110,6 @@ struct xc_entry {
             struct group_dpif *group;
             struct ofputil_bucket *bucket;
         } group;
-        struct {
-            char br_name[IFNAMSIZ];
-            struct in6_addr d_ipv6;
-        } tnl_neigh_cache;
         struct {
             struct ofproto_dpif *ofproto;
             struct ofproto_async_msg *am;
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 4e7d6fb40..baf878175 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -3758,57 +3758,158 @@ tnl_route_lookup_flow(const struct xlate_ctx *ctx,
     return -ENOENT;
 }
 
-static int
-compose_table_xlate(struct xlate_ctx *ctx, const struct xport *out_dev,
-                    struct dp_packet *packet)
+static void
+xlate_send_packet_pipeline(const struct xport *out_dev,
+                           struct dp_packet *packet, int depth, int resubmits)
 {
     struct xbridge *xbridge = out_dev->xbridge;
     ovs_version_t version = ofproto_dpif_get_tables_version(xbridge->ofproto);
     struct ofpact_output output;
     struct flow flow;
 
-    if (!xlate_resubmit_resource_check(ctx)) {
-        return 0;
-    }
-
     ofpact_init(&output.ofpact, OFPACT_OUTPUT, sizeof output);
     flow_extract(packet, &flow);
     flow.in_port.ofp_port = out_dev->ofp_port;
     output.port = OFPP_TABLE;
     output.max_len = 0;
 
-    return ofproto_dpif_execute_actions__(xbridge->ofproto, version, &flow,
-                                          NULL, &output.ofpact, sizeof output,
-                                          ctx->depth + 1, ctx->resubmits,
-                                          packet);
+    ofproto_dpif_execute_actions__(xbridge->ofproto, version, &flow, NULL,
+                                   &output.ofpact, sizeof output,
+                                   depth, resubmits, packet);
 }
 
 static void
-tnl_send_nd_request(struct xlate_ctx *ctx, const struct xport *out_dev,
-                     const struct eth_addr eth_src,
-                     struct in6_addr * ipv6_src, struct in6_addr * ipv6_dst)
+tnl_send_neigh_request(const struct xport *out_dev, struct eth_addr smac,
+                       const struct in6_addr *src, const struct in6_addr *dst,
+                       int depth, int resubmits)
 {
     struct dp_packet packet;
 
     dp_packet_init(&packet, 0);
-    compose_nd_ns(&packet, true, eth_src, eth_addr_zero, ipv6_src, ipv6_dst);
-    compose_table_xlate(ctx, out_dev, &packet);
+    if (IN6_IS_ADDR_V4MAPPED(dst)) {
+        compose_arp(&packet, ARP_OP_REQUEST, smac, eth_addr_zero, true,
+                    in6_addr_get_mapped_ipv4(src),
+                    in6_addr_get_mapped_ipv4(dst));
+    } else {
+        compose_nd_ns(&packet, true, smac, eth_addr_zero, src, dst);
+    }
+    xlate_send_packet_pipeline(out_dev, &packet, depth, resubmits);
     dp_packet_uninit(&packet);
 }
 
-static void
-tnl_send_arp_request(struct xlate_ctx *ctx, const struct xport *out_dev,
-                     const struct eth_addr eth_src,
-                     ovs_be32 ip_src, ovs_be32 ip_dst)
+/* With a null address, test whether the port has any IP address. */
+static bool
+xport_has_ip(const struct xport *port, const struct in6_addr *ip)
 {
-    struct dp_packet packet;
+    struct in6_addr *addrs, *masks;
+    int n_addrs;
 
-    dp_packet_init(&packet, 0);
-    compose_arp(&packet, ARP_OP_REQUEST,
-                eth_src, eth_addr_zero, true, ip_src, ip_dst);
+    if (netdev_get_addr_list(port->netdev, &addrs, &masks, &n_addrs)) {
+        return false;
+    }
 
-    compose_table_xlate(ctx, out_dev, &packet);
-    dp_packet_uninit(&packet);
+    bool found = false;
+    for (int i = 0; i < n_addrs; i++) {
+        if (!ip || ipv6_addr_equals(ip, &addrs[i])) {
+            found = true;
+            break;
+        }
+    }
+    free(addrs);
+    free(masks);
+    return found;
+}
+
+static struct xport *
+tnl_neigh_refresh_port(struct xbridge *xbridge, const char *learned_dev,
+                       const struct in6_addr *dst,
+                       const struct in6_addr *local_ip, struct in6_addr *src)
+{
+    struct xport *candidate = NULL;
+    char route_dev[IFNAMSIZ];
+    struct in6_addr gw;
+    struct xport *port;
+    int n_matches = 0;
+
+    /* A manual entry has no tunnel source or packet mark.  Prefer a direct
+     * route in the default lookup, then an unambiguous port on this bridge. */
+    bool routed = !learned_dev[0]
+                  && ovs_router_lookup(0, dst, route_dev, NULL, &gw)
+                  && (!ipv6_addr_is_set(&gw)
+                      || ipv6_addr_equals(&gw, &in6addr_v4mapped_any)
+                      || ipv6_addr_equals(&gw, dst));
+
+    HMAP_FOR_EACH (port, ofp_node, &xbridge->xports) {
+        const char *name = netdev_get_name(port->netdev);
+
+        if (learned_dev[0] && strcmp(name, learned_dev)) {
+            continue;
+        }
+
+        if (ovs_router_get_netdev_source_address(dst, name, src)) {
+            /* An off-prefix gateway can reply to the route's local source.
+             * Reuse that address only while it belongs to the learned port. */
+            if (!learned_dev[0] || !ipv6_addr_is_set(local_ip)
+                || !xport_has_ip(port, local_ip)) {
+                continue;
+            }
+            *src = *local_ip;
+        }
+        if (learned_dev[0] || (routed && !strcmp(route_dev, name))) {
+            return port;
+        }
+        candidate = port;
+        n_matches++;
+    }
+
+    return n_matches == 1 ? candidate : NULL;
+}
+
+/* Sends all tunnel neighbor refresh requests queued by the cache. */
+void
+xlate_tnl_neigh_refresh(void)
+{
+    struct xlate_cfg *xcfg = ovsrcu_get(struct xlate_cfg *, &xcfgp);
+    char br_name[IFNAMSIZ], out_dev_name[IFNAMSIZ];
+    struct in6_addr dst, local_ip;
+
+    if (!xcfg) {
+        return;
+    }
+
+    while (tnl_neigh_get_refresh(br_name, out_dev_name, &dst, &local_ip)) {
+        struct xbridge *xbridge = NULL;
+        char dst_s[INET6_ADDRSTRLEN];
+        struct xport *out_dev;
+        struct xbridge *iter;
+        struct eth_addr smac;
+        struct in6_addr src;
+
+        HMAP_FOR_EACH (iter, hmap_node, &xcfg->xbridges) {
+            if (!strcmp(iter->name, br_name)) {
+                xbridge = iter;
+                break;
+            }
+        }
+
+        if (!xbridge) {
+            continue;
+        }
+
+        ipv6_string_mapped(dst_s, &dst);
+        VLOG_DBG("refreshing tunnel neighbor %s on bridge %s",
+                 dst_s, xbridge->name);
+
+        out_dev = tnl_neigh_refresh_port(xbridge, out_dev_name, &dst,
+                                         &local_ip, &src);
+        if (!out_dev || netdev_get_etheraddr(out_dev->netdev, &smac)) {
+            VLOG_DBG("no output port for tunnel neighbor %s", dst_s);
+            continue;
+        }
+
+        COVERAGE_INC(xlate_actions_neigh_sent);
+        tnl_send_neigh_request(out_dev, smac, &src, &dst, 0, 0);
+    }
 }
 
 static void
@@ -3990,26 +4091,13 @@ native_tunnel_output(struct xlate_ctx *ctx, const 
struct xport *xport,
             nh_s_ip6 = s_ip6;
         }
 
-        if (d_ip) {
-            ovs_be32 nh_s_ip;
-
-            nh_s_ip = in6_addr_get_mapped_ipv4(&nh_s_ip6);
-            tnl_send_arp_request(ctx, out_dev, smac, nh_s_ip, d_ip);
-        } else {
-            tnl_send_nd_request(ctx, out_dev, smac, &nh_s_ip6, &d_ip6);
+        if (xlate_resubmit_resource_check(ctx)) {
+            tnl_send_neigh_request(out_dev, smac, &nh_s_ip6, &d_ip6,
+                                   ctx->depth + 1, ctx->resubmits);
         }
         return err;
     }
 
-    if (ctx->xin->xcache) {
-        struct xc_entry *entry;
-
-        entry = xlate_cache_add_entry(ctx->xin->xcache, XC_TNL_NEIGH);
-        ovs_strlcpy(entry->tnl_neigh_cache.br_name, out_dev->xbridge->name,
-                    sizeof entry->tnl_neigh_cache.br_name);
-        entry->tnl_neigh_cache.d_ipv6 = d_ip6;
-    }
-
     xlate_report(ctx, OFT_DETAIL, "tunneling from "ETH_ADDR_FMT" %s"
                  " to "ETH_ADDR_FMT" %s",
                  ETH_ADDR_ARGS(smac), ipv6_string_mapped(buf_sip6, &s_ip6),
@@ -4429,21 +4517,6 @@ is_neighbor_reply_correct(const struct xlate_ctx *ctx, 
const struct flow *flow)
     return ret;
 }
 
-static bool
-xport_has_ip(const struct xport *xport)
-{
-    struct in6_addr *ip_addr, *mask;
-    int n_in6 = 0;
-
-    if (netdev_get_addr_list(xport->netdev, &ip_addr, &mask, &n_in6)) {
-        n_in6 = 0;
-    } else {
-        free(ip_addr);
-        free(mask);
-    }
-    return n_in6 ? true : false;
-}
-
 static bool check_neighbor_reply(struct xlate_ctx *ctx, struct flow *flow)
 {
     if (flow->dl_type == htons(ETH_TYPE_ARP) ||
@@ -4468,28 +4541,36 @@ terminate_native_tunnel(struct xlate_ctx *ctx, const 
struct xport *xport,
      * Not performing a lookup in this case to avoid unwildcarding extra
      * flow fields (dl_dst). */
     if (ovs_native_tunneling_is_on(ctx->xbridge->ofproto)
-        && xport_has_ip(xport)) {
+        && xport_has_ip(xport, NULL)) {
         *tnl_port = tnl_port_map_lookup(flow, wc);
 
         /* If no tunnel port was found and it's about an ARP or ICMPv6 packet,
          * do tunnel neighbor snooping. */
         if (*tnl_port == ODPP_NONE &&
             (check_neighbor_reply(ctx, flow) || is_garp(flow, wc))) {
-            tnl_neigh_snoop(flow, wc, ctx->xbridge->name,
-                            ctx->xin->allow_side_effects);
+            if (!tnl_neigh_snoop(flow, wc, ctx->xbridge->name,
+                                 netdev_get_name(xport->netdev),
+                                 ctx->xin->allow_side_effects)) {
+                /* Each reply must renew the entry, including replies that
+                 * match an already installed datapath flow. */
+                ctx->xout->slow |= SLOW_ACTION;
+            }
         } else if (*tnl_port != ODPP_NONE &&
                    ctx->xin->allow_side_effects &&
                    dl_type_is_ip_any(flow->dl_type)) {
             struct eth_addr mac = flow->dl_src;
-            struct in6_addr s_ip6;
+            struct in6_addr s_ip6, d_ip6;
 
             if (flow->dl_type == htons(ETH_TYPE_IP)) {
                 in6_addr_set_mapped_ipv4(&s_ip6, flow->nw_src);
+                in6_addr_set_mapped_ipv4(&d_ip6, flow->nw_dst);
             } else {
                 s_ip6 = flow->ipv6_src;
+                d_ip6 = flow->ipv6_dst;
             }
 
-            tnl_neigh_set(ctx->xbridge->name, &s_ip6, mac);
+            tnl_neigh_set(ctx->xbridge->name, netdev_get_name(xport->netdev),
+                          &s_ip6, mac, &d_ip6);
         }
     }
 
diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h
index d973a634a..7b87ed73c 100644
--- a/ofproto/ofproto-dpif-xlate.h
+++ b/ofproto/ofproto-dpif-xlate.h
@@ -231,6 +231,7 @@ enum ofperr xlate_resume(struct ofproto_dpif *,
                          struct ofpbuf *odp_actions, enum slow_path_reason *,
                          struct flow *, struct xlate_cache *);
 int xlate_send_packet(const struct ofport_dpif *, bool oam, struct dp_packet 
*);
+void xlate_tnl_neigh_refresh(void);
 
 void xlate_mac_learning_update(const struct ofproto_dpif *ofproto,
                                ofp_port_t in_port, struct eth_addr dl_src,
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 0f0f71d14..57d1cb15f 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -69,6 +69,7 @@
 #include "simap.h"
 #include "smap.h"
 #include "timer.h"
+#include "tnl-neigh-cache.h"
 #include "tunnel.h"
 #include "unaligned.h"
 #include "unixctl.h"
@@ -361,6 +362,7 @@ static int
 type_run(const char *type)
 {
     struct dpif_backer *backer;
+    int error = 0;
 
     backer = shash_find_data(&all_dpif_backers, type);
     if (!backer) {
@@ -369,6 +371,10 @@ type_run(const char *type)
         return 0;
     }
 
+    if (dpif_supports_tnl_push_pop(backer->dpif)) {
+        tnl_neigh_cache_run();
+    }
+
     if (dpif_run(backer->dpif)) {
         backer->need_revalidate = REV_RECONFIGURE;
     }
@@ -379,21 +385,19 @@ type_run(const char *type)
      * and the configuration has now changed to "false", enable receiving
      * packets from the datapath. */
     if (!backer->recv_set_enable && !ofproto_get_flow_restore_wait()) {
-        int error;
-
-        backer->recv_set_enable = true;
-
-        error = dpif_recv_set(backer->dpif, backer->recv_set_enable);
-        if (error) {
-            VLOG_ERR("Failed to enable receiving packets in dpif.");
-            return error;
+        error = dpif_recv_set(backer->dpif, true);
+        if (!error) {
+            backer->recv_set_enable = true;
+            dpif_flow_flush(backer->dpif);
+            backer->need_revalidate = REV_RECONFIGURE;
         }
-        dpif_flow_flush(backer->dpif);
-        backer->need_revalidate = REV_RECONFIGURE;
     }
 
     if (backer->recv_set_enable) {
         udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
+        if (dpif_supports_tnl_push_pop(backer->dpif)) {
+            xlate_tnl_neigh_refresh();
+        }
     }
 
     if (recheck_support_explicit_drop_action(backer)) {
@@ -525,7 +529,7 @@ type_run(const char *type)
     ct_zone_timeout_policy_sweep(backer);
     ct_zone_limits_commit(backer);
 
-    return 0;
+    return error;
 }
 
 /* Check for and handle port changes in 'backer''s dpif. */
@@ -674,6 +678,9 @@ type_wait(const char *type)
         return;
     }
 
+    if (dpif_supports_tnl_push_pop(backer->dpif)) {
+        tnl_neigh_cache_wait();
+    }
     dpif_wait(backer->dpif);
 }
 
@@ -5172,7 +5179,6 @@ ofproto_dpif_xcache_execute(struct ofproto_dpif *ofproto,
         case XC_MIRROR:
         case XC_NORMAL:
         case XC_GROUP:
-        case XC_TNL_NEIGH:
         case XC_TUNNEL_HEADER:
             xlate_push_stats_entry(entry, stats, false);
             break;
diff --git a/ofproto/ofproto-tnl-unixctl.man b/ofproto/ofproto-tnl-unixctl.man
index b2a401564..c63bdc9e7 100644
--- a/ofproto/ofproto-tnl-unixctl.man
+++ b/ofproto/ofproto-tnl-unixctl.man
@@ -52,13 +52,19 @@ the first matching rule will be selected for deletion.
 .
 .IP "\fBtnl/neigh/show\fR"
 .IP "\fBtnl/arp/show\fR"
-OVS builds ARP cache by snooping are messages. This command shows
-ARP cache table.
+Shows the tunnel neighbor cache learned from ARP and IPv6 Neighbor Discovery
+or configured with \fBtnl/neigh/set\fR.  An entry marked \fBREFRESHING\fR
+can still forward packets using its cached MAC while OVS tries to renew it.
+If the neighbor is not learned again, the entry expires at its original
+deadline.
 .
 .IP "\fBtnl/neigh/set\fR \fIbridge\fR \fIip\fR \fImac\fR"
 .IP "\fBtnl/arp/set\fR \fIbridge\fR \fIip\fR \fImac\fR"
 Adds or modifies an ARP cache entry in \fIbridge\fR, mapping \fIip\fR
-to \fImac\fR.
+to \fImac\fR.  When refreshing an entry without a learned interface, OVS
+looks up a direct route to \fIip\fR without a packet mark or source address.
+If the route does not identify an eligible port on \fIbridge\fR, OVS probes
+only when exactly one port on the bridge can reach the neighbor's subnet.
 .
 .IP "\fBtnl/neigh/flush\fR"
 .IP "\fBtnl/arp/flush\fR"
diff --git a/tests/tunnel-push-pop-ipv6.at b/tests/tunnel-push-pop-ipv6.at
index ec757f7d7..9e2f75440 100644
--- a/tests/tunnel-push-pop-ipv6.at
+++ b/tests/tunnel-push-pop-ipv6.at
@@ -373,7 +373,7 @@ AT_CHECK([cat p0.pcap.txt | grep 
93aa55aa55000086dd6000000000203aff2001cafe | un
 ])
 
 dnl Set the aging time to 5 seconds
-AT_CHECK([ovs-appctl tnl/neigh/retrans_time 5000], [0], [OK
+AT_CHECK([ovs-appctl tnl/neigh/retrans_time 1000], [0], [OK
 ])
 AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
 ])
@@ -382,6 +382,9 @@ dnl Read the current aging time
 AT_CHECK([ovs-appctl tnl/neigh/aging], [0], [5
 ])
 
+dnl Freeze time so deadlines depend only on explicit time/warp calls.
+AT_CHECK([ovs-appctl time/stop])
+
 dnl Add an entry
 AT_CHECK([ovs-appctl tnl/neigh/set br0 2001:cafe::92 aa:bb:cc:00:00:01], [0], 
[OK
 ])
@@ -391,6 +394,55 @@ AT_CHECK([ovs-appctl tnl/neigh/show | grep br0 | sort], 
[0], [dnl
 2001:cafe::93                                                     br0 
INCOMPLETE
 ])
 
+dnl Refresh early enough to retry twice before expiration.
+AT_CHECK([ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l > nd_count])
+ovs-appctl time/warp 2500
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l` \
+                    -gt `cat nd_count`])
+
+dnl The cached MAC remains usable while the refresh is outstanding.
+AT_CHECK([ovs-appctl tnl/neigh/show | grep br0 | sort], [0], [dnl
+2001:cafe::92                                 aa:bb:cc:00:00:01   br0 
REFRESHING
+])
+
+dnl Forward a packet through the tunnel while the refresh is unanswered.
+AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER "output:2" 
'50540000000a5054000000091235'])
+OVS_WAIT_UNTIL([ovs-pcap p0.pcap | grep -q 
'^aabbcc000001.*50540000000a5054000000091235'])
+
+dnl A lost first probe is retried before the original expiration.
+AT_CHECK([ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l > nd_count])
+ovs-appctl time/warp 1000
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l` \
+                    -gt `cat nd_count`])
+
+dnl A second lost probe gets one more attempt before expiration.
+AT_CHECK([ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l > nd_count])
+ovs-appctl time/warp 1000
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l` \
+                    -gt `cat nd_count`])
+
+dnl A reply renews the entry and allows another refresh cycle.
+reply='in_port(1),eth(src=aa:bb:cc:00:00:01,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:cafe::92,dst=2001:cafe::88,label=0,proto=58,tclass=0,hlimit=255,frag=no),icmpv6(type=136,code=0),nd(target=2001:cafe::92,sll=00:00:00:00:00:00,tll=aa:bb:cc:00:00:01)'
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 "$reply"])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -q 'aa:bb:cc:00:00:01   
br0$'])
+AT_CHECK([ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l > nd_count])
+ovs-appctl time/warp 4000
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 92aa55aa55000086dd | wc -l` \
+                    -gt `cat nd_count`])
+
+AT_CHECK([ovs-appctl tnl/neigh/show | grep br0 | sort], [0], [dnl
+2001:cafe::92                                 aa:bb:cc:00:00:01   br0 
REFRESHING
+])
+
+dnl Forward beyond the original deadline after the reply renewed the entry.
+AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER "output:2" 
'50540000000a5054000000091236'])
+OVS_WAIT_UNTIL([ovs-pcap p0.pcap | grep -q 
'^aabbcc000001.*50540000000a5054000000091236'])
+
+dnl The same reply must renew the entry even after its flow is installed.
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 "$reply"])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -q 'aa:bb:cc:00:00:01   
br0$'])
+
+dnl An unanswered refresh does not keep the entry past its expiration.
 ovs-appctl time/warp 5000
 
 dnl Check the entry has been removed
@@ -957,3 +1009,82 @@ AT_CHECK([grep -q "GENEVE_ACT" stdout])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([tunnel_push_pop_ipv6 - neighbor changes revalidate cached flows])
+
+OVS_VSWITCHD_START([add-port br0 p0 \
+                    -- set Interface p0 type=dummy ofport_request=1])
+AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy \
+          -- add-port int-br t1 -- set Interface t1 type=vxlan \
+             options:remote_ip=2001:cafe::92 ofport_request=2])
+AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:cafe::88/64], [0], [OK
+])
+dnl Avoid NORMAL learning so it cannot independently trigger revalidation.
+AT_CHECK([ovs-ofctl add-flow br0 'in_port=LOCAL,actions=1'])
+AT_CHECK([ovs-ofctl add-flow br0 'in_port=1,actions=LOCAL'])
+AT_CHECK([ovs-ofctl add-flow int-br 'in_port=LOCAL,actions=2'])
+AT_CHECK([ovs-vsctl set Interface p0 options:tx_pcap=p0.pcap])
+AT_CHECK([ovs-appctl time/stop])
+AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
+])
+AT_CHECK([ovs-appctl tnl/neigh/set br0 2001:cafe::92 aa:bb:cc:00:00:01], [0], 
[OK
+])
+
+packet=50540000000a5054000000091235
+dnl Install a datapath flow and exercise its cached action.
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:01'])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000001.*$packet"` -eq 
2])
+OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-flows | grep -q 
'packets:1,.*tnl_push.*dst=aa:bb:cc:00:00:01'])
+
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+dnl The existing flow still forwards while the proactive probe is unanswered.
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000001.*$packet"` -eq 
3])
+AT_CHECK([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:01'])
+
+dnl A reply with a changed MAC must invalidate the already-cached action.
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 
'eth(src=aa:bb:cc:00:00:02,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:cafe::92,dst=2001:cafe::88,label=0,proto=58,tclass=0,hlimit=255,frag=no),icmpv6(type=136,code=0),nd(target=2001:cafe::92,sll=00:00:00:00:00:00,tll=aa:bb:cc:00:00:02)'])
+OVS_WAIT_UNTIL([test `ovs-appctl dpctl/dump-flows | grep -c 
'tnl_push.*dst=aa:bb:cc:00:00:01'` -eq 0])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:02'])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000002.*$packet"` -eq 
2])
+
+dnl Keep hitting the flow throughout the next three unanswered probes.
+dnl Transmitting packets must not extend the neighbor's learned lifetime.
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000002.*$packet"` -eq 
5])
+AT_CHECK([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:02'])
+AT_CHECK([ovs-appctl time/warp 500], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-appctl dpctl/dump-flows | grep -c 
'tnl_push.*dst=aa:bb:cc:00:00:02'` -eq 0])
+drops=drop_action_tunnel_neigh_cache_miss
+AT_CHECK([ovs-appctl coverage/read-counter $drops > before])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-appctl coverage/read-counter $drops` -gt `cat 
before`])
+AT_CHECK([ovs-pcap p0.pcap | grep -c "^aabbcc000002.*$packet"], [0], [5
+])
+
+dnl Cold resolution and refresh must use the same local address for a
+dnl reachable gateway outside the interface prefix.  Revalidating the new
+dnl route can send the first probe before the packet-out.
+src=2001cafe000000000000000000000088
+target=20010db8000100000000000000000001
+gateway_ns="${src}ff0200000000000000000001ff0000018700............${target}"
+AT_CHECK([ovs-appctl ovs/route/add 2001:cafe::92/128 br0 2001:db8:1::1], [0], 
[OK
+])
+AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER output:2 
"$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "$gateway_ns"` -eq 1])
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 
'eth(src=aa:bb:cc:00:00:02,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:db8:1::1,dst=2001:cafe::88,label=0,proto=58,tclass=0,hlimit=255,frag=no),icmpv6(type=136,code=0),nd(target=2001:db8:1::1,sll=00:00:00:00:00:00,tll=aa:bb:cc:00:00:02)'])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -F '2001:db8:1::1 ' | grep -q 
'aa:bb:cc:00:00:02'])
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "$gateway_ns"` -eq 2])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
diff --git a/tests/tunnel-push-pop.at b/tests/tunnel-push-pop.at
index ab393cfc7..5ee88e94b 100644
--- a/tests/tunnel-push-pop.at
+++ b/tests/tunnel-push-pop.at
@@ -325,6 +325,9 @@ aging value cannot be less than retrans_time
 ovs-appctl: ovs-vswitchd: server returned an error
 ])
 
+AT_CHECK([ovs-appctl tnl/neigh/retrans_time 1000], [0], [OK
+])
+
 dnl Set the aging time to 5 seconds
 AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
 ])
@@ -333,9 +336,12 @@ dnl Read the current aging time
 AT_CHECK([ovs-appctl tnl/neigh/aging], [0], [5
 ])
 
-AT_CHECK([ovs-appctl tnl/neigh/retrans_time], [0], [5000
+AT_CHECK([ovs-appctl tnl/neigh/retrans_time], [0], [1000
 ])
 
+dnl Freeze time so deadlines depend only on explicit time/warp calls.
+AT_CHECK([ovs-appctl time/stop])
+
 dnl Add an entry
 AT_CHECK([ovs-appctl tnl/neigh/set br0 1.1.2.92 aa:bb:cc:00:00:01], [0], [OK
 ])
@@ -344,6 +350,69 @@ AT_CHECK([ovs-appctl tnl/neigh/show | grep br0 | sort], 
[0], [dnl
 1.1.2.92                                      aa:bb:cc:00:00:01   br0
 ])
 
+dnl Refresh early enough to retry twice before expiration.
+AT_CHECK([ovs-pcap p0.pcap | grep 101025c | wc -l > arp_count])
+ovs-appctl time/warp 2500
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 101025c | wc -l` \
+                    -gt `cat arp_count`])
+
+dnl The cached MAC remains usable while the refresh is outstanding.
+AT_CHECK([ovs-appctl tnl/neigh/show | grep br0 | sort], [0], [dnl
+1.1.2.92                                      aa:bb:cc:00:00:01   br0 
REFRESHING
+])
+
+dnl Forward a packet through the tunnel while the refresh is unanswered.
+AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER "output:2" 
'50540000000a5054000000091235'])
+OVS_WAIT_UNTIL([ovs-pcap p0.pcap | grep -q 
'^aabbcc000001.*50540000000a5054000000091235'])
+
+dnl A lost first probe is retried before the original expiration.
+AT_CHECK([ovs-pcap p0.pcap | grep 101025c | wc -l > arp_count])
+AT_CHECK([ovs-appctl time/warp 100], [0], [ignore])
+AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
+])
+AT_CHECK([ovs-appctl tnl/neigh/retrans_time 1000], [0], [OK
+])
+AT_CHECK([ovs-appctl time/warp 1], [0], [ignore])
+AT_CHECK([test `ovs-pcap p0.pcap | grep 101025c | wc -l` -eq `cat arp_count`])
+dnl A changed interval is measured from the last attempt.
+AT_CHECK([ovs-appctl tnl/neigh/retrans_time 1200], [0], [OK
+])
+AT_CHECK([ovs-appctl time/warp 1098], [0], [ignore])
+AT_CHECK([test `ovs-pcap p0.pcap | grep 101025c | wc -l` -eq `cat arp_count`])
+AT_CHECK([ovs-appctl time/warp 1], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 101025c | wc -l` \
+                    -gt `cat arp_count`])
+
+dnl A second lost probe gets one more attempt before expiration.
+AT_CHECK([ovs-pcap p0.pcap | grep 101025c | wc -l > arp_count])
+AT_CHECK([ovs-appctl tnl/neigh/retrans_time 1000], [0], [OK
+])
+ovs-appctl time/warp 1000
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 101025c | wc -l` \
+                    -gt `cat arp_count`])
+
+dnl A reply renews the entry and allows another refresh cycle.
+reply='recirc_id(0),in_port(1),eth(src=aa:bb:cc:00:00:01,dst=aa:55:aa:55:00:00),eth_type(0x0806),arp(sip=1.1.2.92,tip=1.1.2.88,op=2,sha=aa:bb:cc:00:00:01,tha=aa:55:aa:55:00:00)'
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 "$reply"])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -q 'aa:bb:cc:00:00:01   
br0$'])
+AT_CHECK([ovs-pcap p0.pcap | grep 101025c | wc -l > arp_count])
+ovs-appctl time/warp 4000
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep 101025c | wc -l` \
+                    -gt `cat arp_count`])
+
+AT_CHECK([ovs-appctl tnl/neigh/show | grep br0 | sort], [0], [dnl
+1.1.2.92                                      aa:bb:cc:00:00:01   br0 
REFRESHING
+])
+
+dnl Forward beyond the original deadline after the reply renewed the entry.
+AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER "output:2" 
'50540000000a5054000000091236'])
+OVS_WAIT_UNTIL([ovs-pcap p0.pcap | grep -q 
'^aabbcc000001.*50540000000a5054000000091236'])
+
+dnl The same reply must renew the entry even after its flow is installed.
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 "$reply"])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -q 'aa:bb:cc:00:00:01   
br0$'])
+
+dnl An unanswered refresh does not keep the entry past its expiration.
 ovs-appctl time/warp 5000
 
 dnl Check the entry has been removed
@@ -1304,6 +1373,42 @@ 
ipv4(src=1.1.2.88,dst=1.1.2.92,proto=47,tos=0,ttl=64,frag=0x4000),dnl
 gre((flags=0x0,proto=0x6558))),out_port(2)),1
 ])
 
+dnl Refresh uses the non-local IP interface, including for manual entries.
+AT_CHECK([ovs-appctl time/stop])
+AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
+])
+AT_CHECK([ovs-vsctl set Interface p0 options:tx_pcap=refresh.pcap])
+AT_CHECK([ovs-appctl time/warp 3000], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-pcap refresh.pcap | wc -l` -eq 1])
+AT_CHECK([ovs-pcap refresh.pcap], [0], [dnl
+ffffffffffffaa55aa55000308060001080006040001aa55aa550003010102580000000000000101025c
+])
+AT_CHECK([ovs-appctl tnl/neigh/flush], [0], [OK
+])
+AT_CHECK([ovs-appctl tnl/neigh/set br0 1.1.2.92 f8:bc:12:44:34:b6], [0], [OK
+])
+AT_CHECK([ovs-appctl time/warp 3000], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-pcap refresh.pcap | wc -l` -eq 2])
+AT_CHECK([ovs-pcap refresh.pcap | sort -u], [0], [dnl
+ffffffffffffaa55aa55000308060001080006040001aa55aa550003010102580000000000000101025c
+])
+
+dnl Relearn on vtep0, then remove it.  Even though br0 can address the
+dnl neighbor, refresh must preserve the learned interface and aging deadline.
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 'in_port(1),dnl
+  eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:03),eth_type(0x0806),dnl
+  
arp(sip=1.1.2.92,tip=1.1.2.88,op=2,sha=f8:bc:12:44:34:b6,tha=aa:55:aa:55:00:03)'])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -q 'f8:bc:12:44:34:b6   
br0$'])
+AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 1.1.2.89/24], [0], [OK
+])
+AT_CHECK([ovs-vsctl del-port br0 vtep0])
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -q 'f8:bc:12:44:34:b6   br0 
REFRESHING$'])
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+OVS_WAIT_WHILE([ovs-appctl tnl/neigh/show | grep -qF 1.1.2.92])
+AT_CHECK([ovs-pcap refresh.pcap | grep -c '0101025c$'], [0], [2
+])
+
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
@@ -1614,5 +1719,175 @@ AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 
'in_port(int-br),dnl
      -> tunneling to 1.1.2.91 via br1
 ])
 
+dnl Refresh must retain each learned interface despite the source-based routes.
+dnl Equal aging/retrans timers must leave a quiet period after learning.
+AT_CHECK([ovs-appctl time/stop])
+AT_CHECK([ovs-appctl tnl/neigh/aging 2], [0], [OK
+])
+AT_CHECK([ovs-appctl tnl/neigh/retrans_time 2000], [0], [OK
+])
+AT_CHECK([ovs-vsctl set Interface p0 options:tx_pcap=refresh0.pcap \
+                   -- set Interface p1 options:tx_pcap=refresh1.pcap])
+AT_CHECK([ovs-appctl time/warp 1], [0], [ignore])
+AT_CHECK([ovs-pcap refresh0.pcap | wc -l], [0], [0
+])
+AT_CHECK([ovs-pcap refresh1.pcap | wc -l], [0], [0
+])
+AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-pcap refresh0.pcap | wc -l` -eq 1])
+OVS_WAIT_UNTIL([test `ovs-pcap refresh1.pcap | wc -l` -eq 1])
+AT_CHECK([ovs-pcap refresh0.pcap], [0], [dnl
+ffffffffffffaa55aa55000008060001080006040001aa55aa550000010102500000000000000101025a
+])
+AT_CHECK([ovs-pcap refresh1.pcap | grep -q '010102510000000000000101025b$'])
+dnl Renew the same MAC without causing an immediate new probe.
+AT_CHECK([ovs-appctl tnl/neigh/set br0 1.1.2.90 f8:bc:12:44:34:b0], [0], [OK
+])
+AT_CHECK([ovs-appctl time/warp 1], [0], [ignore])
+AT_CHECK([ovs-pcap refresh0.pcap | wc -l], [0], [1
+])
+AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-pcap refresh0.pcap | wc -l` -eq 2])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([tunnel_push_pop - neighbor changes revalidate cached flows])
+
+OVS_VSWITCHD_START([add-port br0 p0 \
+                    -- set Interface p0 type=dummy ofport_request=1])
+AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy \
+          -- add-port int-br t1 -- set Interface t1 type=vxlan \
+             options:remote_ip=1.1.2.92 ofport_request=2])
+AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 1.1.2.88/24], [0], [OK
+])
+dnl Avoid NORMAL learning so it cannot independently trigger revalidation.
+AT_CHECK([ovs-ofctl add-flow br0 'in_port=LOCAL,actions=1'])
+AT_CHECK([ovs-ofctl add-flow br0 'in_port=1,actions=LOCAL'])
+AT_CHECK([ovs-ofctl add-flow int-br 'in_port=LOCAL,actions=2'])
+AT_CHECK([ovs-vsctl set Interface p0 options:tx_pcap=p0.pcap])
+AT_CHECK([ovs-appctl time/stop])
+AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
+])
+AT_CHECK([ovs-appctl tnl/neigh/set br0 1.1.2.92 aa:bb:cc:00:00:01], [0], [OK
+])
+
+packet=50540000000a5054000000091235
+dnl Install a datapath flow and exercise its cached action.
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:01'])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000001.*$packet"` -eq 
2])
+OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-flows | grep -q 
'packets:1,.*tnl_push.*dst=aa:bb:cc:00:00:01'])
+
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+dnl The existing flow still forwards while the proactive probe is unanswered.
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000001.*$packet"` -eq 
3])
+AT_CHECK([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:01'])
+
+dnl A reply with a changed MAC must invalidate the already-cached action.
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 
'eth(src=aa:bb:cc:00:00:02,dst=aa:55:aa:55:00:00),eth_type(0x0806),arp(sip=1.1.2.92,tip=1.1.2.88,op=2,sha=aa:bb:cc:00:00:02,tha=aa:55:aa:55:00:00)'])
+OVS_WAIT_UNTIL([test `ovs-appctl dpctl/dump-flows | grep -c 
'tnl_push.*dst=aa:bb:cc:00:00:01'` -eq 0])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:02'])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000002.*$packet"` -eq 
2])
+
+dnl Keep hitting the flow throughout the next three unanswered probes.
+dnl Transmitting packets must not extend the neighbor's learned lifetime.
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "^aabbcc000002.*$packet"` -eq 
5])
+AT_CHECK([ovs-appctl dpctl/dump-flows | grep -q 
'tnl_push.*dst=aa:bb:cc:00:00:02'])
+AT_CHECK([ovs-appctl time/warp 500], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-appctl dpctl/dump-flows | grep -c 
'tnl_push.*dst=aa:bb:cc:00:00:02'` -eq 0])
+drops=drop_action_tunnel_neigh_cache_miss
+AT_CHECK([ovs-appctl coverage/read-counter $drops > before])
+AT_CHECK([ovs-appctl netdev-dummy/receive int-br "$packet"])
+OVS_WAIT_UNTIL([test `ovs-appctl coverage/read-counter $drops` -gt `cat 
before`])
+AT_CHECK([ovs-pcap p0.pcap | grep -c "^aabbcc000002.*$packet"], [0], [5
+])
+
+dnl Cold resolution and refresh must use the same local address for a
+dnl reachable gateway outside the interface prefix.  Revalidating the new
+dnl route can send the first probe before the packet-out.
+gateway_arp='08060001080006040001aa55aa55000001010258000000000000c6336401$'
+AT_CHECK([ovs-appctl ovs/route/add 1.1.2.92/32 br0 198.51.100.1], [0], [OK
+])
+AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out int-br CONTROLLER output:2 
"$packet"])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "$gateway_arp"` -eq 1])
+AT_CHECK([ovs-appctl netdev-dummy/receive p0 
'eth(src=aa:bb:cc:00:00:02,dst=aa:55:aa:55:00:00),eth_type(0x0806),arp(sip=198.51.100.1,tip=1.1.2.88,op=2,sha=aa:bb:cc:00:00:02,tha=aa:55:aa:55:00:00)'])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -F '198.51.100.1 ' | grep -q 
'aa:bb:cc:00:00:02'])
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+OVS_WAIT_UNTIL([test `ovs-pcap p0.pcap | grep -c "$gateway_arp"` -eq 2])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([tunnel_push_pop - neighbor refresh during flow restoration])
+
+OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy dnl
+                    ofport_request=1 options:tx_pcap=p0.pcap], [], [], [],
+                   [-- set Open_vSwitch . other_config:flow-restore-wait=true])
+AT_CHECK([ovs-ofctl add-flow br0 'in_port=LOCAL,actions=1'])
+AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 192.0.2.10/24], [0], [OK
+])
+AT_CHECK([ovs-appctl time/stop])
+AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
+])
+AT_CHECK([ovs-appctl tnl/neigh/set br0 192.0.2.91 aa:bb:cc:00:00:01], [0], [OK
+])
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+AT_CHECK([ovs-appctl tnl/neigh/set br0 192.0.2.92 aa:bb:cc:00:00:02], [0], [OK
+])
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+OVS_WAIT_UNTIL([ovs-appctl tnl/neigh/show | grep -q '192.0.2.92.*REFRESHING'])
+AT_CHECK([ovs-appctl tnl/neigh/show | grep -qF 192.0.2.91], [1])
+AT_CHECK([ovs-pcap p0.pcap])
+AT_CHECK([ovs-vsctl remove Open_vSwitch . other_config flow-restore-wait])
+OVS_WAIT_UNTIL([ovs-pcap p0.pcap | grep -q 'c000025c$'])
+AT_CHECK([ovs-pcap p0.pcap | wc -l], [0], [1
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([tunnel_push_pop - manual neighbors on overlapping VLANs])
+
+OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy dnl
+                    ofport_request=1 options:tx_pcap=p0.pcap])
+AT_CHECK([ovs-vsctl add-port br0 vtep10 -- set Interface vtep10 type=dummy 
ofport_request=10 dnl
+                 -- add-port br0 vtep20 -- set Interface vtep20 type=dummy 
ofport_request=20])
+AT_CHECK([ovs-appctl netdev-dummy/ip4addr vtep10 192.0.2.10/24], [0], [OK
+])
+AT_CHECK([ovs-appctl netdev-dummy/ip4addr vtep20 192.0.2.20/24], [0], [OK
+])
+AT_CHECK([ovs-ofctl add-flow br0 
'in_port=10,actions=mod_vlan_vid:10,output:1'])
+AT_CHECK([ovs-ofctl add-flow br0 
'in_port=20,actions=mod_vlan_vid:20,output:1'])
+AT_CHECK([ovs-appctl ovs/route/add 192.0.2.91/32 vtep10], [0], [OK
+])
+AT_CHECK([ovs-appctl ovs/route/add 192.0.2.92/32 vtep20], [0], [OK
+])
+dnl A route via another next hop cannot identify the neighbor's VLAN.
+AT_CHECK([ovs-appctl ovs/route/add 192.0.2.93/32 vtep10 192.0.2.1], [0], [OK
+])
+AT_CHECK([ovs-appctl time/stop])
+AT_CHECK([ovs-appctl tnl/neigh/aging 5], [0], [OK
+])
+for host in 91 92 93; do
+    AT_CHECK([ovs-appctl tnl/neigh/set br0 192.0.2.$host 
aa:bb:cc:00:00:$host], [0], [OK
+])
+done
+AT_CHECK([ovs-appctl time/warp 2500], [0], [ignore])
+OVS_WAIT_UNTIL([ovs-pcap p0.pcap | grep -q 
'8100000a0806.*c000020a000000000000c000025b$'])
+OVS_WAIT_UNTIL([ovs-pcap p0.pcap | grep -q 
'810000140806.*c0000214000000000000c000025c$'])
+AT_CHECK([ovs-pcap p0.pcap | wc -l], [0], [2
+])
+
 OVS_VSWITCHD_STOP
 AT_CLEANUP
-- 
2.56.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to