blob: abc4471cad5177929999d679f4e7f8ef29311012 [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
2 * IS-IS Rout(e)ing protocol - isis_events.h
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
jardineb5d44e2003-12-23 08:09:43 +000022#include <zebra.h>
jardineb5d44e2003-12-23 08:09:43 +000023
24#include "log.h"
25#include "memory.h"
26#include "if.h"
27#include "linklist.h"
28#include "command.h"
29#include "thread.h"
30#include "hash.h"
31#include "prefix.h"
32#include "stream.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070033#include "table.h"
jardineb5d44e2003-12-23 08:09:43 +000034
35#include "isisd/dict.h"
36#include "isisd/include-netbsd/iso.h"
37#include "isisd/isis_constants.h"
38#include "isisd/isis_common.h"
Josh Bailey3f045a02012-03-24 08:35:20 -070039#include "isisd/isis_flags.h"
jardineb5d44e2003-12-23 08:09:43 +000040#include "isisd/isis_circuit.h"
41#include "isisd/isis_tlv.h"
42#include "isisd/isis_lsp.h"
43#include "isisd/isis_pdu.h"
44#include "isisd/isis_network.h"
45#include "isisd/isis_misc.h"
46#include "isisd/isis_constants.h"
47#include "isisd/isis_adjacency.h"
48#include "isisd/isis_dr.h"
jardineb5d44e2003-12-23 08:09:43 +000049#include "isisd/isisd.h"
50#include "isisd/isis_csm.h"
51#include "isisd/isis_events.h"
52#include "isisd/isis_spf.h"
53
jardineb5d44e2003-12-23 08:09:43 +000054/* debug isis-spf spf-events
55 4w4d: ISIS-Spf (tlt): L2 SPF needed, new adjacency, from 0x609229F4
56 4w4d: ISIS-Spf (tlt): L2, 0000.0000.0042.01-00 TLV contents changed, code 0x2
57 4w4d: ISIS-Spf (tlt): L2, new LSP 0 DEAD.BEEF.0043.00-00
58 4w5d: ISIS-Spf (tlt): L1 SPF needed, periodic SPF, from 0x6091C844
59 4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844
60*/
61
hassof390d2c2004-09-10 20:48:21 +000062void
Josh Bailey3f045a02012-03-24 08:35:20 -070063isis_event_circuit_state_change (struct isis_circuit *circuit,
64 struct isis_area *area, int up)
jardineb5d44e2003-12-23 08:09:43 +000065{
jardineb5d44e2003-12-23 08:09:43 +000066 area->circuit_state_changes++;
hassof390d2c2004-09-10 20:48:21 +000067
68 if (isis->debugs & DEBUG_EVENTS)
Josh Bailey3f045a02012-03-24 08:35:20 -070069 zlog_debug ("ISIS-Evt (%s) circuit %s", area->area_tag,
70 up ? "up" : "down");
hassof390d2c2004-09-10 20:48:21 +000071
jardineb5d44e2003-12-23 08:09:43 +000072 /*
73 * Regenerate LSPs this affects
74 */
Josh Bailey3f045a02012-03-24 08:35:20 -070075 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
jardineb5d44e2003-12-23 08:09:43 +000076
77 return;
78}
79
Josh Bailey3f045a02012-03-24 08:35:20 -070080static void
jardineb5d44e2003-12-23 08:09:43 +000081circuit_commence_level (struct isis_circuit *circuit, int level)
82{
hassof390d2c2004-09-10 20:48:21 +000083 if (level == 1)
84 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -070085 if (! circuit->is_passive)
86 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
87 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
hassod70f99e2004-02-11 20:26:31 +000088
hassof390d2c2004-09-10 20:48:21 +000089 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
90 {
hassof390d2c2004-09-10 20:48:21 +000091 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
Josh Bailey3f045a02012-03-24 08:35:20 -070092 circuit, 2 * circuit->hello_interval[0]);
hassof390d2c2004-09-10 20:48:21 +000093
94 THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
95 send_lan_l1_hello, circuit,
96 isis_jitter (circuit->hello_interval[0],
97 IIH_JITTER));
98
99 circuit->u.bc.lan_neighs[0] = list_new ();
100 }
jardineb5d44e2003-12-23 08:09:43 +0000101 }
hassof390d2c2004-09-10 20:48:21 +0000102 else
103 {
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -0700104 if (! circuit->is_passive)
105 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
106 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
hassof390d2c2004-09-10 20:48:21 +0000107
108 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
109 {
hassof390d2c2004-09-10 20:48:21 +0000110 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
hassoa211d652004-09-20 14:55:29 +0000111 circuit, 2 * circuit->hello_interval[1]);
hassof390d2c2004-09-10 20:48:21 +0000112
113 THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
114 send_lan_l2_hello, circuit,
115 isis_jitter (circuit->hello_interval[1],
116 IIH_JITTER));
117
118 circuit->u.bc.lan_neighs[1] = list_new ();
119 }
120 }
121
jardineb5d44e2003-12-23 08:09:43 +0000122 return;
123}
124
hasso92365882005-01-18 13:53:33 +0000125static void
jardineb5d44e2003-12-23 08:09:43 +0000126circuit_resign_level (struct isis_circuit *circuit, int level)
127{
128 int idx = level - 1;
jardineb5d44e2003-12-23 08:09:43 +0000129
hassof390d2c2004-09-10 20:48:21 +0000130 THREAD_TIMER_OFF (circuit->t_send_csnp[idx]);
131 THREAD_TIMER_OFF (circuit->t_send_psnp[idx]);
132
133 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
134 {
135 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[idx]);
136 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[idx]);
hasso13fb40a2005-10-01 06:03:04 +0000137 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[idx]);
Christian Franke61010c32015-11-10 18:43:34 +0100138 circuit->lsp_regenerate_pending[idx] = 0;
hassof390d2c2004-09-10 20:48:21 +0000139 circuit->u.bc.run_dr_elect[idx] = 0;
boris yakubova0a661f2013-04-26 14:38:34 -0400140 if (circuit->u.bc.lan_neighs[idx] != NULL) {
141 list_delete (circuit->u.bc.lan_neighs[idx]);
142 circuit->u.bc.lan_neighs[idx] = NULL;
143 }
hassof390d2c2004-09-10 20:48:21 +0000144 }
145
jardineb5d44e2003-12-23 08:09:43 +0000146 return;
147}
148
hassof390d2c2004-09-10 20:48:21 +0000149void
David Lamparter4c7d7172016-08-13 01:32:52 +0200150isis_circuit_is_type_set (struct isis_circuit *circuit, int newtype)
jardineb5d44e2003-12-23 08:09:43 +0000151{
Josh Bailey3f045a02012-03-24 08:35:20 -0700152 if (circuit->state != C_STATE_UP)
153 {
154 circuit->is_type = newtype;
155 return;
156 }
hassof390d2c2004-09-10 20:48:21 +0000157
158 if (isis->debugs & DEBUG_EVENTS)
hasso529d65b2004-12-24 00:14:50 +0000159 zlog_debug ("ISIS-Evt (%s) circuit type change %s -> %s",
hassof390d2c2004-09-10 20:48:21 +0000160 circuit->area->area_tag,
Josh Bailey3f045a02012-03-24 08:35:20 -0700161 circuit_t2string (circuit->is_type),
jardineb5d44e2003-12-23 08:09:43 +0000162 circuit_t2string (newtype));
163
Josh Bailey3f045a02012-03-24 08:35:20 -0700164 if (circuit->is_type == newtype)
hassof390d2c2004-09-10 20:48:21 +0000165 return; /* No change */
jardineb5d44e2003-12-23 08:09:43 +0000166
hassof390d2c2004-09-10 20:48:21 +0000167 if (!(newtype & circuit->area->is_type))
168 {
169 zlog_err ("ISIS-Evt (%s) circuit type change - invalid level %s because"
170 " area is %s", circuit->area->area_tag,
171 circuit_t2string (newtype),
172 circuit_t2string (circuit->area->is_type));
173 return;
174 }
175
Lu Feng92cff4f2015-01-08 01:21:02 +0000176 if (! circuit->is_passive)
hassof390d2c2004-09-10 20:48:21 +0000177 {
Lu Feng92cff4f2015-01-08 01:21:02 +0000178 switch (circuit->is_type)
179 {
180 case IS_LEVEL_1:
181 if (newtype == IS_LEVEL_2)
182 circuit_resign_level (circuit, 1);
183 circuit_commence_level (circuit, 2);
184 break;
185 case IS_LEVEL_1_AND_2:
186 if (newtype == IS_LEVEL_1)
187 circuit_resign_level (circuit, 2);
188 else
189 circuit_resign_level (circuit, 1);
190 break;
191 case IS_LEVEL_2:
192 if (newtype == IS_LEVEL_1)
193 circuit_resign_level (circuit, 2);
194 circuit_commence_level (circuit, 1);
195 break;
196 default:
197 break;
198 }
hassof390d2c2004-09-10 20:48:21 +0000199 }
200
Josh Bailey3f045a02012-03-24 08:35:20 -0700201 circuit->is_type = newtype;
202 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
jardineb5d44e2003-12-23 08:09:43 +0000203
204 return;
205}
206
207 /* 04/18/2002 by Gwak. */
208 /**************************************************************************
209 *
210 * EVENTS for LSP generation
211 *
212 * 1) an Adajacency or Circuit Up/Down event
213 * 2) a chnage in Circuit metric
214 * 3) a change in Reachable Address metric
215 * 4) a change in manualAreaAddresses
216 * 5) a change in systemID
217 * 6) a change in DIS status
218 * 7) a chnage in the waiting status
219 *
220 * ***********************************************************************
221 *
222 * current support event
223 *
224 * 1) Adjacency Up/Down event
225 * 6) a change in DIS status
226 *
227 * ***********************************************************************/
228
hassof390d2c2004-09-10 20:48:21 +0000229void
jardineb5d44e2003-12-23 08:09:43 +0000230isis_event_adjacency_state_change (struct isis_adjacency *adj, int newstate)
231{
232 /* adjacency state change event.
233 * - the only proto-type was supported */
hassof390d2c2004-09-10 20:48:21 +0000234
235 /* invalid arguments */
236 if (!adj || !adj->circuit || !adj->circuit->area)
237 return;
238
hassoc89c05d2005-09-04 21:36:36 +0000239 if (isis->debugs & DEBUG_EVENTS)
240 zlog_debug ("ISIS-Evt (%s) Adjacency State change",
241 adj->circuit->area->area_tag);
hassof390d2c2004-09-10 20:48:21 +0000242
jardineb5d44e2003-12-23 08:09:43 +0000243 /* LSP generation again */
Josh Bailey3f045a02012-03-24 08:35:20 -0700244 lsp_regenerate_schedule (adj->circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
jardineb5d44e2003-12-23 08:09:43 +0000245
246 return;
247}
248
249/* events supporting code */
250
251int
252isis_event_dis_status_change (struct thread *thread)
253{
254 struct isis_circuit *circuit;
hassof390d2c2004-09-10 20:48:21 +0000255
jardineb5d44e2003-12-23 08:09:43 +0000256 circuit = THREAD_ARG (thread);
hassof390d2c2004-09-10 20:48:21 +0000257
jardineb5d44e2003-12-23 08:09:43 +0000258 /* invalid arguments */
hassof390d2c2004-09-10 20:48:21 +0000259 if (!circuit || !circuit->area)
260 return 0;
hassoc89c05d2005-09-04 21:36:36 +0000261 if (isis->debugs & DEBUG_EVENTS)
262 zlog_debug ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag);
jardineb5d44e2003-12-23 08:09:43 +0000263
264 /* LSP generation again */
Josh Bailey3f045a02012-03-24 08:35:20 -0700265 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
hassof390d2c2004-09-10 20:48:21 +0000266
jardineb5d44e2003-12-23 08:09:43 +0000267 return 0;
268}
269
hassof390d2c2004-09-10 20:48:21 +0000270void
hasso1cd80842004-10-07 20:07:40 +0000271isis_event_auth_failure (char *area_tag, const char *error_string, u_char *sysid)
jardineb5d44e2003-12-23 08:09:43 +0000272{
hassoc89c05d2005-09-04 21:36:36 +0000273 if (isis->debugs & DEBUG_EVENTS)
274 zlog_debug ("ISIS-Evt (%s) Authentication failure %s from %s",
275 area_tag, error_string, sysid_print (sysid));
hassof390d2c2004-09-10 20:48:21 +0000276
jardineb5d44e2003-12-23 08:09:43 +0000277 return;
278}