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 static void isis_circuit_enable(struct isis_circuit
*circuit
)
81 struct isis_area
*area
= circuit
->area
;
82 struct interface
*ifp
= circuit
->interface
;
85 area
= isis_area_lookup(circuit
->tag
, ifp
->vrf
->vrf_id
);
87 isis_area_add_circuit(area
, circuit
);
90 if (if_is_operative(ifp
))
91 isis_csm_state_change(IF_UP_FROM_Z
, circuit
, ifp
);
94 static void isis_circuit_disable(struct isis_circuit
*circuit
)
96 struct isis_area
*area
= circuit
->area
;
97 struct interface
*ifp
= circuit
->interface
;
99 if (if_is_operative(ifp
))
100 isis_csm_state_change(IF_DOWN_FROM_Z
, circuit
, ifp
);
103 isis_area_del_circuit(area
, circuit
);
106 struct isis_circuit
*isis_circuit_new(struct interface
*ifp
, const char *tag
)
108 struct isis_circuit
*circuit
;
111 circuit
= XCALLOC(MTYPE_ISIS_CIRCUIT
, sizeof(struct isis_circuit
));
113 circuit
->tag
= XSTRDUP(MTYPE_ISIS_CIRCUIT
, tag
);
119 circuit
->is_type_config
= yang_get_default_enum(
120 "/frr-interface:lib/interface/frr-isisd:isis/circuit-type");
123 circuit
->pad_hellos
= yang_get_default_bool(
124 "/frr-interface:lib/interface/frr-isisd:isis/hello/padding");
125 circuit
->hello_interval
[0] = yang_get_default_uint32(
126 "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1");
127 circuit
->hello_interval
[1] = yang_get_default_uint32(
128 "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2");
129 circuit
->hello_multiplier
[0] = yang_get_default_uint32(
130 "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1");
131 circuit
->hello_multiplier
[1] = yang_get_default_uint32(
132 "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2");
133 circuit
->csnp_interval
[0] = yang_get_default_uint16(
134 "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1");
135 circuit
->csnp_interval
[1] = yang_get_default_uint16(
136 "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2");
137 circuit
->psnp_interval
[0] = yang_get_default_uint16(
138 "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1");
139 circuit
->psnp_interval
[1] = yang_get_default_uint16(
140 "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2");
141 circuit
->priority
[0] = yang_get_default_uint8(
142 "/frr-interface:lib/interface/frr-isisd:isis/priority/level-1");
143 circuit
->priority
[1] = yang_get_default_uint8(
144 "/frr-interface:lib/interface/frr-isisd:isis/priority/level-2");
145 circuit
->metric
[0] = yang_get_default_uint32(
146 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1");
147 circuit
->metric
[1] = yang_get_default_uint32(
148 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2");
149 circuit
->te_metric
[0] = yang_get_default_uint32(
150 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1");
151 circuit
->te_metric
[1] = yang_get_default_uint32(
152 "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2");
154 for (i
= 0; i
< 2; i
++) {
155 circuit
->level_arg
[i
].level
= i
+ 1;
156 circuit
->level_arg
[i
].circuit
= circuit
;
159 circuit
->is_type_config
= IS_LEVEL_1_AND_2
;
161 circuit
->pad_hellos
= 1;
162 for (i
= 0; i
< 2; i
++) {
163 circuit
->hello_interval
[i
] = DEFAULT_HELLO_INTERVAL
;
164 circuit
->hello_multiplier
[i
] = DEFAULT_HELLO_MULTIPLIER
;
165 circuit
->csnp_interval
[i
] = DEFAULT_CSNP_INTERVAL
;
166 circuit
->psnp_interval
[i
] = DEFAULT_PSNP_INTERVAL
;
167 circuit
->priority
[i
] = DEFAULT_PRIORITY
;
168 circuit
->metric
[i
] = DEFAULT_CIRCUIT_METRIC
;
169 circuit
->te_metric
[i
] = DEFAULT_CIRCUIT_METRIC
;
170 circuit
->level_arg
[i
].level
= i
+ 1;
171 circuit
->level_arg
[i
].circuit
= circuit
;
173 #endif /* ifndef FABRICD */
175 circuit
->is_type
= circuit
->is_type_config
;
177 circuit_mt_init(circuit
);
178 isis_lfa_excluded_ifaces_init(circuit
, ISIS_LEVEL1
);
179 isis_lfa_excluded_ifaces_init(circuit
, ISIS_LEVEL2
);
181 circuit
->ldp_sync_info
= ldp_sync_info_create();
182 circuit
->ldp_sync_info
->enabled
= LDP_IGP_SYNC_ENABLED
;
184 QOBJ_REG(circuit
, isis_circuit
);
186 isis_circuit_if_bind(circuit
, ifp
);
188 circuit
->ip_addrs
= list_new();
189 circuit
->ipv6_link
= list_new();
190 circuit
->ipv6_non_link
= list_new();
192 if (ifp
->ifindex
!= IFINDEX_INTERNAL
)
193 isis_circuit_enable(circuit
);
198 void isis_circuit_del(struct isis_circuit
*circuit
)
203 if (circuit
->interface
->ifindex
!= IFINDEX_INTERNAL
)
204 isis_circuit_disable(circuit
);
206 isis_circuit_if_unbind(circuit
, circuit
->interface
);
210 ldp_sync_info_free(&circuit
->ldp_sync_info
);
212 circuit_mt_finish(circuit
);
213 isis_lfa_excluded_ifaces_clear(circuit
, ISIS_LEVEL1
);
214 isis_lfa_excluded_ifaces_clear(circuit
, ISIS_LEVEL2
);
216 list_delete(&circuit
->ip_addrs
);
217 list_delete(&circuit
->ipv6_link
);
218 list_delete(&circuit
->ipv6_non_link
);
220 XFREE(MTYPE_TMP
, circuit
->bfd_config
.profile
);
221 XFREE(MTYPE_ISIS_CIRCUIT
, circuit
->tag
);
223 /* and lastly the circuit itself */
224 XFREE(MTYPE_ISIS_CIRCUIT
, circuit
);
229 void isis_circuit_configure(struct isis_circuit
*circuit
,
230 struct isis_area
*area
)
233 circuit
->isis
= area
->isis
;
234 circuit
->area
= area
;
237 * Whenever the is-type of an area is changed, the is-type of each
239 * in that area is updated to a non-empty subset of the area is-type.
240 * Inversely, when configuring a new circuit, this property should be
243 if (area
->is_type
!= IS_LEVEL_1_AND_2
)
244 circuit
->is_type
= area
->is_type
;
247 * Add the circuit into area
249 listnode_add(area
->circuit_list
, circuit
);
251 circuit
->idx
= flags_get_index(&area
->flags
);
253 hook_call(isis_circuit_new_hook
, circuit
);
258 void isis_circuit_deconfigure(struct isis_circuit
*circuit
,
259 struct isis_area
*area
)
261 hook_call(isis_circuit_del_hook
, circuit
);
263 /* Free the index of SRM and SSN flags */
264 flags_free_index(&area
->flags
, circuit
->idx
);
267 /* Reset IS type to configured */
268 circuit
->is_type
= circuit
->is_type_config
;
270 /* Remove circuit from area */
271 assert(circuit
->area
== area
);
272 listnode_delete(area
->circuit_list
, circuit
);
273 circuit
->area
= NULL
;
274 circuit
->isis
= NULL
;
279 struct isis_circuit
*circuit_scan_by_ifp(struct interface
*ifp
)
281 return (struct isis_circuit
*)ifp
->info
;
284 DEFINE_HOOK(isis_circuit_add_addr_hook
, (struct isis_circuit
*circuit
),
287 void isis_circuit_add_addr(struct isis_circuit
*circuit
,
288 struct connected
*connected
)
290 struct listnode
*node
;
291 struct prefix_ipv4
*ipv4
;
292 struct prefix_ipv6
*ipv6
;
294 if (connected
->address
->family
== AF_INET
) {
295 uint32_t addr
= connected
->address
->u
.prefix4
.s_addr
;
297 if (IPV4_NET0(addr
) || IPV4_NET127(addr
) || IN_CLASSD(addr
)
298 || IPV4_LINKLOCAL(addr
))
301 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
, ipv4
))
302 if (prefix_same((struct prefix
*)ipv4
,
306 ipv4
= prefix_ipv4_new();
307 ipv4
->prefixlen
= connected
->address
->prefixlen
;
308 ipv4
->prefix
= connected
->address
->u
.prefix4
;
309 listnode_add(circuit
->ip_addrs
, ipv4
);
311 /* Update Local IP address parameter if MPLS TE is enable */
312 if (circuit
->ext
&& circuit
->area
313 && IS_MPLS_TE(circuit
->area
->mta
)) {
314 circuit
->ext
->local_addr
.s_addr
= ipv4
->prefix
.s_addr
;
315 SET_SUBTLV(circuit
->ext
, EXT_LOCAL_ADDR
);
319 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
324 zlog_debug("Added IP address %pFX to circuit %s",
326 circuit
->interface
->name
);
327 #endif /* EXTREME_DEBUG */
329 if (connected
->address
->family
== AF_INET6
) {
330 if (IN6_IS_ADDR_LOOPBACK(&connected
->address
->u
.prefix6
))
333 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
, ipv6
))
334 if (prefix_same((struct prefix
*)ipv6
,
337 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
, ipv6
))
338 if (prefix_same((struct prefix
*)ipv6
,
342 ipv6
= prefix_ipv6_new();
343 ipv6
->prefixlen
= connected
->address
->prefixlen
;
344 ipv6
->prefix
= connected
->address
->u
.prefix6
;
346 if (IN6_IS_ADDR_LINKLOCAL(&ipv6
->prefix
))
347 listnode_add(circuit
->ipv6_link
, ipv6
);
349 listnode_add(circuit
->ipv6_non_link
, ipv6
);
350 /* Update Local IPv6 address param. if MPLS TE is on */
351 if (circuit
->ext
&& circuit
->area
352 && IS_MPLS_TE(circuit
->area
->mta
)) {
353 IPV6_ADDR_COPY(&circuit
->ext
->local_addr6
,
355 SET_SUBTLV(circuit
->ext
, EXT_LOCAL_ADDR6
);
359 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
364 zlog_debug("Added IPv6 address %pFX to circuit %s",
366 circuit
->interface
->name
);
367 #endif /* EXTREME_DEBUG */
370 hook_call(isis_circuit_add_addr_hook
, circuit
);
375 void isis_circuit_del_addr(struct isis_circuit
*circuit
,
376 struct connected
*connected
)
378 struct prefix_ipv4
*ipv4
, *ip
= NULL
;
379 struct listnode
*node
;
380 struct prefix_ipv6
*ipv6
, *ip6
= NULL
;
383 if (connected
->address
->family
== AF_INET
) {
384 ipv4
= prefix_ipv4_new();
385 ipv4
->prefixlen
= connected
->address
->prefixlen
;
386 ipv4
->prefix
= connected
->address
->u
.prefix4
;
388 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
, ip
))
389 if (prefix_same((struct prefix
*)ip
,
390 (struct prefix
*)ipv4
))
394 listnode_delete(circuit
->ip_addrs
, ip
);
395 prefix_ipv4_free(&ip
);
397 lsp_regenerate_schedule(circuit
->area
,
398 circuit
->is_type
, 0);
401 "Nonexistent ip address %pFX removal attempt from circuit %s",
402 connected
->address
, circuit
->interface
->name
);
403 zlog_warn("Current ip addresses on %s:",
404 circuit
->interface
->name
);
405 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
407 zlog_warn(" %pFX", ip
);
409 zlog_warn("End of addresses");
412 prefix_ipv4_free(&ipv4
);
414 if (connected
->address
->family
== AF_INET6
) {
415 ipv6
= prefix_ipv6_new();
416 ipv6
->prefixlen
= connected
->address
->prefixlen
;
417 ipv6
->prefix
= connected
->address
->u
.prefix6
;
419 if (IN6_IS_ADDR_LINKLOCAL(&ipv6
->prefix
)) {
420 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
422 if (prefix_same((struct prefix
*)ip6
,
423 (struct prefix
*)ipv6
))
427 listnode_delete(circuit
->ipv6_link
, ip6
);
428 prefix_ipv6_free(&ip6
);
432 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
434 if (prefix_same((struct prefix
*)ip6
,
435 (struct prefix
*)ipv6
))
439 listnode_delete(circuit
->ipv6_non_link
, ip6
);
440 prefix_ipv6_free(&ip6
);
447 "Nonexistent ip address %pFX removal attempt from circuit %s",
448 connected
->address
, circuit
->interface
->name
);
449 zlog_warn("Current ip addresses on %s:",
450 circuit
->interface
->name
);
451 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
453 zlog_warn(" %pFX", (struct prefix
*)ip6
);
455 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
457 zlog_warn(" %pFX", (struct prefix
*)ip6
);
458 zlog_warn("End of addresses");
459 } else if (circuit
->area
)
460 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
463 prefix_ipv6_free(&ipv6
);
468 static uint8_t isis_circuit_id_gen(struct isis
*isis
, struct interface
*ifp
)
470 /* Circuit ids MUST be unique for any broadcast circuits. Otherwise,
471 * Pseudo-Node LSPs cannot be generated correctly.
473 * Currently, allocate one circuit ID for any circuit, limiting the total
474 * numer of circuits IS-IS can run on to 255.
476 * We should revisit this when implementing 3-way adjacencies for p2p, since
477 * we then have extended interface IDs available.
479 uint8_t id
= ifp
->ifindex
;
482 for (i
= 0; i
< 256; i
++) {
483 if (id
&& !_ISIS_CHECK_FLAG(isis
->circuit_ids_used
, id
))
489 zlog_warn("Could not allocate a circuit id for '%s'",
494 _ISIS_SET_FLAG(isis
->circuit_ids_used
, id
);
498 void isis_circuit_if_add(struct isis_circuit
*circuit
, struct interface
*ifp
)
500 struct listnode
*node
, *nnode
;
501 struct connected
*conn
;
503 if (if_is_broadcast(ifp
)) {
504 if (fabricd
|| circuit
->circ_type_config
== CIRCUIT_T_P2P
)
505 circuit
->circ_type
= CIRCUIT_T_P2P
;
507 circuit
->circ_type
= CIRCUIT_T_BROADCAST
;
508 } else if (if_is_pointopoint(ifp
)) {
509 circuit
->circ_type
= CIRCUIT_T_P2P
;
510 } else if (if_is_loopback(ifp
)) {
511 circuit
->circ_type
= CIRCUIT_T_LOOPBACK
;
512 circuit
->is_passive
= 1;
514 /* It's normal in case of loopback etc. */
516 zlog_debug("isis_circuit_if_add: unsupported media");
517 circuit
->circ_type
= CIRCUIT_T_UNKNOWN
;
520 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, conn
))
521 isis_circuit_add_addr(circuit
, conn
);
525 void isis_circuit_if_del(struct isis_circuit
*circuit
, struct interface
*ifp
)
527 struct listnode
*node
, *nnode
;
528 struct connected
*conn
;
530 assert(circuit
->interface
== ifp
);
532 /* destroy addresses */
533 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, conn
))
534 isis_circuit_del_addr(circuit
, conn
);
536 circuit
->circ_type
= CIRCUIT_T_UNKNOWN
;
539 void isis_circuit_if_bind(struct isis_circuit
*circuit
, struct interface
*ifp
)
541 assert(circuit
!= NULL
);
543 if (circuit
->interface
)
544 assert(circuit
->interface
== ifp
);
546 circuit
->interface
= ifp
;
548 assert(ifp
->info
== circuit
);
553 void isis_circuit_if_unbind(struct isis_circuit
*circuit
, struct interface
*ifp
)
555 assert(circuit
!= NULL
);
557 assert(circuit
->interface
== ifp
);
558 assert(ifp
->info
== circuit
);
559 circuit
->interface
= NULL
;
563 static void isis_circuit_update_all_srmflags(struct isis_circuit
*circuit
,
566 struct isis_area
*area
;
567 struct isis_lsp
*lsp
;
571 area
= circuit
->area
;
573 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
574 if (!(level
& circuit
->is_type
))
577 if (!lspdb_count(&area
->lspdb
[level
- 1]))
580 frr_each (lspdb
, &area
->lspdb
[level
- 1], lsp
) {
582 isis_tx_queue_add(circuit
->tx_queue
, lsp
,
585 isis_tx_queue_del(circuit
->tx_queue
, lsp
);
591 size_t isis_circuit_pdu_size(struct isis_circuit
*circuit
)
593 return ISO_MTU(circuit
);
596 static bool isis_circuit_lfa_enabled(struct isis_circuit
*circuit
, int level
)
598 return (circuit
->lfa_protection
[level
- 1] ||
599 circuit
->rlfa_protection
[level
- 1] ||
600 circuit
->tilfa_protection
[level
- 1]);
603 void isis_circuit_switchover_routes(struct isis_circuit
*circuit
, int family
,
604 union g_addr
*nexthop_ip
, ifindex_t ifindex
)
606 char is_type
= circuit
->area
->is_type
;
607 if ((is_type
== IS_LEVEL_1
|| is_type
== IS_LEVEL_1_AND_2
) &&
608 isis_circuit_lfa_enabled(circuit
, IS_LEVEL_1
))
609 isis_area_switchover_routes(circuit
->area
, family
, nexthop_ip
,
610 ifindex
, IS_LEVEL_1
);
611 if ((is_type
== IS_LEVEL_2
|| is_type
== IS_LEVEL_1_AND_2
) &&
612 isis_circuit_lfa_enabled(circuit
, IS_LEVEL_2
))
613 isis_area_switchover_routes(circuit
->area
, family
, nexthop_ip
,
614 ifindex
, IS_LEVEL_2
);
617 void isis_circuit_stream(struct isis_circuit
*circuit
, struct stream
**stream
)
619 size_t stream_size
= isis_circuit_pdu_size(circuit
);
622 *stream
= stream_new(stream_size
);
624 if (STREAM_SIZE(*stream
) != stream_size
)
625 stream_resize_inplace(stream
, stream_size
);
626 stream_reset(*stream
);
630 void isis_circuit_prepare(struct isis_circuit
*circuit
)
632 #if ISIS_METHOD != ISIS_METHOD_DLPI
633 thread_add_read(master
, isis_receive
, circuit
, circuit
->fd
,
636 thread_add_timer_msec(master
, isis_receive
, circuit
,
637 listcount(circuit
->area
->circuit_list
) * 100,
642 int isis_circuit_up(struct isis_circuit
*circuit
)
646 /* Set the flags for all the lsps of the circuit. */
647 isis_circuit_update_all_srmflags(circuit
, 1);
649 if (circuit
->state
== C_STATE_UP
)
652 if (circuit
->is_passive
) {
653 circuit
->last_uptime
= time(NULL
);
654 /* make sure the union fields are initialized, else we
655 * could end with garbage values from a previous circuit
656 * type, which would then cause a segfault when building
657 * LSPs or computing the SPF tree
659 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
660 circuit
->u
.bc
.adjdb
[0] = list_new();
661 circuit
->u
.bc
.adjdb
[1] = list_new();
662 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
663 circuit
->u
.p2p
.neighbor
= NULL
;
668 if (circuit
->area
->lsp_mtu
> isis_circuit_pdu_size(circuit
)) {
671 "Interface MTU %zu on %s is too low to support area lsp mtu %u!",
672 isis_circuit_pdu_size(circuit
),
673 circuit
->interface
->name
, circuit
->area
->lsp_mtu
);
675 /* Allow ISIS to continue configuration. With this
676 * configuration failure ISIS will attempt to send lsp
677 * packets but will fail until the mtu is configured properly
681 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
682 circuit
->circuit_id
=
683 isis_circuit_id_gen(circuit
->isis
, circuit
->interface
);
684 if (!circuit
->circuit_id
) {
687 "There are already 255 broadcast circuits active!");
692 * Get the Hardware Address
694 if (circuit
->interface
->hw_addr_len
!= ETH_ALEN
) {
695 zlog_warn("unsupported link layer");
697 memcpy(circuit
->u
.bc
.snpa
, circuit
->interface
->hw_addr
,
703 "isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
704 circuit
->interface
->ifindex
, ISO_MTU(circuit
),
705 snpa_print(circuit
->u
.bc
.snpa
));
706 #endif /* EXTREME_DEBUG */
708 circuit
->u
.bc
.adjdb
[0] = list_new();
709 circuit
->u
.bc
.adjdb
[1] = list_new();
712 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
715 /* initilizing the hello sending threads
719 /* 8.4.1 a) commence sending of IIH PDUs */
721 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
722 if (!(circuit
->is_type
& level
))
725 send_hello_sched(circuit
, level
, TRIGGERED_IIH_DELAY
);
726 circuit
->u
.bc
.lan_neighs
[level
- 1] = list_new();
728 thread_add_timer(master
, isis_run_dr
,
729 &circuit
->level_arg
[level
- 1],
730 2 * circuit
->hello_interval
[level
- 1],
731 &circuit
->u
.bc
.t_run_dr
[level
- 1]);
734 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
735 /* 8.4.1 c) FIXME: listen for ESH PDUs */
736 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
737 /* initializing the hello send threads
740 circuit
->u
.p2p
.neighbor
= NULL
;
741 send_hello_sched(circuit
, 0, TRIGGERED_IIH_DELAY
);
744 /* initializing PSNP timers */
745 if (circuit
->is_type
& IS_LEVEL_1
)
747 master
, send_l1_psnp
, circuit
,
748 isis_jitter(circuit
->psnp_interval
[0], PSNP_JITTER
),
749 &circuit
->t_send_psnp
[0]);
751 if (circuit
->is_type
& IS_LEVEL_2
)
753 master
, send_l2_psnp
, circuit
,
754 isis_jitter(circuit
->psnp_interval
[1], PSNP_JITTER
),
755 &circuit
->t_send_psnp
[1]);
757 /* unified init for circuits; ignore warnings below this level */
758 retv
= isis_sock_init(circuit
);
759 if (retv
!= ISIS_OK
) {
760 isis_circuit_down(circuit
);
764 /* initialize the circuit streams after opening connection */
765 isis_circuit_stream(circuit
, &circuit
->rcv_stream
);
766 isis_circuit_stream(circuit
, &circuit
->snd_stream
);
768 isis_circuit_prepare(circuit
);
770 circuit
->tx_queue
= isis_tx_queue_new(circuit
, send_lsp
);
772 circuit
->last_uptime
= time(NULL
);
774 if (circuit
->area
->mta
&& circuit
->area
->mta
->status
)
775 isis_link_params_update(circuit
, circuit
->interface
);
777 isis_if_ldp_sync_enable(circuit
);
780 /* send northbound notification */
781 isis_notif_if_state_change(circuit
, false);
782 #endif /* ifndef FABRICD */
787 void isis_circuit_down(struct isis_circuit
*circuit
)
790 /* send northbound notification */
791 isis_notif_if_state_change(circuit
, true);
792 #endif /* ifndef FABRICD */
794 isis_if_ldp_sync_disable(circuit
);
796 /* log adjacency changes if configured to do so */
797 if (circuit
->area
->log_adj_changes
) {
798 struct isis_adjacency
*adj
= NULL
;
799 if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
800 adj
= circuit
->u
.p2p
.neighbor
;
803 adj
, adj
->adj_state
, ISIS_ADJ_DOWN
,
804 "circuit is being brought down");
805 } else if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
806 struct list
*adj_list
;
807 struct listnode
*node
;
808 if (circuit
->u
.bc
.adjdb
[0]) {
809 adj_list
= list_new();
810 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[0],
812 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
816 "circuit is being brought down");
817 list_delete(&adj_list
);
819 if (circuit
->u
.bc
.adjdb
[1]) {
820 adj_list
= list_new();
821 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[1],
823 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
827 "circuit is being brought down");
828 list_delete(&adj_list
);
833 /* Clear the flags for all the lsps of the circuit. */
834 isis_circuit_update_all_srmflags(circuit
, 0);
836 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
837 /* destroy neighbour lists */
838 if (circuit
->u
.bc
.lan_neighs
[0]) {
839 list_delete(&circuit
->u
.bc
.lan_neighs
[0]);
840 circuit
->u
.bc
.lan_neighs
[0] = NULL
;
842 if (circuit
->u
.bc
.lan_neighs
[1]) {
843 list_delete(&circuit
->u
.bc
.lan_neighs
[1]);
844 circuit
->u
.bc
.lan_neighs
[1] = NULL
;
846 /* destroy adjacency databases */
847 if (circuit
->u
.bc
.adjdb
[0]) {
848 circuit
->u
.bc
.adjdb
[0]->del
= isis_delete_adj
;
849 list_delete(&circuit
->u
.bc
.adjdb
[0]);
850 circuit
->u
.bc
.adjdb
[0] = NULL
;
852 if (circuit
->u
.bc
.adjdb
[1]) {
853 circuit
->u
.bc
.adjdb
[1]->del
= isis_delete_adj
;
854 list_delete(&circuit
->u
.bc
.adjdb
[1]);
855 circuit
->u
.bc
.adjdb
[1] = NULL
;
857 if (circuit
->u
.bc
.is_dr
[0]) {
858 isis_dr_resign(circuit
, 1);
859 circuit
->u
.bc
.is_dr
[0] = 0;
861 memset(circuit
->u
.bc
.l1_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
862 if (circuit
->u
.bc
.is_dr
[1]) {
863 isis_dr_resign(circuit
, 2);
864 circuit
->u
.bc
.is_dr
[1] = 0;
866 memset(circuit
->u
.bc
.l2_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
867 memset(circuit
->u
.bc
.snpa
, 0, ETH_ALEN
);
869 thread_cancel(&circuit
->u
.bc
.t_send_lan_hello
[0]);
870 thread_cancel(&circuit
->u
.bc
.t_send_lan_hello
[1]);
871 thread_cancel(&circuit
->u
.bc
.t_run_dr
[0]);
872 thread_cancel(&circuit
->u
.bc
.t_run_dr
[1]);
873 thread_cancel(&circuit
->u
.bc
.t_refresh_pseudo_lsp
[0]);
874 thread_cancel(&circuit
->u
.bc
.t_refresh_pseudo_lsp
[1]);
875 circuit
->lsp_regenerate_pending
[0] = 0;
876 circuit
->lsp_regenerate_pending
[1] = 0;
878 _ISIS_CLEAR_FLAG(circuit
->isis
->circuit_ids_used
,
879 circuit
->circuit_id
);
880 circuit
->circuit_id
= 0;
881 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
882 isis_delete_adj(circuit
->u
.p2p
.neighbor
);
883 circuit
->u
.p2p
.neighbor
= NULL
;
884 thread_cancel(&circuit
->u
.p2p
.t_send_p2p_hello
);
888 * All adjacencies have to be gone, delete snmp list
889 * and reset snmpd idx generator
891 if (circuit
->snmp_adj_list
!= NULL
)
892 list_delete(&circuit
->snmp_adj_list
);
894 circuit
->snmp_adj_idx_gen
= 0;
896 /* Cancel all active threads */
897 thread_cancel(&circuit
->t_send_csnp
[0]);
898 thread_cancel(&circuit
->t_send_csnp
[1]);
899 thread_cancel(&circuit
->t_send_psnp
[0]);
900 thread_cancel(&circuit
->t_send_psnp
[1]);
901 thread_cancel(&circuit
->t_read
);
903 if (circuit
->tx_queue
) {
904 isis_tx_queue_free(circuit
->tx_queue
);
905 circuit
->tx_queue
= NULL
;
908 /* send one gratuitous hello to spead up convergence */
909 if (circuit
->state
== C_STATE_UP
) {
910 if (circuit
->is_type
& IS_LEVEL_1
)
911 send_hello(circuit
, IS_LEVEL_1
);
912 if (circuit
->is_type
& IS_LEVEL_2
)
913 send_hello(circuit
, IS_LEVEL_2
);
916 circuit
->upadjcount
[0] = 0;
917 circuit
->upadjcount
[1] = 0;
919 /* close the socket */
925 if (circuit
->rcv_stream
!= NULL
) {
926 stream_free(circuit
->rcv_stream
);
927 circuit
->rcv_stream
= NULL
;
930 if (circuit
->snd_stream
!= NULL
) {
931 stream_free(circuit
->snd_stream
);
932 circuit
->snd_stream
= NULL
;
935 thread_cancel_event(master
, circuit
);
940 void circuit_update_nlpids(struct isis_circuit
*circuit
)
942 circuit
->nlpids
.count
= 0;
944 if (circuit
->ip_router
) {
945 circuit
->nlpids
.nlpids
[0] = NLPID_IP
;
946 circuit
->nlpids
.count
++;
948 if (circuit
->ipv6_router
) {
949 circuit
->nlpids
.nlpids
[circuit
->nlpids
.count
] = NLPID_IPV6
;
950 circuit
->nlpids
.count
++;
955 void isis_circuit_print_json(struct isis_circuit
*circuit
,
956 struct json_object
*json
, char detail
)
959 json_object
*iface_json
, *ipv4_addr_json
, *ipv6_link_json
,
960 *ipv6_non_link_json
, *hold_json
, *lan_prio_json
, *levels_json
,
962 char buf_prx
[INET6_BUFSIZ
];
965 snprintfrr(buf
, sizeof(buf
), "0x%x", circuit
->circuit_id
);
966 if (detail
== ISIS_UI_LEVEL_BRIEF
) {
967 iface_json
= json_object_new_object();
968 json_object_object_add(json
, "interface", iface_json
);
969 json_object_string_add(iface_json
, "name",
970 circuit
->interface
->name
);
971 json_object_string_add(iface_json
, "circuit-id", buf
);
972 json_object_string_add(iface_json
, "state",
973 circuit_state2string(circuit
->state
));
974 json_object_string_add(iface_json
, "type",
975 circuit_type2string(circuit
->circ_type
));
976 json_object_string_add(iface_json
, "level",
977 circuit_t2string(circuit
->is_type
));
980 if (detail
== ISIS_UI_LEVEL_DETAIL
) {
981 struct listnode
*node
;
982 struct prefix
*ip_addr
;
984 iface_json
= json_object_new_object();
985 json_object_object_add(json
, "interface", iface_json
);
986 json_object_string_add(iface_json
, "name",
987 circuit
->interface
->name
);
988 json_object_string_add(iface_json
, "state",
989 circuit_state2string(circuit
->state
));
990 if (circuit
->is_passive
)
991 json_object_string_add(iface_json
, "is-passive",
994 json_object_string_add(iface_json
, "is-passive",
996 json_object_string_add(iface_json
, "circuit-id", buf
);
997 json_object_string_add(iface_json
, "type",
998 circuit_type2string(circuit
->circ_type
));
999 json_object_string_add(iface_json
, "level",
1000 circuit_t2string(circuit
->is_type
));
1001 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1002 json_object_string_add(iface_json
, "snpa",
1003 snpa_print(circuit
->u
.bc
.snpa
));
1006 levels_json
= json_object_new_array();
1007 json_object_object_add(iface_json
, "levels", levels_json
);
1008 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
1009 if ((circuit
->is_type
& level
) == 0)
1011 level_json
= json_object_new_object();
1012 json_object_string_add(level_json
, "level",
1013 circuit_t2string(level
));
1014 if (circuit
->area
->newmetric
)
1015 json_object_int_add(level_json
, "metric",
1016 circuit
->te_metric
[0]);
1018 json_object_int_add(level_json
, "metric",
1019 circuit
->metric
[0]);
1020 if (!circuit
->is_passive
) {
1021 json_object_int_add(level_json
,
1023 circuit
->upadjcount
[0]);
1024 json_object_int_add(level_json
,
1026 circuit
->hello_interval
[0]);
1027 hold_json
= json_object_new_object();
1028 json_object_object_add(level_json
, "holddown",
1030 json_object_int_add(
1032 circuit
->hello_multiplier
[0]);
1033 json_object_string_add(
1035 (circuit
->pad_hellos
? "yes" : "no"));
1036 json_object_int_add(level_json
, "cnsp-interval",
1037 circuit
->csnp_interval
[0]);
1038 json_object_int_add(level_json
, "psnp-interval",
1039 circuit
->psnp_interval
[0]);
1040 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
1042 json_object_new_object();
1043 json_object_object_add(level_json
,
1046 json_object_int_add(
1047 lan_prio_json
, "priority",
1048 circuit
->priority
[0]);
1049 json_object_string_add(
1050 lan_prio_json
, "is-dis",
1051 (circuit
->u
.bc
.is_dr
[0]
1056 json_object_array_add(levels_json
, level_json
);
1059 if (listcount(circuit
->ip_addrs
) > 0) {
1060 ipv4_addr_json
= json_object_new_object();
1061 json_object_object_add(iface_json
, "ip-prefix",
1063 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
1065 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1067 json_object_string_add(ipv4_addr_json
, "ip",
1071 if (listcount(circuit
->ipv6_link
) > 0) {
1072 ipv6_link_json
= json_object_new_object();
1073 json_object_object_add(iface_json
, "ipv6-link-locals",
1075 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
1077 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1079 json_object_string_add(ipv6_link_json
, "ipv6",
1083 if (listcount(circuit
->ipv6_non_link
) > 0) {
1084 ipv6_non_link_json
= json_object_new_object();
1085 json_object_object_add(iface_json
, "ipv6-prefixes",
1086 ipv6_non_link_json
);
1087 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
1089 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1091 json_object_string_add(ipv6_non_link_json
,
1099 void isis_circuit_print_vty(struct isis_circuit
*circuit
, struct vty
*vty
,
1102 if (detail
== ISIS_UI_LEVEL_BRIEF
) {
1103 vty_out(vty
, " %-12s", circuit
->interface
->name
);
1104 vty_out(vty
, "0x%-7x", circuit
->circuit_id
);
1105 vty_out(vty
, "%-9s", circuit_state2string(circuit
->state
));
1106 vty_out(vty
, "%-9s", circuit_type2string(circuit
->circ_type
));
1107 vty_out(vty
, "%-9s", circuit_t2string(circuit
->is_type
));
1111 if (detail
== ISIS_UI_LEVEL_DETAIL
) {
1112 struct listnode
*node
;
1113 struct prefix
*ip_addr
;
1115 vty_out(vty
, " Interface: %s", circuit
->interface
->name
);
1116 vty_out(vty
, ", State: %s",
1117 circuit_state2string(circuit
->state
));
1118 if (circuit
->is_passive
)
1119 vty_out(vty
, ", Passive");
1121 vty_out(vty
, ", Active");
1122 vty_out(vty
, ", Circuit Id: 0x%x", circuit
->circuit_id
);
1124 vty_out(vty
, " Type: %s",
1125 circuit_type2string(circuit
->circ_type
));
1126 vty_out(vty
, ", Level: %s", circuit_t2string(circuit
->is_type
));
1127 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1128 vty_out(vty
, ", SNPA: %-10s",
1129 snpa_print(circuit
->u
.bc
.snpa
));
1131 if (circuit
->is_type
& IS_LEVEL_1
) {
1132 vty_out(vty
, " Level-1 Information:\n");
1133 if (circuit
->area
->newmetric
)
1134 vty_out(vty
, " Metric: %d",
1135 circuit
->te_metric
[0]);
1137 vty_out(vty
, " Metric: %d",
1138 circuit
->metric
[0]);
1139 if (!circuit
->is_passive
) {
1140 vty_out(vty
, ", Active neighbors: %u\n",
1141 circuit
->upadjcount
[0]);
1143 " Hello interval: %u, Holddown count: %u %s\n",
1144 circuit
->hello_interval
[0],
1145 circuit
->hello_multiplier
[0],
1146 (circuit
->pad_hellos
? "(pad)"
1149 " CNSP interval: %u, PSNP interval: %u\n",
1150 circuit
->csnp_interval
[0],
1151 circuit
->psnp_interval
[0]);
1152 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1154 " LAN Priority: %u, %s\n",
1155 circuit
->priority
[0],
1156 (circuit
->u
.bc
.is_dr
[0]
1163 if (circuit
->is_type
& IS_LEVEL_2
) {
1164 vty_out(vty
, " Level-2 Information:\n");
1165 if (circuit
->area
->newmetric
)
1166 vty_out(vty
, " Metric: %d",
1167 circuit
->te_metric
[1]);
1169 vty_out(vty
, " Metric: %d",
1170 circuit
->metric
[1]);
1171 if (!circuit
->is_passive
) {
1172 vty_out(vty
, ", Active neighbors: %u\n",
1173 circuit
->upadjcount
[1]);
1175 " Hello interval: %u, Holddown count: %u %s\n",
1176 circuit
->hello_interval
[1],
1177 circuit
->hello_multiplier
[1],
1178 (circuit
->pad_hellos
? "(pad)"
1181 " CNSP interval: %u, PSNP interval: %u\n",
1182 circuit
->csnp_interval
[1],
1183 circuit
->psnp_interval
[1]);
1184 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1186 " LAN Priority: %u, %s\n",
1187 circuit
->priority
[1],
1188 (circuit
->u
.bc
.is_dr
[1]
1195 if (listcount(circuit
->ip_addrs
) > 0) {
1196 vty_out(vty
, " IP Prefix(es):\n");
1197 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
1199 vty_out(vty
, " %pFX\n", ip_addr
);
1201 if (listcount(circuit
->ipv6_link
) > 0) {
1202 vty_out(vty
, " IPv6 Link-Locals:\n");
1203 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
1205 vty_out(vty
, " %pFX\n", ip_addr
);
1207 if (listcount(circuit
->ipv6_non_link
) > 0) {
1208 vty_out(vty
, " IPv6 Prefixes:\n");
1209 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
1211 vty_out(vty
, " %pFX\n", ip_addr
);
1220 DEFINE_HOOK(isis_circuit_config_write
,
1221 (struct isis_circuit
*circuit
, struct vty
*vty
),
1224 static int isis_interface_config_write(struct vty
*vty
)
1226 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1228 struct interface
*ifp
;
1229 struct isis_circuit
*circuit
;
1232 FOR_ALL_INTERFACES (vrf
, ifp
) {
1234 if_vty_config_start(vty
, ifp
);
1238 vty_out(vty
, " description %s\n", ifp
->desc
);
1243 circuit
= circuit_scan_by_ifp(ifp
);
1244 if (circuit
== NULL
)
1246 if (circuit
->ip_router
) {
1247 vty_out(vty
, " ip router " PROTO_NAME
" %s\n",
1251 if (circuit
->is_passive
) {
1252 vty_out(vty
, " " PROTO_NAME
" passive\n");
1255 if (circuit
->circ_type_config
== CIRCUIT_T_P2P
) {
1256 vty_out(vty
, " " PROTO_NAME
" network point-to-point\n");
1259 if (circuit
->ipv6_router
) {
1260 vty_out(vty
, " ipv6 router " PROTO_NAME
" %s\n",
1265 /* ISIS - circuit type */
1267 if (circuit
->is_type
== IS_LEVEL_1
) {
1268 vty_out(vty
, " " PROTO_NAME
" circuit-type level-1\n");
1271 if (circuit
->is_type
== IS_LEVEL_2
) {
1273 " " PROTO_NAME
" circuit-type level-2-only\n");
1279 /* ISIS - CSNP interval */
1280 if (circuit
->csnp_interval
[0]
1281 == circuit
->csnp_interval
[1]) {
1282 if (circuit
->csnp_interval
[0]
1283 != DEFAULT_CSNP_INTERVAL
) {
1284 vty_out(vty
, " " PROTO_NAME
" csnp-interval %d\n",
1285 circuit
->csnp_interval
[0]);
1289 for (i
= 0; i
< 2; i
++) {
1290 if (circuit
->csnp_interval
[i
]
1291 != DEFAULT_CSNP_INTERVAL
) {
1293 " " PROTO_NAME
" csnp-interval %d level-%d\n",
1294 circuit
->csnp_interval
1302 /* ISIS - PSNP interval */
1303 if (circuit
->psnp_interval
[0]
1304 == circuit
->psnp_interval
[1]) {
1305 if (circuit
->psnp_interval
[0]
1306 != DEFAULT_PSNP_INTERVAL
) {
1307 vty_out(vty
, " " PROTO_NAME
" psnp-interval %d\n",
1308 circuit
->psnp_interval
[0]);
1312 for (i
= 0; i
< 2; i
++) {
1313 if (circuit
->psnp_interval
[i
]
1314 != DEFAULT_PSNP_INTERVAL
) {
1316 " " PROTO_NAME
" psnp-interval %d level-%d\n",
1317 circuit
->psnp_interval
1325 /* ISIS - Hello padding - Defaults to true so only
1326 * display if false */
1327 if (circuit
->pad_hellos
== 0) {
1328 vty_out(vty
, " no " PROTO_NAME
" hello padding\n");
1332 if (circuit
->disable_threeway_adj
) {
1333 vty_out(vty
, " no isis three-way-handshake\n");
1337 /* ISIS - Hello interval */
1338 if (circuit
->hello_interval
[0]
1339 == circuit
->hello_interval
[1]) {
1340 if (circuit
->hello_interval
[0]
1341 != DEFAULT_HELLO_INTERVAL
) {
1343 " " PROTO_NAME
" hello-interval %d\n",
1344 circuit
->hello_interval
[0]);
1348 for (i
= 0; i
< 2; i
++) {
1349 if (circuit
->hello_interval
[i
]
1350 != DEFAULT_HELLO_INTERVAL
) {
1352 " " PROTO_NAME
" hello-interval %d level-%d\n",
1353 circuit
->hello_interval
1361 /* ISIS - Hello Multiplier */
1362 if (circuit
->hello_multiplier
[0]
1363 == circuit
->hello_multiplier
[1]) {
1364 if (circuit
->hello_multiplier
[0]
1365 != DEFAULT_HELLO_MULTIPLIER
) {
1367 " " PROTO_NAME
" hello-multiplier %d\n",
1368 circuit
->hello_multiplier
[0]);
1372 for (i
= 0; i
< 2; i
++) {
1373 if (circuit
->hello_multiplier
[i
]
1374 != DEFAULT_HELLO_MULTIPLIER
) {
1376 " " PROTO_NAME
" hello-multiplier %d level-%d\n",
1377 circuit
->hello_multiplier
1385 /* ISIS - Priority */
1386 if (circuit
->priority
[0] == circuit
->priority
[1]) {
1387 if (circuit
->priority
[0] != DEFAULT_PRIORITY
) {
1388 vty_out(vty
, " " PROTO_NAME
" priority %d\n",
1389 circuit
->priority
[0]);
1393 for (i
= 0; i
< 2; i
++) {
1394 if (circuit
->priority
[i
]
1395 != DEFAULT_PRIORITY
) {
1397 " " PROTO_NAME
" priority %d level-%d\n",
1398 circuit
->priority
[i
],
1406 if (circuit
->te_metric
[0] == circuit
->te_metric
[1]) {
1407 if (circuit
->te_metric
[0]
1408 != DEFAULT_CIRCUIT_METRIC
) {
1409 vty_out(vty
, " " PROTO_NAME
" metric %d\n",
1410 circuit
->te_metric
[0]);
1414 for (i
= 0; i
< 2; i
++) {
1415 if (circuit
->te_metric
[i
]
1416 != DEFAULT_CIRCUIT_METRIC
) {
1418 " " PROTO_NAME
" metric %d level-%d\n",
1419 circuit
->te_metric
[i
],
1425 if (circuit
->passwd
.type
== ISIS_PASSWD_TYPE_HMAC_MD5
) {
1426 vty_out(vty
, " " PROTO_NAME
" password md5 %s\n",
1427 circuit
->passwd
.passwd
);
1429 } else if (circuit
->passwd
.type
1430 == ISIS_PASSWD_TYPE_CLEARTXT
) {
1431 vty_out(vty
, " " PROTO_NAME
" password clear %s\n",
1432 circuit
->passwd
.passwd
);
1435 if (circuit
->bfd_config
.enabled
) {
1436 vty_out(vty
, " " PROTO_NAME
" bfd\n");
1439 write
+= hook_call(isis_circuit_config_write
,
1442 if_vty_config_end(vty
);
1447 #endif /* ifdef FABRICD */
1449 void isis_circuit_af_set(struct isis_circuit
*circuit
, bool ip_router
,
1452 struct isis_area
*area
= circuit
->area
;
1453 int old_ipr
= circuit
->ip_router
;
1454 int old_ipv6r
= circuit
->ipv6_router
;
1456 /* is there something to do? */
1457 if (old_ipr
== ip_router
&& old_ipv6r
== ipv6_router
)
1460 circuit
->ip_router
= ip_router
;
1461 circuit
->ipv6_router
= ipv6_router
;
1462 circuit_update_nlpids(circuit
);
1465 area
->ip_circuits
+= ip_router
- old_ipr
;
1466 area
->ipv6_circuits
+= ipv6_router
- old_ipv6r
;
1468 if (ip_router
|| ipv6_router
)
1469 lsp_regenerate_schedule(area
, circuit
->is_type
, 0);
1473 ferr_r
isis_circuit_passive_set(struct isis_circuit
*circuit
, bool passive
)
1475 if (circuit
->is_passive
== passive
)
1478 if (if_is_loopback(circuit
->interface
) && !passive
)
1479 return ferr_cfg_invalid("loopback is always passive");
1481 if (circuit
->state
!= C_STATE_UP
) {
1482 circuit
->is_passive
= passive
;
1484 struct isis_area
*area
= circuit
->area
;
1485 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1486 circuit
->is_passive
= passive
;
1487 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1493 ferr_r
isis_circuit_metric_set(struct isis_circuit
*circuit
, int level
,
1496 assert(level
== IS_LEVEL_1
|| level
== IS_LEVEL_2
);
1497 if (metric
> MAX_WIDE_LINK_METRIC
)
1498 return ferr_cfg_invalid("metric %d too large for wide metric",
1500 if (circuit
->area
&& circuit
->area
->oldmetric
1501 && metric
> MAX_NARROW_LINK_METRIC
)
1502 return ferr_cfg_invalid("metric %d too large for narrow metric",
1505 /* inform ldp-sync of metric change
1506 * if ldp-sync is running need to save metric
1507 * and restore new values after ldp-sync completion.
1509 if (isis_ldp_sync_if_metric_config(circuit
, level
, metric
)) {
1510 circuit
->te_metric
[level
- 1] = metric
;
1511 circuit
->metric
[level
- 1] = metric
;
1513 lsp_regenerate_schedule(circuit
->area
, level
, 0);
1518 ferr_r
isis_circuit_passwd_unset(struct isis_circuit
*circuit
)
1520 memset(&circuit
->passwd
, 0, sizeof(circuit
->passwd
));
1524 ferr_r
isis_circuit_passwd_set(struct isis_circuit
*circuit
,
1525 uint8_t passwd_type
, const char *passwd
)
1530 return ferr_code_bug("no circuit password given");
1532 len
= strlen(passwd
);
1534 return ferr_code_bug(
1535 "circuit password too long (max 254 chars)");
1537 circuit
->passwd
.len
= len
;
1538 strlcpy((char *)circuit
->passwd
.passwd
, passwd
,
1539 sizeof(circuit
->passwd
.passwd
));
1540 circuit
->passwd
.type
= passwd_type
;
1544 ferr_r
isis_circuit_passwd_cleartext_set(struct isis_circuit
*circuit
,
1547 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_CLEARTXT
,
1551 ferr_r
isis_circuit_passwd_hmac_md5_set(struct isis_circuit
*circuit
,
1554 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1558 void isis_circuit_circ_type_set(struct isis_circuit
*circuit
, int circ_type
)
1560 if (circuit
->circ_type
== circ_type
)
1563 if (circuit
->state
!= C_STATE_UP
) {
1564 circuit
->circ_type
= circ_type
;
1565 circuit
->circ_type_config
= circ_type
;
1567 struct isis_area
*area
= circuit
->area
;
1569 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1570 circuit
->circ_type
= circ_type
;
1571 circuit
->circ_type_config
= circ_type
;
1572 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1576 int isis_circuit_mt_enabled_set(struct isis_circuit
*circuit
, uint16_t mtid
,
1579 struct isis_circuit_mt_setting
*setting
;
1581 setting
= circuit_get_mt_setting(circuit
, mtid
);
1582 if (setting
->enabled
!= enabled
) {
1583 setting
->enabled
= enabled
;
1585 lsp_regenerate_schedule(circuit
->area
,
1586 IS_LEVEL_1
| IS_LEVEL_2
, 0);
1592 int isis_if_new_hook(struct interface
*ifp
)
1597 int isis_if_delete_hook(struct interface
*ifp
)
1600 isis_circuit_del(ifp
->info
);
1605 static int isis_ifp_create(struct interface
*ifp
)
1607 struct isis_circuit
*circuit
= ifp
->info
;
1610 isis_circuit_enable(circuit
);
1612 hook_call(isis_if_new_hook
, ifp
);
1617 static int isis_ifp_up(struct interface
*ifp
)
1619 struct isis_circuit
*circuit
= ifp
->info
;
1622 isis_csm_state_change(IF_UP_FROM_Z
, circuit
, ifp
);
1627 static int isis_ifp_down(struct interface
*ifp
)
1630 struct isis_circuit
*circuit
= ifp
->info
;
1633 for (afi
= AFI_IP
; afi
<= AFI_IP6
; afi
++)
1634 isis_circuit_switchover_routes(
1635 circuit
, afi
== AFI_IP
? AF_INET
: AF_INET6
,
1636 NULL
, ifp
->ifindex
);
1637 isis_csm_state_change(IF_DOWN_FROM_Z
, circuit
, ifp
);
1639 SET_FLAG(circuit
->flags
, ISIS_CIRCUIT_FLAPPED_AFTER_SPF
);
1645 static int isis_ifp_destroy(struct interface
*ifp
)
1647 struct isis_circuit
*circuit
= ifp
->info
;
1650 isis_circuit_disable(circuit
);
1655 void isis_circuit_init(void)
1657 /* Initialize Zebra interface data structure */
1658 hook_register_prio(if_add
, 0, isis_if_new_hook
);
1659 hook_register_prio(if_del
, 0, isis_if_delete_hook
);
1661 /* Install interface node */
1663 if_cmd_init(isis_interface_config_write
);
1665 if_cmd_init_default();
1667 if_zapi_callbacks(isis_ifp_create
, isis_ifp_up
,
1668 isis_ifp_down
, isis_ifp_destroy
);