]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_events.c
Merge branch 'stable/3.0'
[mirror_frr.git] / isisd / isis_events.c
1 /*
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; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 #include <zebra.h>
23
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"
33 #include "table.h"
34
35 #include "isisd/dict.h"
36 #include "isisd/isis_constants.h"
37 #include "isisd/isis_common.h"
38 #include "isisd/isis_flags.h"
39 #include "isisd/isis_circuit.h"
40 #include "isisd/isis_tlv.h"
41 #include "isisd/isis_lsp.h"
42 #include "isisd/isis_pdu.h"
43 #include "isisd/isis_network.h"
44 #include "isisd/isis_misc.h"
45 #include "isisd/isis_constants.h"
46 #include "isisd/isis_adjacency.h"
47 #include "isisd/isis_dr.h"
48 #include "isisd/isisd.h"
49 #include "isisd/isis_csm.h"
50 #include "isisd/isis_events.h"
51 #include "isisd/isis_spf.h"
52
53 /* debug isis-spf spf-events
54 4w4d: ISIS-Spf (tlt): L2 SPF needed, new adjacency, from 0x609229F4
55 4w4d: ISIS-Spf (tlt): L2, 0000.0000.0042.01-00 TLV contents changed, code 0x2
56 4w4d: ISIS-Spf (tlt): L2, new LSP 0 DEAD.BEEF.0043.00-00
57 4w5d: ISIS-Spf (tlt): L1 SPF needed, periodic SPF, from 0x6091C844
58 4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844
59 */
60
61 void
62 isis_event_circuit_state_change (struct isis_circuit *circuit,
63 struct isis_area *area, int up)
64 {
65 area->circuit_state_changes++;
66
67 if (isis->debugs & DEBUG_EVENTS)
68 zlog_debug ("ISIS-Evt (%s) circuit %s", area->area_tag,
69 up ? "up" : "down");
70
71 /*
72 * Regenerate LSPs this affects
73 */
74 lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
75
76 return;
77 }
78
79 static void
80 circuit_commence_level (struct isis_circuit *circuit, int level)
81 {
82 if (level == 1)
83 {
84 if (! circuit->is_passive)
85 thread_add_timer(master, send_l1_psnp, circuit,
86 isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
87 &circuit->t_send_psnp[0]);
88
89 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
90 {
91 thread_add_timer(master, isis_run_dr_l1, circuit,
92 2 * circuit->hello_interval[0],
93 &circuit->u.bc.t_run_dr[0]);
94
95 thread_add_timer(master, send_lan_l1_hello, circuit,
96 isis_jitter(circuit->hello_interval[0], IIH_JITTER),
97 &circuit->u.bc.t_send_lan_hello[0]);
98
99 circuit->u.bc.lan_neighs[0] = list_new ();
100 }
101 }
102 else
103 {
104 if (! circuit->is_passive)
105 thread_add_timer(master, send_l2_psnp, circuit,
106 isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
107 &circuit->t_send_psnp[1]);
108
109 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
110 {
111 thread_add_timer(master, isis_run_dr_l2, circuit,
112 2 * circuit->hello_interval[1],
113 &circuit->u.bc.t_run_dr[1]);
114
115 thread_add_timer(master, send_lan_l2_hello, circuit,
116 isis_jitter(circuit->hello_interval[1], IIH_JITTER),
117 &circuit->u.bc.t_send_lan_hello[1]);
118
119 circuit->u.bc.lan_neighs[1] = list_new ();
120 }
121 }
122
123 return;
124 }
125
126 static void
127 circuit_resign_level (struct isis_circuit *circuit, int level)
128 {
129 int idx = level - 1;
130
131 THREAD_TIMER_OFF (circuit->t_send_csnp[idx]);
132 THREAD_TIMER_OFF (circuit->t_send_psnp[idx]);
133
134 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
135 {
136 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[idx]);
137 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[idx]);
138 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[idx]);
139 circuit->lsp_regenerate_pending[idx] = 0;
140 circuit->u.bc.run_dr_elect[idx] = 0;
141 if (circuit->u.bc.lan_neighs[idx] != NULL) {
142 list_delete (circuit->u.bc.lan_neighs[idx]);
143 circuit->u.bc.lan_neighs[idx] = NULL;
144 }
145 }
146
147 return;
148 }
149
150 void
151 isis_circuit_is_type_set (struct isis_circuit *circuit, int newtype)
152 {
153 if (circuit->state != C_STATE_UP)
154 {
155 circuit->is_type = newtype;
156 return;
157 }
158
159 if (isis->debugs & DEBUG_EVENTS)
160 zlog_debug ("ISIS-Evt (%s) circuit type change %s -> %s",
161 circuit->area->area_tag,
162 circuit_t2string (circuit->is_type),
163 circuit_t2string (newtype));
164
165 if (circuit->is_type == newtype)
166 return; /* No change */
167
168 if (!(newtype & circuit->area->is_type))
169 {
170 zlog_err ("ISIS-Evt (%s) circuit type change - invalid level %s because"
171 " area is %s", circuit->area->area_tag,
172 circuit_t2string (newtype),
173 circuit_t2string (circuit->area->is_type));
174 return;
175 }
176
177 if (! circuit->is_passive)
178 {
179 switch (circuit->is_type)
180 {
181 case IS_LEVEL_1:
182 if (newtype == IS_LEVEL_2)
183 circuit_resign_level (circuit, 1);
184 circuit_commence_level (circuit, 2);
185 break;
186 case IS_LEVEL_1_AND_2:
187 if (newtype == IS_LEVEL_1)
188 circuit_resign_level (circuit, 2);
189 else
190 circuit_resign_level (circuit, 1);
191 break;
192 case IS_LEVEL_2:
193 if (newtype == IS_LEVEL_1)
194 circuit_resign_level (circuit, 2);
195 circuit_commence_level (circuit, 1);
196 break;
197 default:
198 break;
199 }
200 }
201
202 circuit->is_type = newtype;
203 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
204
205 return;
206 }
207
208 /* 04/18/2002 by Gwak. */
209 /**************************************************************************
210 *
211 * EVENTS for LSP generation
212 *
213 * 1) an Adajacency or Circuit Up/Down event
214 * 2) a chnage in Circuit metric
215 * 3) a change in Reachable Address metric
216 * 4) a change in manualAreaAddresses
217 * 5) a change in systemID
218 * 6) a change in DIS status
219 * 7) a chnage in the waiting status
220 *
221 * ***********************************************************************
222 *
223 * current support event
224 *
225 * 1) Adjacency Up/Down event
226 * 6) a change in DIS status
227 *
228 * ***********************************************************************/
229
230 void
231 isis_event_adjacency_state_change (struct isis_adjacency *adj, int newstate)
232 {
233 /* adjacency state change event.
234 * - the only proto-type was supported */
235
236 /* invalid arguments */
237 if (!adj || !adj->circuit || !adj->circuit->area)
238 return;
239
240 if (isis->debugs & DEBUG_EVENTS)
241 zlog_debug ("ISIS-Evt (%s) Adjacency State change",
242 adj->circuit->area->area_tag);
243
244 /* LSP generation again */
245 lsp_regenerate_schedule (adj->circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
246
247 return;
248 }
249
250 /* events supporting code */
251
252 int
253 isis_event_dis_status_change (struct thread *thread)
254 {
255 struct isis_circuit *circuit;
256
257 circuit = THREAD_ARG (thread);
258
259 /* invalid arguments */
260 if (!circuit || !circuit->area)
261 return 0;
262 if (isis->debugs & DEBUG_EVENTS)
263 zlog_debug ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag);
264
265 /* LSP generation again */
266 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
267
268 return 0;
269 }
270
271 void
272 isis_event_auth_failure (char *area_tag, const char *error_string, u_char *sysid)
273 {
274 if (isis->debugs & DEBUG_EVENTS)
275 zlog_debug ("ISIS-Evt (%s) Authentication failure %s from %s",
276 area_tag, error_string, sysid_print (sysid));
277
278 return;
279 }