]> git.puffer.fish Git - mirror/frr.git/commitdiff
* isis_dynh.c, isisd.h: Implement dynamic hostname cache cleanup.
authorhasso <hasso>
Wed, 28 Sep 2005 18:30:51 +0000 (18:30 +0000)
committerhasso <hasso>
Wed, 28 Sep 2005 18:30:51 +0000 (18:30 +0000)
* isis_lsp.c: Refresh dynamic hostname in the cache while refreshing
  topology LSP.

isisd/ChangeLog
isisd/isis_dynhn.c
isisd/isis_lsp.c
isisd/isisd.h

index 3abe3ae77557d143b51292ff0c95b80445d1ccfd..f69364c491da8ba82207f27563200f58b078dcd9 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-28 Hasso Tepper <hasso at quagga.net>
+
+       * isis_dynh.c, isisd.h: Implement dynamic hostname cache cleanup.
+       * isis_lsp.c: Refresh dynamic hostname in the cache while refreshing
+         topology LSP.
+
 2005-09-28 Hasso Tepper <hasso at quagga.net>
 
        * isis_lsp.c: Make topology generator generate TE TLVs if necessary.
index 68257ddce86a7bf6a61600d51e8772ae867cdeaa..13acae71f301599e8b842d0bcb852e446ed428e4 100644 (file)
@@ -30,6 +30,7 @@
 #include "stream.h"
 #include "command.h"
 #include "if.h"
+#include "thread.h"
 
 #include "isisd/dict.h"
 #include "isisd/isis_constants.h"
 #include "isisd/isis_constants.h"
 
 extern struct isis *isis;
+extern struct thread_master *master;
 extern struct host host;
 
 struct list *dyn_cache = NULL;
+static int dyn_cache_cleanup (struct thread *);
 
 void
 dyn_cache_init (void)
 {
   dyn_cache = list_new ();
-
+  THREAD_TIMER_ON (master, isis->t_dync_clean, dyn_cache_cleanup, NULL, 120);
   return;
 }
 
+static int
+dyn_cache_cleanup (struct thread *thread)
+{
+  struct listnode *node, *nnode;
+  struct isis_dynhn *dyn;
+  time_t now = time (NULL);
+
+  isis->t_dync_clean = NULL;
+
+  for (ALL_LIST_ELEMENTS (dyn_cache, node, nnode, dyn))
+    {
+      if ((now - dyn->refresh) < (MAX_AGE + 120))
+       continue;
+
+      list_delete_node (dyn_cache, node);
+      XFREE (MTYPE_ISIS_DYNHN, dyn);
+    }
+
+  THREAD_TIMER_ON (master, isis->t_dync_clean, dyn_cache_cleanup, NULL, 120);
+  return ISIS_OK;
+}
+
 struct isis_dynhn *
 dynhn_find_by_id (u_char * id)
 {
@@ -80,13 +105,13 @@ isis_dynhn_insert (u_char * id, struct hostname *hostname, int level)
       dyn->refresh = time (NULL);
       return;
     }
-  dyn = XMALLOC (MTYPE_ISIS_DYNHN, sizeof (struct isis_dynhn));
+  dyn = XCALLOC (MTYPE_ISIS_DYNHN, sizeof (struct isis_dynhn));
   if (!dyn)
     {
       zlog_warn ("isis_dynhn_insert(): out of memory!");
       return;
     }
-  memset (dyn, 0, sizeof (struct isis_dynhn));
+
   /* we also copy the length */
   memcpy (&dyn->name, hostname, hostname->namelen + 1);
   memcpy (dyn->id, id, ISIS_SYS_ID_LEN);
index c0574adb20286cc681e0db0430db82da04f5ff3c..f4a42a606270ed298c138b2b7c3b254c62e9743b 100644 (file)
@@ -2154,6 +2154,10 @@ top_lsp_refresh (struct thread *thread)
       zlog_debug ("ISIS-Upd (): refreshing Topology L1 %s",
                  rawlspid_print (lsp->lsp_header->lsp_id));
     }
+  /* Refresh dynamic hostname in the cache. */
+  isis_dynhn_insert (lsp->lsp_header->lsp_id, lsp->tlv_data.hostname,
+                    IS_LEVEL_1);
+
   lsp->lsp_header->rem_lifetime =
     htons (isis_jitter (lsp->area->max_lsp_lifetime[0], MAX_AGE_JITTER));
 
index 4e71640511e8532241bb87b8de4f5956bcde6410..2277f27c68cf3f05f863ee99f5205f84ad6be7ec 100644 (file)
@@ -50,6 +50,7 @@ struct isis
   struct area_addr *man_area_addrs;    /* manualAreaAddresses */
   u_int32_t debugs;            /* bitmap for debug */
   time_t uptime;               /* when did we start */
+  struct thread *t_dync_clean; /* dynamic hostname cache cleanup thread */
 
   /* Redistributed external information. */
   struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];