]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
eb5d44eb | 2 | /* |
d62a17ae | 3 | * IS-IS Rout(e)ing protocol - isis_events.h |
eb5d44eb | 4 | * |
5 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 6 | * Tampere University of Technology |
eb5d44eb | 7 | * Institute of Communications Engineering |
eb5d44eb | 8 | */ |
eb5d44eb | 9 | #include <zebra.h> |
eb5d44eb | 10 | |
11 | #include "log.h" | |
12 | #include "memory.h" | |
13 | #include "if.h" | |
14 | #include "linklist.h" | |
15 | #include "command.h" | |
24a58196 | 16 | #include "frrevent.h" |
eb5d44eb | 17 | #include "hash.h" |
18 | #include "prefix.h" | |
19 | #include "stream.h" | |
3f045a08 | 20 | #include "table.h" |
eb5d44eb | 21 | |
eb5d44eb | 22 | #include "isisd/isis_constants.h" |
23 | #include "isisd/isis_common.h" | |
3f045a08 | 24 | #include "isisd/isis_flags.h" |
eb5d44eb | 25 | #include "isisd/isis_circuit.h" |
eb5d44eb | 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" | |
eb5d44eb | 33 | #include "isisd/isisd.h" |
34 | #include "isisd/isis_csm.h" | |
35 | #include "isisd/isis_events.h" | |
36 | #include "isisd/isis_spf.h" | |
54ece698 | 37 | #include "isisd/isis_errors.h" |
eb5d44eb | 38 | |
d62a17ae | 39 | void isis_event_circuit_state_change(struct isis_circuit *circuit, |
40 | struct isis_area *area, int up) | |
eb5d44eb | 41 | { |
d62a17ae | 42 | area->circuit_state_changes++; |
f390d2c7 | 43 | |
e740f9c1 | 44 | if (IS_DEBUG_EVENTS) |
d62a17ae | 45 | zlog_debug("ISIS-Evt (%s) circuit %s", area->area_tag, |
46 | up ? "up" : "down"); | |
f390d2c7 | 47 | |
d62a17ae | 48 | /* |
49 | * Regenerate LSPs this affects | |
50 | */ | |
51 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
eb5d44eb | 52 | |
d62a17ae | 53 | return; |
eb5d44eb | 54 | } |
55 | ||
d62a17ae | 56 | static void circuit_commence_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 57 | { |
2286851d EDP |
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 | ||
7c4f7aab CF |
64 | if (!circuit->is_passive) { |
65 | if (level == 1) { | |
907a2395 DS |
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]); | |
7c4f7aab | 70 | } else { |
907a2395 DS |
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]); | |
7c4f7aab CF |
75 | } |
76 | } | |
d62a17ae | 77 | |
7c4f7aab | 78 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
907a2395 DS |
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]); | |
d62a17ae | 83 | |
a0a707ee | 84 | send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY); |
7c4f7aab | 85 | circuit->u.bc.lan_neighs[level - 1] = list_new(); |
f390d2c7 | 86 | } |
eb5d44eb | 87 | } |
88 | ||
d62a17ae | 89 | static void circuit_resign_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 90 | { |
d62a17ae | 91 | int idx = level - 1; |
92 | ||
2286851d EDP |
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 | ||
e16d030c DS |
99 | EVENT_OFF(circuit->t_send_csnp[idx]); |
100 | EVENT_OFF(circuit->t_send_psnp[idx]); | |
d62a17ae | 101 | |
102 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
e16d030c DS |
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]); | |
d62a17ae | 106 | circuit->lsp_regenerate_pending[idx] = 0; |
107 | circuit->u.bc.run_dr_elect[idx] = 0; | |
2286851d | 108 | circuit->u.bc.is_dr[idx] = 0; |
affe9e99 | 109 | if (circuit->u.bc.lan_neighs[idx] != NULL) |
6a154c88 | 110 | list_delete(&circuit->u.bc.lan_neighs[idx]); |
d62a17ae | 111 | } |
112 | ||
113 | return; | |
eb5d44eb | 114 | } |
115 | ||
d62a17ae | 116 | void isis_circuit_is_type_set(struct isis_circuit *circuit, int newtype) |
eb5d44eb | 117 | { |
2f9a06f0 | 118 | if (!circuit->area) { |
d62a17ae | 119 | circuit->is_type = newtype; |
120 | return; | |
121 | } | |
122 | ||
e740f9c1 | 123 | if (IS_DEBUG_EVENTS) |
d62a17ae | 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)) { | |
af4c2728 | 133 | flog_err( |
1a7ecb96 | 134 | EC_ISIS_CONFIG, |
54ece698 | 135 | "ISIS-Evt (%s) circuit type change - invalid level %s because area is %s", |
d62a17ae | 136 | circuit->area->area_tag, circuit_t2string(newtype), |
137 | circuit_t2string(circuit->area->is_type)); | |
138 | return; | |
139 | } | |
140 | ||
2f9a06f0 IR |
141 | if (circuit->state != C_STATE_UP) { |
142 | circuit->is_type = newtype; | |
143 | return; | |
144 | } | |
145 | ||
d62a17ae | 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; | |
eb5d44eb | 173 | } |
174 | ||
d62a17ae | 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 | ||
eb5d44eb | 197 | /* events supporting code */ |
198 | ||
e6685141 | 199 | void isis_event_dis_status_change(struct event *thread) |
eb5d44eb | 200 | { |
d62a17ae | 201 | struct isis_circuit *circuit; |
f390d2c7 | 202 | |
e16d030c | 203 | circuit = EVENT_ARG(thread); |
f390d2c7 | 204 | |
d62a17ae | 205 | /* invalid arguments */ |
206 | if (!circuit || !circuit->area) | |
cc9f21da | 207 | return; |
e740f9c1 | 208 | if (IS_DEBUG_EVENTS) |
d62a17ae | 209 | zlog_debug("ISIS-Evt (%s) DIS status change", |
210 | circuit->area->area_tag); | |
eb5d44eb | 211 | |
d62a17ae | 212 | /* LSP generation again */ |
213 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
eb5d44eb | 214 | } |
215 | ||
d62a17ae | 216 | void isis_event_auth_failure(char *area_tag, const char *error_string, |
d7c0a89a | 217 | uint8_t *sysid) |
eb5d44eb | 218 | { |
e740f9c1 | 219 | if (IS_DEBUG_EVENTS) |
5d39a819 OD |
220 | zlog_debug("ISIS-Evt (%s) Authentication failure %s from %pSY", |
221 | area_tag, error_string, sysid); | |
f390d2c7 | 222 | |
d62a17ae | 223 | return; |
eb5d44eb | 224 | } |