]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_circuit.c
Merge pull request #2681 from qlyoung/doc-cleanup-rpki
[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
42 #include "isisd/dict.h"
43 #include "isisd/isis_constants.h"
44 #include "isisd/isis_common.h"
45 #include "isisd/isis_flags.h"
46 #include "isisd/isis_circuit.h"
47 #include "isisd/isis_lsp.h"
48 #include "isisd/isis_lsp_hash.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
61 DEFINE_QOBJ_TYPE(isis_circuit)
62
63 /*
64 * Prototypes.
65 */
66 int isis_interface_config_write(struct vty *);
67 int isis_if_new_hook(struct interface *);
68 int isis_if_delete_hook(struct interface *);
69
70 struct isis_circuit *isis_circuit_new()
71 {
72 struct isis_circuit *circuit;
73 int i;
74
75 circuit = XCALLOC(MTYPE_ISIS_CIRCUIT, sizeof(struct isis_circuit));
76 if (circuit == NULL) {
77 zlog_err("Can't malloc isis circuit");
78 return NULL;
79 }
80
81 /*
82 * Default values
83 */
84 circuit->is_type = IS_LEVEL_1_AND_2;
85 circuit->flags = 0;
86 circuit->pad_hellos = 1;
87 for (i = 0; i < 2; i++) {
88 circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL;
89 circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER;
90 circuit->csnp_interval[i] = DEFAULT_CSNP_INTERVAL;
91 circuit->psnp_interval[i] = DEFAULT_PSNP_INTERVAL;
92 circuit->priority[i] = DEFAULT_PRIORITY;
93 circuit->metric[i] = DEFAULT_CIRCUIT_METRIC;
94 circuit->te_metric[i] = DEFAULT_CIRCUIT_METRIC;
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 (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_and_null(&circuit->ip_addrs);
456 }
457
458 if (circuit->ipv6_link) {
459 assert(listcount(circuit->ipv6_link) == 0);
460 list_delete_and_null(&circuit->ipv6_link);
461 }
462
463 if (circuit->ipv6_non_link) {
464 assert(listcount(circuit->ipv6_non_link) == 0);
465 list_delete_and_null(&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, *dnode_next;
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 if (area->lspdb[level - 1]
510 && dict_count(area->lspdb[level - 1]) > 0) {
511 for (dnode = dict_first(area->lspdb[level - 1]);
512 dnode != NULL; dnode = dnode_next) {
513 dnode_next = dict_next(
514 area->lspdb[level - 1], dnode);
515 lsp = dnode_get(dnode);
516 if (is_set) {
517 ISIS_SET_FLAG(lsp->SRMflags,
518 circuit);
519 } else {
520 ISIS_CLEAR_FLAG(lsp->SRMflags,
521 circuit);
522 }
523 }
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(*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 zlog_err(
574 "Interface MTU %zu on %s is too low to support area lsp mtu %u!",
575 isis_circuit_pdu_size(circuit),
576 circuit->interface->name, circuit->area->lsp_mtu);
577 isis_circuit_update_all_srmflags(circuit, 0);
578 return ISIS_ERROR;
579 }
580
581 if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
582 circuit->circuit_id = isis_circuit_id_gen(isis, circuit->interface);
583 if (!circuit->circuit_id) {
584 zlog_err("There are already 255 broadcast circuits active!");
585 return ISIS_ERROR;
586 }
587
588 /*
589 * Get the Hardware Address
590 */
591 if (circuit->interface->hw_addr_len != ETH_ALEN) {
592 zlog_warn("unsupported link layer");
593 } else {
594 memcpy(circuit->u.bc.snpa, circuit->interface->hw_addr,
595 ETH_ALEN);
596 }
597 #ifdef EXTREME_DEGUG
598 zlog_debug("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
599 circuit->interface->ifindex, ISO_MTU(circuit),
600 snpa_print(circuit->u.bc.snpa));
601 #endif /* EXTREME_DEBUG */
602
603 circuit->u.bc.adjdb[0] = list_new();
604 circuit->u.bc.adjdb[1] = list_new();
605
606 /*
607 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
608 */
609
610 /* initilizing the hello sending threads
611 * for a broadcast IF
612 */
613
614 /* 8.4.1 a) commence sending of IIH PDUs */
615
616 if (circuit->is_type & IS_LEVEL_1) {
617 thread_add_event(master, send_lan_l1_hello, circuit, 0,
618 NULL);
619 circuit->u.bc.lan_neighs[0] = list_new();
620 }
621
622 if (circuit->is_type & IS_LEVEL_2) {
623 thread_add_event(master, send_lan_l2_hello, circuit, 0,
624 NULL);
625 circuit->u.bc.lan_neighs[1] = list_new();
626 }
627
628 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
629 /* 8.4.1 c) FIXME: listen for ESH PDUs */
630
631 /* 8.4.1 d) */
632 /* dr election will commence in... */
633 if (circuit->is_type & IS_LEVEL_1)
634 thread_add_timer(master, isis_run_dr_l1, circuit,
635 2 * circuit->hello_interval[0],
636 &circuit->u.bc.t_run_dr[0]);
637 if (circuit->is_type & IS_LEVEL_2)
638 thread_add_timer(master, isis_run_dr_l2, circuit,
639 2 * circuit->hello_interval[1],
640 &circuit->u.bc.t_run_dr[1]);
641 } else if (circuit->circ_type == CIRCUIT_T_P2P) {
642 /* initializing the hello send threads
643 * for a ptp IF
644 */
645 circuit->u.p2p.neighbor = NULL;
646 thread_add_event(master, send_p2p_hello, circuit, 0, NULL);
647 }
648
649 /* initializing PSNP timers */
650 if (circuit->is_type & IS_LEVEL_1)
651 thread_add_timer(
652 master, send_l1_psnp, circuit,
653 isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
654 &circuit->t_send_psnp[0]);
655
656 if (circuit->is_type & IS_LEVEL_2)
657 thread_add_timer(
658 master, send_l2_psnp, circuit,
659 isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
660 &circuit->t_send_psnp[1]);
661
662 /* unified init for circuits; ignore warnings below this level */
663 retv = isis_sock_init(circuit);
664 if (retv != ISIS_OK) {
665 isis_circuit_down(circuit);
666 return retv;
667 }
668
669 /* initialize the circuit streams after opening connection */
670 isis_circuit_stream(circuit, &circuit->rcv_stream);
671 isis_circuit_stream(circuit, &circuit->snd_stream);
672
673 isis_circuit_prepare(circuit);
674
675 circuit->lsp_queue = list_new();
676 circuit->lsp_hash = isis_lsp_hash_new();
677 circuit->lsp_queue_last_push[0] = circuit->lsp_queue_last_push[1] =
678 monotime(NULL);
679
680 return ISIS_OK;
681 }
682
683 void isis_circuit_down(struct isis_circuit *circuit)
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_and_null(&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_and_null(&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_and_null(&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_and_null(&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_send_lsp);
744 THREAD_OFF(circuit->t_read);
745
746 if (circuit->lsp_queue) {
747 list_delete_and_null(&circuit->lsp_queue);
748 }
749
750 if (circuit->lsp_hash) {
751 isis_lsp_hash_free(circuit->lsp_hash);
752 circuit->lsp_hash = NULL;
753 }
754
755 /* send one gratuitous hello to spead up convergence */
756 if (circuit->state == C_STATE_UP) {
757 if (circuit->is_type & IS_LEVEL_1)
758 send_hello(circuit, IS_LEVEL_1);
759 if (circuit->is_type & IS_LEVEL_2)
760 send_hello(circuit, IS_LEVEL_2);
761 }
762
763 circuit->upadjcount[0] = 0;
764 circuit->upadjcount[1] = 0;
765
766 /* close the socket */
767 if (circuit->fd) {
768 close(circuit->fd);
769 circuit->fd = 0;
770 }
771
772 if (circuit->rcv_stream != NULL) {
773 stream_free(circuit->rcv_stream);
774 circuit->rcv_stream = NULL;
775 }
776
777 if (circuit->snd_stream != NULL) {
778 stream_free(circuit->snd_stream);
779 circuit->snd_stream = NULL;
780 }
781
782 thread_cancel_event(master, circuit);
783
784 return;
785 }
786
787 void circuit_update_nlpids(struct isis_circuit *circuit)
788 {
789 circuit->nlpids.count = 0;
790
791 if (circuit->ip_router) {
792 circuit->nlpids.nlpids[0] = NLPID_IP;
793 circuit->nlpids.count++;
794 }
795 if (circuit->ipv6_router) {
796 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
797 circuit->nlpids.count++;
798 }
799 return;
800 }
801
802 void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty,
803 char detail)
804 {
805 if (detail == ISIS_UI_LEVEL_BRIEF) {
806 vty_out(vty, " %-12s", circuit->interface->name);
807 vty_out(vty, "0x%-7x", circuit->circuit_id);
808 vty_out(vty, "%-9s", circuit_state2string(circuit->state));
809 vty_out(vty, "%-9s", circuit_type2string(circuit->circ_type));
810 vty_out(vty, "%-9s", circuit_t2string(circuit->is_type));
811 vty_out(vty, "\n");
812 }
813
814 if (detail == ISIS_UI_LEVEL_DETAIL) {
815 struct listnode *node;
816 struct prefix *ip_addr;
817 char buf[BUFSIZ];
818
819 vty_out(vty, " Interface: %s", circuit->interface->name);
820 vty_out(vty, ", State: %s",
821 circuit_state2string(circuit->state));
822 if (circuit->is_passive)
823 vty_out(vty, ", Passive");
824 else
825 vty_out(vty, ", Active");
826 vty_out(vty, ", Circuit Id: 0x%x", circuit->circuit_id);
827 vty_out(vty, "\n");
828 vty_out(vty, " Type: %s",
829 circuit_type2string(circuit->circ_type));
830 vty_out(vty, ", Level: %s", circuit_t2string(circuit->is_type));
831 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
832 vty_out(vty, ", SNPA: %-10s",
833 snpa_print(circuit->u.bc.snpa));
834 vty_out(vty, "\n");
835 if (circuit->is_type & IS_LEVEL_1) {
836 vty_out(vty, " Level-1 Information:\n");
837 if (circuit->area->newmetric)
838 vty_out(vty, " Metric: %d",
839 circuit->te_metric[0]);
840 else
841 vty_out(vty, " Metric: %d",
842 circuit->metric[0]);
843 if (!circuit->is_passive) {
844 vty_out(vty, ", Active neighbors: %u\n",
845 circuit->upadjcount[0]);
846 vty_out(vty,
847 " Hello interval: %u, "
848 "Holddown count: %u %s\n",
849 circuit->hello_interval[0],
850 circuit->hello_multiplier[0],
851 (circuit->pad_hellos ? "(pad)"
852 : "(no-pad)"));
853 vty_out(vty,
854 " CNSP interval: %u, "
855 "PSNP interval: %u\n",
856 circuit->csnp_interval[0],
857 circuit->psnp_interval[0]);
858 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
859 vty_out(vty,
860 " LAN Priority: %u, %s\n",
861 circuit->priority[0],
862 (circuit->u.bc.is_dr[0]
863 ? "is DIS"
864 : "is not DIS"));
865 } else {
866 vty_out(vty, "\n");
867 }
868 }
869 if (circuit->is_type & IS_LEVEL_2) {
870 vty_out(vty, " Level-2 Information:\n");
871 if (circuit->area->newmetric)
872 vty_out(vty, " Metric: %d",
873 circuit->te_metric[1]);
874 else
875 vty_out(vty, " Metric: %d",
876 circuit->metric[1]);
877 if (!circuit->is_passive) {
878 vty_out(vty, ", Active neighbors: %u\n",
879 circuit->upadjcount[1]);
880 vty_out(vty,
881 " Hello interval: %u, "
882 "Holddown count: %u %s\n",
883 circuit->hello_interval[1],
884 circuit->hello_multiplier[1],
885 (circuit->pad_hellos ? "(pad)"
886 : "(no-pad)"));
887 vty_out(vty,
888 " CNSP interval: %u, "
889 "PSNP interval: %u\n",
890 circuit->csnp_interval[1],
891 circuit->psnp_interval[1]);
892 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
893 vty_out(vty,
894 " LAN Priority: %u, %s\n",
895 circuit->priority[1],
896 (circuit->u.bc.is_dr[1]
897 ? "is DIS"
898 : "is not DIS"));
899 } else {
900 vty_out(vty, "\n");
901 }
902 }
903 if (circuit->ip_addrs && listcount(circuit->ip_addrs) > 0) {
904 vty_out(vty, " IP Prefix(es):\n");
905 for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node,
906 ip_addr)) {
907 prefix2str(ip_addr, buf, sizeof(buf)),
908 vty_out(vty, " %s\n", buf);
909 }
910 }
911 if (circuit->ipv6_link && listcount(circuit->ipv6_link) > 0) {
912 vty_out(vty, " IPv6 Link-Locals:\n");
913 for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node,
914 ip_addr)) {
915 prefix2str(ip_addr, (char *)buf, BUFSIZ),
916 vty_out(vty, " %s\n", buf);
917 }
918 }
919 if (circuit->ipv6_non_link
920 && listcount(circuit->ipv6_non_link) > 0) {
921 vty_out(vty, " IPv6 Prefixes:\n");
922 for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node,
923 ip_addr)) {
924 prefix2str(ip_addr, (char *)buf, BUFSIZ),
925 vty_out(vty, " %s\n", buf);
926 }
927 }
928
929 vty_out(vty, "\n");
930 }
931 return;
932 }
933
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 isis %s\n",
961 area->area_tag);
962 write++;
963 }
964 if (circuit->is_passive) {
965 vty_out(vty, " isis passive\n");
966 write++;
967 }
968 if (circuit->circ_type_config == CIRCUIT_T_P2P) {
969 vty_out(vty, " isis network point-to-point\n");
970 write++;
971 }
972 if (circuit->ipv6_router) {
973 vty_out(vty, " ipv6 router isis %s\n",
974 area->area_tag);
975 write++;
976 }
977
978 /* ISIS - circuit type */
979 if (circuit->is_type == IS_LEVEL_1) {
980 vty_out(vty, " isis circuit-type level-1\n");
981 write++;
982 } else {
983 if (circuit->is_type == IS_LEVEL_2) {
984 vty_out(vty,
985 " isis circuit-type level-2-only\n");
986 write++;
987 }
988 }
989
990 /* ISIS - CSNP interval */
991 if (circuit->csnp_interval[0]
992 == circuit->csnp_interval[1]) {
993 if (circuit->csnp_interval[0]
994 != DEFAULT_CSNP_INTERVAL) {
995 vty_out(vty, " isis csnp-interval %d\n",
996 circuit->csnp_interval[0]);
997 write++;
998 }
999 } else {
1000 for (i = 0; i < 2; i++) {
1001 if (circuit->csnp_interval[i]
1002 != DEFAULT_CSNP_INTERVAL) {
1003 vty_out(vty,
1004 " isis csnp-interval %d level-%d\n",
1005 circuit->csnp_interval
1006 [i],
1007 i + 1);
1008 write++;
1009 }
1010 }
1011 }
1012
1013 /* ISIS - PSNP interval */
1014 if (circuit->psnp_interval[0]
1015 == circuit->psnp_interval[1]) {
1016 if (circuit->psnp_interval[0]
1017 != DEFAULT_PSNP_INTERVAL) {
1018 vty_out(vty, " isis psnp-interval %d\n",
1019 circuit->psnp_interval[0]);
1020 write++;
1021 }
1022 } else {
1023 for (i = 0; i < 2; i++) {
1024 if (circuit->psnp_interval[i]
1025 != DEFAULT_PSNP_INTERVAL) {
1026 vty_out(vty,
1027 " isis psnp-interval %d level-%d\n",
1028 circuit->psnp_interval
1029 [i],
1030 i + 1);
1031 write++;
1032 }
1033 }
1034 }
1035
1036 /* ISIS - Hello padding - Defaults to true so only
1037 * display if false */
1038 if (circuit->pad_hellos == 0) {
1039 vty_out(vty, " no isis hello padding\n");
1040 write++;
1041 }
1042
1043 if (circuit->disable_threeway_adj) {
1044 vty_out(vty, " no isis three-way-handshake\n");
1045 write++;
1046 }
1047
1048 /* ISIS - Hello interval */
1049 if (circuit->hello_interval[0]
1050 == circuit->hello_interval[1]) {
1051 if (circuit->hello_interval[0]
1052 != DEFAULT_HELLO_INTERVAL) {
1053 vty_out(vty,
1054 " isis hello-interval %d\n",
1055 circuit->hello_interval[0]);
1056 write++;
1057 }
1058 } else {
1059 for (i = 0; i < 2; i++) {
1060 if (circuit->hello_interval[i]
1061 != DEFAULT_HELLO_INTERVAL) {
1062 vty_out(vty,
1063 " isis hello-interval %d level-%d\n",
1064 circuit->hello_interval
1065 [i],
1066 i + 1);
1067 write++;
1068 }
1069 }
1070 }
1071
1072 /* ISIS - Hello Multiplier */
1073 if (circuit->hello_multiplier[0]
1074 == circuit->hello_multiplier[1]) {
1075 if (circuit->hello_multiplier[0]
1076 != DEFAULT_HELLO_MULTIPLIER) {
1077 vty_out(vty,
1078 " isis hello-multiplier %d\n",
1079 circuit->hello_multiplier[0]);
1080 write++;
1081 }
1082 } else {
1083 for (i = 0; i < 2; i++) {
1084 if (circuit->hello_multiplier[i]
1085 != DEFAULT_HELLO_MULTIPLIER) {
1086 vty_out(vty,
1087 " isis hello-multiplier %d level-%d\n",
1088 circuit->hello_multiplier
1089 [i],
1090 i + 1);
1091 write++;
1092 }
1093 }
1094 }
1095
1096 /* ISIS - Priority */
1097 if (circuit->priority[0] == circuit->priority[1]) {
1098 if (circuit->priority[0] != DEFAULT_PRIORITY) {
1099 vty_out(vty, " isis priority %d\n",
1100 circuit->priority[0]);
1101 write++;
1102 }
1103 } else {
1104 for (i = 0; i < 2; i++) {
1105 if (circuit->priority[i]
1106 != DEFAULT_PRIORITY) {
1107 vty_out(vty,
1108 " isis priority %d level-%d\n",
1109 circuit->priority[i],
1110 i + 1);
1111 write++;
1112 }
1113 }
1114 }
1115
1116 /* ISIS - Metric */
1117 if (circuit->te_metric[0] == circuit->te_metric[1]) {
1118 if (circuit->te_metric[0]
1119 != DEFAULT_CIRCUIT_METRIC) {
1120 vty_out(vty, " isis metric %d\n",
1121 circuit->te_metric[0]);
1122 write++;
1123 }
1124 } else {
1125 for (i = 0; i < 2; i++) {
1126 if (circuit->te_metric[i]
1127 != DEFAULT_CIRCUIT_METRIC) {
1128 vty_out(vty,
1129 " isis metric %d level-%d\n",
1130 circuit->te_metric[i],
1131 i + 1);
1132 write++;
1133 }
1134 }
1135 }
1136 if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) {
1137 vty_out(vty, " isis password md5 %s\n",
1138 circuit->passwd.passwd);
1139 write++;
1140 } else if (circuit->passwd.type
1141 == ISIS_PASSWD_TYPE_CLEARTXT) {
1142 vty_out(vty, " isis password clear %s\n",
1143 circuit->passwd.passwd);
1144 write++;
1145 }
1146 write += circuit_write_mt_settings(circuit, vty);
1147 }
1148 vty_endframe(vty, "!\n");
1149 }
1150
1151 return write;
1152 }
1153
1154 struct isis_circuit *isis_circuit_create(struct isis_area *area,
1155 struct interface *ifp)
1156 {
1157 struct isis_circuit *circuit = circuit_scan_by_ifp(ifp);
1158 if (circuit && circuit->area)
1159 return NULL;
1160 circuit = isis_csm_state_change(ISIS_ENABLE, circuit, area);
1161 if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP)
1162 return circuit;
1163 isis_circuit_if_bind(circuit, ifp);
1164 return circuit;
1165 }
1166
1167 void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router,
1168 bool ipv6_router)
1169 {
1170 struct isis_area *area = circuit->area;
1171 bool change = circuit->ip_router != ip_router
1172 || circuit->ipv6_router != ipv6_router;
1173
1174 area->ip_circuits += ip_router - circuit->ip_router;
1175 area->ipv6_circuits += ipv6_router - circuit->ipv6_router;
1176 circuit->ip_router = ip_router;
1177 circuit->ipv6_router = ipv6_router;
1178
1179 if (!change)
1180 return;
1181
1182 circuit_update_nlpids(circuit);
1183
1184 if (!ip_router && !ipv6_router)
1185 isis_csm_state_change(ISIS_DISABLE, circuit, area);
1186 else
1187 lsp_regenerate_schedule(circuit->area, circuit->is_type, 0);
1188 }
1189
1190 ferr_r isis_circuit_passive_set(struct isis_circuit *circuit, bool passive)
1191 {
1192 if (circuit->is_passive == passive)
1193 return ferr_ok();
1194
1195 if (if_is_loopback(circuit->interface) && !passive)
1196 return ferr_cfg_invalid("loopback is always passive");
1197
1198 if (circuit->state != C_STATE_UP) {
1199 circuit->is_passive = passive;
1200 } else {
1201 struct isis_area *area = circuit->area;
1202 isis_csm_state_change(ISIS_DISABLE, circuit, area);
1203 circuit->is_passive = passive;
1204 isis_csm_state_change(ISIS_ENABLE, circuit, area);
1205 }
1206
1207 return ferr_ok();
1208 }
1209
1210 ferr_r isis_circuit_metric_set(struct isis_circuit *circuit, int level,
1211 int metric)
1212 {
1213 assert(level == IS_LEVEL_1 || level == IS_LEVEL_2);
1214 if (metric > MAX_WIDE_LINK_METRIC)
1215 return ferr_cfg_invalid("metric %d too large for wide metric",
1216 metric);
1217 if (circuit->area && circuit->area->oldmetric
1218 && metric > MAX_NARROW_LINK_METRIC)
1219 return ferr_cfg_invalid("metric %d too large for narrow metric",
1220 metric);
1221
1222 circuit->te_metric[level - 1] = metric;
1223 circuit->metric[level - 1] = metric;
1224
1225 if (circuit->area)
1226 lsp_regenerate_schedule(circuit->area, level, 0);
1227 return ferr_ok();
1228 }
1229
1230 ferr_r isis_circuit_passwd_unset(struct isis_circuit *circuit)
1231 {
1232 memset(&circuit->passwd, 0, sizeof(circuit->passwd));
1233 return ferr_ok();
1234 }
1235
1236 static int isis_circuit_passwd_set(struct isis_circuit *circuit,
1237 uint8_t passwd_type, const char *passwd)
1238 {
1239 int len;
1240
1241 if (!passwd)
1242 return ferr_code_bug("no circuit password given");
1243
1244 len = strlen(passwd);
1245 if (len > 254)
1246 return ferr_code_bug(
1247 "circuit password too long (max 254 chars)");
1248
1249 circuit->passwd.len = len;
1250 strncpy((char *)circuit->passwd.passwd, passwd, 255);
1251 circuit->passwd.type = passwd_type;
1252 return ferr_ok();
1253 }
1254
1255 ferr_r isis_circuit_passwd_cleartext_set(struct isis_circuit *circuit,
1256 const char *passwd)
1257 {
1258 return isis_circuit_passwd_set(circuit, ISIS_PASSWD_TYPE_CLEARTXT,
1259 passwd);
1260 }
1261
1262 ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit,
1263 const char *passwd)
1264 {
1265 return isis_circuit_passwd_set(circuit, ISIS_PASSWD_TYPE_HMAC_MD5,
1266 passwd);
1267 }
1268
1269 struct cmd_node interface_node = {
1270 INTERFACE_NODE, "%s(config-if)# ", 1,
1271 };
1272
1273 ferr_r isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type)
1274 {
1275 if (circuit->circ_type == circ_type)
1276 return ferr_ok();
1277
1278 /* Changing the network type to/of loopback or unknown interfaces
1279 * is not supported. */
1280 if (circ_type == CIRCUIT_T_UNKNOWN || circ_type == CIRCUIT_T_LOOPBACK
1281 || circuit->circ_type == CIRCUIT_T_LOOPBACK) {
1282 return ferr_cfg_invalid(
1283 "cannot change network type on unknown interface");
1284 }
1285
1286 if (circuit->state != C_STATE_UP) {
1287 circuit->circ_type = circ_type;
1288 circuit->circ_type_config = circ_type;
1289 } else {
1290 struct isis_area *area = circuit->area;
1291 if (circ_type == CIRCUIT_T_BROADCAST
1292 && !if_is_broadcast(circuit->interface))
1293 return ferr_cfg_reality(
1294 "cannot configure non-broadcast interface for broadcast operation");
1295
1296 isis_csm_state_change(ISIS_DISABLE, circuit, area);
1297 circuit->circ_type = circ_type;
1298 circuit->circ_type_config = circ_type;
1299 isis_csm_state_change(ISIS_ENABLE, circuit, area);
1300 }
1301 return ferr_ok();
1302 }
1303
1304 int isis_circuit_mt_enabled_set(struct isis_circuit *circuit, uint16_t mtid,
1305 bool enabled)
1306 {
1307 struct isis_circuit_mt_setting *setting;
1308
1309 setting = circuit_get_mt_setting(circuit, mtid);
1310 if (setting->enabled != enabled) {
1311 setting->enabled = enabled;
1312 lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2,
1313 0);
1314 }
1315
1316 return CMD_SUCCESS;
1317 }
1318
1319 int isis_if_new_hook(struct interface *ifp)
1320 {
1321 return 0;
1322 }
1323
1324 int isis_if_delete_hook(struct interface *ifp)
1325 {
1326 struct isis_circuit *circuit;
1327 /* Clean up the circuit data */
1328 if (ifp && ifp->info) {
1329 circuit = ifp->info;
1330 isis_csm_state_change(IF_DOWN_FROM_Z, circuit, circuit->area);
1331 isis_csm_state_change(ISIS_DISABLE, circuit, circuit->area);
1332 }
1333
1334 return 0;
1335 }
1336
1337 void isis_circuit_init()
1338 {
1339 /* Initialize Zebra interface data structure */
1340 hook_register_prio(if_add, 0, isis_if_new_hook);
1341 hook_register_prio(if_del, 0, isis_if_delete_hook);
1342
1343 /* Install interface node */
1344 install_node(&interface_node, isis_interface_config_write);
1345 if_cmd_init();
1346
1347 isis_vty_init();
1348 }
1349
1350 void isis_circuit_schedule_lsp_send(struct isis_circuit *circuit)
1351 {
1352 if (circuit->t_send_lsp)
1353 return;
1354 circuit->t_send_lsp =
1355 thread_add_event(master, send_lsp, circuit, 0, NULL);
1356 }
1357
1358 void isis_circuit_queue_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp)
1359 {
1360 if (isis_lsp_hash_lookup(circuit->lsp_hash, lsp))
1361 return;
1362
1363 listnode_add(circuit->lsp_queue, lsp);
1364 isis_lsp_hash_add(circuit->lsp_hash, lsp);
1365 isis_circuit_schedule_lsp_send(circuit);
1366 }
1367
1368 void isis_circuit_lsp_queue_clean(struct isis_circuit *circuit)
1369 {
1370 if (!circuit->lsp_queue)
1371 return;
1372
1373 list_delete_all_node(circuit->lsp_queue);
1374 isis_lsp_hash_clean(circuit->lsp_hash);
1375 }
1376
1377 void isis_circuit_cancel_queued_lsp(struct isis_circuit *circuit,
1378 struct isis_lsp *lsp)
1379 {
1380 if (!circuit->lsp_queue)
1381 return;
1382
1383 listnode_delete(circuit->lsp_queue, lsp);
1384 isis_lsp_hash_release(circuit->lsp_hash, lsp);
1385 }
1386
1387 struct isis_lsp *isis_circuit_lsp_queue_pop(struct isis_circuit *circuit)
1388 {
1389 if (!circuit->lsp_queue)
1390 return NULL;
1391
1392 struct listnode *node = listhead(circuit->lsp_queue);
1393 if (!node)
1394 return NULL;
1395
1396 struct isis_lsp *rv = listgetdata(node);
1397
1398 list_delete_node(circuit->lsp_queue, node);
1399 isis_lsp_hash_release(circuit->lsp_hash, rv);
1400
1401 return rv;
1402 }