tnl-neigh-cache: check for arp expiration.
authorPravin B Shelar <pshelar@ovn.org>
Mon, 25 Apr 2016 22:58:33 +0000 (15:58 -0700)
committerPravin B Shelar <pshelar@ovn.org>
Tue, 10 May 2016 17:33:31 +0000 (10:33 -0700)
The neighbor entry expiry is only checked in dpif-poll
event handler, But in absence of any event we could keep
using arp entry forever. This patch changes it to check
expiration on each lookup.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
lib/tnl-neigh-cache.c

index d01ec7f..e571980 100644 (file)
@@ -73,6 +73,10 @@ tnl_neigh_lookup__(const char br_name[IFNAMSIZ], const struct in6_addr *dst)
     hash = tnl_neigh_hash(dst);
     CMAP_FOR_EACH_WITH_HASH (neigh, cmap_node, hash, &table) {
         if (ipv6_addr_equals(&neigh->ip, dst) && !strcmp(neigh->br_name, br_name)) {
+            if (neigh->expires <= time_now()) {
+                return NULL;
+            }
+
             neigh->expires = time_now() + NEIGH_ENTRY_DEFAULT_IDLE_TIME;
             return neigh;
         }
@@ -300,8 +304,12 @@ tnl_neigh_cache_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
         need_ws = INET6_ADDRSTRLEN - (ds.length - start_len);
         ds_put_char_multiple(&ds, ' ', need_ws);
 
-        ds_put_format(&ds, ETH_ADDR_FMT"   %s\n",
+        ds_put_format(&ds, ETH_ADDR_FMT"   %s",
                       ETH_ADDR_ARGS(neigh->mac), neigh->br_name);
+        if (neigh->expires <= time_now()) {
+            ds_put_format(&ds, " STALE");
+        }
+        ds_put_char(&ds, '\n');
 
     }
     ovs_mutex_unlock(&mutex);