]>
Commit | Line | Data |
---|---|---|
eb5d44eb | 1 | /* |
2 | * IS-IS Rout(e)ing protocol - isis_circuit.h | |
3 | * | |
4 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 5 | * Tampere University of Technology |
eb5d44eb | 6 | * Institute of Communications Engineering |
7 | * | |
d62a17ae | 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) | |
eb5d44eb | 11 | * any later version. |
12 | * | |
d62a17ae | 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 | |
eb5d44eb | 16 | * more details. |
896014f4 DL |
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 | |
eb5d44eb | 21 | */ |
eb5d44eb | 22 | #include <zebra.h> |
37da8c01 | 23 | #ifdef GNU_LINUX |
eb5d44eb | 24 | #include <net/ethernet.h> |
37da8c01 | 25 | #else |
26 | #include <netinet/if_ether.h> | |
27 | #endif | |
eb5d44eb | 28 | |
29 | #include "log.h" | |
30 | #include "memory.h" | |
b2d7c082 | 31 | #include "vrf.h" |
eb5d44eb | 32 | #include "if.h" |
33 | #include "linklist.h" | |
34 | #include "command.h" | |
35 | #include "thread.h" | |
f8c06e2c | 36 | #include "vty.h" |
eb5d44eb | 37 | #include "hash.h" |
38 | #include "prefix.h" | |
39 | #include "stream.h" | |
676a4ea3 | 40 | #include "qobj.h" |
20600086 | 41 | #include "lib/northbound_cli.h" |
eb5d44eb | 42 | |
eb5d44eb | 43 | #include "isisd/isis_constants.h" |
44 | #include "isisd/isis_common.h" | |
3f045a08 | 45 | #include "isisd/isis_flags.h" |
eb5d44eb | 46 | #include "isisd/isis_circuit.h" |
eb5d44eb | 47 | #include "isisd/isis_lsp.h" |
48 | #include "isisd/isis_pdu.h" | |
49 | #include "isisd/isis_network.h" | |
50 | #include "isisd/isis_misc.h" | |
51 | #include "isisd/isis_constants.h" | |
52 | #include "isisd/isis_adjacency.h" | |
53 | #include "isisd/isis_dr.h" | |
eb5d44eb | 54 | #include "isisd/isisd.h" |
55 | #include "isisd/isis_csm.h" | |
56 | #include "isisd/isis_events.h" | |
f8c06e2c | 57 | #include "isisd/isis_te.h" |
064f4896 | 58 | #include "isisd/isis_mt.h" |
54ece698 | 59 | #include "isisd/isis_errors.h" |
9b39405f | 60 | #include "isisd/isis_tx_queue.h" |
2a1c520e | 61 | #include "isisd/isis_nb.h" |
eb5d44eb | 62 | |
676a4ea3 DL |
63 | DEFINE_QOBJ_TYPE(isis_circuit) |
64 | ||
ef7bd2a3 DS |
65 | DEFINE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp)) |
66 | ||
41b36e90 PJ |
67 | /* |
68 | * Prototypes. | |
69 | */ | |
41b36e90 PJ |
70 | int isis_if_new_hook(struct interface *); |
71 | int isis_if_delete_hook(struct interface *); | |
72 | ||
4d762f26 | 73 | struct isis_circuit *isis_circuit_new(void) |
eb5d44eb | 74 | { |
d62a17ae | 75 | struct isis_circuit *circuit; |
76 | int i; | |
77 | ||
78 | circuit = XCALLOC(MTYPE_ISIS_CIRCUIT, sizeof(struct isis_circuit)); | |
d62a17ae | 79 | |
80 | /* | |
81 | * Default values | |
82 | */ | |
cc50ddb2 EDP |
83 | #ifndef FABRICD |
84 | circuit->is_type = yang_get_default_enum( | |
85 | "/frr-interface:lib/interface/frr-isisd:isis/circuit-type"); | |
86 | circuit->flags = 0; | |
87 | ||
88 | circuit->pad_hellos = yang_get_default_bool( | |
89 | "/frr-interface:lib/interface/frr-isisd:isis/hello/padding"); | |
90 | circuit->hello_interval[0] = yang_get_default_uint32( | |
91 | "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1"); | |
92 | circuit->hello_interval[1] = yang_get_default_uint32( | |
93 | "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2"); | |
94 | circuit->hello_multiplier[0] = yang_get_default_uint32( | |
95 | "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1"); | |
96 | circuit->hello_multiplier[1] = yang_get_default_uint32( | |
97 | "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2"); | |
98 | circuit->csnp_interval[0] = yang_get_default_uint16( | |
99 | "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1"); | |
100 | circuit->csnp_interval[1] = yang_get_default_uint16( | |
101 | "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2"); | |
102 | circuit->psnp_interval[0] = yang_get_default_uint16( | |
103 | "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1"); | |
104 | circuit->psnp_interval[1] = yang_get_default_uint16( | |
105 | "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2"); | |
106 | circuit->priority[0] = yang_get_default_uint8( | |
107 | "/frr-interface:lib/interface/frr-isisd:isis/priority/level-1"); | |
108 | circuit->priority[1] = yang_get_default_uint8( | |
109 | "/frr-interface:lib/interface/frr-isisd:isis/priority/level-2"); | |
110 | circuit->metric[0] = yang_get_default_uint32( | |
111 | "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1"); | |
112 | circuit->metric[1] = yang_get_default_uint32( | |
113 | "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2"); | |
114 | circuit->te_metric[0] = yang_get_default_uint32( | |
115 | "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1"); | |
116 | circuit->te_metric[1] = yang_get_default_uint32( | |
117 | "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2"); | |
118 | ||
119 | for (i = 0; i < 2; i++) { | |
120 | circuit->level_arg[i].level = i + 1; | |
121 | circuit->level_arg[i].circuit = circuit; | |
122 | } | |
123 | #else | |
d62a17ae | 124 | circuit->is_type = IS_LEVEL_1_AND_2; |
125 | circuit->flags = 0; | |
126 | circuit->pad_hellos = 1; | |
127 | for (i = 0; i < 2; i++) { | |
128 | circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL; | |
129 | circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER; | |
130 | circuit->csnp_interval[i] = DEFAULT_CSNP_INTERVAL; | |
131 | circuit->psnp_interval[i] = DEFAULT_PSNP_INTERVAL; | |
132 | circuit->priority[i] = DEFAULT_PRIORITY; | |
133 | circuit->metric[i] = DEFAULT_CIRCUIT_METRIC; | |
134 | circuit->te_metric[i] = DEFAULT_CIRCUIT_METRIC; | |
7da4aa3c CF |
135 | circuit->level_arg[i].level = i + 1; |
136 | circuit->level_arg[i].circuit = circuit; | |
d62a17ae | 137 | } |
cc50ddb2 | 138 | #endif /* ifndef FABRICD */ |
d62a17ae | 139 | |
d62a17ae | 140 | circuit_mt_init(circuit); |
141 | ||
142 | QOBJ_REG(circuit, isis_circuit); | |
143 | ||
144 | return circuit; | |
eb5d44eb | 145 | } |
146 | ||
d62a17ae | 147 | void isis_circuit_del(struct isis_circuit *circuit) |
3f045a08 | 148 | { |
d62a17ae | 149 | if (!circuit) |
150 | return; | |
3f045a08 | 151 | |
d62a17ae | 152 | QOBJ_UNREG(circuit); |
676a4ea3 | 153 | |
d62a17ae | 154 | isis_circuit_if_unbind(circuit, circuit->interface); |
3f045a08 | 155 | |
d62a17ae | 156 | circuit_mt_finish(circuit); |
064f4896 | 157 | |
d62a17ae | 158 | /* and lastly the circuit itself */ |
159 | XFREE(MTYPE_ISIS_CIRCUIT, circuit); | |
3f045a08 | 160 | |
d62a17ae | 161 | return; |
3f045a08 JB |
162 | } |
163 | ||
d62a17ae | 164 | void isis_circuit_configure(struct isis_circuit *circuit, |
165 | struct isis_area *area) | |
eb5d44eb | 166 | { |
d62a17ae | 167 | assert(area); |
168 | circuit->area = area; | |
169 | ||
170 | /* | |
171 | * Whenever the is-type of an area is changed, the is-type of each | |
172 | * circuit | |
173 | * in that area is updated to a non-empty subset of the area is-type. | |
174 | * Inversely, when configuring a new circuit, this property should be | |
175 | * ensured as well. | |
176 | */ | |
177 | if (area->is_type != IS_LEVEL_1_AND_2) | |
178 | circuit->is_type = area->is_type; | |
179 | ||
180 | /* | |
181 | * Add the circuit into area | |
182 | */ | |
183 | listnode_add(area->circuit_list, circuit); | |
184 | ||
185 | circuit->idx = flags_get_index(&area->flags); | |
186 | ||
187 | return; | |
eb5d44eb | 188 | } |
189 | ||
d62a17ae | 190 | void isis_circuit_deconfigure(struct isis_circuit *circuit, |
191 | struct isis_area *area) | |
eb5d44eb | 192 | { |
d62a17ae | 193 | /* Free the index of SRM and SSN flags */ |
194 | flags_free_index(&area->flags, circuit->idx); | |
195 | circuit->idx = 0; | |
196 | /* Remove circuit from area */ | |
197 | assert(circuit->area == area); | |
198 | listnode_delete(area->circuit_list, circuit); | |
199 | circuit->area = NULL; | |
200 | ||
201 | return; | |
eb5d44eb | 202 | } |
203 | ||
d62a17ae | 204 | struct isis_circuit *circuit_lookup_by_ifp(struct interface *ifp, |
205 | struct list *list) | |
eb5d44eb | 206 | { |
d62a17ae | 207 | struct isis_circuit *circuit = NULL; |
208 | struct listnode *node; | |
f390d2c7 | 209 | |
d62a17ae | 210 | if (!list) |
211 | return NULL; | |
f390d2c7 | 212 | |
d62a17ae | 213 | for (ALL_LIST_ELEMENTS_RO(list, node, circuit)) |
214 | if (circuit->interface == ifp) { | |
215 | assert(ifp->info == circuit); | |
216 | return circuit; | |
217 | } | |
3f045a08 | 218 | |
d62a17ae | 219 | return NULL; |
eb5d44eb | 220 | } |
221 | ||
d62a17ae | 222 | struct isis_circuit *circuit_scan_by_ifp(struct interface *ifp) |
eb5d44eb | 223 | { |
d62a17ae | 224 | struct isis_area *area; |
225 | struct listnode *node; | |
226 | struct isis_circuit *circuit; | |
227 | ||
228 | if (ifp->info) | |
229 | return (struct isis_circuit *)ifp->info; | |
230 | ||
231 | if (isis->area_list) { | |
232 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { | |
233 | circuit = | |
234 | circuit_lookup_by_ifp(ifp, area->circuit_list); | |
235 | if (circuit) | |
236 | return circuit; | |
237 | } | |
238 | } | |
239 | return circuit_lookup_by_ifp(ifp, isis->init_circ_list); | |
eb5d44eb | 240 | } |
241 | ||
d62a17ae | 242 | void isis_circuit_add_addr(struct isis_circuit *circuit, |
243 | struct connected *connected) | |
eb5d44eb | 244 | { |
d62a17ae | 245 | struct listnode *node; |
246 | struct prefix_ipv4 *ipv4; | |
4690c7d7 | 247 | #if defined(EXTREME_DEBUG) |
d62a17ae | 248 | char buf[PREFIX2STR_BUFFER]; |
4690c7d7 | 249 | #endif |
d62a17ae | 250 | struct prefix_ipv6 *ipv6; |
f891f443 | 251 | |
d62a17ae | 252 | if (connected->address->family == AF_INET) { |
d7c0a89a | 253 | uint32_t addr = connected->address->u.prefix4.s_addr; |
d62a17ae | 254 | addr = ntohl(addr); |
255 | if (IPV4_NET0(addr) || IPV4_NET127(addr) || IN_CLASSD(addr) | |
256 | || IPV4_LINKLOCAL(addr)) | |
257 | return; | |
3f045a08 | 258 | |
d62a17ae | 259 | for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, ipv4)) |
260 | if (prefix_same((struct prefix *)ipv4, | |
261 | connected->address)) | |
262 | return; | |
3f045a08 | 263 | |
d62a17ae | 264 | ipv4 = prefix_ipv4_new(); |
265 | ipv4->prefixlen = connected->address->prefixlen; | |
266 | ipv4->prefix = connected->address->u.prefix4; | |
267 | listnode_add(circuit->ip_addrs, ipv4); | |
f8c06e2c | 268 | |
1b3f47d0 | 269 | /* Update Local IP address parameter if MPLS TE is enable */ |
d80e23f8 EDP |
270 | if (circuit->ext && circuit->area |
271 | && IS_MPLS_TE(circuit->area->mta)) { | |
1b3f47d0 OD |
272 | circuit->ext->local_addr.s_addr = ipv4->prefix.s_addr; |
273 | SET_SUBTLV(circuit->ext, EXT_LOCAL_ADDR); | |
274 | } | |
f8c06e2c | 275 | |
d62a17ae | 276 | if (circuit->area) |
277 | lsp_regenerate_schedule(circuit->area, circuit->is_type, | |
278 | 0); | |
f891f443 | 279 | |
eb5d44eb | 280 | #ifdef EXTREME_DEBUG |
d62a17ae | 281 | prefix2str(connected->address, buf, sizeof(buf)); |
c59f88c8 CF |
282 | zlog_debug("Added IP address %s to circuit %s", buf, |
283 | circuit->interface->name); | |
f390d2c7 | 284 | #endif /* EXTREME_DEBUG */ |
d62a17ae | 285 | } |
286 | if (connected->address->family == AF_INET6) { | |
287 | if (IN6_IS_ADDR_LOOPBACK(&connected->address->u.prefix6)) | |
288 | return; | |
289 | ||
290 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ipv6)) | |
291 | if (prefix_same((struct prefix *)ipv6, | |
292 | connected->address)) | |
293 | return; | |
294 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ipv6)) | |
295 | if (prefix_same((struct prefix *)ipv6, | |
296 | connected->address)) | |
297 | return; | |
298 | ||
299 | ipv6 = prefix_ipv6_new(); | |
300 | ipv6->prefixlen = connected->address->prefixlen; | |
301 | ipv6->prefix = connected->address->u.prefix6; | |
302 | ||
303 | if (IN6_IS_ADDR_LINKLOCAL(&ipv6->prefix)) | |
304 | listnode_add(circuit->ipv6_link, ipv6); | |
305 | else | |
306 | listnode_add(circuit->ipv6_non_link, ipv6); | |
307 | if (circuit->area) | |
308 | lsp_regenerate_schedule(circuit->area, circuit->is_type, | |
309 | 0); | |
f891f443 | 310 | |
eb5d44eb | 311 | #ifdef EXTREME_DEBUG |
d62a17ae | 312 | prefix2str(connected->address, buf, sizeof(buf)); |
c59f88c8 CF |
313 | zlog_debug("Added IPv6 address %s to circuit %s", buf, |
314 | circuit->interface->name); | |
f390d2c7 | 315 | #endif /* EXTREME_DEBUG */ |
d62a17ae | 316 | } |
317 | return; | |
eb5d44eb | 318 | } |
319 | ||
d62a17ae | 320 | void isis_circuit_del_addr(struct isis_circuit *circuit, |
321 | struct connected *connected) | |
eb5d44eb | 322 | { |
d62a17ae | 323 | struct prefix_ipv4 *ipv4, *ip = NULL; |
324 | struct listnode *node; | |
325 | char buf[PREFIX2STR_BUFFER]; | |
326 | struct prefix_ipv6 *ipv6, *ip6 = NULL; | |
327 | int found = 0; | |
328 | ||
329 | if (connected->address->family == AF_INET) { | |
330 | ipv4 = prefix_ipv4_new(); | |
331 | ipv4->prefixlen = connected->address->prefixlen; | |
332 | ipv4->prefix = connected->address->u.prefix4; | |
333 | ||
334 | for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, ip)) | |
335 | if (prefix_same((struct prefix *)ip, | |
336 | (struct prefix *)ipv4)) | |
337 | break; | |
338 | ||
339 | if (ip) { | |
340 | listnode_delete(circuit->ip_addrs, ip); | |
63265b5c | 341 | prefix_ipv4_free(&ip); |
d62a17ae | 342 | if (circuit->area) |
343 | lsp_regenerate_schedule(circuit->area, | |
344 | circuit->is_type, 0); | |
345 | } else { | |
346 | prefix2str(connected->address, buf, sizeof(buf)); | |
347 | zlog_warn( | |
d6951e5e | 348 | "Nonexistent ip address %s removal attempt from circuit %s", |
c59f88c8 | 349 | buf, circuit->interface->name); |
d62a17ae | 350 | zlog_warn("Current ip addresses on %s:", |
351 | circuit->interface->name); | |
352 | for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, | |
353 | ip)) { | |
354 | prefix2str(ip, buf, sizeof(buf)); | |
355 | zlog_warn(" %s", buf); | |
356 | } | |
357 | zlog_warn("End of addresses"); | |
358 | } | |
359 | ||
63265b5c | 360 | prefix_ipv4_free(&ipv4); |
f891f443 | 361 | } |
d62a17ae | 362 | if (connected->address->family == AF_INET6) { |
363 | ipv6 = prefix_ipv6_new(); | |
364 | ipv6->prefixlen = connected->address->prefixlen; | |
365 | ipv6->prefix = connected->address->u.prefix6; | |
366 | ||
367 | if (IN6_IS_ADDR_LINKLOCAL(&ipv6->prefix)) { | |
368 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, | |
369 | ip6)) { | |
370 | if (prefix_same((struct prefix *)ip6, | |
371 | (struct prefix *)ipv6)) | |
372 | break; | |
373 | } | |
374 | if (ip6) { | |
375 | listnode_delete(circuit->ipv6_link, ip6); | |
63265b5c | 376 | prefix_ipv6_free(&ip6); |
d62a17ae | 377 | found = 1; |
378 | } | |
379 | } else { | |
380 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, | |
381 | ip6)) { | |
382 | if (prefix_same((struct prefix *)ip6, | |
383 | (struct prefix *)ipv6)) | |
384 | break; | |
385 | } | |
386 | if (ip6) { | |
387 | listnode_delete(circuit->ipv6_non_link, ip6); | |
63265b5c | 388 | prefix_ipv6_free(&ip6); |
d62a17ae | 389 | found = 1; |
390 | } | |
391 | } | |
392 | ||
393 | if (!found) { | |
394 | prefix2str(connected->address, buf, sizeof(buf)); | |
395 | zlog_warn( | |
d6951e5e | 396 | "Nonexistent ip address %s removal attempt from circuit %s", |
c59f88c8 | 397 | buf, circuit->interface->name); |
d62a17ae | 398 | zlog_warn("Current ip addresses on %s:", |
399 | circuit->interface->name); | |
400 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, | |
401 | ip6)) { | |
402 | prefix2str((struct prefix *)ip6, (char *)buf, | |
c28135f3 | 403 | sizeof(buf)); |
d62a17ae | 404 | zlog_warn(" %s", buf); |
405 | } | |
406 | zlog_warn(" -----"); | |
407 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, | |
408 | ip6)) { | |
409 | prefix2str((struct prefix *)ip6, (char *)buf, | |
c28135f3 | 410 | sizeof(buf)); |
d62a17ae | 411 | zlog_warn(" %s", buf); |
412 | } | |
413 | zlog_warn("End of addresses"); | |
414 | } else if (circuit->area) | |
415 | lsp_regenerate_schedule(circuit->area, circuit->is_type, | |
416 | 0); | |
417 | ||
63265b5c | 418 | prefix_ipv6_free(&ipv6); |
f891f443 | 419 | } |
d62a17ae | 420 | return; |
421 | } | |
e8aca32f | 422 | |
0849c75e | 423 | static uint8_t isis_circuit_id_gen(struct isis *isis, struct interface *ifp) |
d62a17ae | 424 | { |
068c8222 CF |
425 | /* Circuit ids MUST be unique for any broadcast circuits. Otherwise, |
426 | * Pseudo-Node LSPs cannot be generated correctly. | |
427 | * | |
98c5bc15 | 428 | * Currently, allocate one circuit ID for any circuit, limiting the total |
068c8222 CF |
429 | * numer of circuits IS-IS can run on to 255. |
430 | * | |
98c5bc15 | 431 | * We should revisit this when implementing 3-way adjacencies for p2p, since |
068c8222 CF |
432 | * we then have extended interface IDs available. |
433 | */ | |
434 | uint8_t id = ifp->ifindex; | |
d62a17ae | 435 | unsigned int i; |
d62a17ae | 436 | |
068c8222 CF |
437 | for (i = 0; i < 256; i++) { |
438 | if (id && !_ISIS_CHECK_FLAG(isis->circuit_ids_used, id)) | |
d62a17ae | 439 | break; |
068c8222 | 440 | id++; |
f891f443 | 441 | } |
442 | ||
068c8222 | 443 | if (i == 256) { |
996c9314 LB |
444 | zlog_warn("Could not allocate a circuit id for '%s'", |
445 | ifp->name); | |
068c8222 | 446 | return 0; |
f891f443 | 447 | } |
e8aca32f | 448 | |
0849c75e | 449 | _ISIS_SET_FLAG(isis->circuit_ids_used, id); |
d62a17ae | 450 | return id; |
3f045a08 JB |
451 | } |
452 | ||
d62a17ae | 453 | void isis_circuit_if_add(struct isis_circuit *circuit, struct interface *ifp) |
eb5d44eb | 454 | { |
d62a17ae | 455 | struct listnode *node, *nnode; |
456 | struct connected *conn; | |
457 | ||
d62a17ae | 458 | isis_circuit_if_bind(circuit, ifp); |
d62a17ae | 459 | |
460 | if (if_is_broadcast(ifp)) { | |
65f18157 | 461 | if (fabricd || circuit->circ_type_config == CIRCUIT_T_P2P) |
d62a17ae | 462 | circuit->circ_type = CIRCUIT_T_P2P; |
463 | else | |
464 | circuit->circ_type = CIRCUIT_T_BROADCAST; | |
465 | } else if (if_is_pointopoint(ifp)) { | |
466 | circuit->circ_type = CIRCUIT_T_P2P; | |
467 | } else if (if_is_loopback(ifp)) { | |
468 | circuit->circ_type = CIRCUIT_T_LOOPBACK; | |
469 | circuit->is_passive = 1; | |
470 | } else { | |
471 | /* It's normal in case of loopback etc. */ | |
472 | if (isis->debugs & DEBUG_EVENTS) | |
473 | zlog_debug("isis_circuit_if_add: unsupported media"); | |
474 | circuit->circ_type = CIRCUIT_T_UNKNOWN; | |
475 | } | |
476 | ||
477 | circuit->ip_addrs = list_new(); | |
478 | circuit->ipv6_link = list_new(); | |
479 | circuit->ipv6_non_link = list_new(); | |
480 | ||
481 | for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, conn)) | |
482 | isis_circuit_add_addr(circuit, conn); | |
1b3f47d0 | 483 | |
eb5d44eb | 484 | } |
485 | ||
d62a17ae | 486 | void isis_circuit_if_del(struct isis_circuit *circuit, struct interface *ifp) |
eb5d44eb | 487 | { |
d62a17ae | 488 | struct listnode *node, *nnode; |
489 | struct connected *conn; | |
490 | ||
491 | assert(circuit->interface == ifp); | |
492 | ||
493 | /* destroy addresses */ | |
494 | for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, conn)) | |
495 | isis_circuit_del_addr(circuit, conn); | |
496 | ||
497 | if (circuit->ip_addrs) { | |
498 | assert(listcount(circuit->ip_addrs) == 0); | |
6a154c88 | 499 | list_delete(&circuit->ip_addrs); |
d62a17ae | 500 | } |
501 | ||
502 | if (circuit->ipv6_link) { | |
503 | assert(listcount(circuit->ipv6_link) == 0); | |
6a154c88 | 504 | list_delete(&circuit->ipv6_link); |
d62a17ae | 505 | } |
506 | ||
507 | if (circuit->ipv6_non_link) { | |
508 | assert(listcount(circuit->ipv6_non_link) == 0); | |
6a154c88 | 509 | list_delete(&circuit->ipv6_non_link); |
d62a17ae | 510 | } |
511 | ||
512 | circuit->circ_type = CIRCUIT_T_UNKNOWN; | |
eb5d44eb | 513 | } |
514 | ||
d62a17ae | 515 | void isis_circuit_if_bind(struct isis_circuit *circuit, struct interface *ifp) |
3f045a08 | 516 | { |
d62a17ae | 517 | assert(circuit != NULL); |
518 | assert(ifp != NULL); | |
519 | if (circuit->interface) | |
520 | assert(circuit->interface == ifp); | |
521 | else | |
522 | circuit->interface = ifp; | |
523 | if (ifp->info) | |
524 | assert(ifp->info == circuit); | |
525 | else | |
526 | ifp->info = circuit; | |
3f045a08 JB |
527 | } |
528 | ||
d62a17ae | 529 | void isis_circuit_if_unbind(struct isis_circuit *circuit, struct interface *ifp) |
eb5d44eb | 530 | { |
d62a17ae | 531 | assert(circuit != NULL); |
532 | assert(ifp != NULL); | |
533 | assert(circuit->interface == ifp); | |
534 | assert(ifp->info == circuit); | |
535 | circuit->interface = NULL; | |
536 | ifp->info = NULL; | |
3f045a08 | 537 | } |
f390d2c7 | 538 | |
d62a17ae | 539 | static void isis_circuit_update_all_srmflags(struct isis_circuit *circuit, |
540 | int is_set) | |
3f045a08 | 541 | { |
d62a17ae | 542 | struct isis_area *area; |
543 | struct isis_lsp *lsp; | |
d62a17ae | 544 | int level; |
545 | ||
546 | assert(circuit); | |
547 | area = circuit->area; | |
548 | assert(area); | |
549 | for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { | |
9b39405f CF |
550 | if (!(level & circuit->is_type)) |
551 | continue; | |
552 | ||
4bef0ec4 | 553 | if (!lspdb_count(&area->lspdb[level - 1])) |
9b39405f CF |
554 | continue; |
555 | ||
81fddbe7 | 556 | frr_each (lspdb, &area->lspdb[level - 1], lsp) { |
9b39405f CF |
557 | if (is_set) { |
558 | isis_tx_queue_add(circuit->tx_queue, lsp, | |
559 | TX_LSP_NORMAL); | |
560 | } else { | |
561 | isis_tx_queue_del(circuit->tx_queue, lsp); | |
d62a17ae | 562 | } |
563 | } | |
564 | } | |
eb5d44eb | 565 | } |
566 | ||
d62a17ae | 567 | size_t isis_circuit_pdu_size(struct isis_circuit *circuit) |
b20ccb3a | 568 | { |
d62a17ae | 569 | return ISO_MTU(circuit); |
b20ccb3a CF |
570 | } |
571 | ||
d62a17ae | 572 | void isis_circuit_stream(struct isis_circuit *circuit, struct stream **stream) |
b20ccb3a | 573 | { |
d62a17ae | 574 | size_t stream_size = isis_circuit_pdu_size(circuit); |
575 | ||
576 | if (!*stream) { | |
577 | *stream = stream_new(stream_size); | |
578 | } else { | |
579 | if (STREAM_SIZE(*stream) != stream_size) | |
db3c830a | 580 | stream_resize_inplace(stream, stream_size); |
d62a17ae | 581 | stream_reset(*stream); |
582 | } | |
b20ccb3a CF |
583 | } |
584 | ||
d62a17ae | 585 | void isis_circuit_prepare(struct isis_circuit *circuit) |
5904f19f | 586 | { |
b0dd98e7 | 587 | #if ISIS_METHOD != ISIS_METHOD_DLPI |
d62a17ae | 588 | thread_add_read(master, isis_receive, circuit, circuit->fd, |
589 | &circuit->t_read); | |
5904f19f | 590 | #else |
d62a17ae | 591 | thread_add_timer_msec(master, isis_receive, circuit, |
592 | listcount(circuit->area->circuit_list) * 100, | |
593 | &circuit->t_read); | |
5904f19f RW |
594 | #endif |
595 | } | |
596 | ||
d62a17ae | 597 | int isis_circuit_up(struct isis_circuit *circuit) |
eb5d44eb | 598 | { |
d62a17ae | 599 | int retv; |
600 | ||
601 | /* Set the flags for all the lsps of the circuit. */ | |
602 | isis_circuit_update_all_srmflags(circuit, 1); | |
603 | ||
604 | if (circuit->state == C_STATE_UP) | |
605 | return ISIS_OK; | |
606 | ||
607 | if (circuit->is_passive) | |
608 | return ISIS_OK; | |
609 | ||
610 | if (circuit->area->lsp_mtu > isis_circuit_pdu_size(circuit)) { | |
af4c2728 | 611 | flog_err( |
1a7ecb96 | 612 | EC_ISIS_CONFIG, |
d62a17ae | 613 | "Interface MTU %zu on %s is too low to support area lsp mtu %u!", |
614 | isis_circuit_pdu_size(circuit), | |
615 | circuit->interface->name, circuit->area->lsp_mtu); | |
616 | isis_circuit_update_all_srmflags(circuit, 0); | |
617 | return ISIS_ERROR; | |
618 | } | |
619 | ||
620 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
0849c75e CF |
621 | circuit->circuit_id = isis_circuit_id_gen(isis, circuit->interface); |
622 | if (!circuit->circuit_id) { | |
af4c2728 | 623 | flog_err( |
1a7ecb96 | 624 | EC_ISIS_CONFIG, |
54ece698 | 625 | "There are already 255 broadcast circuits active!"); |
0849c75e CF |
626 | return ISIS_ERROR; |
627 | } | |
628 | ||
d62a17ae | 629 | /* |
630 | * Get the Hardware Address | |
631 | */ | |
632 | if (circuit->interface->hw_addr_len != ETH_ALEN) { | |
633 | zlog_warn("unsupported link layer"); | |
634 | } else { | |
635 | memcpy(circuit->u.bc.snpa, circuit->interface->hw_addr, | |
636 | ETH_ALEN); | |
637 | } | |
3f045a08 | 638 | #ifdef EXTREME_DEGUG |
d62a17ae | 639 | zlog_debug("isis_circuit_if_add: if_id %d, isomtu %d snpa %s", |
640 | circuit->interface->ifindex, ISO_MTU(circuit), | |
641 | snpa_print(circuit->u.bc.snpa)); | |
3f045a08 | 642 | #endif /* EXTREME_DEBUG */ |
3f045a08 | 643 | |
d62a17ae | 644 | circuit->u.bc.adjdb[0] = list_new(); |
645 | circuit->u.bc.adjdb[1] = list_new(); | |
646 | ||
647 | /* | |
648 | * ISO 10589 - 8.4.1 Enabling of broadcast circuits | |
649 | */ | |
650 | ||
651 | /* initilizing the hello sending threads | |
652 | * for a broadcast IF | |
653 | */ | |
654 | ||
655 | /* 8.4.1 a) commence sending of IIH PDUs */ | |
656 | ||
7c4f7aab CF |
657 | for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { |
658 | if (!(circuit->is_type & level)) | |
659 | continue; | |
660 | ||
a0a707ee | 661 | send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY); |
7c4f7aab CF |
662 | circuit->u.bc.lan_neighs[level - 1] = list_new(); |
663 | ||
664 | thread_add_timer(master, isis_run_dr, | |
665 | &circuit->level_arg[level - 1], | |
666 | 2 * circuit->hello_interval[level - 1], | |
667 | &circuit->u.bc.t_run_dr[level - 1]); | |
d62a17ae | 668 | } |
669 | ||
670 | /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */ | |
671 | /* 8.4.1 c) FIXME: listen for ESH PDUs */ | |
d4670f51 | 672 | } else if (circuit->circ_type == CIRCUIT_T_P2P) { |
d62a17ae | 673 | /* initializing the hello send threads |
674 | * for a ptp IF | |
675 | */ | |
676 | circuit->u.p2p.neighbor = NULL; | |
a0a707ee | 677 | send_hello_sched(circuit, 0, TRIGGERED_IIH_DELAY); |
d62a17ae | 678 | } |
679 | ||
680 | /* initializing PSNP timers */ | |
681 | if (circuit->is_type & IS_LEVEL_1) | |
682 | thread_add_timer( | |
683 | master, send_l1_psnp, circuit, | |
684 | isis_jitter(circuit->psnp_interval[0], PSNP_JITTER), | |
685 | &circuit->t_send_psnp[0]); | |
686 | ||
687 | if (circuit->is_type & IS_LEVEL_2) | |
688 | thread_add_timer( | |
689 | master, send_l2_psnp, circuit, | |
690 | isis_jitter(circuit->psnp_interval[1], PSNP_JITTER), | |
691 | &circuit->t_send_psnp[1]); | |
692 | ||
693 | /* unified init for circuits; ignore warnings below this level */ | |
694 | retv = isis_sock_init(circuit); | |
695 | if (retv != ISIS_OK) { | |
696 | isis_circuit_down(circuit); | |
697 | return retv; | |
698 | } | |
699 | ||
700 | /* initialize the circuit streams after opening connection */ | |
701 | isis_circuit_stream(circuit, &circuit->rcv_stream); | |
702 | isis_circuit_stream(circuit, &circuit->snd_stream); | |
703 | ||
704 | isis_circuit_prepare(circuit); | |
705 | ||
9b39405f | 706 | circuit->tx_queue = isis_tx_queue_new(circuit, send_lsp); |
d62a17ae | 707 | |
392b89f3 EDP |
708 | #ifndef FABRICD |
709 | /* send northbound notification */ | |
710 | isis_notif_if_state_change(circuit, false); | |
711 | #endif /* ifndef FABRICD */ | |
712 | ||
d62a17ae | 713 | return ISIS_OK; |
eb5d44eb | 714 | } |
715 | ||
d62a17ae | 716 | void isis_circuit_down(struct isis_circuit *circuit) |
eb5d44eb | 717 | { |
392b89f3 EDP |
718 | #ifndef FABRICD |
719 | /* send northbound notification */ | |
720 | isis_notif_if_state_change(circuit, true); | |
721 | #endif /* ifndef FABRICD */ | |
722 | ||
d62a17ae | 723 | /* Clear the flags for all the lsps of the circuit. */ |
724 | isis_circuit_update_all_srmflags(circuit, 0); | |
725 | ||
726 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
727 | /* destroy neighbour lists */ | |
728 | if (circuit->u.bc.lan_neighs[0]) { | |
6a154c88 | 729 | list_delete(&circuit->u.bc.lan_neighs[0]); |
d62a17ae | 730 | circuit->u.bc.lan_neighs[0] = NULL; |
731 | } | |
732 | if (circuit->u.bc.lan_neighs[1]) { | |
6a154c88 | 733 | list_delete(&circuit->u.bc.lan_neighs[1]); |
d62a17ae | 734 | circuit->u.bc.lan_neighs[1] = NULL; |
735 | } | |
736 | /* destroy adjacency databases */ | |
737 | if (circuit->u.bc.adjdb[0]) { | |
738 | circuit->u.bc.adjdb[0]->del = isis_delete_adj; | |
6a154c88 | 739 | list_delete(&circuit->u.bc.adjdb[0]); |
d62a17ae | 740 | circuit->u.bc.adjdb[0] = NULL; |
741 | } | |
742 | if (circuit->u.bc.adjdb[1]) { | |
743 | circuit->u.bc.adjdb[1]->del = isis_delete_adj; | |
6a154c88 | 744 | list_delete(&circuit->u.bc.adjdb[1]); |
d62a17ae | 745 | circuit->u.bc.adjdb[1] = NULL; |
746 | } | |
747 | if (circuit->u.bc.is_dr[0]) { | |
748 | isis_dr_resign(circuit, 1); | |
749 | circuit->u.bc.is_dr[0] = 0; | |
750 | } | |
751 | memset(circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1); | |
752 | if (circuit->u.bc.is_dr[1]) { | |
753 | isis_dr_resign(circuit, 2); | |
754 | circuit->u.bc.is_dr[1] = 0; | |
755 | } | |
756 | memset(circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1); | |
757 | memset(circuit->u.bc.snpa, 0, ETH_ALEN); | |
758 | ||
759 | THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[0]); | |
760 | THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[1]); | |
761 | THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[0]); | |
762 | THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[1]); | |
763 | THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[0]); | |
764 | THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[1]); | |
765 | circuit->lsp_regenerate_pending[0] = 0; | |
766 | circuit->lsp_regenerate_pending[1] = 0; | |
0849c75e CF |
767 | |
768 | _ISIS_CLEAR_FLAG(isis->circuit_ids_used, circuit->circuit_id); | |
769 | circuit->circuit_id = 0; | |
d62a17ae | 770 | } else if (circuit->circ_type == CIRCUIT_T_P2P) { |
771 | isis_delete_adj(circuit->u.p2p.neighbor); | |
772 | circuit->u.p2p.neighbor = NULL; | |
773 | THREAD_TIMER_OFF(circuit->u.p2p.t_send_p2p_hello); | |
774 | } | |
775 | ||
776 | /* Cancel all active threads */ | |
777 | THREAD_TIMER_OFF(circuit->t_send_csnp[0]); | |
778 | THREAD_TIMER_OFF(circuit->t_send_csnp[1]); | |
779 | THREAD_TIMER_OFF(circuit->t_send_psnp[0]); | |
780 | THREAD_TIMER_OFF(circuit->t_send_psnp[1]); | |
781 | THREAD_OFF(circuit->t_read); | |
782 | ||
9b39405f CF |
783 | if (circuit->tx_queue) { |
784 | isis_tx_queue_free(circuit->tx_queue); | |
785 | circuit->tx_queue = NULL; | |
58e16237 CF |
786 | } |
787 | ||
d62a17ae | 788 | /* send one gratuitous hello to spead up convergence */ |
d4670f51 CF |
789 | if (circuit->state == C_STATE_UP) { |
790 | if (circuit->is_type & IS_LEVEL_1) | |
791 | send_hello(circuit, IS_LEVEL_1); | |
792 | if (circuit->is_type & IS_LEVEL_2) | |
793 | send_hello(circuit, IS_LEVEL_2); | |
794 | } | |
d62a17ae | 795 | |
796 | circuit->upadjcount[0] = 0; | |
797 | circuit->upadjcount[1] = 0; | |
798 | ||
799 | /* close the socket */ | |
800 | if (circuit->fd) { | |
801 | close(circuit->fd); | |
802 | circuit->fd = 0; | |
803 | } | |
804 | ||
805 | if (circuit->rcv_stream != NULL) { | |
806 | stream_free(circuit->rcv_stream); | |
807 | circuit->rcv_stream = NULL; | |
808 | } | |
809 | ||
810 | if (circuit->snd_stream != NULL) { | |
811 | stream_free(circuit->snd_stream); | |
812 | circuit->snd_stream = NULL; | |
813 | } | |
814 | ||
815 | thread_cancel_event(master, circuit); | |
816 | ||
817 | return; | |
eb5d44eb | 818 | } |
819 | ||
d62a17ae | 820 | void circuit_update_nlpids(struct isis_circuit *circuit) |
eb5d44eb | 821 | { |
d62a17ae | 822 | circuit->nlpids.count = 0; |
823 | ||
824 | if (circuit->ip_router) { | |
825 | circuit->nlpids.nlpids[0] = NLPID_IP; | |
826 | circuit->nlpids.count++; | |
827 | } | |
828 | if (circuit->ipv6_router) { | |
829 | circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6; | |
830 | circuit->nlpids.count++; | |
831 | } | |
832 | return; | |
eb5d44eb | 833 | } |
834 | ||
d62a17ae | 835 | void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty, |
836 | char detail) | |
3f045a08 | 837 | { |
d62a17ae | 838 | if (detail == ISIS_UI_LEVEL_BRIEF) { |
839 | vty_out(vty, " %-12s", circuit->interface->name); | |
840 | vty_out(vty, "0x%-7x", circuit->circuit_id); | |
841 | vty_out(vty, "%-9s", circuit_state2string(circuit->state)); | |
842 | vty_out(vty, "%-9s", circuit_type2string(circuit->circ_type)); | |
843 | vty_out(vty, "%-9s", circuit_t2string(circuit->is_type)); | |
844 | vty_out(vty, "\n"); | |
845 | } | |
846 | ||
847 | if (detail == ISIS_UI_LEVEL_DETAIL) { | |
848 | struct listnode *node; | |
849 | struct prefix *ip_addr; | |
850 | char buf[BUFSIZ]; | |
851 | ||
852 | vty_out(vty, " Interface: %s", circuit->interface->name); | |
853 | vty_out(vty, ", State: %s", | |
854 | circuit_state2string(circuit->state)); | |
855 | if (circuit->is_passive) | |
856 | vty_out(vty, ", Passive"); | |
857 | else | |
858 | vty_out(vty, ", Active"); | |
859 | vty_out(vty, ", Circuit Id: 0x%x", circuit->circuit_id); | |
860 | vty_out(vty, "\n"); | |
861 | vty_out(vty, " Type: %s", | |
862 | circuit_type2string(circuit->circ_type)); | |
863 | vty_out(vty, ", Level: %s", circuit_t2string(circuit->is_type)); | |
864 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) | |
865 | vty_out(vty, ", SNPA: %-10s", | |
866 | snpa_print(circuit->u.bc.snpa)); | |
867 | vty_out(vty, "\n"); | |
868 | if (circuit->is_type & IS_LEVEL_1) { | |
869 | vty_out(vty, " Level-1 Information:\n"); | |
870 | if (circuit->area->newmetric) | |
871 | vty_out(vty, " Metric: %d", | |
872 | circuit->te_metric[0]); | |
873 | else | |
874 | vty_out(vty, " Metric: %d", | |
875 | circuit->metric[0]); | |
876 | if (!circuit->is_passive) { | |
877 | vty_out(vty, ", Active neighbors: %u\n", | |
878 | circuit->upadjcount[0]); | |
879 | vty_out(vty, | |
880 | " Hello interval: %u, " | |
881 | "Holddown count: %u %s\n", | |
882 | circuit->hello_interval[0], | |
883 | circuit->hello_multiplier[0], | |
884 | (circuit->pad_hellos ? "(pad)" | |
885 | : "(no-pad)")); | |
886 | vty_out(vty, | |
887 | " CNSP interval: %u, " | |
888 | "PSNP interval: %u\n", | |
889 | circuit->csnp_interval[0], | |
890 | circuit->psnp_interval[0]); | |
891 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) | |
892 | vty_out(vty, | |
893 | " LAN Priority: %u, %s\n", | |
894 | circuit->priority[0], | |
895 | (circuit->u.bc.is_dr[0] | |
896 | ? "is DIS" | |
897 | : "is not DIS")); | |
898 | } else { | |
899 | vty_out(vty, "\n"); | |
900 | } | |
901 | } | |
902 | if (circuit->is_type & IS_LEVEL_2) { | |
903 | vty_out(vty, " Level-2 Information:\n"); | |
904 | if (circuit->area->newmetric) | |
905 | vty_out(vty, " Metric: %d", | |
906 | circuit->te_metric[1]); | |
907 | else | |
908 | vty_out(vty, " Metric: %d", | |
909 | circuit->metric[1]); | |
910 | if (!circuit->is_passive) { | |
911 | vty_out(vty, ", Active neighbors: %u\n", | |
912 | circuit->upadjcount[1]); | |
913 | vty_out(vty, | |
914 | " Hello interval: %u, " | |
915 | "Holddown count: %u %s\n", | |
916 | circuit->hello_interval[1], | |
917 | circuit->hello_multiplier[1], | |
918 | (circuit->pad_hellos ? "(pad)" | |
919 | : "(no-pad)")); | |
920 | vty_out(vty, | |
921 | " CNSP interval: %u, " | |
922 | "PSNP interval: %u\n", | |
923 | circuit->csnp_interval[1], | |
924 | circuit->psnp_interval[1]); | |
925 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) | |
926 | vty_out(vty, | |
927 | " LAN Priority: %u, %s\n", | |
928 | circuit->priority[1], | |
929 | (circuit->u.bc.is_dr[1] | |
930 | ? "is DIS" | |
931 | : "is not DIS")); | |
932 | } else { | |
933 | vty_out(vty, "\n"); | |
934 | } | |
935 | } | |
936 | if (circuit->ip_addrs && listcount(circuit->ip_addrs) > 0) { | |
937 | vty_out(vty, " IP Prefix(es):\n"); | |
938 | for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, | |
939 | ip_addr)) { | |
1445b43c A |
940 | prefix2str(ip_addr, buf, sizeof(buf)); |
941 | vty_out(vty, " %s\n", buf); | |
d62a17ae | 942 | } |
943 | } | |
944 | if (circuit->ipv6_link && listcount(circuit->ipv6_link) > 0) { | |
945 | vty_out(vty, " IPv6 Link-Locals:\n"); | |
946 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, | |
947 | ip_addr)) { | |
1445b43c A |
948 | prefix2str(ip_addr, (char *)buf, BUFSIZ); |
949 | vty_out(vty, " %s\n", buf); | |
d62a17ae | 950 | } |
951 | } | |
952 | if (circuit->ipv6_non_link | |
953 | && listcount(circuit->ipv6_non_link) > 0) { | |
954 | vty_out(vty, " IPv6 Prefixes:\n"); | |
955 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, | |
956 | ip_addr)) { | |
1445b43c A |
957 | prefix2str(ip_addr, (char *)buf, BUFSIZ); |
958 | vty_out(vty, " %s\n", buf); | |
d62a17ae | 959 | } |
960 | } | |
961 | ||
962 | vty_out(vty, "\n"); | |
963 | } | |
964 | return; | |
3f045a08 JB |
965 | } |
966 | ||
05e4ec37 | 967 | #ifdef FABRICD |
d56afe53 CF |
968 | DEFINE_HOOK(isis_circuit_config_write, |
969 | (struct isis_circuit *circuit, struct vty *vty), | |
970 | (circuit, vty)) | |
971 | ||
612c2c15 | 972 | static int isis_interface_config_write(struct vty *vty) |
eb5d44eb | 973 | { |
f4e14fdb | 974 | struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); |
d62a17ae | 975 | int write = 0; |
f4e14fdb | 976 | struct listnode *node; |
d62a17ae | 977 | struct interface *ifp; |
978 | struct isis_area *area; | |
979 | struct isis_circuit *circuit; | |
980 | int i; | |
981 | ||
451fda4f | 982 | FOR_ALL_INTERFACES (vrf, ifp) { |
d62a17ae | 983 | /* IF name */ |
a8b828f3 | 984 | vty_frame(vty, "interface %s\n", ifp->name); |
d62a17ae | 985 | write++; |
986 | /* IF desc */ | |
987 | if (ifp->desc) { | |
988 | vty_out(vty, " description %s\n", ifp->desc); | |
989 | write++; | |
990 | } | |
991 | /* ISIS Circuit */ | |
f4e14fdb | 992 | for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { |
d62a17ae | 993 | circuit = |
994 | circuit_lookup_by_ifp(ifp, area->circuit_list); | |
995 | if (circuit == NULL) | |
996 | continue; | |
997 | if (circuit->ip_router) { | |
7c0cbd0e | 998 | vty_out(vty, " ip router " PROTO_NAME " %s\n", |
d62a17ae | 999 | area->area_tag); |
1000 | write++; | |
1001 | } | |
1002 | if (circuit->is_passive) { | |
7c0cbd0e | 1003 | vty_out(vty, " " PROTO_NAME " passive\n"); |
d62a17ae | 1004 | write++; |
1005 | } | |
1006 | if (circuit->circ_type_config == CIRCUIT_T_P2P) { | |
7c0cbd0e | 1007 | vty_out(vty, " " PROTO_NAME " network point-to-point\n"); |
d62a17ae | 1008 | write++; |
1009 | } | |
1010 | if (circuit->ipv6_router) { | |
7c0cbd0e | 1011 | vty_out(vty, " ipv6 router " PROTO_NAME " %s\n", |
d62a17ae | 1012 | area->area_tag); |
1013 | write++; | |
1014 | } | |
1015 | ||
1016 | /* ISIS - circuit type */ | |
65f18157 CF |
1017 | if (!fabricd) { |
1018 | if (circuit->is_type == IS_LEVEL_1) { | |
1019 | vty_out(vty, " " PROTO_NAME " circuit-type level-1\n"); | |
d62a17ae | 1020 | write++; |
65f18157 CF |
1021 | } else { |
1022 | if (circuit->is_type == IS_LEVEL_2) { | |
1023 | vty_out(vty, | |
1024 | " " PROTO_NAME " circuit-type level-2-only\n"); | |
1025 | write++; | |
1026 | } | |
d62a17ae | 1027 | } |
1028 | } | |
1029 | ||
1030 | /* ISIS - CSNP interval */ | |
1031 | if (circuit->csnp_interval[0] | |
1032 | == circuit->csnp_interval[1]) { | |
1033 | if (circuit->csnp_interval[0] | |
1034 | != DEFAULT_CSNP_INTERVAL) { | |
7c0cbd0e | 1035 | vty_out(vty, " " PROTO_NAME " csnp-interval %d\n", |
d62a17ae | 1036 | circuit->csnp_interval[0]); |
1037 | write++; | |
1038 | } | |
1039 | } else { | |
1040 | for (i = 0; i < 2; i++) { | |
1041 | if (circuit->csnp_interval[i] | |
1042 | != DEFAULT_CSNP_INTERVAL) { | |
1043 | vty_out(vty, | |
7c0cbd0e | 1044 | " " PROTO_NAME " csnp-interval %d level-%d\n", |
d62a17ae | 1045 | circuit->csnp_interval |
1046 | [i], | |
1047 | i + 1); | |
1048 | write++; | |
1049 | } | |
1050 | } | |
1051 | } | |
1052 | ||
1053 | /* ISIS - PSNP interval */ | |
1054 | if (circuit->psnp_interval[0] | |
1055 | == circuit->psnp_interval[1]) { | |
1056 | if (circuit->psnp_interval[0] | |
1057 | != DEFAULT_PSNP_INTERVAL) { | |
7c0cbd0e | 1058 | vty_out(vty, " " PROTO_NAME " psnp-interval %d\n", |
d62a17ae | 1059 | circuit->psnp_interval[0]); |
1060 | write++; | |
1061 | } | |
1062 | } else { | |
1063 | for (i = 0; i < 2; i++) { | |
1064 | if (circuit->psnp_interval[i] | |
1065 | != DEFAULT_PSNP_INTERVAL) { | |
1066 | vty_out(vty, | |
7c0cbd0e | 1067 | " " PROTO_NAME " psnp-interval %d level-%d\n", |
d62a17ae | 1068 | circuit->psnp_interval |
1069 | [i], | |
1070 | i + 1); | |
1071 | write++; | |
1072 | } | |
1073 | } | |
1074 | } | |
1075 | ||
1076 | /* ISIS - Hello padding - Defaults to true so only | |
1077 | * display if false */ | |
1078 | if (circuit->pad_hellos == 0) { | |
7c0cbd0e | 1079 | vty_out(vty, " no " PROTO_NAME " hello padding\n"); |
d62a17ae | 1080 | write++; |
1081 | } | |
1082 | ||
58e5d748 CF |
1083 | if (circuit->disable_threeway_adj) { |
1084 | vty_out(vty, " no isis three-way-handshake\n"); | |
1085 | write++; | |
1086 | } | |
1087 | ||
d62a17ae | 1088 | /* ISIS - Hello interval */ |
1089 | if (circuit->hello_interval[0] | |
1090 | == circuit->hello_interval[1]) { | |
1091 | if (circuit->hello_interval[0] | |
1092 | != DEFAULT_HELLO_INTERVAL) { | |
1093 | vty_out(vty, | |
7c0cbd0e | 1094 | " " PROTO_NAME " hello-interval %d\n", |
d62a17ae | 1095 | circuit->hello_interval[0]); |
1096 | write++; | |
1097 | } | |
1098 | } else { | |
1099 | for (i = 0; i < 2; i++) { | |
1100 | if (circuit->hello_interval[i] | |
1101 | != DEFAULT_HELLO_INTERVAL) { | |
1102 | vty_out(vty, | |
7c0cbd0e | 1103 | " " PROTO_NAME " hello-interval %d level-%d\n", |
d62a17ae | 1104 | circuit->hello_interval |
1105 | [i], | |
1106 | i + 1); | |
1107 | write++; | |
1108 | } | |
1109 | } | |
1110 | } | |
1111 | ||
1112 | /* ISIS - Hello Multiplier */ | |
1113 | if (circuit->hello_multiplier[0] | |
1114 | == circuit->hello_multiplier[1]) { | |
1115 | if (circuit->hello_multiplier[0] | |
1116 | != DEFAULT_HELLO_MULTIPLIER) { | |
1117 | vty_out(vty, | |
7c0cbd0e | 1118 | " " PROTO_NAME " hello-multiplier %d\n", |
d62a17ae | 1119 | circuit->hello_multiplier[0]); |
1120 | write++; | |
1121 | } | |
1122 | } else { | |
1123 | for (i = 0; i < 2; i++) { | |
1124 | if (circuit->hello_multiplier[i] | |
1125 | != DEFAULT_HELLO_MULTIPLIER) { | |
1126 | vty_out(vty, | |
7c0cbd0e | 1127 | " " PROTO_NAME " hello-multiplier %d level-%d\n", |
d62a17ae | 1128 | circuit->hello_multiplier |
1129 | [i], | |
1130 | i + 1); | |
1131 | write++; | |
1132 | } | |
1133 | } | |
1134 | } | |
1135 | ||
1136 | /* ISIS - Priority */ | |
1137 | if (circuit->priority[0] == circuit->priority[1]) { | |
1138 | if (circuit->priority[0] != DEFAULT_PRIORITY) { | |
7c0cbd0e | 1139 | vty_out(vty, " " PROTO_NAME " priority %d\n", |
d62a17ae | 1140 | circuit->priority[0]); |
1141 | write++; | |
1142 | } | |
1143 | } else { | |
1144 | for (i = 0; i < 2; i++) { | |
1145 | if (circuit->priority[i] | |
1146 | != DEFAULT_PRIORITY) { | |
1147 | vty_out(vty, | |
7c0cbd0e | 1148 | " " PROTO_NAME " priority %d level-%d\n", |
d62a17ae | 1149 | circuit->priority[i], |
1150 | i + 1); | |
1151 | write++; | |
1152 | } | |
1153 | } | |
1154 | } | |
1155 | ||
1156 | /* ISIS - Metric */ | |
1157 | if (circuit->te_metric[0] == circuit->te_metric[1]) { | |
1158 | if (circuit->te_metric[0] | |
1159 | != DEFAULT_CIRCUIT_METRIC) { | |
7c0cbd0e | 1160 | vty_out(vty, " " PROTO_NAME " metric %d\n", |
d62a17ae | 1161 | circuit->te_metric[0]); |
1162 | write++; | |
1163 | } | |
1164 | } else { | |
1165 | for (i = 0; i < 2; i++) { | |
1166 | if (circuit->te_metric[i] | |
1167 | != DEFAULT_CIRCUIT_METRIC) { | |
1168 | vty_out(vty, | |
7c0cbd0e | 1169 | " " PROTO_NAME " metric %d level-%d\n", |
d62a17ae | 1170 | circuit->te_metric[i], |
1171 | i + 1); | |
1172 | write++; | |
1173 | } | |
1174 | } | |
1175 | } | |
1176 | if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) { | |
7c0cbd0e | 1177 | vty_out(vty, " " PROTO_NAME " password md5 %s\n", |
d62a17ae | 1178 | circuit->passwd.passwd); |
1179 | write++; | |
1180 | } else if (circuit->passwd.type | |
1181 | == ISIS_PASSWD_TYPE_CLEARTXT) { | |
7c0cbd0e | 1182 | vty_out(vty, " " PROTO_NAME " password clear %s\n", |
d62a17ae | 1183 | circuit->passwd.passwd); |
1184 | write++; | |
1185 | } | |
5489eb45 CF |
1186 | write += hook_call(isis_circuit_config_write, |
1187 | circuit, vty); | |
d62a17ae | 1188 | } |
a8b828f3 | 1189 | vty_endframe(vty, "!\n"); |
d62a17ae | 1190 | } |
1191 | ||
1192 | return write; | |
eb5d44eb | 1193 | } |
20600086 | 1194 | #else |
612c2c15 | 1195 | static int isis_interface_config_write(struct vty *vty) |
20600086 EDP |
1196 | { |
1197 | struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); | |
1198 | int write = 0; | |
1199 | struct interface *ifp; | |
20600086 EDP |
1200 | struct lyd_node *dnode; |
1201 | ||
1202 | FOR_ALL_INTERFACES (vrf, ifp) { | |
1203 | dnode = yang_dnode_get( | |
1204 | running_config->dnode, | |
1205 | "/frr-interface:lib/interface[name='%s'][vrf='%s']", | |
1206 | ifp->name, vrf->name); | |
1207 | if (dnode == NULL) | |
1208 | continue; | |
1209 | ||
1210 | write++; | |
1211 | nb_cli_show_dnode_cmds(vty, dnode, false); | |
20600086 EDP |
1212 | } |
1213 | return write; | |
1214 | } | |
1215 | #endif /* ifdef FABRICD */ | |
eb5d44eb | 1216 | |
d62a17ae | 1217 | struct isis_circuit *isis_circuit_create(struct isis_area *area, |
1218 | struct interface *ifp) | |
eb5d44eb | 1219 | { |
d62a17ae | 1220 | struct isis_circuit *circuit = circuit_scan_by_ifp(ifp); |
1221 | if (circuit && circuit->area) | |
1222 | return NULL; | |
1223 | circuit = isis_csm_state_change(ISIS_ENABLE, circuit, area); | |
1224 | if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP) | |
1225 | return circuit; | |
1226 | isis_circuit_if_bind(circuit, ifp); | |
89cf2f20 EDP |
1227 | if (circuit->area->mta && circuit->area->mta->status) |
1228 | isis_link_params_update(circuit, ifp); | |
d62a17ae | 1229 | return circuit; |
eb5d44eb | 1230 | } |
1231 | ||
d62a17ae | 1232 | void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router, |
1233 | bool ipv6_router) | |
eb5d44eb | 1234 | { |
d62a17ae | 1235 | struct isis_area *area = circuit->area; |
e8cff6d1 EDP |
1236 | int old_ipr = circuit->ip_router; |
1237 | int old_ipv6r = circuit->ipv6_router; | |
1238 | ||
1239 | /* is there something to do? */ | |
1240 | if (old_ipr == ip_router && old_ipv6r == ipv6_router) | |
1241 | return; | |
d62a17ae | 1242 | |
d62a17ae | 1243 | circuit->ip_router = ip_router; |
1244 | circuit->ipv6_router = ipv6_router; | |
e8cff6d1 | 1245 | circuit_update_nlpids(circuit); |
d62a17ae | 1246 | |
e8cff6d1 EDP |
1247 | /* the area should always be there if we get here, but in the past |
1248 | * there were corner cases where the area was NULL (e.g. because the | |
1249 | * circuit was deconfigured following a validation error). Do not | |
1250 | * segfault if this happens again. | |
1251 | */ | |
1252 | if (!area) { | |
1253 | zlog_err("%s: NULL area for circuit %u", __func__, | |
1254 | circuit->circuit_id); | |
d62a17ae | 1255 | return; |
e8cff6d1 | 1256 | } |
d62a17ae | 1257 | |
e8cff6d1 EDP |
1258 | area->ip_circuits += ip_router - old_ipr; |
1259 | area->ipv6_circuits += ipv6_router - old_ipv6r; | |
d62a17ae | 1260 | |
1261 | if (!ip_router && !ipv6_router) | |
1262 | isis_csm_state_change(ISIS_DISABLE, circuit, area); | |
d62a17ae | 1263 | else |
e8cff6d1 | 1264 | lsp_regenerate_schedule(area, circuit->is_type, 0); |
3f045a08 | 1265 | } |
eb5d44eb | 1266 | |
64dd3ffe | 1267 | ferr_r isis_circuit_passive_set(struct isis_circuit *circuit, bool passive) |
3f045a08 | 1268 | { |
d62a17ae | 1269 | if (circuit->is_passive == passive) |
64dd3ffe | 1270 | return ferr_ok(); |
d62a17ae | 1271 | |
1272 | if (if_is_loopback(circuit->interface) && !passive) | |
64dd3ffe | 1273 | return ferr_cfg_invalid("loopback is always passive"); |
d62a17ae | 1274 | |
1275 | if (circuit->state != C_STATE_UP) { | |
1276 | circuit->is_passive = passive; | |
1277 | } else { | |
1278 | struct isis_area *area = circuit->area; | |
1279 | isis_csm_state_change(ISIS_DISABLE, circuit, area); | |
1280 | circuit->is_passive = passive; | |
1281 | isis_csm_state_change(ISIS_ENABLE, circuit, area); | |
1282 | } | |
1283 | ||
64dd3ffe | 1284 | return ferr_ok(); |
eb5d44eb | 1285 | } |
1286 | ||
64dd3ffe DL |
1287 | ferr_r isis_circuit_metric_set(struct isis_circuit *circuit, int level, |
1288 | int metric) | |
3f045a08 | 1289 | { |
d62a17ae | 1290 | assert(level == IS_LEVEL_1 || level == IS_LEVEL_2); |
1291 | if (metric > MAX_WIDE_LINK_METRIC) | |
64dd3ffe DL |
1292 | return ferr_cfg_invalid("metric %d too large for wide metric", |
1293 | metric); | |
d62a17ae | 1294 | if (circuit->area && circuit->area->oldmetric |
1295 | && metric > MAX_NARROW_LINK_METRIC) | |
64dd3ffe DL |
1296 | return ferr_cfg_invalid("metric %d too large for narrow metric", |
1297 | metric); | |
d62a17ae | 1298 | |
1299 | circuit->te_metric[level - 1] = metric; | |
1300 | circuit->metric[level - 1] = metric; | |
1301 | ||
1302 | if (circuit->area) | |
1303 | lsp_regenerate_schedule(circuit->area, level, 0); | |
64dd3ffe | 1304 | return ferr_ok(); |
eb5d44eb | 1305 | } |
1306 | ||
64dd3ffe | 1307 | ferr_r isis_circuit_passwd_unset(struct isis_circuit *circuit) |
eb5d44eb | 1308 | { |
d62a17ae | 1309 | memset(&circuit->passwd, 0, sizeof(circuit->passwd)); |
64dd3ffe | 1310 | return ferr_ok(); |
3f045a08 JB |
1311 | } |
1312 | ||
e28544ed QY |
1313 | ferr_r isis_circuit_passwd_set(struct isis_circuit *circuit, |
1314 | uint8_t passwd_type, const char *passwd) | |
3f045a08 | 1315 | { |
d62a17ae | 1316 | int len; |
f390d2c7 | 1317 | |
d62a17ae | 1318 | if (!passwd) |
64dd3ffe | 1319 | return ferr_code_bug("no circuit password given"); |
50c7d14a | 1320 | |
d62a17ae | 1321 | len = strlen(passwd); |
1322 | if (len > 254) | |
64dd3ffe DL |
1323 | return ferr_code_bug( |
1324 | "circuit password too long (max 254 chars)"); | |
f390d2c7 | 1325 | |
d62a17ae | 1326 | circuit->passwd.len = len; |
e28544ed QY |
1327 | strlcpy((char *)circuit->passwd.passwd, passwd, |
1328 | sizeof(circuit->passwd.passwd)); | |
d62a17ae | 1329 | circuit->passwd.type = passwd_type; |
64dd3ffe | 1330 | return ferr_ok(); |
eb5d44eb | 1331 | } |
1332 | ||
64dd3ffe DL |
1333 | ferr_r isis_circuit_passwd_cleartext_set(struct isis_circuit *circuit, |
1334 | const char *passwd) | |
eb5d44eb | 1335 | { |
d62a17ae | 1336 | return isis_circuit_passwd_set(circuit, ISIS_PASSWD_TYPE_CLEARTXT, |
1337 | passwd); | |
50c7d14a | 1338 | } |
f390d2c7 | 1339 | |
64dd3ffe DL |
1340 | ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit, |
1341 | const char *passwd) | |
50c7d14a | 1342 | { |
d62a17ae | 1343 | return isis_circuit_passwd_set(circuit, ISIS_PASSWD_TYPE_HMAC_MD5, |
1344 | passwd); | |
eb5d44eb | 1345 | } |
64dd3ffe | 1346 | |
3f045a08 | 1347 | struct cmd_node interface_node = { |
f4b8291f | 1348 | .name = "interface", |
62b346ee | 1349 | .node = INTERFACE_NODE, |
24389580 | 1350 | .parent_node = CONFIG_NODE, |
62b346ee | 1351 | .prompt = "%s(config-if)# ", |
612c2c15 | 1352 | .config_write = isis_interface_config_write, |
eb5d44eb | 1353 | }; |
1354 | ||
d0820765 | 1355 | void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type) |
3f045a08 | 1356 | { |
64dd3ffe | 1357 | if (circuit->circ_type == circ_type) |
d0820765 | 1358 | return; |
d62a17ae | 1359 | |
d62a17ae | 1360 | if (circuit->state != C_STATE_UP) { |
1361 | circuit->circ_type = circ_type; | |
1362 | circuit->circ_type_config = circ_type; | |
1363 | } else { | |
1364 | struct isis_area *area = circuit->area; | |
d62a17ae | 1365 | |
1366 | isis_csm_state_change(ISIS_DISABLE, circuit, area); | |
1367 | circuit->circ_type = circ_type; | |
1368 | circuit->circ_type_config = circ_type; | |
1369 | isis_csm_state_change(ISIS_ENABLE, circuit, area); | |
1370 | } | |
3f045a08 JB |
1371 | } |
1372 | ||
d62a17ae | 1373 | int isis_circuit_mt_enabled_set(struct isis_circuit *circuit, uint16_t mtid, |
1374 | bool enabled) | |
064f4896 | 1375 | { |
d62a17ae | 1376 | struct isis_circuit_mt_setting *setting; |
064f4896 | 1377 | |
d62a17ae | 1378 | setting = circuit_get_mt_setting(circuit, mtid); |
1379 | if (setting->enabled != enabled) { | |
1380 | setting->enabled = enabled; | |
1381 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, | |
1382 | 0); | |
1383 | } | |
064f4896 | 1384 | |
d62a17ae | 1385 | return CMD_SUCCESS; |
064f4896 CF |
1386 | } |
1387 | ||
d62a17ae | 1388 | int isis_if_new_hook(struct interface *ifp) |
eb5d44eb | 1389 | { |
d62a17ae | 1390 | return 0; |
eb5d44eb | 1391 | } |
1392 | ||
d62a17ae | 1393 | int isis_if_delete_hook(struct interface *ifp) |
eb5d44eb | 1394 | { |
d62a17ae | 1395 | struct isis_circuit *circuit; |
1396 | /* Clean up the circuit data */ | |
1397 | if (ifp && ifp->info) { | |
1398 | circuit = ifp->info; | |
1399 | isis_csm_state_change(IF_DOWN_FROM_Z, circuit, circuit->area); | |
d62a17ae | 1400 | } |
1401 | ||
1402 | return 0; | |
eb5d44eb | 1403 | } |
1404 | ||
138c5a74 DS |
1405 | static int isis_ifp_create(struct interface *ifp) |
1406 | { | |
ef7bd2a3 DS |
1407 | if (if_is_operative(ifp)) |
1408 | isis_csm_state_change(IF_UP_FROM_Z, circuit_scan_by_ifp(ifp), | |
1409 | ifp); | |
1410 | ||
1411 | hook_call(isis_if_new_hook, ifp); | |
1412 | ||
138c5a74 DS |
1413 | return 0; |
1414 | } | |
1415 | ||
1416 | static int isis_ifp_up(struct interface *ifp) | |
1417 | { | |
ddbf3e60 DS |
1418 | isis_csm_state_change(IF_UP_FROM_Z, circuit_scan_by_ifp(ifp), ifp); |
1419 | ||
138c5a74 DS |
1420 | return 0; |
1421 | } | |
1422 | ||
1423 | static int isis_ifp_down(struct interface *ifp) | |
1424 | { | |
b0b69e59 DS |
1425 | struct isis_circuit *circuit; |
1426 | ||
1427 | circuit = isis_csm_state_change(IF_DOWN_FROM_Z, | |
1428 | circuit_scan_by_ifp(ifp), ifp); | |
1429 | if (circuit) | |
1430 | SET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF); | |
1431 | ||
138c5a74 DS |
1432 | return 0; |
1433 | } | |
1434 | ||
1435 | static int isis_ifp_destroy(struct interface *ifp) | |
1436 | { | |
3c3c3252 DS |
1437 | if (if_is_operative(ifp)) |
1438 | zlog_warn("Zebra: got delete of %s, but interface is still up", | |
1439 | ifp->name); | |
1440 | ||
1441 | isis_csm_state_change(IF_DOWN_FROM_Z, circuit_scan_by_ifp(ifp), ifp); | |
1442 | ||
1443 | /* Cannot call if_delete because we should retain the pseudo interface | |
1444 | in case there is configuration info attached to it. */ | |
1445 | if_delete_retain(ifp); | |
1446 | ||
138c5a74 DS |
1447 | return 0; |
1448 | } | |
1449 | ||
4d762f26 | 1450 | void isis_circuit_init(void) |
eb5d44eb | 1451 | { |
d62a17ae | 1452 | /* Initialize Zebra interface data structure */ |
ce19a04a DL |
1453 | hook_register_prio(if_add, 0, isis_if_new_hook); |
1454 | hook_register_prio(if_del, 0, isis_if_delete_hook); | |
eb5d44eb | 1455 | |
d62a17ae | 1456 | /* Install interface node */ |
612c2c15 | 1457 | install_node(&interface_node); |
d62a17ae | 1458 | if_cmd_init(); |
138c5a74 DS |
1459 | if_zapi_callbacks(isis_ifp_create, isis_ifp_up, |
1460 | isis_ifp_down, isis_ifp_destroy); | |
eb5d44eb | 1461 | } |