]> git.proxmox.com Git - mirror_frr.git/blobdiff - isisd/isis_events.c
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[mirror_frr.git] / isisd / isis_events.c
index 8011d2db9ce44a88c46299a60b99b464960d14ce..4da23c591261a1b98588830877a98149003d4d39 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * IS-IS Rout(e)ing protocol - isis_events.h   
+ * IS-IS Rout(e)ing protocol - isis_events.h
  *
  * Copyright (C) 2001,2002   Sampo Saaristo
- *                           Tampere University of Technology      
+ *                           Tampere University of Technology
  *                           Institute of Communications Engineering
  *
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of the GNU General Public Licenseas published by the Free 
- * Software Foundation; either version 2 of the License, or (at your option) 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public Licenseas published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
  * any later version.
  *
- * This program is distributed in the hope that it will be useful,but WITHOUT 
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
+ * This program is distributed in the hope that it will be useful,but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
  * You should have received a copy of the GNU General Public License along
@@ -37,7 +37,6 @@
 #include "isisd/isis_common.h"
 #include "isisd/isis_flags.h"
 #include "isisd/isis_circuit.h"
-#include "isisd/isis_tlv.h"
 #include "isisd/isis_lsp.h"
 #include "isisd/isis_pdu.h"
 #include "isisd/isis_network.h"
@@ -49,8 +48,9 @@
 #include "isisd/isis_csm.h"
 #include "isisd/isis_events.h"
 #include "isisd/isis_spf.h"
+#include "isisd/isis_errors.h"
 
-/* debug isis-spf spf-events 
+/* debug isis-spf spf-events
  4w4d: ISIS-Spf (tlt): L2 SPF needed, new adjacency, from 0x609229F4
  4w4d: ISIS-Spf (tlt): L2, 0000.0000.0042.01-00 TLV contents changed, code 0x2
  4w4d: ISIS-Spf (tlt): L2, new LSP 0 DEAD.BEEF.0043.00-00
  4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844
 */
 
-void
-isis_event_circuit_state_change (struct isis_circuit *circuit,
-                                 struct isis_area *area, int up)
+void isis_event_circuit_state_change(struct isis_circuit *circuit,
+                                    struct isis_area *area, int up)
 {
-  area->circuit_state_changes++;
+       area->circuit_state_changes++;
 
-  if (isis->debugs & DEBUG_EVENTS)
-    zlog_debug ("ISIS-Evt (%s) circuit %s", area->area_tag,
-                up ? "up" : "down");
+       if (isis->debugs & DEBUG_EVENTS)
+               zlog_debug("ISIS-Evt (%s) circuit %s", area->area_tag,
+                          up ? "up" : "down");
 
-  /*
-   * Regenerate LSPs this affects
-   */
-  lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
+       /*
+        * Regenerate LSPs this affects
+        */
+       lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
 
-  return;
+       return;
 }
 
-static void
-circuit_commence_level (struct isis_circuit *circuit, int level)
+static void circuit_commence_level(struct isis_circuit *circuit, int level)
 {
-  if (level == 1)
-    {
-      if (! circuit->is_passive)
-        thread_add_timer(master, send_l1_psnp, circuit,
-                         isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
-                         &circuit->t_send_psnp[0]);
-
-      if (circuit->circ_type == CIRCUIT_T_BROADCAST)
-       {
-         thread_add_timer(master, isis_run_dr_l1, circuit,
-                           2 * circuit->hello_interval[0],
-                           &circuit->u.bc.t_run_dr[0]);
-
-         thread_add_timer(master, send_lan_l1_hello, circuit,
-                           isis_jitter(circuit->hello_interval[0], IIH_JITTER),
-                           &circuit->u.bc.t_send_lan_hello[0]);
-
-         circuit->u.bc.lan_neighs[0] = list_new ();
+       if (!circuit->is_passive) {
+               if (level == 1) {
+                       thread_add_timer(master, send_l1_psnp, circuit,
+                                        isis_jitter(circuit->psnp_interval[0],
+                                                    PSNP_JITTER),
+                                        &circuit->t_send_psnp[0]);
+               } else {
+                       thread_add_timer(master, send_l2_psnp, circuit,
+                                        isis_jitter(circuit->psnp_interval[1],
+                                                    PSNP_JITTER),
+                                        &circuit->t_send_psnp[1]);
+               }
        }
-    }
-  else
-    {
-      if (! circuit->is_passive)
-        thread_add_timer(master, send_l2_psnp, circuit,
-                         isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
-                         &circuit->t_send_psnp[1]);
-
-      if (circuit->circ_type == CIRCUIT_T_BROADCAST)
-       {
-         thread_add_timer(master, isis_run_dr_l2, circuit,
-                           2 * circuit->hello_interval[1],
-                           &circuit->u.bc.t_run_dr[1]);
 
-         thread_add_timer(master, send_lan_l2_hello, circuit,
-                           isis_jitter(circuit->hello_interval[1], IIH_JITTER),
-                           &circuit->u.bc.t_send_lan_hello[1]);
+       if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
+               thread_add_timer(master, isis_run_dr,
+                                &circuit->level_arg[level - 1],
+                                2 * circuit->hello_interval[level - 1],
+                                &circuit->u.bc.t_run_dr[level - 1]);
 
-         circuit->u.bc.lan_neighs[1] = list_new ();
+               send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY);
+               circuit->u.bc.lan_neighs[level - 1] = list_new();
        }
-    }
-
-  return;
 }
 
