]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_events.c
Merge pull request #3024 from ton31337/fix/validate_route-map
[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_lsp.h"
41 #include "isisd/isis_pdu.h"
42 #include "isisd/isis_network.h"
43 #include "isisd/isis_misc.h"
44 #include "isisd/isis_constants.h"
45 #include "isisd/isis_adjacency.h"
46 #include "isisd/isis_dr.h"
47 #include "isisd/isisd.h"
48 #include "isisd/isis_csm.h"
49 #include "isisd/isis_events.h"
50 #include "isisd/isis_spf.h"
51 #include "isisd/isis_errors.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 isis_event_circuit_state_change(struct isis_circuit *circuit,
62 struct isis_area *area, int up)
63 {
64 area->circuit_state_changes++;
65
66 if (isis->debugs & DEBUG_EVENTS)
67 zlog_debug("ISIS-Evt (%s) circuit %s", area->area_tag,
68 up ? "up" : "down");
69
70 /*
71 * Regenerate LSPs this affects
72 */
73 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
74
75 return;
76 }
77
78 static void circuit_commence_level(struct isis_circuit *circuit, int level)
79 {
80 if (level == 1) {
81 if (!circuit->is_passive)
82 thread_add_timer(master, send_l1_psnp, circuit,
83 isis_jitter(circuit->psnp_interval[0],
84 PSNP_JITTER),
85 &circuit->t_send_psnp[0]);
86
87 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
88 thread_add_timer(master, isis_run_dr_l1, circuit,
89 2 * circuit->hello_interval[0],
90 &circuit->u.bc.t_run_dr[0]);
91
92 thread_add_timer(master, send_lan_l1_hello, circuit,
93 isis_jitter(circuit->hello_interval[0],
94 IIH_JITTER),
95 &circuit->u.bc.t_send_lan_hello[0]);
96
97 circuit->u.bc.lan_neighs[0] = list_new();
98 }
99 } else {
100 if (!circuit->is_passive)
101 thread_add_timer(master, send_l2_psnp, circuit,
102 isis_jitter(circuit->psnp_interval[1],
103 PSNP_JITTER),
104 &circuit->t_send_psnp[1]);
105
106 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
107 thread_add_timer(master, isis_run_dr_l2, circuit,
108 2 * circuit->hello_interval[1],
109 &circuit->u.bc.t_run_dr[1]);
110
111 thread_add_timer(master, send_lan_l2_hello, circuit,
112 isis_jitter(circuit->hello_interval[1],
113 IIH_JITTER),
114 &circuit->u.bc.t_send_lan_hello[1]);
115
116 circuit->u.bc.lan_neighs[1] = list_new();
117 }
118 }
119
120 return;
121 }
122
123 static void circuit_resign_level(struct isis_circuit *circuit, int level)
124 {
125 int idx = level - 1;
126
127 THREAD_TIMER_OFF(circuit->t_send_csnp[idx]);
128 THREAD_TIMER_OFF(circuit->t_send_psnp[idx]);
129
130 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
131 THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[idx]);
132 THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[idx]);
133 THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[idx]);
134 circuit->lsp_regenerate_pending[idx] = 0;
135 circuit->u.bc.run_dr_elect[idx] = 0;
136 if (circuit->u.bc.lan_neighs[idx] != NULL)
137 list_delete(&circuit->u.bc.lan_neighs[idx]);
138 }
139
140 return;
141 }
142
143 void isis_circuit_is_type_set(struct isis_circuit *circuit, int newtype)
144 {
145 if (circuit->state != C_STATE_UP) {
146 circuit->is_type = newtype;
147 return;
148 }
149
150 if (isis->debugs & DEBUG_EVENTS)
151 zlog_debug("ISIS-Evt (%s) circuit type change %s -> %s",
152 circuit->area->area_tag,
153 circuit_t2string(circuit->is_type),
154 circuit_t2string(newtype));
155
156 if (circuit->is_type == newtype)
157 return; /* No change */
158
159 if (!(newtype & circuit->area->is_type)) {
160 flog_err(
161 EC_ISIS_CONFIG,
162 "ISIS-Evt (%s) circuit type change - invalid level %s because area is %s",
163 circuit->area->area_tag, circuit_t2string(newtype),
164 circuit_t2string(circuit->area->is_type));
165 return;
166 }
167
168 if (!circuit->is_passive) {
169 switch (circuit->is_type) {
170 case IS_LEVEL_1:
171 if (newtype == IS_LEVEL_2)
172 circuit_resign_level(circuit, 1);
173 circuit_commence_level(circuit, 2);
174 break;
175 case IS_LEVEL_1_AND_2:
176 if (newtype == IS_LEVEL_1)
177 circuit_resign_level(circuit, 2);
178 else
179 circuit_resign_level(circuit, 1);
180 break;
181 case IS_LEVEL_2:
182 if (newtype == IS_LEVEL_1)
183 circuit_resign_level(circuit, 2);
184 circuit_commence_level(circuit, 1);
185 break;
186 default:
187 break;
188 }
189 }
190
191 circuit->is_type = newtype;
192 lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
193
194 return;
195 }
196
197 /* 04/18/2002 by Gwak. */
198 /**************************************************************************
199 *
200 * EVENTS for LSP generation
201 *
202 * 1) an Adajacency or Circuit Up/Down event
203 * 2) a chnage in Circuit metric
204 * 3) a change in Reachable Address metric
205 * 4) a change in manualAreaAddresses
206 * 5) a change in systemID
207 * 6) a change in DIS status
208 * 7) a chnage in the waiting status
209 *
210 * ***********************************************************************
211 *
212 * current support event
213 *
214 * 1) Adjacency Up/Down event
215 * 6) a change in DIS status
216 *
217 * ***********************************************************************/
218
219 /* events supporting code */
220
221 int isis_event_dis_status_change(struct thread *thread)
222 {
223 struct isis_circuit *circuit;
224
225 circuit = THREAD_ARG(thread);
226
227 /* invalid arguments */
228 if (!circuit || !circuit->area)
229 return 0;
230 if (isis->debugs & DEBUG_EVENTS)
231 zlog_debug("ISIS-Evt (%s) DIS status change",
232 circuit->area->area_tag);
233
234 /* LSP generation again */
235 lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
236
237 return 0;
238 }
239
240 void isis_event_auth_failure(char *area_tag, const char *error_string,
241 uint8_t *sysid)
242 {
243 if (isis->debugs & DEBUG_EVENTS)
244 zlog_debug("ISIS-Evt (%s) Authentication failure %s from %s",
245 area_tag, error_string, sysid_print(sysid));
246
247 return;
248 }