]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: Combine lsp_l1/l2_refresh
authorChristian Franke <chris@opensourcerouting.org>
Wed, 24 Oct 2018 04:27:17 +0000 (06:27 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Wed, 24 Oct 2018 05:52:44 +0000 (07:52 +0200)
lsp_l1_refresh and lsp_l2_refresh are identical apart from the
hardcoded IS-IS level they are referring to. So merge them and
pass the level as part of the argument.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
isisd/isis_lsp.c
isisd/isisd.c
isisd/isisd.h

index 8320ad9d75abcf63f55d0863d8c7a9bfcb991b58..e01364dfecbd2ed26fa593be0ae4c2a0fb0dab57 100644 (file)
@@ -59,8 +59,7 @@
 #include "isisd/fabricd.h"
 #include "isisd/isis_tx_queue.h"
 
-static int lsp_l1_refresh(struct thread *thread);
-static int lsp_l2_refresh(struct thread *thread);
+static int lsp_refresh(struct thread *thread);
 static int lsp_l1_refresh_pseudo(struct thread *thread);
 static int lsp_l2_refresh_pseudo(struct thread *thread);
 
@@ -1251,12 +1250,9 @@ int lsp_generate(struct isis_area *area, int level)
 
        THREAD_TIMER_OFF(area->t_lsp_refresh[level - 1]);
        area->lsp_regenerate_pending[level - 1] = 0;
-       if (level == IS_LEVEL_1)
-               thread_add_timer(master, lsp_l1_refresh, area, refresh_time,
-                                &area->t_lsp_refresh[level - 1]);
-       else if (level == IS_LEVEL_2)
-               thread_add_timer(master, lsp_l2_refresh, area, refresh_time,
-                                &area->t_lsp_refresh[level - 1]);
+       thread_add_timer(master, lsp_refresh,
+                        &area->lsp_refresh_arg[level - 1], refresh_time,
+                        &area->t_lsp_refresh[level - 1]);
 
        if (isis->debugs & DEBUG_UPDATE_PACKETS) {
                zlog_debug("ISIS-Upd (%s): Building L%d LSP %s, len %" PRIu16
@@ -1323,12 +1319,9 @@ static int lsp_regenerate(struct isis_area *area, int level)
        lsp_seqno_update(lsp);
 
        refresh_time = lsp_refresh_time(lsp, rem_lifetime);
-       if (level == IS_LEVEL_1)
-               thread_add_timer(master, lsp_l1_refresh, area, refresh_time,
-                                &area->t_lsp_refresh[level - 1]);
-       else if (level == IS_LEVEL_2)
-               thread_add_timer(master, lsp_l2_refresh, area, refresh_time,
-                                &area->t_lsp_refresh[level - 1]);
+       thread_add_timer(master, lsp_refresh,
+                        &area->lsp_refresh_arg[level - 1], refresh_time,
+                        &area->t_lsp_refresh[level - 1]);
        area->lsp_regenerate_pending[level - 1] = 0;
 
        if (isis->debugs & DEBUG_UPDATE_PACKETS) {
@@ -1350,42 +1343,28 @@ static int lsp_regenerate(struct isis_area *area, int level)
 /*
  * Something has changed or periodic refresh -> regenerate LSP
  */
-static int lsp_l1_refresh(struct thread *thread)
+static int lsp_refresh(struct thread *thread)
 {
-       struct isis_area *area;
-
-       area = THREAD_ARG(thread);
-       assert(area);
-
-       area->t_lsp_refresh[0] = NULL;
-       area->lsp_regenerate_pending[0] = 0;
-
-       if ((area->is_type & IS_LEVEL_1) == 0)
-               return ISIS_ERROR;
+       struct lsp_refresh_arg *arg = THREAD_ARG(thread);
 
-       sched_debug(
-               "ISIS (%s): LSP L1 refresh timer expired. Refreshing LSP...",
-               area->area_tag);
-       return lsp_regenerate(area, IS_LEVEL_1);
-}
+       assert(arg);
 
-static int lsp_l2_refresh(struct thread *thread)
-{
-       struct isis_area *area;
+       struct isis_area *area = arg->area;
 
-       area = THREAD_ARG(thread);
        assert(area);
 
-       area->t_lsp_refresh[1] = NULL;
-       area->lsp_regenerate_pending[1] = 0;
+       int level = arg->level;
 
-       if ((area->is_type & IS_LEVEL_2) == 0)
+       area->t_lsp_refresh[level - 1] = NULL;
+       area->lsp_regenerate_pending[level - 1] = 0;
+
+       if ((area->is_type & level) == 0)
                return ISIS_ERROR;
 
        sched_debug(
-               "ISIS (%s): LSP L2 refresh timer expired. Refreshing LSP...",
-               area->area_tag);
-       return lsp_regenerate(area, IS_LEVEL_2);
+               "ISIS (%s): LSP L%d refresh timer expired. Refreshing LSP...",
+               area->area_tag, level);
+       return lsp_regenerate(area, level);
 }
 
 int _lsp_regenerate_schedule(struct isis_area *area, int level,
@@ -1472,15 +1451,10 @@ int _lsp_regenerate_schedule(struct isis_area *area, int level,
                }
 
                area->lsp_regenerate_pending[lvl - 1] = 1;
-               if (lvl == IS_LEVEL_1) {
-                       thread_add_timer_msec(master, lsp_l1_refresh, area,
-                                             timeout,
-                                             &area->t_lsp_refresh[lvl - 1]);
-               } else if (lvl == IS_LEVEL_2) {
-                       thread_add_timer_msec(master, lsp_l2_refresh, area,
-                                             timeout,
-                                             &area->t_lsp_refresh[lvl - 1]);
-               }
+               thread_add_timer_msec(master, lsp_refresh,
+                                     &area->lsp_refresh_arg[lvl - 1],
+                                     timeout,
+                                     &area->t_lsp_refresh[lvl - 1]);
        }
 
        if (all_pseudo) {
index 94e6a63855b30758d4b6d107efb68f1624a99b5e..54bdbf3eb3ef66115d91d4c1ffa335c5471eefad 100644 (file)
@@ -160,6 +160,13 @@ struct isis_area *isis_area_create(const char *area_tag)
 
        if (fabricd)
                area->fabricd = fabricd_new(area);
+
+       area->lsp_refresh_arg[0].area = area;
+       area->lsp_refresh_arg[0].level = IS_LEVEL_1;
+       area->lsp_refresh_arg[1].area = area;
+       area->lsp_refresh_arg[1].level = IS_LEVEL_2;
+
+
        QOBJ_REG(area, isis_area);
 
        return area;
index 7572f551743758ffc6f09a95cedf2e360f8cd733..5c4cf3e0da81b4f0acac9b001b40ee8600b35bf2 100644 (file)
@@ -90,6 +90,11 @@ enum spf_tree_id {
        SPFTREE_COUNT
 };
 
+struct lsp_refresh_arg {
+       struct isis_area *area;
+       int level;
+};
+
 struct isis_area {
        struct isis *isis;                             /* back pointer */
        dict_t *lspdb[ISIS_LEVELS];                    /* link-state dbs */
@@ -160,6 +165,8 @@ struct isis_area {
                                                            parameters*/
        struct thread *spf_timer[ISIS_LEVELS];
 
+       struct lsp_refresh_arg lsp_refresh_arg[ISIS_LEVELS];
+
        QOBJ_FIELDS
 };
 DECLARE_QOBJ_TYPE(isis_area)