-static void
-circuit_resign_level (struct isis_circuit *circuit, int level)
+static void circuit_resign_level(struct isis_circuit *circuit, int level)
 {
-  int idx = level - 1;
-
-  THREAD_TIMER_OFF (circuit->t_send_csnp[idx]);
-  THREAD_TIMER_OFF (circuit->t_send_psnp[idx]);
-
-  if (circuit->circ_type == CIRCUIT_T_BROADCAST)
-    {
-      THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[idx]);
-      THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[idx]);
-      THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[idx]);
-      circuit->lsp_regenerate_pending[idx] = 0;
-      circuit->u.bc.run_dr_elect[idx] = 0;
-      if (circuit->u.bc.lan_neighs[idx] != NULL) {
-        list_delete (circuit->u.bc.lan_neighs[idx]);
-        circuit->u.bc.lan_neighs[idx] = NULL;
-      }
-    }
+       int idx = level - 1;
+
+       THREAD_TIMER_OFF(circuit->t_send_csnp[idx]);
+       THREAD_TIMER_OFF(circuit->t_send_psnp[idx]);
+
+       if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
+               THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[idx]);
+               THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[idx]);
+               THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[idx]);
+               circuit->lsp_regenerate_pending[idx] = 0;
+               circuit->u.bc.run_dr_elect[idx] = 0;
+               if (circuit->u.bc.lan_neighs[idx] != NULL)
+                       list_delete(&circuit->u.bc.lan_neighs[idx]);
+       }
 
-  return;
+       return;
 }
 
-void
-isis_circuit_is_type_set (struct isis_circuit *circuit, int newtype)
+void isis_circuit_is_type_set(struct isis_circuit *circuit, int newtype)
 {
-  if (circuit->state != C_STATE_UP)
-  {
-    circuit->is_type = newtype;
-    return;
-  }
-
-  if (isis->debugs & DEBUG_EVENTS)
-    zlog_debug ("ISIS-Evt (%s) circuit type change %s -> %s",
-              circuit->area->area_tag,
-              circuit_t2string (circuit->is_type),
-              circuit_t2string (newtype));
-
-  if (circuit->is_type == newtype)
-    return;                    /* No change */
+       if (circuit->state != C_STATE_UP) {
+               circuit->is_type = newtype;
+               return;
+       }
 
-  if (!(newtype & circuit->area->is_type))
-    {
-      zlog_err ("ISIS-Evt (%s) circuit type change - invalid level %s because"
-               " area is %s", circuit->area->area_tag,
-               circuit_t2string (newtype),
-               circuit_t2string (circuit->area->is_type));
-      return;
-    }
+       if (isis->debugs & DEBUG_EVENTS)
+               zlog_debug("ISIS-Evt (%s) circuit type change %s -> %s",
+                          circuit->area->area_tag,
+                          circuit_t2string(circuit->is_type),
+                          circuit_t2string(newtype));
+
+       if (circuit->is_type == newtype)
+               return; /* No change */
+
+       if (!(newtype & circuit->area->is_type)) {
+               flog_err(
+                       EC_ISIS_CONFIG,
+                       "ISIS-Evt (%s) circuit type change - invalid level %s because area is %s",
+                       circuit->area->area_tag, circuit_t2string(newtype),
+                       circuit_t2string(circuit->area->is_type));
+               return;
+       }
 
-  if (! circuit->is_passive)
-    {
-      switch (circuit->is_type)
-        {
-        case IS_LEVEL_1:
-          if (newtype == IS_LEVEL_2)
-            circuit_resign_level (circuit, 1);
-          circuit_commence_level (circuit, 2);
-          break;
-        case IS_LEVEL_1_AND_2:
-          if (newtype == IS_LEVEL_1)
-            circuit_resign_level (circuit, 2);
-          else
-            circuit_resign_level (circuit, 1);
-          break;
-        case IS_LEVEL_2:
-          if (newtype == IS_LEVEL_1)
-            circuit_resign_level (circuit, 2);
-          circuit_commence_level (circuit, 1);
-          break;
-        default:
-          break;
-        }
-    }
+       if (!circuit->is_passive) {
+               switch (circuit->is_type) {
+               case IS_LEVEL_1:
+                       if (newtype == IS_LEVEL_2)
+                               circuit_resign_level(circuit, 1);
+                       circuit_commence_level(circuit, 2);
+                       break;
+               case IS_LEVEL_1_AND_2:
+                       if (newtype == IS_LEVEL_1)
+                               circuit_resign_level(circuit, 2);
+                       else
+                               circuit_resign_level(circuit, 1);
+                       break;
+               case IS_LEVEL_2:
+                       if (newtype == IS_LEVEL_1)
+                               circuit_resign_level(circuit, 2);
+                       circuit_commence_level(circuit, 1);
+                       break;
+               default:
+                       break;
+               }
+       }
 
-  circuit->is_type = newtype;
-  lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
+       circuit->is_type = newtype;
+       lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
 
-  return;
+       return;
 }
 
