2 * IS-IS Rout(e)ing protocol - isis_circuit.h
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
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)
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
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
24 #include <net/ethernet.h>
26 #include <netinet/if_ether.h>
41 #include "lib/northbound_cli.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_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"
54 #include "isisd/isisd.h"
55 #include "isisd/isis_csm.h"
56 #include "isisd/isis_events.h"
57 #include "isisd/isis_te.h"
58 #include "isisd/isis_mt.h"
59 #include "isisd/isis_errors.h"
60 #include "isisd/isis_tx_queue.h"
61 #include "isisd/isis_nb.h"
62 #include "isisd/isis_ldp_sync.h"
64 DEFINE_MTYPE_STATIC(ISISD
, ISIS_CIRCUIT
, "ISIS circuit");
66 DEFINE_QOBJ_TYPE(isis_circuit
);
68 DEFINE_HOOK(isis_if_new_hook
, (struct interface
*ifp
), (ifp
));
73 int isis_if_new_hook(struct interface
*);
74 int isis_if_delete_hook(struct interface
*);
76 DEFINE_HOOK(isis_circuit_new_hook
, (struct isis_circuit
*circuit
), (circuit
));
77 DEFINE_HOOK(isis_circuit_del_hook
, (struct isis_circuit
*circuit
), (circuit
));
79 struct isis_circuit
*isis_circuit_new(struct isis
*isis
)
81 struct isis_circuit
*circuit
;
84 circuit
= XCALLOC(MTYPE_ISIS_CIRCUIT
, sizeof(struct isis_circuit
));
92 circuit
->is_type
= yang_get_default_enum(
93 "/frr-interface:lib/interface/frr-isisd:isis/circuit-type");
96 circuit
->pad_hellos
= yang_get_default_bool(
97 "/frr-interface:lib/interface/frr-isisd:isis/hello/padding");
98 circuit
->hello_interval
[0] = yang_get_default_uint32(
99 "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1");
100 circuit
->hello_interval
[1] = yang_get_default_uint32(
101 "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2");
102 circuit
->hello_multiplier
[0] = yang_get_default_uint32(
103 "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1");
104 circuit
->hello_multiplier
[1] = yang_get_default_uint32(
105 "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2");
106 circuit
->csnp_interval
[0] = yang_get_default_uint16(
107 "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1");
108 circuit
->csnp_interval
[1] = yang_get_default_uint16(
109 "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2");
110 circuit
->psnp_interval
[0] = yang_get_default_uint16(
111 "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1");
112 circuit
->psnp_interval
[1] = yang_get_default_uint16(
113 "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2");
114 circuit
->priority
[0] = yang_get_default_uint8(
115 "/frr-interface:lib/interface/frr-isisd:isis/priority/level-1");
116 circuit
->priority
[1] = yang_get_default_uint8(
117 "/frr-interface:lib/interface/frr-isisd:isis/priority/level-2");
118 circuit
->metric
[0] = yang_get_default_uint32(
119 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1");
120 circuit
->metric
[1] = yang_get_default_uint32(
121 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2");
122 circuit
->te_metric
[0] = yang_get_default_uint32(
123 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1");
124 circuit
->te_metric
[1] = yang_get_default_uint32(
125 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2");
127 for (i
= 0; i
< 2; i
++) {
128 circuit
->level_arg
[i
].level
= i
+ 1;
129 circuit
->level_arg
[i
].circuit
= circuit
;
132 circuit
->is_type
= IS_LEVEL_1_AND_2
;
134 circuit
->pad_hellos
= 1;
135 for (i
= 0; i
< 2; i
++) {
136 circuit
->hello_interval
[i
] = DEFAULT_HELLO_INTERVAL
;
137 circuit
->hello_multiplier
[i
] = DEFAULT_HELLO_MULTIPLIER
;
138 circuit
->csnp_interval
[i
] = DEFAULT_CSNP_INTERVAL
;
139 circuit
->psnp_interval
[i
] = DEFAULT_PSNP_INTERVAL
;
140 circuit
->priority
[i
] = DEFAULT_PRIORITY
;
141 circuit
->metric
[i
] = DEFAULT_CIRCUIT_METRIC
;
142 circuit
->te_metric
[i
] = DEFAULT_CIRCUIT_METRIC
;
143 circuit
->level_arg
[i
].level
= i
+ 1;
144 circuit
->level_arg
[i
].circuit
= circuit
;
146 #endif /* ifndef FABRICD */
148 circuit_mt_init(circuit
);
149 isis_lfa_excluded_ifaces_init(circuit
, ISIS_LEVEL1
);
150 isis_lfa_excluded_ifaces_init(circuit
, ISIS_LEVEL2
);
152 hook_call(isis_circuit_new_hook
, circuit
);
154 QOBJ_REG(circuit
, isis_circuit
);
159 void isis_circuit_del(struct isis_circuit
*circuit
)
166 hook_call(isis_circuit_del_hook
, circuit
);
168 isis_circuit_if_unbind(circuit
, circuit
->interface
);
170 circuit_mt_finish(circuit
);
171 isis_lfa_excluded_ifaces_clear(circuit
, ISIS_LEVEL1
);
172 isis_lfa_excluded_ifaces_clear(circuit
, ISIS_LEVEL2
);
174 /* and lastly the circuit itself */
175 XFREE(MTYPE_ISIS_CIRCUIT
, circuit
);
180 void isis_circuit_configure(struct isis_circuit
*circuit
,
181 struct isis_area
*area
)
184 circuit
->area
= area
;
187 * Whenever the is-type of an area is changed, the is-type of each
189 * in that area is updated to a non-empty subset of the area is-type.
190 * Inversely, when configuring a new circuit, this property should be
193 if (area
->is_type
!= IS_LEVEL_1_AND_2
)
194 circuit
->is_type
= area
->is_type
;
197 * Add the circuit into area
199 listnode_add(area
->circuit_list
, circuit
);
201 circuit
->idx
= flags_get_index(&area
->flags
);
206 void isis_circuit_deconfigure(struct isis_circuit
*circuit
,
207 struct isis_area
*area
)
209 /* Free the index of SRM and SSN flags */
210 flags_free_index(&area
->flags
, circuit
->idx
);
212 /* Remove circuit from area */
213 assert(circuit
->area
== area
);
214 listnode_delete(area
->circuit_list
, circuit
);
215 circuit
->area
= NULL
;
220 struct isis_circuit
*circuit_lookup_by_ifp(struct interface
*ifp
,
223 struct isis_circuit
*circuit
= NULL
;
224 struct listnode
*node
;
229 for (ALL_LIST_ELEMENTS_RO(list
, node
, circuit
))
230 if (circuit
->interface
== ifp
) {
231 assert(ifp
->info
== circuit
);
238 struct isis_circuit
*circuit_scan_by_ifp(struct interface
*ifp
)
240 struct isis_area
*area
;
241 struct listnode
*node
;
242 struct isis_circuit
*circuit
;
243 struct isis
*isis
= NULL
;
246 return (struct isis_circuit
*)ifp
->info
;
248 isis
= isis_lookup_by_vrfid(ifp
->vrf_id
);
250 zlog_warn(" %s : ISIS routing instance not found", __func__
);
254 if (isis
->area_list
) {
255 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
257 circuit_lookup_by_ifp(ifp
, area
->circuit_list
);
262 return circuit_lookup_by_ifp(ifp
, isis
->init_circ_list
);
265 DEFINE_HOOK(isis_circuit_add_addr_hook
, (struct isis_circuit
*circuit
),
268 void isis_circuit_add_addr(struct isis_circuit
*circuit
,
269 struct connected
*connected
)
271 struct listnode
*node
;
272 struct prefix_ipv4
*ipv4
;
273 struct prefix_ipv6
*ipv6
;
275 if (connected
->address
->family
== AF_INET
) {
276 uint32_t addr
= connected
->address
->u
.prefix4
.s_addr
;
278 if (IPV4_NET0(addr
) || IPV4_NET127(addr
) || IN_CLASSD(addr
)
279 || IPV4_LINKLOCAL(addr
))
282 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
, ipv4
))
283 if (prefix_same((struct prefix
*)ipv4
,
287 ipv4
= prefix_ipv4_new();
288 ipv4
->prefixlen
= connected
->address
->prefixlen
;
289 ipv4
->prefix
= connected
->address
->u
.prefix4
;
290 listnode_add(circuit
->ip_addrs
, ipv4
);
292 /* Update Local IP address parameter if MPLS TE is enable */
293 if (circuit
->ext
&& circuit
->area
294 && IS_MPLS_TE(circuit
->area
->mta
)) {
295 circuit
->ext
->local_addr
.s_addr
= ipv4
->prefix
.s_addr
;
296 SET_SUBTLV(circuit
->ext
, EXT_LOCAL_ADDR
);
300 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
304 zlog_debug("Added IP address %pFX to circuit %s",
305 connected
->address
, circuit
->interface
->name
);
306 #endif /* EXTREME_DEBUG */
308 if (connected
->address
->family
== AF_INET6
) {
309 if (IN6_IS_ADDR_LOOPBACK(&connected
->address
->u
.prefix6
))
312 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
, ipv6
))
313 if (prefix_same((struct prefix
*)ipv6
,
316 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
, ipv6
))
317 if (prefix_same((struct prefix
*)ipv6
,
321 ipv6
= prefix_ipv6_new();
322 ipv6
->prefixlen
= connected
->address
->prefixlen
;
323 ipv6
->prefix
= connected
->address
->u
.prefix6
;
325 if (IN6_IS_ADDR_LINKLOCAL(&ipv6
->prefix
))
326 listnode_add(circuit
->ipv6_link
, ipv6
);
328 listnode_add(circuit
->ipv6_non_link
, ipv6
);
330 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
334 zlog_debug("Added IPv6 address %pFX to circuit %s",
335 connected
->address
, circuit
->interface
->name
);
336 #endif /* EXTREME_DEBUG */
339 hook_call(isis_circuit_add_addr_hook
, circuit
);
344 void isis_circuit_del_addr(struct isis_circuit
*circuit
,
345 struct connected
*connected
)
347 struct prefix_ipv4
*ipv4
, *ip
= NULL
;
348 struct listnode
*node
;
349 struct prefix_ipv6
*ipv6
, *ip6
= NULL
;
352 if (connected
->address
->family
== AF_INET
) {
353 ipv4
= prefix_ipv4_new();
354 ipv4
->prefixlen
= connected
->address
->prefixlen
;
355 ipv4
->prefix
= connected
->address
->u
.prefix4
;
357 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
, ip
))
358 if (prefix_same((struct prefix
*)ip
,
359 (struct prefix
*)ipv4
))
363 listnode_delete(circuit
->ip_addrs
, ip
);
364 prefix_ipv4_free(&ip
);
366 lsp_regenerate_schedule(circuit
->area
,
367 circuit
->is_type
, 0);
370 "Nonexistent ip address %pFX removal attempt from circuit %s",
371 connected
->address
, circuit
->interface
->name
);
372 zlog_warn("Current ip addresses on %s:",
373 circuit
->interface
->name
);
374 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
376 zlog_warn(" %pFX", ip
);
378 zlog_warn("End of addresses");
381 prefix_ipv4_free(&ipv4
);
383 if (connected
->address
->family
== AF_INET6
) {
384 ipv6
= prefix_ipv6_new();
385 ipv6
->prefixlen
= connected
->address
->prefixlen
;
386 ipv6
->prefix
= connected
->address
->u
.prefix6
;
388 if (IN6_IS_ADDR_LINKLOCAL(&ipv6
->prefix
)) {
389 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
391 if (prefix_same((struct prefix
*)ip6
,
392 (struct prefix
*)ipv6
))
396 listnode_delete(circuit
->ipv6_link
, ip6
);
397 prefix_ipv6_free(&ip6
);
401 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
403 if (prefix_same((struct prefix
*)ip6
,
404 (struct prefix
*)ipv6
))
408 listnode_delete(circuit
->ipv6_non_link
, ip6
);
409 prefix_ipv6_free(&ip6
);
416 "Nonexistent ip address %pFX removal attempt from circuit %s",
417 connected
->address
, circuit
->interface
->name
);
418 zlog_warn("Current ip addresses on %s:",
419 circuit
->interface
->name
);
420 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
422 zlog_warn(" %pFX", (struct prefix
*)ip6
);
424 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
426 zlog_warn(" %pFX", (struct prefix
*)ip6
);
427 zlog_warn("End of addresses");
428 } else if (circuit
->area
)
429 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
432 prefix_ipv6_free(&ipv6
);
437 static uint8_t isis_circuit_id_gen(struct isis
*isis
, struct interface
*ifp
)
439 /* Circuit ids MUST be unique for any broadcast circuits. Otherwise,
440 * Pseudo-Node LSPs cannot be generated correctly.
442 * Currently, allocate one circuit ID for any circuit, limiting the total
443 * numer of circuits IS-IS can run on to 255.
445 * We should revisit this when implementing 3-way adjacencies for p2p, since
446 * we then have extended interface IDs available.
448 uint8_t id
= ifp
->ifindex
;
451 for (i
= 0; i
< 256; i
++) {
452 if (id
&& !_ISIS_CHECK_FLAG(isis
->circuit_ids_used
, id
))
458 zlog_warn("Could not allocate a circuit id for '%s'",
463 _ISIS_SET_FLAG(isis
->circuit_ids_used
, id
);
467 void isis_circuit_if_add(struct isis_circuit
*circuit
, struct interface
*ifp
)
469 struct listnode
*node
, *nnode
;
470 struct connected
*conn
;
472 isis_circuit_if_bind(circuit
, ifp
);
474 if (if_is_broadcast(ifp
)) {
475 if (fabricd
|| circuit
->circ_type_config
== CIRCUIT_T_P2P
)
476 circuit
->circ_type
= CIRCUIT_T_P2P
;
478 circuit
->circ_type
= CIRCUIT_T_BROADCAST
;
479 } else if (if_is_pointopoint(ifp
)) {
480 circuit
->circ_type
= CIRCUIT_T_P2P
;
481 } else if (if_is_loopback(ifp
)) {
482 circuit
->circ_type
= CIRCUIT_T_LOOPBACK
;
483 circuit
->is_passive
= 1;
485 /* It's normal in case of loopback etc. */
487 zlog_debug("isis_circuit_if_add: unsupported media");
488 circuit
->circ_type
= CIRCUIT_T_UNKNOWN
;
491 circuit
->ip_addrs
= list_new();
492 circuit
->ipv6_link
= list_new();
493 circuit
->ipv6_non_link
= list_new();
495 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, conn
))
496 isis_circuit_add_addr(circuit
, conn
);
500 void isis_circuit_if_del(struct isis_circuit
*circuit
, struct interface
*ifp
)
502 struct listnode
*node
, *nnode
;
503 struct connected
*conn
;
505 assert(circuit
->interface
== ifp
);
507 /* destroy addresses */
508 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, conn
))
509 isis_circuit_del_addr(circuit
, conn
);
511 if (circuit
->ip_addrs
) {
512 assert(listcount(circuit
->ip_addrs
) == 0);
513 list_delete(&circuit
->ip_addrs
);
516 if (circuit
->ipv6_link
) {
517 assert(listcount(circuit
->ipv6_link
) == 0);
518 list_delete(&circuit
->ipv6_link
);
521 if (circuit
->ipv6_non_link
) {
522 assert(listcount(circuit
->ipv6_non_link
) == 0);
523 list_delete(&circuit
->ipv6_non_link
);
526 circuit
->circ_type
= CIRCUIT_T_UNKNOWN
;
529 void isis_circuit_if_bind(struct isis_circuit
*circuit
, struct interface
*ifp
)
531 assert(circuit
!= NULL
);
533 if (circuit
->interface
)
534 assert(circuit
->interface
== ifp
);
536 circuit
->interface
= ifp
;
538 assert(ifp
->info
== circuit
);
543 void isis_circuit_if_unbind(struct isis_circuit
*circuit
, struct interface
*ifp
)
545 assert(circuit
!= NULL
);
547 assert(circuit
->interface
== ifp
);
548 assert(ifp
->info
== circuit
);
549 circuit
->interface
= NULL
;
553 static void isis_circuit_update_all_srmflags(struct isis_circuit
*circuit
,
556 struct isis_area
*area
;
557 struct isis_lsp
*lsp
;
561 area
= circuit
->area
;
563 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
564 if (!(level
& circuit
->is_type
))
567 if (!lspdb_count(&area
->lspdb
[level
- 1]))
570 frr_each (lspdb
, &area
->lspdb
[level
- 1], lsp
) {
572 isis_tx_queue_add(circuit
->tx_queue
, lsp
,
575 isis_tx_queue_del(circuit
->tx_queue
, lsp
);
581 size_t isis_circuit_pdu_size(struct isis_circuit
*circuit
)
583 return ISO_MTU(circuit
);
586 void isis_circuit_stream(struct isis_circuit
*circuit
, struct stream
**stream
)
588 size_t stream_size
= isis_circuit_pdu_size(circuit
);
591 *stream
= stream_new(stream_size
);
593 if (STREAM_SIZE(*stream
) != stream_size
)
594 stream_resize_inplace(stream
, stream_size
);
595 stream_reset(*stream
);
599 void isis_circuit_prepare(struct isis_circuit
*circuit
)
601 #if ISIS_METHOD != ISIS_METHOD_DLPI
602 thread_add_read(master
, isis_receive
, circuit
, circuit
->fd
,
605 thread_add_timer_msec(master
, isis_receive
, circuit
,
606 listcount(circuit
->area
->circuit_list
) * 100,
611 int isis_circuit_up(struct isis_circuit
*circuit
)
615 /* Set the flags for all the lsps of the circuit. */
616 isis_circuit_update_all_srmflags(circuit
, 1);
618 if (circuit
->state
== C_STATE_UP
)
621 if (circuit
->is_passive
) {
622 circuit
->last_uptime
= time(NULL
);
623 /* make sure the union fields are initialized, else we
624 * could end with garbage values from a previous circuit
625 * type, which would then cause a segfault when building
626 * LSPs or computing the SPF tree
628 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
629 circuit
->u
.bc
.adjdb
[0] = list_new();
630 circuit
->u
.bc
.adjdb
[1] = list_new();
631 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
632 circuit
->u
.p2p
.neighbor
= NULL
;
637 if (circuit
->area
->lsp_mtu
> isis_circuit_pdu_size(circuit
)) {
640 "Interface MTU %zu on %s is too low to support area lsp mtu %u!",
641 isis_circuit_pdu_size(circuit
),
642 circuit
->interface
->name
, circuit
->area
->lsp_mtu
);
643 isis_circuit_update_all_srmflags(circuit
, 0);
647 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
648 circuit
->circuit_id
=
649 isis_circuit_id_gen(circuit
->isis
, circuit
->interface
);
650 if (!circuit
->circuit_id
) {
653 "There are already 255 broadcast circuits active!");
658 * Get the Hardware Address
660 if (circuit
->interface
->hw_addr_len
!= ETH_ALEN
) {
661 zlog_warn("unsupported link layer");
663 memcpy(circuit
->u
.bc
.snpa
, circuit
->interface
->hw_addr
,
667 zlog_debug("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
668 circuit
->interface
->ifindex
, ISO_MTU(circuit
),
669 snpa_print(circuit
->u
.bc
.snpa
));
670 #endif /* EXTREME_DEBUG */
672 circuit
->u
.bc
.adjdb
[0] = list_new();
673 circuit
->u
.bc
.adjdb
[1] = list_new();
676 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
679 /* initilizing the hello sending threads
683 /* 8.4.1 a) commence sending of IIH PDUs */
685 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
686 if (!(circuit
->is_type
& level
))
689 send_hello_sched(circuit
, level
, TRIGGERED_IIH_DELAY
);
690 circuit
->u
.bc
.lan_neighs
[level
- 1] = list_new();
692 thread_add_timer(master
, isis_run_dr
,
693 &circuit
->level_arg
[level
- 1],
694 2 * circuit
->hello_interval
[level
- 1],
695 &circuit
->u
.bc
.t_run_dr
[level
- 1]);
698 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
699 /* 8.4.1 c) FIXME: listen for ESH PDUs */
700 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
701 /* initializing the hello send threads
704 circuit
->u
.p2p
.neighbor
= NULL
;
705 send_hello_sched(circuit
, 0, TRIGGERED_IIH_DELAY
);
708 /* initializing PSNP timers */
709 if (circuit
->is_type
& IS_LEVEL_1
)
711 master
, send_l1_psnp
, circuit
,
712 isis_jitter(circuit
->psnp_interval
[0], PSNP_JITTER
),
713 &circuit
->t_send_psnp
[0]);
715 if (circuit
->is_type
& IS_LEVEL_2
)
717 master
, send_l2_psnp
, circuit
,
718 isis_jitter(circuit
->psnp_interval
[1], PSNP_JITTER
),
719 &circuit
->t_send_psnp
[1]);
721 /* unified init for circuits; ignore warnings below this level */
722 retv
= isis_sock_init(circuit
);
723 if (retv
!= ISIS_OK
) {
724 isis_circuit_down(circuit
);
728 /* initialize the circuit streams after opening connection */
729 isis_circuit_stream(circuit
, &circuit
->rcv_stream
);
730 isis_circuit_stream(circuit
, &circuit
->snd_stream
);
732 isis_circuit_prepare(circuit
);
734 circuit
->tx_queue
= isis_tx_queue_new(circuit
, send_lsp
);
736 circuit
->last_uptime
= time(NULL
);
738 if (circuit
->area
->mta
&& circuit
->area
->mta
->status
)
739 isis_link_params_update(circuit
, circuit
->interface
);
742 /* send northbound notification */
743 isis_notif_if_state_change(circuit
, false);
744 #endif /* ifndef FABRICD */
749 void isis_circuit_down(struct isis_circuit
*circuit
)
752 /* send northbound notification */
753 isis_notif_if_state_change(circuit
, true);
754 #endif /* ifndef FABRICD */
756 /* log adjacency changes if configured to do so */
757 if (circuit
->area
->log_adj_changes
) {
758 struct isis_adjacency
*adj
= NULL
;
759 if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
760 adj
= circuit
->u
.p2p
.neighbor
;
763 adj
, adj
->adj_state
, ISIS_ADJ_DOWN
,
764 "circuit is being brought down");
765 } else if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
766 struct list
*adj_list
;
767 struct listnode
*node
;
768 if (circuit
->u
.bc
.adjdb
[0]) {
769 adj_list
= list_new();
770 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[0],
772 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
776 "circuit is being brought down");
777 list_delete(&adj_list
);
779 if (circuit
->u
.bc
.adjdb
[1]) {
780 adj_list
= list_new();
781 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[1],
783 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
787 "circuit is being brought down");
788 list_delete(&adj_list
);
793 /* Clear the flags for all the lsps of the circuit. */
794 isis_circuit_update_all_srmflags(circuit
, 0);
796 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
797 /* destroy neighbour lists */
798 if (circuit
->u
.bc
.lan_neighs
[0]) {
799 list_delete(&circuit
->u
.bc
.lan_neighs
[0]);
800 circuit
->u
.bc
.lan_neighs
[0] = NULL
;
802 if (circuit
->u
.bc
.lan_neighs
[1]) {
803 list_delete(&circuit
->u
.bc
.lan_neighs
[1]);
804 circuit
->u
.bc
.lan_neighs
[1] = NULL
;
806 /* destroy adjacency databases */
807 if (circuit
->u
.bc
.adjdb
[0]) {
808 circuit
->u
.bc
.adjdb
[0]->del
= isis_delete_adj
;
809 list_delete(&circuit
->u
.bc
.adjdb
[0]);
810 circuit
->u
.bc
.adjdb
[0] = NULL
;
812 if (circuit
->u
.bc
.adjdb
[1]) {
813 circuit
->u
.bc
.adjdb
[1]->del
= isis_delete_adj
;
814 list_delete(&circuit
->u
.bc
.adjdb
[1]);
815 circuit
->u
.bc
.adjdb
[1] = NULL
;
817 if (circuit
->u
.bc
.is_dr
[0]) {
818 isis_dr_resign(circuit
, 1);
819 circuit
->u
.bc
.is_dr
[0] = 0;
821 memset(circuit
->u
.bc
.l1_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
822 if (circuit
->u
.bc
.is_dr
[1]) {
823 isis_dr_resign(circuit
, 2);
824 circuit
->u
.bc
.is_dr
[1] = 0;
826 memset(circuit
->u
.bc
.l2_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
827 memset(circuit
->u
.bc
.snpa
, 0, ETH_ALEN
);
829 thread_cancel(&circuit
->u
.bc
.t_send_lan_hello
[0]);
830 thread_cancel(&circuit
->u
.bc
.t_send_lan_hello
[1]);
831 thread_cancel(&circuit
->u
.bc
.t_run_dr
[0]);
832 thread_cancel(&circuit
->u
.bc
.t_run_dr
[1]);
833 thread_cancel(&circuit
->u
.bc
.t_refresh_pseudo_lsp
[0]);
834 thread_cancel(&circuit
->u
.bc
.t_refresh_pseudo_lsp
[1]);
835 circuit
->lsp_regenerate_pending
[0] = 0;
836 circuit
->lsp_regenerate_pending
[1] = 0;
838 _ISIS_CLEAR_FLAG(circuit
->isis
->circuit_ids_used
,
839 circuit
->circuit_id
);
840 circuit
->circuit_id
= 0;
841 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
842 isis_delete_adj(circuit
->u
.p2p
.neighbor
);
843 circuit
->u
.p2p
.neighbor
= NULL
;
844 thread_cancel(&circuit
->u
.p2p
.t_send_p2p_hello
);
848 * All adjacencies have to be gone, delete snmp list
849 * and reset snmpd idx generator
851 if (circuit
->snmp_adj_list
!= NULL
)
852 list_delete(&circuit
->snmp_adj_list
);
854 circuit
->snmp_adj_idx_gen
= 0;
856 /* Cancel all active threads */
857 thread_cancel(&circuit
->t_send_csnp
[0]);
858 thread_cancel(&circuit
->t_send_csnp
[1]);
859 thread_cancel(&circuit
->t_send_psnp
[0]);
860 thread_cancel(&circuit
->t_send_psnp
[1]);
861 thread_cancel(&circuit
->t_read
);
863 if (circuit
->tx_queue
) {
864 isis_tx_queue_free(circuit
->tx_queue
);
865 circuit
->tx_queue
= NULL
;
868 /* send one gratuitous hello to spead up convergence */
869 if (circuit
->state
== C_STATE_UP
) {
870 if (circuit
->is_type
& IS_LEVEL_1
)
871 send_hello(circuit
, IS_LEVEL_1
);
872 if (circuit
->is_type
& IS_LEVEL_2
)
873 send_hello(circuit
, IS_LEVEL_2
);
876 circuit
->upadjcount
[0] = 0;
877 circuit
->upadjcount
[1] = 0;
879 /* close the socket */
885 if (circuit
->rcv_stream
!= NULL
) {
886 stream_free(circuit
->rcv_stream
);
887 circuit
->rcv_stream
= NULL
;
890 if (circuit
->snd_stream
!= NULL
) {
891 stream_free(circuit
->snd_stream
);
892 circuit
->snd_stream
= NULL
;
895 thread_cancel_event(master
, circuit
);
900 void circuit_update_nlpids(struct isis_circuit
*circuit
)
902 circuit
->nlpids
.count
= 0;
904 if (circuit
->ip_router
) {
905 circuit
->nlpids
.nlpids
[0] = NLPID_IP
;
906 circuit
->nlpids
.count
++;
908 if (circuit
->ipv6_router
) {
909 circuit
->nlpids
.nlpids
[circuit
->nlpids
.count
] = NLPID_IPV6
;
910 circuit
->nlpids
.count
++;
915 void isis_circuit_print_vty(struct isis_circuit
*circuit
, struct vty
*vty
,
918 if (detail
== ISIS_UI_LEVEL_BRIEF
) {
919 vty_out(vty
, " %-12s", circuit
->interface
->name
);
920 vty_out(vty
, "0x%-7x", circuit
->circuit_id
);
921 vty_out(vty
, "%-9s", circuit_state2string(circuit
->state
));
922 vty_out(vty
, "%-9s", circuit_type2string(circuit
->circ_type
));
923 vty_out(vty
, "%-9s", circuit_t2string(circuit
->is_type
));
927 if (detail
== ISIS_UI_LEVEL_DETAIL
) {
928 struct listnode
*node
;
929 struct prefix
*ip_addr
;
931 vty_out(vty
, " Interface: %s", circuit
->interface
->name
);
932 vty_out(vty
, ", State: %s",
933 circuit_state2string(circuit
->state
));
934 if (circuit
->is_passive
)
935 vty_out(vty
, ", Passive");
937 vty_out(vty
, ", Active");
938 vty_out(vty
, ", Circuit Id: 0x%x", circuit
->circuit_id
);
940 vty_out(vty
, " Type: %s",
941 circuit_type2string(circuit
->circ_type
));
942 vty_out(vty
, ", Level: %s", circuit_t2string(circuit
->is_type
));
943 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
944 vty_out(vty
, ", SNPA: %-10s",
945 snpa_print(circuit
->u
.bc
.snpa
));
947 if (circuit
->is_type
& IS_LEVEL_1
) {
948 vty_out(vty
, " Level-1 Information:\n");
949 if (circuit
->area
->newmetric
)
950 vty_out(vty
, " Metric: %d",
951 circuit
->te_metric
[0]);
953 vty_out(vty
, " Metric: %d",
955 if (!circuit
->is_passive
) {
956 vty_out(vty
, ", Active neighbors: %u\n",
957 circuit
->upadjcount
[0]);
959 " Hello interval: %u, Holddown count: %u %s\n",
960 circuit
->hello_interval
[0],
961 circuit
->hello_multiplier
[0],
962 (circuit
->pad_hellos
? "(pad)"
965 " CNSP interval: %u, PSNP interval: %u\n",
966 circuit
->csnp_interval
[0],
967 circuit
->psnp_interval
[0]);
968 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
970 " LAN Priority: %u, %s\n",
971 circuit
->priority
[0],
972 (circuit
->u
.bc
.is_dr
[0]
979 if (circuit
->is_type
& IS_LEVEL_2
) {
980 vty_out(vty
, " Level-2 Information:\n");
981 if (circuit
->area
->newmetric
)
982 vty_out(vty
, " Metric: %d",
983 circuit
->te_metric
[1]);
985 vty_out(vty
, " Metric: %d",
987 if (!circuit
->is_passive
) {
988 vty_out(vty
, ", Active neighbors: %u\n",
989 circuit
->upadjcount
[1]);
991 " Hello interval: %u, Holddown count: %u %s\n",
992 circuit
->hello_interval
[1],
993 circuit
->hello_multiplier
[1],
994 (circuit
->pad_hellos
? "(pad)"
997 " CNSP interval: %u, PSNP interval: %u\n",
998 circuit
->csnp_interval
[1],
999 circuit
->psnp_interval
[1]);
1000 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1002 " LAN Priority: %u, %s\n",
1003 circuit
->priority
[1],
1004 (circuit
->u
.bc
.is_dr
[1]
1011 if (circuit
->ip_addrs
&& listcount(circuit
->ip_addrs
) > 0) {
1012 vty_out(vty
, " IP Prefix(es):\n");
1013 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
1015 vty_out(vty
, " %pFX\n", ip_addr
);
1017 if (circuit
->ipv6_link
&& listcount(circuit
->ipv6_link
) > 0) {
1018 vty_out(vty
, " IPv6 Link-Locals:\n");
1019 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
1021 vty_out(vty
, " %pFX\n", ip_addr
);
1023 if (circuit
->ipv6_non_link
1024 && listcount(circuit
->ipv6_non_link
) > 0) {
1025 vty_out(vty
, " IPv6 Prefixes:\n");
1026 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
1028 vty_out(vty
, " %pFX\n", ip_addr
);
1037 DEFINE_HOOK(isis_circuit_config_write
,
1038 (struct isis_circuit
*circuit
, struct vty
*vty
),
1041 static int isis_interface_config_write(struct vty
*vty
)
1043 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1045 struct listnode
*node
;
1046 struct interface
*ifp
;
1047 struct isis_area
*area
;
1048 struct isis_circuit
*circuit
;
1050 struct isis
*isis
= NULL
;
1052 isis
= isis_lookup_by_vrfid(vrf
->vrf_id
);
1055 vty_out(vty
, "ISIS routing instance not found");
1059 FOR_ALL_INTERFACES (vrf
, ifp
) {
1061 vty_frame(vty
, "interface %s\n", ifp
->name
);
1065 vty_out(vty
, " description %s\n", ifp
->desc
);
1069 for (ALL_LIST_ELEMENTS_RO(isis
->area_list
, node
, area
)) {
1071 circuit_lookup_by_ifp(ifp
, area
->circuit_list
);
1072 if (circuit
== NULL
)
1074 if (circuit
->ip_router
) {
1075 vty_out(vty
, " ip router " PROTO_NAME
" %s\n",
1079 if (circuit
->is_passive
) {
1080 vty_out(vty
, " " PROTO_NAME
" passive\n");
1083 if (circuit
->circ_type_config
== CIRCUIT_T_P2P
) {
1084 vty_out(vty
, " " PROTO_NAME
" network point-to-point\n");
1087 if (circuit
->ipv6_router
) {
1088 vty_out(vty
, " ipv6 router " PROTO_NAME
" %s\n",
1093 /* ISIS - circuit type */
1095 if (circuit
->is_type
== IS_LEVEL_1
) {
1096 vty_out(vty
, " " PROTO_NAME
" circuit-type level-1\n");
1099 if (circuit
->is_type
== IS_LEVEL_2
) {
1101 " " PROTO_NAME
" circuit-type level-2-only\n");
1107 /* ISIS - CSNP interval */
1108 if (circuit
->csnp_interval
[0]
1109 == circuit
->csnp_interval
[1]) {
1110 if (circuit
->csnp_interval
[0]
1111 != DEFAULT_CSNP_INTERVAL
) {
1112 vty_out(vty
, " " PROTO_NAME
" csnp-interval %d\n",
1113 circuit
->csnp_interval
[0]);
1117 for (i
= 0; i
< 2; i
++) {
1118 if (circuit
->csnp_interval
[i
]
1119 != DEFAULT_CSNP_INTERVAL
) {
1121 " " PROTO_NAME
" csnp-interval %d level-%d\n",
1122 circuit
->csnp_interval
1130 /* ISIS - PSNP interval */
1131 if (circuit
->psnp_interval
[0]
1132 == circuit
->psnp_interval
[1]) {
1133 if (circuit
->psnp_interval
[0]
1134 != DEFAULT_PSNP_INTERVAL
) {
1135 vty_out(vty
, " " PROTO_NAME
" psnp-interval %d\n",
1136 circuit
->psnp_interval
[0]);
1140 for (i
= 0; i
< 2; i
++) {
1141 if (circuit
->psnp_interval
[i
]
1142 != DEFAULT_PSNP_INTERVAL
) {
1144 " " PROTO_NAME
" psnp-interval %d level-%d\n",
1145 circuit
->psnp_interval
1153 /* ISIS - Hello padding - Defaults to true so only
1154 * display if false */
1155 if (circuit
->pad_hellos
== 0) {
1156 vty_out(vty
, " no " PROTO_NAME
" hello padding\n");
1160 if (circuit
->disable_threeway_adj
) {
1161 vty_out(vty
, " no isis three-way-handshake\n");
1165 /* ISIS - Hello interval */
1166 if (circuit
->hello_interval
[0]
1167 == circuit
->hello_interval
[1]) {
1168 if (circuit
->hello_interval
[0]
1169 != DEFAULT_HELLO_INTERVAL
) {
1171 " " PROTO_NAME
" hello-interval %d\n",
1172 circuit
->hello_interval
[0]);
1176 for (i
= 0; i
< 2; i
++) {
1177 if (circuit
->hello_interval
[i
]
1178 != DEFAULT_HELLO_INTERVAL
) {
1180 " " PROTO_NAME
" hello-interval %d level-%d\n",
1181 circuit
->hello_interval
1189 /* ISIS - Hello Multiplier */
1190 if (circuit
->hello_multiplier
[0]
1191 == circuit
->hello_multiplier
[1]) {
1192 if (circuit
->hello_multiplier
[0]
1193 != DEFAULT_HELLO_MULTIPLIER
) {
1195 " " PROTO_NAME
" hello-multiplier %d\n",
1196 circuit
->hello_multiplier
[0]);
1200 for (i
= 0; i
< 2; i
++) {
1201 if (circuit
->hello_multiplier
[i
]
1202 != DEFAULT_HELLO_MULTIPLIER
) {
1204 " " PROTO_NAME
" hello-multiplier %d level-%d\n",
1205 circuit
->hello_multiplier
1213 /* ISIS - Priority */
1214 if (circuit
->priority
[0] == circuit
->priority
[1]) {
1215 if (circuit
->priority
[0] != DEFAULT_PRIORITY
) {
1216 vty_out(vty
, " " PROTO_NAME
" priority %d\n",
1217 circuit
->priority
[0]);
1221 for (i
= 0; i
< 2; i
++) {
1222 if (circuit
->priority
[i
]
1223 != DEFAULT_PRIORITY
) {
1225 " " PROTO_NAME
" priority %d level-%d\n",
1226 circuit
->priority
[i
],
1234 if (circuit
->te_metric
[0] == circuit
->te_metric
[1]) {
1235 if (circuit
->te_metric
[0]
1236 != DEFAULT_CIRCUIT_METRIC
) {
1237 vty_out(vty
, " " PROTO_NAME
" metric %d\n",
1238 circuit
->te_metric
[0]);
1242 for (i
= 0; i
< 2; i
++) {
1243 if (circuit
->te_metric
[i
]
1244 != DEFAULT_CIRCUIT_METRIC
) {
1246 " " PROTO_NAME
" metric %d level-%d\n",
1247 circuit
->te_metric
[i
],
1253 if (circuit
->passwd
.type
== ISIS_PASSWD_TYPE_HMAC_MD5
) {
1254 vty_out(vty
, " " PROTO_NAME
" password md5 %s\n",
1255 circuit
->passwd
.passwd
);
1257 } else if (circuit
->passwd
.type
1258 == ISIS_PASSWD_TYPE_CLEARTXT
) {
1259 vty_out(vty
, " " PROTO_NAME
" password clear %s\n",
1260 circuit
->passwd
.passwd
);
1263 write
+= hook_call(isis_circuit_config_write
,
1266 vty_endframe(vty
, "!\n");
1272 static int isis_interface_config_write(struct vty
*vty
)
1274 struct vrf
*vrf
= NULL
;
1277 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
1278 struct interface
*ifp
;
1280 FOR_ALL_INTERFACES (vrf
, ifp
) {
1281 struct lyd_node
*dnode
;
1282 dnode
= yang_dnode_get(
1283 running_config
->dnode
,
1284 "/frr-interface:lib/interface[name='%s'][vrf='%s']",
1285 ifp
->name
, vrf
->name
);
1290 nb_cli_show_dnode_cmds(vty
, dnode
, false);
1295 #endif /* ifdef FABRICD */
1297 struct isis_circuit
*isis_circuit_create(struct isis_area
*area
,
1298 struct interface
*ifp
)
1300 struct isis_circuit
*circuit
= circuit_scan_by_ifp(ifp
);
1302 if (circuit
&& circuit
->area
)
1304 circuit
= isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1305 if (circuit
->state
!= C_STATE_CONF
&& circuit
->state
!= C_STATE_UP
)
1307 isis_circuit_if_bind(circuit
, ifp
);
1312 void isis_circuit_af_set(struct isis_circuit
*circuit
, bool ip_router
,
1315 struct isis_area
*area
= circuit
->area
;
1316 int old_ipr
= circuit
->ip_router
;
1317 int old_ipv6r
= circuit
->ipv6_router
;
1319 /* is there something to do? */
1320 if (old_ipr
== ip_router
&& old_ipv6r
== ipv6_router
)
1323 circuit
->ip_router
= ip_router
;
1324 circuit
->ipv6_router
= ipv6_router
;
1325 circuit_update_nlpids(circuit
);
1327 /* the area should always be there if we get here, but in the past
1328 * there were corner cases where the area was NULL (e.g. because the
1329 * circuit was deconfigured following a validation error). Do not
1330 * segfault if this happens again.
1333 zlog_err("%s: NULL area for circuit %u", __func__
,
1334 circuit
->circuit_id
);
1338 area
->ip_circuits
+= ip_router
- old_ipr
;
1339 area
->ipv6_circuits
+= ipv6_router
- old_ipv6r
;
1341 if (!ip_router
&& !ipv6_router
)
1342 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1344 lsp_regenerate_schedule(area
, circuit
->is_type
, 0);
1347 ferr_r
isis_circuit_passive_set(struct isis_circuit
*circuit
, bool passive
)
1349 if (circuit
->is_passive
== passive
)
1352 if (if_is_loopback(circuit
->interface
) && !passive
)
1353 return ferr_cfg_invalid("loopback is always passive");
1355 if (circuit
->state
!= C_STATE_UP
) {
1356 circuit
->is_passive
= passive
;
1358 struct isis_area
*area
= circuit
->area
;
1359 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1360 circuit
->is_passive
= passive
;
1361 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1367 ferr_r
isis_circuit_metric_set(struct isis_circuit
*circuit
, int level
,
1370 assert(level
== IS_LEVEL_1
|| level
== IS_LEVEL_2
);
1371 if (metric
> MAX_WIDE_LINK_METRIC
)
1372 return ferr_cfg_invalid("metric %d too large for wide metric",
1374 if (circuit
->area
&& circuit
->area
->oldmetric
1375 && metric
> MAX_NARROW_LINK_METRIC
)
1376 return ferr_cfg_invalid("metric %d too large for narrow metric",
1379 /* inform ldp-sync of metric change
1380 * if ldp-sync is running need to save metric
1381 * and restore new values after ldp-sync completion.
1383 if (isis_ldp_sync_if_metric_config(circuit
, level
, metric
)) {
1384 circuit
->te_metric
[level
- 1] = metric
;
1385 circuit
->metric
[level
- 1] = metric
;
1387 lsp_regenerate_schedule(circuit
->area
, level
, 0);
1392 ferr_r
isis_circuit_passwd_unset(struct isis_circuit
*circuit
)
1394 memset(&circuit
->passwd
, 0, sizeof(circuit
->passwd
));
1398 ferr_r
isis_circuit_passwd_set(struct isis_circuit
*circuit
,
1399 uint8_t passwd_type
, const char *passwd
)
1404 return ferr_code_bug("no circuit password given");
1406 len
= strlen(passwd
);
1408 return ferr_code_bug(
1409 "circuit password too long (max 254 chars)");
1411 circuit
->passwd
.len
= len
;
1412 strlcpy((char *)circuit
->passwd
.passwd
, passwd
,
1413 sizeof(circuit
->passwd
.passwd
));
1414 circuit
->passwd
.type
= passwd_type
;
1418 ferr_r
isis_circuit_passwd_cleartext_set(struct isis_circuit
*circuit
,
1421 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_CLEARTXT
,
1425 ferr_r
isis_circuit_passwd_hmac_md5_set(struct isis_circuit
*circuit
,
1428 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1432 struct cmd_node interface_node
= {
1433 .name
= "interface",
1434 .node
= INTERFACE_NODE
,
1435 .parent_node
= CONFIG_NODE
,
1436 .prompt
= "%s(config-if)# ",
1437 .config_write
= isis_interface_config_write
,
1440 void isis_circuit_circ_type_set(struct isis_circuit
*circuit
, int circ_type
)
1442 if (circuit
->circ_type
== circ_type
)
1445 if (circuit
->state
!= C_STATE_UP
) {
1446 circuit
->circ_type
= circ_type
;
1447 circuit
->circ_type_config
= circ_type
;
1449 struct isis_area
*area
= circuit
->area
;
1451 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1452 circuit
->circ_type
= circ_type
;
1453 circuit
->circ_type_config
= circ_type
;
1454 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1458 int isis_circuit_mt_enabled_set(struct isis_circuit
*circuit
, uint16_t mtid
,
1461 struct isis_circuit_mt_setting
*setting
;
1463 setting
= circuit_get_mt_setting(circuit
, mtid
);
1464 if (setting
->enabled
!= enabled
) {
1465 setting
->enabled
= enabled
;
1466 lsp_regenerate_schedule(circuit
->area
, IS_LEVEL_1
| IS_LEVEL_2
,
1473 int isis_if_new_hook(struct interface
*ifp
)
1478 int isis_if_delete_hook(struct interface
*ifp
)
1480 struct isis_circuit
*circuit
;
1481 /* Clean up the circuit data */
1482 if (ifp
&& ifp
->info
) {
1483 circuit
= ifp
->info
;
1484 isis_csm_state_change(IF_DOWN_FROM_Z
, circuit
, ifp
);
1490 static int isis_ifp_create(struct interface
*ifp
)
1492 struct vrf
*vrf
= NULL
;
1494 if (if_is_operative(ifp
)) {
1495 vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
1497 isis_global_instance_create(vrf
->name
);
1498 isis_csm_state_change(IF_UP_FROM_Z
, circuit_scan_by_ifp(ifp
),
1501 hook_call(isis_if_new_hook
, ifp
);
1506 static int isis_ifp_up(struct interface
*ifp
)
1508 isis_csm_state_change(IF_UP_FROM_Z
, circuit_scan_by_ifp(ifp
), ifp
);
1513 static int isis_ifp_down(struct interface
*ifp
)
1515 struct isis_circuit
*circuit
;
1517 circuit
= isis_csm_state_change(IF_DOWN_FROM_Z
,
1518 circuit_scan_by_ifp(ifp
), ifp
);
1520 SET_FLAG(circuit
->flags
, ISIS_CIRCUIT_FLAPPED_AFTER_SPF
);
1525 static int isis_ifp_destroy(struct interface
*ifp
)
1527 if (if_is_operative(ifp
))
1528 zlog_warn("Zebra: got delete of %s, but interface is still up",
1531 isis_csm_state_change(IF_DOWN_FROM_Z
, circuit_scan_by_ifp(ifp
), ifp
);
1533 /* Cannot call if_delete because we should retain the pseudo interface
1534 in case there is configuration info attached to it. */
1535 if_delete_retain(ifp
);
1540 void isis_circuit_init(void)
1542 /* Initialize Zebra interface data structure */
1543 hook_register_prio(if_add
, 0, isis_if_new_hook
);
1544 hook_register_prio(if_del
, 0, isis_if_delete_hook
);
1546 /* Install interface node */
1547 install_node(&interface_node
);
1549 if_zapi_callbacks(isis_ifp_create
, isis_ifp_up
,
1550 isis_ifp_down
, isis_ifp_destroy
);