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