- /* 04/18/2002 by Gwak. */
- /**************************************************************************
-  *
-  * EVENTS for LSP generation
-  *
-  * 1) an Adajacency or Circuit Up/Down event
-  * 2) a chnage in Circuit metric
-  * 3) a change in Reachable Address metric
-  * 4) a change in manualAreaAddresses
-  * 5) a change in systemID
-  * 6) a change in DIS status
-  * 7) a chnage in the waiting status
-  *
-  * ***********************************************************************
-  *
-  * current support event
-  *
-  * 1) Adjacency Up/Down event
-  * 6) a change in DIS status
-  *
-  * ***********************************************************************/
-
-void
-isis_event_adjacency_state_change (struct isis_adjacency *adj, int newstate)
-{
-  /* adjacency state change event. 
-   * - the only proto-type was supported */
-
-  /* invalid arguments */
-  if (!adj || !adj->circuit || !adj->circuit->area)
-    return;
-
-  if (isis->debugs & DEBUG_EVENTS)
-    zlog_debug ("ISIS-Evt (%s) Adjacency State change",
-               adj->circuit->area->area_tag);
-
-  /* LSP generation again */
-  lsp_regenerate_schedule (adj->circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
-
-  return;
-}
+/* 04/18/2002 by Gwak. */
+/**************************************************************************
+ *
+ * EVENTS for LSP generation
+ *
+ * 1) an Adajacency or Circuit Up/Down event
+ * 2) a chnage in Circuit metric
+ * 3) a change in Reachable Address metric
+ * 4) a change in manualAreaAddresses
+ * 5) a change in systemID
+ * 6) a change in DIS status
+ * 7) a chnage in the waiting status
+ *
+ * ***********************************************************************
+ *
+ * current support event
+ *
+ * 1) Adjacency Up/Down event
+ * 6) a change in DIS status
+ *
+ * ***********************************************************************/
 
 /* events supporting code */
 
-int
-isis_event_dis_status_change (struct thread *thread)
+int isis_event_dis_status_change(struct thread *thread)
 {
-  struct isis_circuit *circuit;
+       struct isis_circuit *circuit;
 
-  circuit = THREAD_ARG (thread);
+       circuit = THREAD_ARG(thread);
 
-  /* invalid arguments */
-  if (!circuit || !circuit->area)
-    return 0;
-  if (isis->debugs & DEBUG_EVENTS)
-    zlog_debug ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag);
+       /* invalid arguments */
+       if (!circuit || !circuit->area)
+               return 0;
+       if (isis->debugs & DEBUG_EVENTS)
+               zlog_debug("ISIS-Evt (%s) DIS status change",
+                          circuit->area->area_tag);
 
-  /* LSP generation again */
-  lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
+       /* LSP generation again */
+       lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
 
-  return 0;
+       return 0;
 }
 
-void
-isis_event_auth_failure (char *area_tag, const char *error_string, u_char *sysid)
+void isis_event_auth_failure(char *area_tag, const char *error_string,
+                            uint8_t *sysid)
 {
-  if (isis->debugs & DEBUG_EVENTS)
-    zlog_debug ("ISIS-Evt (%s) Authentication failure %s from %s",
-               area_tag, error_string, sysid_print (sysid));
+       if (isis->debugs & DEBUG_EVENTS)
+               zlog_debug("ISIS-Evt (%s) Authentication failure %s from %s",
+                          area_tag, error_string, sysid_print(sysid));
 
-  return;
+       return;
 }