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 void isis_circuit_stream(struct isis_circuit
*circuit
, struct stream
**stream
)
598 size_t stream_size
= isis_circuit_pdu_size(circuit
);
601 *stream
= stream_new(stream_size
);
603 if (STREAM_SIZE(*stream
) != stream_size
)
604 stream_resize_inplace(stream
, stream_size
);
605 stream_reset(*stream
);
609 void isis_circuit_prepare(struct isis_circuit
*circuit
)
611 #if ISIS_METHOD != ISIS_METHOD_DLPI
612 thread_add_read(master
, isis_receive
, circuit
, circuit
->fd
,
615 thread_add_timer_msec(master
, isis_receive
, circuit
,
616 listcount(circuit
->area
->circuit_list
) * 100,
621 int isis_circuit_up(struct isis_circuit
*circuit
)
625 /* Set the flags for all the lsps of the circuit. */
626 isis_circuit_update_all_srmflags(circuit
, 1);
628 if (circuit
->state
== C_STATE_UP
)
631 if (circuit
->is_passive
) {
632 circuit
->last_uptime
= time(NULL
);
633 /* make sure the union fields are initialized, else we
634 * could end with garbage values from a previous circuit
635 * type, which would then cause a segfault when building
636 * LSPs or computing the SPF tree
638 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
639 circuit
->u
.bc
.adjdb
[0] = list_new();
640 circuit
->u
.bc
.adjdb
[1] = list_new();
641 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
642 circuit
->u
.p2p
.neighbor
= NULL
;
647 if (circuit
->area
->lsp_mtu
> isis_circuit_pdu_size(circuit
)) {
650 "Interface MTU %zu on %s is too low to support area lsp mtu %u!",
651 isis_circuit_pdu_size(circuit
),
652 circuit
->interface
->name
, circuit
->area
->lsp_mtu
);
654 /* Allow ISIS to continue configuration. With this
655 * configuration failure ISIS will attempt to send lsp
656 * packets but will fail until the mtu is configured properly
660 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
661 circuit
->circuit_id
=
662 isis_circuit_id_gen(circuit
->isis
, circuit
->interface
);
663 if (!circuit
->circuit_id
) {
666 "There are already 255 broadcast circuits active!");
671 * Get the Hardware Address
673 if (circuit
->interface
->hw_addr_len
!= ETH_ALEN
) {
674 zlog_warn("unsupported link layer");
676 memcpy(circuit
->u
.bc
.snpa
, circuit
->interface
->hw_addr
,
682 "isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
683 circuit
->interface
->ifindex
, ISO_MTU(circuit
),
684 snpa_print(circuit
->u
.bc
.snpa
));
685 #endif /* EXTREME_DEBUG */
687 circuit
->u
.bc
.adjdb
[0] = list_new();
688 circuit
->u
.bc
.adjdb
[1] = list_new();
691 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
694 /* initilizing the hello sending threads
698 /* 8.4.1 a) commence sending of IIH PDUs */
700 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
701 if (!(circuit
->is_type
& level
))
704 send_hello_sched(circuit
, level
, TRIGGERED_IIH_DELAY
);
705 circuit
->u
.bc
.lan_neighs
[level
- 1] = list_new();
707 thread_add_timer(master
, isis_run_dr
,
708 &circuit
->level_arg
[level
- 1],
709 2 * circuit
->hello_interval
[level
- 1],
710 &circuit
->u
.bc
.t_run_dr
[level
- 1]);
713 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
714 /* 8.4.1 c) FIXME: listen for ESH PDUs */
715 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
716 /* initializing the hello send threads
719 circuit
->u
.p2p
.neighbor
= NULL
;
720 send_hello_sched(circuit
, 0, TRIGGERED_IIH_DELAY
);
723 /* initializing PSNP timers */
724 if (circuit
->is_type
& IS_LEVEL_1
)
726 master
, send_l1_psnp
, circuit
,
727 isis_jitter(circuit
->psnp_interval
[0], PSNP_JITTER
),
728 &circuit
->t_send_psnp
[0]);
730 if (circuit
->is_type
& IS_LEVEL_2
)
732 master
, send_l2_psnp
, circuit
,
733 isis_jitter(circuit
->psnp_interval
[1], PSNP_JITTER
),
734 &circuit
->t_send_psnp
[1]);
736 /* unified init for circuits; ignore warnings below this level */
737 retv
= isis_sock_init(circuit
);
738 if (retv
!= ISIS_OK
) {
739 isis_circuit_down(circuit
);
743 /* initialize the circuit streams after opening connection */
744 isis_circuit_stream(circuit
, &circuit
->rcv_stream
);
745 isis_circuit_stream(circuit
, &circuit
->snd_stream
);
747 isis_circuit_prepare(circuit
);
749 circuit
->tx_queue
= isis_tx_queue_new(circuit
, send_lsp
);
751 circuit
->last_uptime
= time(NULL
);
753 if (circuit
->area
->mta
&& circuit
->area
->mta
->status
)
754 isis_link_params_update(circuit
, circuit
->interface
);
756 isis_if_ldp_sync_enable(circuit
);
759 /* send northbound notification */
760 isis_notif_if_state_change(circuit
, false);
761 #endif /* ifndef FABRICD */
766 void isis_circuit_down(struct isis_circuit
*circuit
)
769 /* send northbound notification */
770 isis_notif_if_state_change(circuit
, true);
771 #endif /* ifndef FABRICD */
773 isis_if_ldp_sync_disable(circuit
);
775 /* log adjacency changes if configured to do so */
776 if (circuit
->area
->log_adj_changes
) {
777 struct isis_adjacency
*adj
= NULL
;
778 if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
779 adj
= circuit
->u
.p2p
.neighbor
;
782 adj
, adj
->adj_state
, ISIS_ADJ_DOWN
,
783 "circuit is being brought down");
784 } else if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
785 struct list
*adj_list
;
786 struct listnode
*node
;
787 if (circuit
->u
.bc
.adjdb
[0]) {
788 adj_list
= list_new();
789 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[0],
791 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
795 "circuit is being brought down");
796 list_delete(&adj_list
);
798 if (circuit
->u
.bc
.adjdb
[1]) {
799 adj_list
= list_new();
800 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[1],
802 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
806 "circuit is being brought down");
807 list_delete(&adj_list
);
812 /* Clear the flags for all the lsps of the circuit. */
813 isis_circuit_update_all_srmflags(circuit
, 0);
815 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
816 /* destroy neighbour lists */
817 if (circuit
->u
.bc
.lan_neighs
[0]) {
818 list_delete(&circuit
->u
.bc
.lan_neighs
[0]);
819 circuit
->u
.bc
.lan_neighs
[0] = NULL
;
821 if (circuit
->u
.bc
.lan_neighs
[1]) {
822 list_delete(&circuit
->u
.bc
.lan_neighs
[1]);
823 circuit
->u
.bc
.lan_neighs
[1] = NULL
;
825 /* destroy adjacency databases */
826 if (circuit
->u
.bc
.adjdb
[0]) {
827 circuit
->u
.bc
.adjdb
[0]->del
= isis_delete_adj
;
828 list_delete(&circuit
->u
.bc
.adjdb
[0]);
829 circuit
->u
.bc
.adjdb
[0] = NULL
;
831 if (circuit
->u
.bc
.adjdb
[1]) {
832 circuit
->u
.bc
.adjdb
[1]->del
= isis_delete_adj
;
833 list_delete(&circuit
->u
.bc
.adjdb
[1]);
834 circuit
->u
.bc
.adjdb
[1] = NULL
;
836 if (circuit
->u
.bc
.is_dr
[0]) {
837 isis_dr_resign(circuit
, 1);
838 circuit
->u
.bc
.is_dr
[0] = 0;
840 memset(circuit
->u
.bc
.l1_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
841 if (circuit
->u
.bc
.is_dr
[1]) {
842 isis_dr_resign(circuit
, 2);
843 circuit
->u
.bc
.is_dr
[1] = 0;
845 memset(circuit
->u
.bc
.l2_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
846 memset(circuit
->u
.bc
.snpa
, 0, ETH_ALEN
);
848 thread_cancel(&circuit
->u
.bc
.t_send_lan_hello
[0]);
849 thread_cancel(&circuit
->u
.bc
.t_send_lan_hello
[1]);
850 thread_cancel(&circuit
->u
.bc
.t_run_dr
[0]);
851 thread_cancel(&circuit
->u
.bc
.t_run_dr
[1]);
852 thread_cancel(&circuit
->u
.bc
.t_refresh_pseudo_lsp
[0]);
853 thread_cancel(&circuit
->u
.bc
.t_refresh_pseudo_lsp
[1]);
854 circuit
->lsp_regenerate_pending
[0] = 0;
855 circuit
->lsp_regenerate_pending
[1] = 0;
857 _ISIS_CLEAR_FLAG(circuit
->isis
->circuit_ids_used
,
858 circuit
->circuit_id
);
859 circuit
->circuit_id
= 0;
860 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
861 isis_delete_adj(circuit
->u
.p2p
.neighbor
);
862 circuit
->u
.p2p
.neighbor
= NULL
;
863 thread_cancel(&circuit
->u
.p2p
.t_send_p2p_hello
);
867 * All adjacencies have to be gone, delete snmp list
868 * and reset snmpd idx generator
870 if (circuit
->snmp_adj_list
!= NULL
)
871 list_delete(&circuit
->snmp_adj_list
);
873 circuit
->snmp_adj_idx_gen
= 0;
875 /* Cancel all active threads */
876 thread_cancel(&circuit
->t_send_csnp
[0]);
877 thread_cancel(&circuit
->t_send_csnp
[1]);
878 thread_cancel(&circuit
->t_send_psnp
[0]);
879 thread_cancel(&circuit
->t_send_psnp
[1]);
880 thread_cancel(&circuit
->t_read
);
882 if (circuit
->tx_queue
) {
883 isis_tx_queue_free(circuit
->tx_queue
);
884 circuit
->tx_queue
= NULL
;
887 /* send one gratuitous hello to spead up convergence */
888 if (circuit
->state
== C_STATE_UP
) {
889 if (circuit
->is_type
& IS_LEVEL_1
)
890 send_hello(circuit
, IS_LEVEL_1
);
891 if (circuit
->is_type
& IS_LEVEL_2
)
892 send_hello(circuit
, IS_LEVEL_2
);
895 circuit
->upadjcount
[0] = 0;
896 circuit
->upadjcount
[1] = 0;
898 /* close the socket */
904 if (circuit
->rcv_stream
!= NULL
) {
905 stream_free(circuit
->rcv_stream
);
906 circuit
->rcv_stream
= NULL
;
909 if (circuit
->snd_stream
!= NULL
) {
910 stream_free(circuit
->snd_stream
);
911 circuit
->snd_stream
= NULL
;
914 thread_cancel_event(master
, circuit
);
919 void circuit_update_nlpids(struct isis_circuit
*circuit
)
921 circuit
->nlpids
.count
= 0;
923 if (circuit
->ip_router
) {
924 circuit
->nlpids
.nlpids
[0] = NLPID_IP
;
925 circuit
->nlpids
.count
++;
927 if (circuit
->ipv6_router
) {
928 circuit
->nlpids
.nlpids
[circuit
->nlpids
.count
] = NLPID_IPV6
;
929 circuit
->nlpids
.count
++;
934 void isis_circuit_print_json(struct isis_circuit
*circuit
,
935 struct json_object
*json
, char detail
)
938 json_object
*iface_json
, *ipv4_addr_json
, *ipv6_link_json
,
939 *ipv6_non_link_json
, *hold_json
, *lan_prio_json
, *levels_json
,
941 char buf_prx
[INET6_BUFSIZ
];
944 snprintfrr(buf
, sizeof(buf
), "0x%x", circuit
->circuit_id
);
945 if (detail
== ISIS_UI_LEVEL_BRIEF
) {
946 iface_json
= json_object_new_object();
947 json_object_object_add(json
, "interface", iface_json
);
948 json_object_string_add(iface_json
, "name",
949 circuit
->interface
->name
);
950 json_object_string_add(iface_json
, "circuit-id", buf
);
951 json_object_string_add(iface_json
, "state",
952 circuit_state2string(circuit
->state
));
953 json_object_string_add(iface_json
, "type",
954 circuit_type2string(circuit
->circ_type
));
955 json_object_string_add(iface_json
, "level",
956 circuit_t2string(circuit
->is_type
));
959 if (detail
== ISIS_UI_LEVEL_DETAIL
) {
960 struct listnode
*node
;
961 struct prefix
*ip_addr
;
963 iface_json
= json_object_new_object();
964 json_object_object_add(json
, "interface", iface_json
);
965 json_object_string_add(iface_json
, "name",
966 circuit
->interface
->name
);
967 json_object_string_add(iface_json
, "state",
968 circuit_state2string(circuit
->state
));
969 if (circuit
->is_passive
)
970 json_object_string_add(iface_json
, "is-passive",
973 json_object_string_add(iface_json
, "is-passive",
975 json_object_string_add(iface_json
, "circuit-id", buf
);
976 json_object_string_add(iface_json
, "type",
977 circuit_type2string(circuit
->circ_type
));
978 json_object_string_add(iface_json
, "level",
979 circuit_t2string(circuit
->is_type
));
980 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
981 json_object_string_add(iface_json
, "snpa",
982 snpa_print(circuit
->u
.bc
.snpa
));
985 levels_json
= json_object_new_array();
986 json_object_object_add(iface_json
, "levels", levels_json
);
987 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
988 if ((circuit
->is_type
& level
) == 0)
990 level_json
= json_object_new_object();
991 json_object_string_add(level_json
, "level",
992 circuit_t2string(level
));
993 if (circuit
->area
->newmetric
)
994 json_object_int_add(level_json
, "metric",
995 circuit
->te_metric
[0]);
997 json_object_int_add(level_json
, "metric",
999 if (!circuit
->is_passive
) {
1000 json_object_int_add(level_json
,
1002 circuit
->upadjcount
[0]);
1003 json_object_int_add(level_json
,
1005 circuit
->hello_interval
[0]);
1006 hold_json
= json_object_new_object();
1007 json_object_object_add(level_json
, "holddown",
1009 json_object_int_add(
1011 circuit
->hello_multiplier
[0]);
1012 json_object_string_add(
1014 (circuit
->pad_hellos
? "yes" : "no"));
1015 json_object_int_add(level_json
, "cnsp-interval",
1016 circuit
->csnp_interval
[0]);
1017 json_object_int_add(level_json
, "psnp-interval",
1018 circuit
->psnp_interval
[0]);
1019 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
1021 json_object_new_object();
1022 json_object_object_add(level_json
,
1025 json_object_int_add(
1026 lan_prio_json
, "priority",
1027 circuit
->priority
[0]);
1028 json_object_string_add(
1029 lan_prio_json
, "is-dis",
1030 (circuit
->u
.bc
.is_dr
[0]
1035 json_object_array_add(levels_json
, level_json
);
1038 if (listcount(circuit
->ip_addrs
) > 0) {
1039 ipv4_addr_json
= json_object_new_object();
1040 json_object_object_add(iface_json
, "ip-prefix",
1042 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
1044 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1046 json_object_string_add(ipv4_addr_json
, "ip",
1050 if (listcount(circuit
->ipv6_link
) > 0) {
1051 ipv6_link_json
= json_object_new_object();
1052 json_object_object_add(iface_json
, "ipv6-link-locals",
1054 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
1056 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1058 json_object_string_add(ipv6_link_json
, "ipv6",
1062 if (listcount(circuit
->ipv6_non_link
) > 0) {
1063 ipv6_non_link_json
= json_object_new_object();
1064 json_object_object_add(iface_json
, "ipv6-prefixes",
1065 ipv6_non_link_json
);
1066 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
1068 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1070 json_object_string_add(ipv6_non_link_json
,
1078 void isis_circuit_print_vty(struct isis_circuit
*circuit
, struct vty
*vty
,
1081 if (detail
== ISIS_UI_LEVEL_BRIEF
) {
1082 vty_out(vty
, " %-12s", circuit
->interface
->name
);
1083 vty_out(vty
, "0x%-7x", circuit
->circuit_id
);
1084 vty_out(vty
, "%-9s", circuit_state2string(circuit
->state
));
1085 vty_out(vty
, "%-9s", circuit_type2string(circuit
->circ_type
));
1086 vty_out(vty
, "%-9s", circuit_t2string(circuit
->is_type
));
1090 if (detail
== ISIS_UI_LEVEL_DETAIL
) {
1091 struct listnode
*node
;
1092 struct prefix
*ip_addr
;
1094 vty_out(vty
, " Interface: %s", circuit
->interface
->name
);
1095 vty_out(vty
, ", State: %s",
1096 circuit_state2string(circuit
->state
));
1097 if (circuit
->is_passive
)
1098 vty_out(vty
, ", Passive");
1100 vty_out(vty
, ", Active");
1101 vty_out(vty
, ", Circuit Id: 0x%x", circuit
->circuit_id
);
1103 vty_out(vty
, " Type: %s",
1104 circuit_type2string(circuit
->circ_type
));
1105 vty_out(vty
, ", Level: %s", circuit_t2string(circuit
->is_type
));
1106 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1107 vty_out(vty
, ", SNPA: %-10s",
1108 snpa_print(circuit
->u
.bc
.snpa
));
1110 if (circuit
->is_type
& IS_LEVEL_1
) {
1111 vty_out(vty
, " Level-1 Information:\n");
1112 if (circuit
->area
->newmetric
)
1113 vty_out(vty
, " Metric: %d",
1114 circuit
->te_metric
[0]);
1116 vty_out(vty
, " Metric: %d",
1117 circuit
->metric
[0]);
1118 if (!circuit
->is_passive
) {
1119 vty_out(vty
, ", Active neighbors: %u\n",
1120 circuit
->upadjcount
[0]);
1122 " Hello interval: %u, Holddown count: %u %s\n",
1123 circuit
->hello_interval
[0],
1124 circuit
->hello_multiplier
[0],
1125 (circuit
->pad_hellos
? "(pad)"
1128 " CNSP interval: %u, PSNP interval: %u\n",
1129 circuit
->csnp_interval
[0],
1130 circuit
->psnp_interval
[0]);
1131 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1133 " LAN Priority: %u, %s\n",
1134 circuit
->priority
[0],
1135 (circuit
->u
.bc
.is_dr
[0]
1142 if (circuit
->is_type
& IS_LEVEL_2
) {
1143 vty_out(vty
, " Level-2 Information:\n");
1144 if (circuit
->area
->newmetric
)
1145 vty_out(vty
, " Metric: %d",
1146 circuit
->te_metric
[1]);
1148 vty_out(vty
, " Metric: %d",
1149 circuit
->metric
[1]);
1150 if (!circuit
->is_passive
) {
1151 vty_out(vty
, ", Active neighbors: %u\n",
1152 circuit
->upadjcount
[1]);
1154 " Hello interval: %u, Holddown count: %u %s\n",
1155 circuit
->hello_interval
[1],
1156 circuit
->hello_multiplier
[1],
1157 (circuit
->pad_hellos
? "(pad)"
1160 " CNSP interval: %u, PSNP interval: %u\n",
1161 circuit
->csnp_interval
[1],
1162 circuit
->psnp_interval
[1]);
1163 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1165 " LAN Priority: %u, %s\n",
1166 circuit
->priority
[1],
1167 (circuit
->u
.bc
.is_dr
[1]
1174 if (listcount(circuit
->ip_addrs
) > 0) {
1175 vty_out(vty
, " IP Prefix(es):\n");
1176 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
1178 vty_out(vty
, " %pFX\n", ip_addr
);
1180 if (listcount(circuit
->ipv6_link
) > 0) {
1181 vty_out(vty
, " IPv6 Link-Locals:\n");
1182 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
1184 vty_out(vty
, " %pFX\n", ip_addr
);
1186 if (listcount(circuit
->ipv6_non_link
) > 0) {
1187 vty_out(vty
, " IPv6 Prefixes:\n");
1188 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
1190 vty_out(vty
, " %pFX\n", ip_addr
);
1199 DEFINE_HOOK(isis_circuit_config_write
,
1200 (struct isis_circuit
*circuit
, struct vty
*vty
),
1203 static int isis_interface_config_write(struct vty
*vty
)
1205 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1207 struct interface
*ifp
;
1208 struct isis_circuit
*circuit
;
1211 FOR_ALL_INTERFACES (vrf
, ifp
) {
1213 if_vty_config_start(vty
, ifp
);
1217 vty_out(vty
, " description %s\n", ifp
->desc
);
1222 circuit
= circuit_scan_by_ifp(ifp
);
1223 if (circuit
== NULL
)
1225 if (circuit
->ip_router
) {
1226 vty_out(vty
, " ip router " PROTO_NAME
" %s\n",
1230 if (circuit
->is_passive
) {
1231 vty_out(vty
, " " PROTO_NAME
" passive\n");
1234 if (circuit
->circ_type_config
== CIRCUIT_T_P2P
) {
1235 vty_out(vty
, " " PROTO_NAME
" network point-to-point\n");
1238 if (circuit
->ipv6_router
) {
1239 vty_out(vty
, " ipv6 router " PROTO_NAME
" %s\n",
1244 /* ISIS - circuit type */
1246 if (circuit
->is_type
== IS_LEVEL_1
) {
1247 vty_out(vty
, " " PROTO_NAME
" circuit-type level-1\n");
1250 if (circuit
->is_type
== IS_LEVEL_2
) {
1252 " " PROTO_NAME
" circuit-type level-2-only\n");
1258 /* ISIS - CSNP interval */
1259 if (circuit
->csnp_interval
[0]
1260 == circuit
->csnp_interval
[1]) {
1261 if (circuit
->csnp_interval
[0]
1262 != DEFAULT_CSNP_INTERVAL
) {
1263 vty_out(vty
, " " PROTO_NAME
" csnp-interval %d\n",
1264 circuit
->csnp_interval
[0]);
1268 for (i
= 0; i
< 2; i
++) {
1269 if (circuit
->csnp_interval
[i
]
1270 != DEFAULT_CSNP_INTERVAL
) {
1272 " " PROTO_NAME
" csnp-interval %d level-%d\n",
1273 circuit
->csnp_interval
1281 /* ISIS - PSNP interval */
1282 if (circuit
->psnp_interval
[0]
1283 == circuit
->psnp_interval
[1]) {
1284 if (circuit
->psnp_interval
[0]
1285 != DEFAULT_PSNP_INTERVAL
) {
1286 vty_out(vty
, " " PROTO_NAME
" psnp-interval %d\n",
1287 circuit
->psnp_interval
[0]);
1291 for (i
= 0; i
< 2; i
++) {
1292 if (circuit
->psnp_interval
[i
]
1293 != DEFAULT_PSNP_INTERVAL
) {
1295 " " PROTO_NAME
" psnp-interval %d level-%d\n",
1296 circuit
->psnp_interval
1304 /* ISIS - Hello padding - Defaults to true so only
1305 * display if false */
1306 if (circuit
->pad_hellos
== 0) {
1307 vty_out(vty
, " no " PROTO_NAME
" hello padding\n");
1311 if (circuit
->disable_threeway_adj
) {
1312 vty_out(vty
, " no isis three-way-handshake\n");
1316 /* ISIS - Hello interval */
1317 if (circuit
->hello_interval
[0]
1318 == circuit
->hello_interval
[1]) {
1319 if (circuit
->hello_interval
[0]
1320 != DEFAULT_HELLO_INTERVAL
) {
1322 " " PROTO_NAME
" hello-interval %d\n",
1323 circuit
->hello_interval
[0]);
1327 for (i
= 0; i
< 2; i
++) {
1328 if (circuit
->hello_interval
[i
]
1329 != DEFAULT_HELLO_INTERVAL
) {
1331 " " PROTO_NAME
" hello-interval %d level-%d\n",
1332 circuit
->hello_interval
1340 /* ISIS - Hello Multiplier */
1341 if (circuit
->hello_multiplier
[0]
1342 == circuit
->hello_multiplier
[1]) {
1343 if (circuit
->hello_multiplier
[0]
1344 != DEFAULT_HELLO_MULTIPLIER
) {
1346 " " PROTO_NAME
" hello-multiplier %d\n",
1347 circuit
->hello_multiplier
[0]);
1351 for (i
= 0; i
< 2; i
++) {
1352 if (circuit
->hello_multiplier
[i
]
1353 != DEFAULT_HELLO_MULTIPLIER
) {
1355 " " PROTO_NAME
" hello-multiplier %d level-%d\n",
1356 circuit
->hello_multiplier
1364 /* ISIS - Priority */
1365 if (circuit
->priority
[0] == circuit
->priority
[1]) {
1366 if (circuit
->priority
[0] != DEFAULT_PRIORITY
) {
1367 vty_out(vty
, " " PROTO_NAME
" priority %d\n",
1368 circuit
->priority
[0]);
1372 for (i
= 0; i
< 2; i
++) {
1373 if (circuit
->priority
[i
]
1374 != DEFAULT_PRIORITY
) {
1376 " " PROTO_NAME
" priority %d level-%d\n",
1377 circuit
->priority
[i
],
1385 if (circuit
->te_metric
[0] == circuit
->te_metric
[1]) {
1386 if (circuit
->te_metric
[0]
1387 != DEFAULT_CIRCUIT_METRIC
) {
1388 vty_out(vty
, " " PROTO_NAME
" metric %d\n",
1389 circuit
->te_metric
[0]);
1393 for (i
= 0; i
< 2; i
++) {
1394 if (circuit
->te_metric
[i
]
1395 != DEFAULT_CIRCUIT_METRIC
) {
1397 " " PROTO_NAME
" metric %d level-%d\n",
1398 circuit
->te_metric
[i
],
1404 if (circuit
->passwd
.type
== ISIS_PASSWD_TYPE_HMAC_MD5
) {
1405 vty_out(vty
, " " PROTO_NAME
" password md5 %s\n",
1406 circuit
->passwd
.passwd
);
1408 } else if (circuit
->passwd
.type
1409 == ISIS_PASSWD_TYPE_CLEARTXT
) {
1410 vty_out(vty
, " " PROTO_NAME
" password clear %s\n",
1411 circuit
->passwd
.passwd
);
1414 if (circuit
->bfd_config
.enabled
) {
1415 vty_out(vty
, " " PROTO_NAME
" bfd\n");
1418 write
+= hook_call(isis_circuit_config_write
,
1421 if_vty_config_end(vty
);
1426 #endif /* ifdef FABRICD */
1428 void isis_circuit_af_set(struct isis_circuit
*circuit
, bool ip_router
,
1431 struct isis_area
*area
= circuit
->area
;
1432 int old_ipr
= circuit
->ip_router
;
1433 int old_ipv6r
= circuit
->ipv6_router
;
1435 /* is there something to do? */
1436 if (old_ipr
== ip_router
&& old_ipv6r
== ipv6_router
)
1439 circuit
->ip_router
= ip_router
;
1440 circuit
->ipv6_router
= ipv6_router
;
1441 circuit_update_nlpids(circuit
);
1444 area
->ip_circuits
+= ip_router
- old_ipr
;
1445 area
->ipv6_circuits
+= ipv6_router
- old_ipv6r
;
1447 if (ip_router
|| ipv6_router
)
1448 lsp_regenerate_schedule(area
, circuit
->is_type
, 0);
1452 ferr_r
isis_circuit_passive_set(struct isis_circuit
*circuit
, bool passive
)
1454 if (circuit
->is_passive
== passive
)
1457 if (if_is_loopback(circuit
->interface
) && !passive
)
1458 return ferr_cfg_invalid("loopback is always passive");
1460 if (circuit
->state
!= C_STATE_UP
) {
1461 circuit
->is_passive
= passive
;
1463 struct isis_area
*area
= circuit
->area
;
1464 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1465 circuit
->is_passive
= passive
;
1466 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1472 ferr_r
isis_circuit_metric_set(struct isis_circuit
*circuit
, int level
,
1475 assert(level
== IS_LEVEL_1
|| level
== IS_LEVEL_2
);
1476 if (metric
> MAX_WIDE_LINK_METRIC
)
1477 return ferr_cfg_invalid("metric %d too large for wide metric",
1479 if (circuit
->area
&& circuit
->area
->oldmetric
1480 && metric
> MAX_NARROW_LINK_METRIC
)
1481 return ferr_cfg_invalid("metric %d too large for narrow metric",
1484 /* inform ldp-sync of metric change
1485 * if ldp-sync is running need to save metric
1486 * and restore new values after ldp-sync completion.
1488 if (isis_ldp_sync_if_metric_config(circuit
, level
, metric
)) {
1489 circuit
->te_metric
[level
- 1] = metric
;
1490 circuit
->metric
[level
- 1] = metric
;
1492 lsp_regenerate_schedule(circuit
->area
, level
, 0);
1497 ferr_r
isis_circuit_passwd_unset(struct isis_circuit
*circuit
)
1499 memset(&circuit
->passwd
, 0, sizeof(circuit
->passwd
));
1503 ferr_r
isis_circuit_passwd_set(struct isis_circuit
*circuit
,
1504 uint8_t passwd_type
, const char *passwd
)
1509 return ferr_code_bug("no circuit password given");
1511 len
= strlen(passwd
);
1513 return ferr_code_bug(
1514 "circuit password too long (max 254 chars)");
1516 circuit
->passwd
.len
= len
;
1517 strlcpy((char *)circuit
->passwd
.passwd
, passwd
,
1518 sizeof(circuit
->passwd
.passwd
));
1519 circuit
->passwd
.type
= passwd_type
;
1523 ferr_r
isis_circuit_passwd_cleartext_set(struct isis_circuit
*circuit
,
1526 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_CLEARTXT
,
1530 ferr_r
isis_circuit_passwd_hmac_md5_set(struct isis_circuit
*circuit
,
1533 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1537 void isis_circuit_circ_type_set(struct isis_circuit
*circuit
, int circ_type
)
1539 if (circuit
->circ_type
== circ_type
)
1542 if (circuit
->state
!= C_STATE_UP
) {
1543 circuit
->circ_type
= circ_type
;
1544 circuit
->circ_type_config
= circ_type
;
1546 struct isis_area
*area
= circuit
->area
;
1548 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1549 circuit
->circ_type
= circ_type
;
1550 circuit
->circ_type_config
= circ_type
;
1551 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1555 int isis_circuit_mt_enabled_set(struct isis_circuit
*circuit
, uint16_t mtid
,
1558 struct isis_circuit_mt_setting
*setting
;
1560 setting
= circuit_get_mt_setting(circuit
, mtid
);
1561 if (setting
->enabled
!= enabled
) {
1562 setting
->enabled
= enabled
;
1564 lsp_regenerate_schedule(circuit
->area
,
1565 IS_LEVEL_1
| IS_LEVEL_2
, 0);
1571 int isis_if_new_hook(struct interface
*ifp
)
1576 int isis_if_delete_hook(struct interface
*ifp
)
1579 isis_circuit_del(ifp
->info
);
1584 static int isis_ifp_create(struct interface
*ifp
)
1586 struct isis_circuit
*circuit
= ifp
->info
;
1589 isis_circuit_enable(circuit
);
1591 hook_call(isis_if_new_hook
, ifp
);
1596 static int isis_ifp_up(struct interface
*ifp
)
1598 struct isis_circuit
*circuit
= ifp
->info
;
1601 isis_csm_state_change(IF_UP_FROM_Z
, circuit
, ifp
);
1606 static int isis_ifp_down(struct interface
*ifp
)
1608 struct isis_circuit
*circuit
= ifp
->info
;
1611 isis_csm_state_change(IF_DOWN_FROM_Z
, circuit
, ifp
);
1613 SET_FLAG(circuit
->flags
, ISIS_CIRCUIT_FLAPPED_AFTER_SPF
);
1619 static int isis_ifp_destroy(struct interface
*ifp
)
1621 struct isis_circuit
*circuit
= ifp
->info
;
1624 isis_circuit_disable(circuit
);
1629 void isis_circuit_init(void)
1631 /* Initialize Zebra interface data structure */
1632 hook_register_prio(if_add
, 0, isis_if_new_hook
);
1633 hook_register_prio(if_del
, 0, isis_if_delete_hook
);
1635 /* Install interface node */
1637 if_cmd_init(isis_interface_config_write
);
1639 if_cmd_init_default();
1641 if_zapi_callbacks(isis_ifp_create
, isis_ifp_up
,
1642 isis_ifp_down
, isis_ifp_destroy
);