]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_events.c
Merge pull request #13227 from mjstapp/ospf_sock_bufsizes
[mirror_frr.git] / isisd / isis_events.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * IS-IS Rout(e)ing protocol - isis_events.h
4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
6 * Tampere University of Technology
7 * Institute of Communications Engineering
8 */
9 #include <zebra.h>
10
11 #include "log.h"
12 #include "memory.h"
13 #include "if.h"
14 #include "linklist.h"
15 #include "command.h"
16 #include "frrevent.h"
17 #include "hash.h"
18 #include "prefix.h"
19 #include "stream.h"
20 #include "table.h"
21
22 #include "isisd/isis_constants.h"
23 #include "isisd/isis_common.h"
24 #include "isisd/isis_flags.h"
25 #include "isisd/isis_circuit.h"
26 #include "isisd/isis_lsp.h"
27 #include "isisd/isis_pdu.h"
28 #include "isisd/isis_network.h"
29 #include "isisd/isis_misc.h"
30 #include "isisd/isis_constants.h"
31 #include "isisd/isis_adjacency.h"
32 #include "isisd/isis_dr.h"
33 #include "isisd/isisd.h"
34 #include "isisd/isis_csm.h"
35 #include "isisd/isis_events.h"
36 #include "isisd/isis_spf.h"
37 #include "isisd/isis_errors.h"
38
39 void isis_event_circuit_state_change(struct isis_circuit *circuit,
40 struct isis_area *area, int up)
41 {
42 area->circuit_state_changes++;
43
44 if (IS_DEBUG_EVENTS)
45 zlog_debug("ISIS-Evt (%s) circuit %s", area->area_tag,
46 up ? "up" : "down");
47
48 /*
49 * Regenerate LSPs this affects
50 */
51 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
52
53 return;
54 }
55
56 static void circuit_commence_level(struct isis_circuit *circuit, int level)
57 {
58 if (IS_DEBUG_EVENTS)
59 zlog_debug(
60 "ISIS-Evt (%s) circuit %u on iface %s commencing on L%d",
61 circuit->area->area_tag, circuit->circuit_id,
62 circuit->interface->name, level);
63
64 if (!circuit->is_passive) {
65 if (level == 1) {
66 event_add_timer(master, send_l1_psnp, circuit,
67 isis_jitter(circuit->psnp_interval[0],
68 PSNP_JITTER),
69 &circuit->t_send_psnp[0]);
70 } else {
71 event_add_timer(master, send_l2_psnp, circuit,
72 isis_jitter(circuit->psnp_interval[1],
73 PSNP_JITTER),
74 &circuit->t_send_psnp[1]);
75 }
76 }
77
78 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
79 event_add_timer(master, isis_run_dr,
80 &circuit->level_arg[level - 1],
81 2 * circuit->hello_interval[level - 1],
82 &circuit->u.bc.t_run_dr[level - 1]);
83
84 send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY);
85 circuit->u.bc.lan_neighs[level - 1] = list_new();
86 }
87 }
88
89 static void circuit_resign_level(struct isis_circuit *circuit, int level)
90 {
91 int idx = level - 1;
92
93 if (IS_DEBUG_EVENTS)
94 zlog_debug(
95 "ISIS-Evt (%s) circuit %u on iface %s resigning on L%d",
96 circuit->area->area_tag, circuit->circuit_id,
97 circuit->interface->name, level);
98
99 EVENT_OFF(circuit->t_send_csnp[idx]);
100 EVENT_OFF(circuit->t_send_psnp[idx]);
101
102 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
103 EVENT_OFF(circuit->u.bc.t_send_lan_hello[idx]);
104 EVENT_OFF(circuit->u.bc.t_run_dr[idx]);
105 EVENT_OFF(circuit->u.bc.t_refresh_pseudo_lsp[idx]);
106 circuit->lsp_regenerate_pending[idx] = 0;
107 circuit->u.bc.run_dr_elect[idx] = 0;
108 circuit->u.bc.is_dr[idx] = 0;
109 if (circuit->u.bc.lan_neighs[idx] != NULL)
110 list_delete(&circuit->u.bc.lan_neighs[idx]);
111 }
112
113 return;
114 }
115
116 void isis_circuit_is_type_set(struct isis_circuit *circuit, int newtype)
117 {
118 if (!circuit->area) {
119 circuit->is_type = newtype;
120 return;
121 }
122
123 if (IS_DEBUG_EVENTS)
124 zlog_debug("ISIS-Evt (%s) circuit type change %s -> %s",
125 circuit->area->area_tag,
126 circuit_t2string(circuit->is_type),
127 circuit_t2string(newtype));
128
129 if (circuit->is_type == newtype)
130 return; /* No change */
131
132 if (!(newtype & circuit->area->is_type)) {
133 flog_err(
134 EC_ISIS_CONFIG,
135 "ISIS-Evt (%s) circuit type change - invalid level %s because area is %s",
136 circuit->area->area_tag, circuit_t2string(newtype),
137 circuit_t2string(circuit->area->is_type));
138 return;
139 }
140
141 if (circuit->state != C_STATE_UP) {
142 circuit->is_type = newtype;
143 return;
144 }
145
146 if (!circuit->is_passive) {
147 switch (circuit->is_type) {
148 case IS_LEVEL_1:
149 if (newtype == IS_LEVEL_2)
150 circuit_resign_level(circuit, 1);
151 circuit_commence_level(circuit, 2);
152 break;
153 case IS_LEVEL_1_AND_2:
154 if (newtype == IS_LEVEL_1)
155 circuit_resign_level(circuit, 2);
156 else
157 circuit_resign_level(circuit, 1);
158 break;
159 case IS_LEVEL_2:
160 if (newtype == IS_LEVEL_1)
161 circuit_resign_level(circuit, 2);
162 circuit_commence_level(circuit, 1);
163 break;
164 default:
165 break;
166 }
167 }
168
169 circuit->is_type = newtype;
170 lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
171
172 return;
173 }
174
175 /* 04/18/2002 by Gwak. */
176 /**************************************************************************
177 *
178 * EVENTS for LSP generation
179 *
180 * 1) an Adajacency or Circuit Up/Down event
181 * 2) a chnage in Circuit metric
182 * 3) a change in Reachable Address metric
183 * 4) a change in manualAreaAddresses
184 * 5) a change in systemID
185 * 6) a change in DIS status
186 * 7) a chnage in the waiting status
187 *
188 * ***********************************************************************
189 *
190 * current support event
191 *
192 * 1) Adjacency Up/Down event
193 * 6) a change in DIS status
194 *
195 * ***********************************************************************/
196
197 /* events supporting code */
198
199 void isis_event_dis_status_change(struct event *thread)
200 {
201 struct isis_circuit *circuit;
202
203 circuit = EVENT_ARG(thread);
204
205 /* invalid arguments */
206 if (!circuit || !circuit->area)
207 return;
208 if (IS_DEBUG_EVENTS)
209 zlog_debug("ISIS-Evt (%s) DIS status change",
210 circuit->area->area_tag);
211
212 /* LSP generation again */
213 lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
214 }
215
216 void isis_event_auth_failure(char *area_tag, const char *error_string,
217 uint8_t *sysid)
218 {
219 if (IS_DEBUG_EVENTS)
220 zlog_debug("ISIS-Evt (%s) Authentication failure %s from %s",
221 area_tag, error_string, sysid_print(sysid));
222
223 return;
224 }