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