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
);
221 isis_del_ext_subtlvs(circuit
->ext
);
225 XFREE(MTYPE_TMP
, circuit
->bfd_config
.profile
);
226 XFREE(MTYPE_ISIS_CIRCUIT
, circuit
->tag
);
228 /* and lastly the circuit itself */
229 XFREE(MTYPE_ISIS_CIRCUIT
, circuit
);
234 void isis_circuit_configure(struct isis_circuit
*circuit
,
235 struct isis_area
*area
)
238 circuit
->isis
= area
->isis
;
239 circuit
->area
= area
;
242 * Whenever the is-type of an area is changed, the is-type of each
244 * in that area is updated to a non-empty subset of the area is-type.
245 * Inversely, when configuring a new circuit, this property should be
248 if (area
->is_type
!= IS_LEVEL_1_AND_2
)
249 circuit
->is_type
= area
->is_type
;
252 * Add the circuit into area
254 listnode_add(area
->circuit_list
, circuit
);
256 circuit
->idx
= flags_get_index(&area
->flags
);
258 hook_call(isis_circuit_new_hook
, circuit
);
263 void isis_circuit_deconfigure(struct isis_circuit
*circuit
,
264 struct isis_area
*area
)
266 hook_call(isis_circuit_del_hook
, circuit
);
268 /* Free the index of SRM and SSN flags */
269 flags_free_index(&area
->flags
, circuit
->idx
);
272 /* Reset IS type to configured */
273 circuit
->is_type
= circuit
->is_type_config
;
275 /* Remove circuit from area */
276 assert(circuit
->area
== area
);
277 listnode_delete(area
->circuit_list
, circuit
);
278 circuit
->area
= NULL
;
279 circuit
->isis
= NULL
;
284 struct isis_circuit
*circuit_scan_by_ifp(struct interface
*ifp
)
286 return (struct isis_circuit
*)ifp
->info
;
289 DEFINE_HOOK(isis_circuit_add_addr_hook
, (struct isis_circuit
*circuit
),
292 void isis_circuit_add_addr(struct isis_circuit
*circuit
,
293 struct connected
*connected
)
295 struct listnode
*node
;
296 struct prefix_ipv4
*ipv4
;
297 struct prefix_ipv6
*ipv6
;
299 if (connected
->address
->family
== AF_INET
) {
300 uint32_t addr
= connected
->address
->u
.prefix4
.s_addr
;
302 if (IPV4_NET0(addr
) || IPV4_NET127(addr
) || IN_CLASSD(addr
)
303 || IPV4_LINKLOCAL(addr
))
306 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
, ipv4
))
307 if (prefix_same((struct prefix
*)ipv4
,
311 ipv4
= prefix_ipv4_new();
312 ipv4
->prefixlen
= connected
->address
->prefixlen
;
313 ipv4
->prefix
= connected
->address
->u
.prefix4
;
314 listnode_add(circuit
->ip_addrs
, ipv4
);
316 /* Update Local IP address parameter if MPLS TE is enable */
317 if (circuit
->ext
&& circuit
->area
318 && IS_MPLS_TE(circuit
->area
->mta
)) {
319 circuit
->ext
->local_addr
.s_addr
= ipv4
->prefix
.s_addr
;
320 SET_SUBTLV(circuit
->ext
, EXT_LOCAL_ADDR
);
324 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
329 zlog_debug("Added IP address %pFX to circuit %s",
331 circuit
->interface
->name
);
332 #endif /* EXTREME_DEBUG */
334 if (connected
->address
->family
== AF_INET6
) {
335 if (IN6_IS_ADDR_LOOPBACK(&connected
->address
->u
.prefix6
))
338 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
, ipv6
))
339 if (prefix_same((struct prefix
*)ipv6
,
342 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
, ipv6
))
343 if (prefix_same((struct prefix
*)ipv6
,
347 ipv6
= prefix_ipv6_new();
348 ipv6
->prefixlen
= connected
->address
->prefixlen
;
349 ipv6
->prefix
= connected
->address
->u
.prefix6
;
351 if (IN6_IS_ADDR_LINKLOCAL(&ipv6
->prefix
))
352 listnode_add(circuit
->ipv6_link
, ipv6
);
354 listnode_add(circuit
->ipv6_non_link
, ipv6
);
355 /* Update Local IPv6 address param. if MPLS TE is on */
356 if (circuit
->ext
&& circuit
->area
357 && IS_MPLS_TE(circuit
->area
->mta
)) {
358 IPV6_ADDR_COPY(&circuit
->ext
->local_addr6
,
360 SET_SUBTLV(circuit
->ext
, EXT_LOCAL_ADDR6
);
364 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
369 zlog_debug("Added IPv6 address %pFX to circuit %s",
371 circuit
->interface
->name
);
372 #endif /* EXTREME_DEBUG */
375 hook_call(isis_circuit_add_addr_hook
, circuit
);
380 void isis_circuit_del_addr(struct isis_circuit
*circuit
,
381 struct connected
*connected
)
383 struct prefix_ipv4
*ipv4
, *ip
= NULL
;
384 struct listnode
*node
;
385 struct prefix_ipv6
*ipv6
, *ip6
= NULL
;
388 if (connected
->address
->family
== AF_INET
) {
389 ipv4
= prefix_ipv4_new();
390 ipv4
->prefixlen
= connected
->address
->prefixlen
;
391 ipv4
->prefix
= connected
->address
->u
.prefix4
;
393 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
, ip
))
394 if (prefix_same((struct prefix
*)ip
,
395 (struct prefix
*)ipv4
))
399 listnode_delete(circuit
->ip_addrs
, ip
);
400 prefix_ipv4_free(&ip
);
402 lsp_regenerate_schedule(circuit
->area
,
403 circuit
->is_type
, 0);
406 "Nonexistent ip address %pFX removal attempt from circuit %s",
407 connected
->address
, circuit
->interface
->name
);
408 zlog_warn("Current ip addresses on %s:",
409 circuit
->interface
->name
);
410 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
412 zlog_warn(" %pFX", ip
);
414 zlog_warn("End of addresses");
417 prefix_ipv4_free(&ipv4
);
419 if (connected
->address
->family
== AF_INET6
) {
420 ipv6
= prefix_ipv6_new();
421 ipv6
->prefixlen
= connected
->address
->prefixlen
;
422 ipv6
->prefix
= connected
->address
->u
.prefix6
;
424 if (IN6_IS_ADDR_LINKLOCAL(&ipv6
->prefix
)) {
425 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
427 if (prefix_same((struct prefix
*)ip6
,
428 (struct prefix
*)ipv6
))
432 listnode_delete(circuit
->ipv6_link
, ip6
);
433 prefix_ipv6_free(&ip6
);
437 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
439 if (prefix_same((struct prefix
*)ip6
,
440 (struct prefix
*)ipv6
))
444 listnode_delete(circuit
->ipv6_non_link
, ip6
);
445 prefix_ipv6_free(&ip6
);
452 "Nonexistent ip address %pFX removal attempt from circuit %s",
453 connected
->address
, circuit
->interface
->name
);
454 zlog_warn("Current ip addresses on %s:",
455 circuit
->interface
->name
);
456 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
458 zlog_warn(" %pFX", (struct prefix
*)ip6
);
460 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
462 zlog_warn(" %pFX", (struct prefix
*)ip6
);
463 zlog_warn("End of addresses");
464 } else if (circuit
->area
)
465 lsp_regenerate_schedule(circuit
->area
, circuit
->is_type
,
468 prefix_ipv6_free(&ipv6
);
473 static uint8_t isis_circuit_id_gen(struct isis
*isis
, struct interface
*ifp
)
475 /* Circuit ids MUST be unique for any broadcast circuits. Otherwise,
476 * Pseudo-Node LSPs cannot be generated correctly.
478 * Currently, allocate one circuit ID for any circuit, limiting the total
479 * numer of circuits IS-IS can run on to 255.
481 * We should revisit this when implementing 3-way adjacencies for p2p, since
482 * we then have extended interface IDs available.
484 uint8_t id
= ifp
->ifindex
;
487 for (i
= 0; i
< 256; i
++) {
488 if (id
&& !_ISIS_CHECK_FLAG(isis
->circuit_ids_used
, id
))
494 zlog_warn("Could not allocate a circuit id for '%s'",
499 _ISIS_SET_FLAG(isis
->circuit_ids_used
, id
);
503 void isis_circuit_if_add(struct isis_circuit
*circuit
, struct interface
*ifp
)
505 struct listnode
*node
, *nnode
;
506 struct connected
*conn
;
508 if (if_is_broadcast(ifp
)) {
509 if (fabricd
|| circuit
->circ_type_config
== CIRCUIT_T_P2P
)
510 circuit
->circ_type
= CIRCUIT_T_P2P
;
512 circuit
->circ_type
= CIRCUIT_T_BROADCAST
;
513 } else if (if_is_pointopoint(ifp
)) {
514 circuit
->circ_type
= CIRCUIT_T_P2P
;
515 } else if (if_is_loopback(ifp
)) {
516 circuit
->circ_type
= CIRCUIT_T_LOOPBACK
;
517 circuit
->is_passive
= 1;
519 /* It's normal in case of loopback etc. */
521 zlog_debug("%s: unsupported media", __func__
);
522 circuit
->circ_type
= CIRCUIT_T_UNKNOWN
;
525 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, conn
))
526 isis_circuit_add_addr(circuit
, conn
);
530 void isis_circuit_if_del(struct isis_circuit
*circuit
, struct interface
*ifp
)
532 struct listnode
*node
, *nnode
;
533 struct connected
*conn
;
535 assert(circuit
->interface
== ifp
);
537 /* destroy addresses */
538 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, conn
))
539 isis_circuit_del_addr(circuit
, conn
);
541 circuit
->circ_type
= CIRCUIT_T_UNKNOWN
;
544 void isis_circuit_if_bind(struct isis_circuit
*circuit
, struct interface
*ifp
)
546 assert(circuit
!= NULL
);
548 if (circuit
->interface
)
549 assert(circuit
->interface
== ifp
);
551 circuit
->interface
= ifp
;
553 assert(ifp
->info
== circuit
);
558 void isis_circuit_if_unbind(struct isis_circuit
*circuit
, struct interface
*ifp
)
560 assert(circuit
!= NULL
);
562 assert(circuit
->interface
== ifp
);
563 assert(ifp
->info
== circuit
);
564 circuit
->interface
= NULL
;
568 static void isis_circuit_update_all_srmflags(struct isis_circuit
*circuit
,
571 struct isis_area
*area
;
572 struct isis_lsp
*lsp
;
576 area
= circuit
->area
;
578 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
579 if (!(level
& circuit
->is_type
))
582 if (!lspdb_count(&area
->lspdb
[level
- 1]))
585 frr_each (lspdb
, &area
->lspdb
[level
- 1], lsp
) {
587 isis_tx_queue_add(circuit
->tx_queue
, lsp
,
590 isis_tx_queue_del(circuit
->tx_queue
, lsp
);
596 size_t isis_circuit_pdu_size(struct isis_circuit
*circuit
)
598 return ISO_MTU(circuit
);
601 void isis_circuit_stream(struct isis_circuit
*circuit
, struct stream
**stream
)
603 size_t stream_size
= isis_circuit_pdu_size(circuit
);
606 *stream
= stream_new(stream_size
);
608 if (STREAM_SIZE(*stream
) != stream_size
)
609 stream_resize_inplace(stream
, stream_size
);
610 stream_reset(*stream
);
614 void isis_circuit_prepare(struct isis_circuit
*circuit
)
616 #if ISIS_METHOD != ISIS_METHOD_DLPI
617 thread_add_read(master
, isis_receive
, circuit
, circuit
->fd
,
620 thread_add_timer_msec(master
, isis_receive
, circuit
,
621 listcount(circuit
->area
->circuit_list
) * 100,
626 int isis_circuit_up(struct isis_circuit
*circuit
)
630 /* Set the flags for all the lsps of the circuit. */
631 isis_circuit_update_all_srmflags(circuit
, 1);
633 if (circuit
->state
== C_STATE_UP
)
636 if (circuit
->is_passive
) {
637 circuit
->last_uptime
= time(NULL
);
638 /* make sure the union fields are initialized, else we
639 * could end with garbage values from a previous circuit
640 * type, which would then cause a segfault when building
641 * LSPs or computing the SPF tree
643 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
644 circuit
->u
.bc
.adjdb
[0] = list_new();
645 circuit
->u
.bc
.adjdb
[1] = list_new();
646 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
647 circuit
->u
.p2p
.neighbor
= NULL
;
652 if (circuit
->area
->lsp_mtu
> isis_circuit_pdu_size(circuit
)) {
655 "Interface MTU %zu on %s is too low to support area lsp mtu %u!",
656 isis_circuit_pdu_size(circuit
),
657 circuit
->interface
->name
, circuit
->area
->lsp_mtu
);
659 /* Allow ISIS to continue configuration. With this
660 * configuration failure ISIS will attempt to send lsp
661 * packets but will fail until the mtu is configured properly
665 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
666 circuit
->circuit_id
=
667 isis_circuit_id_gen(circuit
->isis
, circuit
->interface
);
668 if (!circuit
->circuit_id
) {
671 "There are already 255 broadcast circuits active!");
676 * Get the Hardware Address
678 if (circuit
->interface
->hw_addr_len
!= ETH_ALEN
) {
679 zlog_warn("unsupported link layer");
681 memcpy(circuit
->u
.bc
.snpa
, circuit
->interface
->hw_addr
,
686 zlog_debug("%s: if_id %d, isomtu %d snpa %s", __func__
,
687 circuit
->interface
->ifindex
,
689 snpa_print(circuit
->u
.bc
.snpa
));
690 #endif /* EXTREME_DEBUG */
692 circuit
->u
.bc
.adjdb
[0] = list_new();
693 circuit
->u
.bc
.adjdb
[1] = list_new();
696 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
699 /* initilizing the hello sending threads
703 /* 8.4.1 a) commence sending of IIH PDUs */
705 for (int level
= ISIS_LEVEL1
; level
<= ISIS_LEVEL2
; level
++) {
706 if (!(circuit
->is_type
& level
))
709 send_hello_sched(circuit
, level
, TRIGGERED_IIH_DELAY
);
710 circuit
->u
.bc
.lan_neighs
[level
- 1] = list_new();
712 thread_add_timer(master
, isis_run_dr
,
713 &circuit
->level_arg
[level
- 1],
714 2 * circuit
->hello_interval
[level
- 1],
715 &circuit
->u
.bc
.t_run_dr
[level
- 1]);
718 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
719 /* 8.4.1 c) FIXME: listen for ESH PDUs */
720 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
721 /* initializing the hello send threads
724 circuit
->u
.p2p
.neighbor
= NULL
;
725 send_hello_sched(circuit
, 0, TRIGGERED_IIH_DELAY
);
728 /* initializing PSNP timers */
729 if (circuit
->is_type
& IS_LEVEL_1
)
731 master
, send_l1_psnp
, circuit
,
732 isis_jitter(circuit
->psnp_interval
[0], PSNP_JITTER
),
733 &circuit
->t_send_psnp
[0]);
735 if (circuit
->is_type
& IS_LEVEL_2
)
737 master
, send_l2_psnp
, circuit
,
738 isis_jitter(circuit
->psnp_interval
[1], PSNP_JITTER
),
739 &circuit
->t_send_psnp
[1]);
741 /* unified init for circuits; ignore warnings below this level */
742 retv
= isis_sock_init(circuit
);
743 if (retv
!= ISIS_OK
) {
744 isis_circuit_down(circuit
);
748 /* initialize the circuit streams after opening connection */
749 isis_circuit_stream(circuit
, &circuit
->rcv_stream
);
750 isis_circuit_stream(circuit
, &circuit
->snd_stream
);
752 isis_circuit_prepare(circuit
);
754 circuit
->tx_queue
= isis_tx_queue_new(circuit
, send_lsp
);
756 circuit
->last_uptime
= time(NULL
);
758 if (circuit
->area
->mta
&& circuit
->area
->mta
->status
)
759 isis_link_params_update(circuit
, circuit
->interface
);
761 isis_if_ldp_sync_enable(circuit
);
764 /* send northbound notification */
765 isis_notif_if_state_change(circuit
, false);
766 #endif /* ifndef FABRICD */
771 void isis_circuit_down(struct isis_circuit
*circuit
)
774 /* send northbound notification */
775 isis_notif_if_state_change(circuit
, true);
776 #endif /* ifndef FABRICD */
778 isis_if_ldp_sync_disable(circuit
);
780 /* log adjacency changes if configured to do so */
781 if (circuit
->area
->log_adj_changes
) {
782 struct isis_adjacency
*adj
= NULL
;
783 if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
784 adj
= circuit
->u
.p2p
.neighbor
;
787 adj
, adj
->adj_state
, ISIS_ADJ_DOWN
,
788 "circuit is being brought down");
789 } else if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
790 struct list
*adj_list
;
791 struct listnode
*node
;
792 if (circuit
->u
.bc
.adjdb
[0]) {
793 adj_list
= list_new();
794 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[0],
796 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
800 "circuit is being brought down");
801 list_delete(&adj_list
);
803 if (circuit
->u
.bc
.adjdb
[1]) {
804 adj_list
= list_new();
805 isis_adj_build_up_list(circuit
->u
.bc
.adjdb
[1],
807 for (ALL_LIST_ELEMENTS_RO(adj_list
, node
, adj
))
811 "circuit is being brought down");
812 list_delete(&adj_list
);
817 /* Clear the flags for all the lsps of the circuit. */
818 isis_circuit_update_all_srmflags(circuit
, 0);
820 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
821 /* destroy neighbour lists */
822 if (circuit
->u
.bc
.lan_neighs
[0]) {
823 list_delete(&circuit
->u
.bc
.lan_neighs
[0]);
824 circuit
->u
.bc
.lan_neighs
[0] = NULL
;
826 if (circuit
->u
.bc
.lan_neighs
[1]) {
827 list_delete(&circuit
->u
.bc
.lan_neighs
[1]);
828 circuit
->u
.bc
.lan_neighs
[1] = NULL
;
830 /* destroy adjacency databases */
831 if (circuit
->u
.bc
.adjdb
[0]) {
832 circuit
->u
.bc
.adjdb
[0]->del
= isis_delete_adj
;
833 list_delete(&circuit
->u
.bc
.adjdb
[0]);
834 circuit
->u
.bc
.adjdb
[0] = NULL
;
836 if (circuit
->u
.bc
.adjdb
[1]) {
837 circuit
->u
.bc
.adjdb
[1]->del
= isis_delete_adj
;
838 list_delete(&circuit
->u
.bc
.adjdb
[1]);
839 circuit
->u
.bc
.adjdb
[1] = NULL
;
841 if (circuit
->u
.bc
.is_dr
[0]) {
842 isis_dr_resign(circuit
, 1);
843 circuit
->u
.bc
.is_dr
[0] = 0;
845 memset(circuit
->u
.bc
.l1_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
846 if (circuit
->u
.bc
.is_dr
[1]) {
847 isis_dr_resign(circuit
, 2);
848 circuit
->u
.bc
.is_dr
[1] = 0;
850 memset(circuit
->u
.bc
.l2_desig_is
, 0, ISIS_SYS_ID_LEN
+ 1);
851 memset(circuit
->u
.bc
.snpa
, 0, ETH_ALEN
);
853 THREAD_OFF(circuit
->u
.bc
.t_send_lan_hello
[0]);
854 THREAD_OFF(circuit
->u
.bc
.t_send_lan_hello
[1]);
855 THREAD_OFF(circuit
->u
.bc
.t_run_dr
[0]);
856 THREAD_OFF(circuit
->u
.bc
.t_run_dr
[1]);
857 THREAD_OFF(circuit
->u
.bc
.t_refresh_pseudo_lsp
[0]);
858 THREAD_OFF(circuit
->u
.bc
.t_refresh_pseudo_lsp
[1]);
859 circuit
->lsp_regenerate_pending
[0] = 0;
860 circuit
->lsp_regenerate_pending
[1] = 0;
862 _ISIS_CLEAR_FLAG(circuit
->isis
->circuit_ids_used
,
863 circuit
->circuit_id
);
864 circuit
->circuit_id
= 0;
865 } else if (circuit
->circ_type
== CIRCUIT_T_P2P
) {
866 isis_delete_adj(circuit
->u
.p2p
.neighbor
);
867 circuit
->u
.p2p
.neighbor
= NULL
;
868 THREAD_OFF(circuit
->u
.p2p
.t_send_p2p_hello
);
872 * All adjacencies have to be gone, delete snmp list
873 * and reset snmpd idx generator
875 if (circuit
->snmp_adj_list
!= NULL
)
876 list_delete(&circuit
->snmp_adj_list
);
878 circuit
->snmp_adj_idx_gen
= 0;
880 /* Cancel all active threads */
881 THREAD_OFF(circuit
->t_send_csnp
[0]);
882 THREAD_OFF(circuit
->t_send_csnp
[1]);
883 THREAD_OFF(circuit
->t_send_psnp
[0]);
884 THREAD_OFF(circuit
->t_send_psnp
[1]);
885 THREAD_OFF(circuit
->t_read
);
887 if (circuit
->tx_queue
) {
888 isis_tx_queue_free(circuit
->tx_queue
);
889 circuit
->tx_queue
= NULL
;
892 /* send one gratuitous hello to spead up convergence */
893 if (circuit
->state
== C_STATE_UP
) {
894 if (circuit
->is_type
& IS_LEVEL_1
)
895 send_hello(circuit
, IS_LEVEL_1
);
896 if (circuit
->is_type
& IS_LEVEL_2
)
897 send_hello(circuit
, IS_LEVEL_2
);
900 circuit
->upadjcount
[0] = 0;
901 circuit
->upadjcount
[1] = 0;
903 /* close the socket */
909 if (circuit
->rcv_stream
!= NULL
) {
910 stream_free(circuit
->rcv_stream
);
911 circuit
->rcv_stream
= NULL
;
914 if (circuit
->snd_stream
!= NULL
) {
915 stream_free(circuit
->snd_stream
);
916 circuit
->snd_stream
= NULL
;
919 thread_cancel_event(master
, circuit
);
924 void circuit_update_nlpids(struct isis_circuit
*circuit
)
926 circuit
->nlpids
.count
= 0;
928 if (circuit
->ip_router
) {
929 circuit
->nlpids
.nlpids
[0] = NLPID_IP
;
930 circuit
->nlpids
.count
++;
932 if (circuit
->ipv6_router
) {
933 circuit
->nlpids
.nlpids
[circuit
->nlpids
.count
] = NLPID_IPV6
;
934 circuit
->nlpids
.count
++;
939 void isis_circuit_print_json(struct isis_circuit
*circuit
,
940 struct json_object
*json
, char detail
)
943 json_object
*iface_json
, *ipv4_addr_json
, *ipv6_link_json
,
944 *ipv6_non_link_json
, *hold_json
, *lan_prio_json
, *levels_json
,
946 char buf_prx
[INET6_BUFSIZ
];
949 snprintfrr(buf
, sizeof(buf
), "0x%x", circuit
->circuit_id
);
950 if (detail
== ISIS_UI_LEVEL_BRIEF
) {
951 iface_json
= json_object_new_object();
952 json_object_object_add(json
, "interface", iface_json
);
953 json_object_string_add(iface_json
, "name",
954 circuit
->interface
->name
);
955 json_object_string_add(iface_json
, "circuit-id", buf
);
956 json_object_string_add(iface_json
, "state",
957 circuit_state2string(circuit
->state
));
958 json_object_string_add(iface_json
, "type",
959 circuit_type2string(circuit
->circ_type
));
960 json_object_string_add(iface_json
, "level",
961 circuit_t2string(circuit
->is_type
));
964 if (detail
== ISIS_UI_LEVEL_DETAIL
) {
965 struct listnode
*node
;
966 struct prefix
*ip_addr
;
968 iface_json
= json_object_new_object();
969 json_object_object_add(json
, "interface", iface_json
);
970 json_object_string_add(iface_json
, "name",
971 circuit
->interface
->name
);
972 json_object_string_add(iface_json
, "state",
973 circuit_state2string(circuit
->state
));
974 if (circuit
->is_passive
)
975 json_object_string_add(iface_json
, "is-passive",
978 json_object_string_add(iface_json
, "is-passive",
980 json_object_string_add(iface_json
, "circuit-id", buf
);
981 json_object_string_add(iface_json
, "type",
982 circuit_type2string(circuit
->circ_type
));
983 json_object_string_add(iface_json
, "level",
984 circuit_t2string(circuit
->is_type
));
985 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
986 json_object_string_add(iface_json
, "snpa",
987 snpa_print(circuit
->u
.bc
.snpa
));
990 levels_json
= json_object_new_array();
991 json_object_object_add(iface_json
, "levels", levels_json
);
992 for (level
= ISIS_LEVEL1
; level
<= ISIS_LEVELS
; level
++) {
993 if ((circuit
->is_type
& level
) == 0)
995 level_json
= json_object_new_object();
996 json_object_string_add(level_json
, "level",
997 circuit_t2string(level
));
998 if (circuit
->area
->newmetric
)
999 json_object_int_add(level_json
, "metric",
1000 circuit
->te_metric
[0]);
1002 json_object_int_add(level_json
, "metric",
1003 circuit
->metric
[0]);
1004 if (!circuit
->is_passive
) {
1005 json_object_int_add(level_json
,
1007 circuit
->upadjcount
[0]);
1008 json_object_int_add(level_json
,
1010 circuit
->hello_interval
[0]);
1011 hold_json
= json_object_new_object();
1012 json_object_object_add(level_json
, "holddown",
1014 json_object_int_add(
1016 circuit
->hello_multiplier
[0]);
1017 json_object_string_add(
1019 (circuit
->pad_hellos
? "yes" : "no"));
1020 json_object_int_add(level_json
, "cnsp-interval",
1021 circuit
->csnp_interval
[0]);
1022 json_object_int_add(level_json
, "psnp-interval",
1023 circuit
->psnp_interval
[0]);
1024 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
) {
1026 json_object_new_object();
1027 json_object_object_add(level_json
,
1030 json_object_int_add(
1031 lan_prio_json
, "priority",
1032 circuit
->priority
[0]);
1033 json_object_string_add(
1034 lan_prio_json
, "is-dis",
1035 (circuit
->u
.bc
.is_dr
[0]
1040 json_object_array_add(levels_json
, level_json
);
1043 if (listcount(circuit
->ip_addrs
) > 0) {
1044 ipv4_addr_json
= json_object_new_object();
1045 json_object_object_add(iface_json
, "ip-prefix",
1047 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
1049 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1051 json_object_string_add(ipv4_addr_json
, "ip",
1055 if (listcount(circuit
->ipv6_link
) > 0) {
1056 ipv6_link_json
= json_object_new_object();
1057 json_object_object_add(iface_json
, "ipv6-link-locals",
1059 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
1061 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1063 json_object_string_add(ipv6_link_json
, "ipv6",
1067 if (listcount(circuit
->ipv6_non_link
) > 0) {
1068 ipv6_non_link_json
= json_object_new_object();
1069 json_object_object_add(iface_json
, "ipv6-prefixes",
1070 ipv6_non_link_json
);
1071 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
1073 snprintfrr(buf_prx
, INET6_BUFSIZ
, "%pFX",
1075 json_object_string_add(ipv6_non_link_json
,
1083 void isis_circuit_print_vty(struct isis_circuit
*circuit
, struct vty
*vty
,
1086 if (detail
== ISIS_UI_LEVEL_BRIEF
) {
1087 vty_out(vty
, " %-12s", circuit
->interface
->name
);
1088 vty_out(vty
, "0x%-7x", circuit
->circuit_id
);
1089 vty_out(vty
, "%-9s", circuit_state2string(circuit
->state
));
1090 vty_out(vty
, "%-9s", circuit_type2string(circuit
->circ_type
));
1091 vty_out(vty
, "%-9s", circuit_t2string(circuit
->is_type
));
1095 if (detail
== ISIS_UI_LEVEL_DETAIL
) {
1096 struct listnode
*node
;
1097 struct prefix
*ip_addr
;
1099 vty_out(vty
, " Interface: %s", circuit
->interface
->name
);
1100 vty_out(vty
, ", State: %s",
1101 circuit_state2string(circuit
->state
));
1102 if (circuit
->is_passive
)
1103 vty_out(vty
, ", Passive");
1105 vty_out(vty
, ", Active");
1106 vty_out(vty
, ", Circuit Id: 0x%x", circuit
->circuit_id
);
1108 vty_out(vty
, " Type: %s",
1109 circuit_type2string(circuit
->circ_type
));
1110 vty_out(vty
, ", Level: %s", circuit_t2string(circuit
->is_type
));
1111 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1112 vty_out(vty
, ", SNPA: %-10s",
1113 snpa_print(circuit
->u
.bc
.snpa
));
1115 if (circuit
->is_type
& IS_LEVEL_1
) {
1116 vty_out(vty
, " Level-1 Information:\n");
1117 if (circuit
->area
->newmetric
)
1118 vty_out(vty
, " Metric: %d",
1119 circuit
->te_metric
[0]);
1121 vty_out(vty
, " Metric: %d",
1122 circuit
->metric
[0]);
1123 if (!circuit
->is_passive
) {
1124 vty_out(vty
, ", Active neighbors: %u\n",
1125 circuit
->upadjcount
[0]);
1127 " Hello interval: %u, Holddown count: %u %s\n",
1128 circuit
->hello_interval
[0],
1129 circuit
->hello_multiplier
[0],
1130 (circuit
->pad_hellos
? "(pad)"
1133 " CNSP interval: %u, PSNP interval: %u\n",
1134 circuit
->csnp_interval
[0],
1135 circuit
->psnp_interval
[0]);
1136 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1138 " LAN Priority: %u, %s\n",
1139 circuit
->priority
[0],
1140 (circuit
->u
.bc
.is_dr
[0]
1147 if (circuit
->is_type
& IS_LEVEL_2
) {
1148 vty_out(vty
, " Level-2 Information:\n");
1149 if (circuit
->area
->newmetric
)
1150 vty_out(vty
, " Metric: %d",
1151 circuit
->te_metric
[1]);
1153 vty_out(vty
, " Metric: %d",
1154 circuit
->metric
[1]);
1155 if (!circuit
->is_passive
) {
1156 vty_out(vty
, ", Active neighbors: %u\n",
1157 circuit
->upadjcount
[1]);
1159 " Hello interval: %u, Holddown count: %u %s\n",
1160 circuit
->hello_interval
[1],
1161 circuit
->hello_multiplier
[1],
1162 (circuit
->pad_hellos
? "(pad)"
1165 " CNSP interval: %u, PSNP interval: %u\n",
1166 circuit
->csnp_interval
[1],
1167 circuit
->psnp_interval
[1]);
1168 if (circuit
->circ_type
== CIRCUIT_T_BROADCAST
)
1170 " LAN Priority: %u, %s\n",
1171 circuit
->priority
[1],
1172 (circuit
->u
.bc
.is_dr
[1]
1179 if (listcount(circuit
->ip_addrs
) > 0) {
1180 vty_out(vty
, " IP Prefix(es):\n");
1181 for (ALL_LIST_ELEMENTS_RO(circuit
->ip_addrs
, node
,
1183 vty_out(vty
, " %pFX\n", ip_addr
);
1185 if (listcount(circuit
->ipv6_link
) > 0) {
1186 vty_out(vty
, " IPv6 Link-Locals:\n");
1187 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_link
, node
,
1189 vty_out(vty
, " %pFX\n", ip_addr
);
1191 if (listcount(circuit
->ipv6_non_link
) > 0) {
1192 vty_out(vty
, " IPv6 Prefixes:\n");
1193 for (ALL_LIST_ELEMENTS_RO(circuit
->ipv6_non_link
, node
,
1195 vty_out(vty
, " %pFX\n", ip_addr
);
1204 DEFINE_HOOK(isis_circuit_config_write
,
1205 (struct isis_circuit
*circuit
, struct vty
*vty
),
1208 static int isis_interface_config_write(struct vty
*vty
)
1210 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1212 struct interface
*ifp
;
1213 struct isis_circuit
*circuit
;
1216 FOR_ALL_INTERFACES (vrf
, ifp
) {
1218 if_vty_config_start(vty
, ifp
);
1222 vty_out(vty
, " description %s\n", ifp
->desc
);
1227 circuit
= circuit_scan_by_ifp(ifp
);
1228 if (circuit
== NULL
)
1230 if (circuit
->ip_router
) {
1231 vty_out(vty
, " ip router " PROTO_NAME
" %s\n",
1235 if (circuit
->is_passive
) {
1236 vty_out(vty
, " " PROTO_NAME
" passive\n");
1239 if (circuit
->circ_type_config
== CIRCUIT_T_P2P
) {
1240 vty_out(vty
, " " PROTO_NAME
" network point-to-point\n");
1243 if (circuit
->ipv6_router
) {
1244 vty_out(vty
, " ipv6 router " PROTO_NAME
" %s\n",
1249 /* ISIS - circuit type */
1251 if (circuit
->is_type
== IS_LEVEL_1
) {
1252 vty_out(vty
, " " PROTO_NAME
" circuit-type level-1\n");
1255 if (circuit
->is_type
== IS_LEVEL_2
) {
1257 " " PROTO_NAME
" circuit-type level-2-only\n");
1263 /* ISIS - CSNP interval */
1264 if (circuit
->csnp_interval
[0]
1265 == circuit
->csnp_interval
[1]) {
1266 if (circuit
->csnp_interval
[0]
1267 != DEFAULT_CSNP_INTERVAL
) {
1268 vty_out(vty
, " " PROTO_NAME
" csnp-interval %d\n",
1269 circuit
->csnp_interval
[0]);
1273 for (i
= 0; i
< 2; i
++) {
1274 if (circuit
->csnp_interval
[i
]
1275 != DEFAULT_CSNP_INTERVAL
) {
1277 " " PROTO_NAME
" csnp-interval %d level-%d\n",
1278 circuit
->csnp_interval
1286 /* ISIS - PSNP interval */
1287 if (circuit
->psnp_interval
[0]
1288 == circuit
->psnp_interval
[1]) {
1289 if (circuit
->psnp_interval
[0]
1290 != DEFAULT_PSNP_INTERVAL
) {
1291 vty_out(vty
, " " PROTO_NAME
" psnp-interval %d\n",
1292 circuit
->psnp_interval
[0]);
1296 for (i
= 0; i
< 2; i
++) {
1297 if (circuit
->psnp_interval
[i
]
1298 != DEFAULT_PSNP_INTERVAL
) {
1300 " " PROTO_NAME
" psnp-interval %d level-%d\n",
1301 circuit
->psnp_interval
1309 /* ISIS - Hello padding - Defaults to true so only
1310 * display if false */
1311 if (circuit
->pad_hellos
== 0) {
1312 vty_out(vty
, " no " PROTO_NAME
" hello padding\n");
1316 if (circuit
->disable_threeway_adj
) {
1317 vty_out(vty
, " no isis three-way-handshake\n");
1321 /* ISIS - Hello interval */
1322 if (circuit
->hello_interval
[0]
1323 == circuit
->hello_interval
[1]) {
1324 if (circuit
->hello_interval
[0]
1325 != DEFAULT_HELLO_INTERVAL
) {
1327 " " PROTO_NAME
" hello-interval %d\n",
1328 circuit
->hello_interval
[0]);
1332 for (i
= 0; i
< 2; i
++) {
1333 if (circuit
->hello_interval
[i
]
1334 != DEFAULT_HELLO_INTERVAL
) {
1336 " " PROTO_NAME
" hello-interval %d level-%d\n",
1337 circuit
->hello_interval
1345 /* ISIS - Hello Multiplier */
1346 if (circuit
->hello_multiplier
[0]
1347 == circuit
->hello_multiplier
[1]) {
1348 if (circuit
->hello_multiplier
[0]
1349 != DEFAULT_HELLO_MULTIPLIER
) {
1351 " " PROTO_NAME
" hello-multiplier %d\n",
1352 circuit
->hello_multiplier
[0]);
1356 for (i
= 0; i
< 2; i
++) {
1357 if (circuit
->hello_multiplier
[i
]
1358 != DEFAULT_HELLO_MULTIPLIER
) {
1360 " " PROTO_NAME
" hello-multiplier %d level-%d\n",
1361 circuit
->hello_multiplier
1369 /* ISIS - Priority */
1370 if (circuit
->priority
[0] == circuit
->priority
[1]) {
1371 if (circuit
->priority
[0] != DEFAULT_PRIORITY
) {
1372 vty_out(vty
, " " PROTO_NAME
" priority %d\n",
1373 circuit
->priority
[0]);
1377 for (i
= 0; i
< 2; i
++) {
1378 if (circuit
->priority
[i
]
1379 != DEFAULT_PRIORITY
) {
1381 " " PROTO_NAME
" priority %d level-%d\n",
1382 circuit
->priority
[i
],
1390 if (circuit
->te_metric
[0] == circuit
->te_metric
[1]) {
1391 if (circuit
->te_metric
[0]
1392 != DEFAULT_CIRCUIT_METRIC
) {
1393 vty_out(vty
, " " PROTO_NAME
" metric %d\n",
1394 circuit
->te_metric
[0]);
1398 for (i
= 0; i
< 2; i
++) {
1399 if (circuit
->te_metric
[i
]
1400 != DEFAULT_CIRCUIT_METRIC
) {
1402 " " PROTO_NAME
" metric %d level-%d\n",
1403 circuit
->te_metric
[i
],
1409 if (circuit
->passwd
.type
== ISIS_PASSWD_TYPE_HMAC_MD5
) {
1410 vty_out(vty
, " " PROTO_NAME
" password md5 %s\n",
1411 circuit
->passwd
.passwd
);
1413 } else if (circuit
->passwd
.type
1414 == ISIS_PASSWD_TYPE_CLEARTXT
) {
1415 vty_out(vty
, " " PROTO_NAME
" password clear %s\n",
1416 circuit
->passwd
.passwd
);
1419 if (circuit
->bfd_config
.enabled
) {
1420 vty_out(vty
, " " PROTO_NAME
" bfd\n");
1423 write
+= hook_call(isis_circuit_config_write
,
1426 if_vty_config_end(vty
);
1431 #endif /* ifdef FABRICD */
1433 void isis_circuit_af_set(struct isis_circuit
*circuit
, bool ip_router
,
1436 struct isis_area
*area
= circuit
->area
;
1437 int old_ipr
= circuit
->ip_router
;
1438 int old_ipv6r
= circuit
->ipv6_router
;
1440 /* is there something to do? */
1441 if (old_ipr
== ip_router
&& old_ipv6r
== ipv6_router
)
1444 circuit
->ip_router
= ip_router
;
1445 circuit
->ipv6_router
= ipv6_router
;
1446 circuit_update_nlpids(circuit
);
1449 area
->ip_circuits
+= ip_router
- old_ipr
;
1450 area
->ipv6_circuits
+= ipv6_router
- old_ipv6r
;
1452 if (ip_router
|| ipv6_router
)
1453 lsp_regenerate_schedule(area
, circuit
->is_type
, 0);
1457 ferr_r
isis_circuit_passive_set(struct isis_circuit
*circuit
, bool passive
)
1459 if (circuit
->is_passive
== passive
)
1462 if (if_is_loopback(circuit
->interface
) && !passive
)
1463 return ferr_cfg_invalid("loopback is always passive");
1465 if (circuit
->state
!= C_STATE_UP
) {
1466 circuit
->is_passive
= passive
;
1468 struct isis_area
*area
= circuit
->area
;
1469 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1470 circuit
->is_passive
= passive
;
1471 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1477 ferr_r
isis_circuit_metric_set(struct isis_circuit
*circuit
, int level
,
1480 assert(level
== IS_LEVEL_1
|| level
== IS_LEVEL_2
);
1481 if (metric
> MAX_WIDE_LINK_METRIC
)
1482 return ferr_cfg_invalid("metric %d too large for wide metric",
1484 if (circuit
->area
&& circuit
->area
->oldmetric
1485 && metric
> MAX_NARROW_LINK_METRIC
)
1486 return ferr_cfg_invalid("metric %d too large for narrow metric",
1489 /* inform ldp-sync of metric change
1490 * if ldp-sync is running need to save metric
1491 * and restore new values after ldp-sync completion.
1493 if (isis_ldp_sync_if_metric_config(circuit
, level
, metric
)) {
1494 circuit
->te_metric
[level
- 1] = metric
;
1495 circuit
->metric
[level
- 1] = metric
;
1497 lsp_regenerate_schedule(circuit
->area
, level
, 0);
1502 ferr_r
isis_circuit_passwd_unset(struct isis_circuit
*circuit
)
1504 memset(&circuit
->passwd
, 0, sizeof(circuit
->passwd
));
1508 ferr_r
isis_circuit_passwd_set(struct isis_circuit
*circuit
,
1509 uint8_t passwd_type
, const char *passwd
)
1514 return ferr_code_bug("no circuit password given");
1516 len
= strlen(passwd
);
1518 return ferr_code_bug(
1519 "circuit password too long (max 254 chars)");
1521 circuit
->passwd
.len
= len
;
1522 strlcpy((char *)circuit
->passwd
.passwd
, passwd
,
1523 sizeof(circuit
->passwd
.passwd
));
1524 circuit
->passwd
.type
= passwd_type
;
1528 ferr_r
isis_circuit_passwd_cleartext_set(struct isis_circuit
*circuit
,
1531 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_CLEARTXT
,
1535 ferr_r
isis_circuit_passwd_hmac_md5_set(struct isis_circuit
*circuit
,
1538 return isis_circuit_passwd_set(circuit
, ISIS_PASSWD_TYPE_HMAC_MD5
,
1542 void isis_circuit_circ_type_set(struct isis_circuit
*circuit
, int circ_type
)
1544 if (circuit
->circ_type
== circ_type
)
1547 if (circuit
->state
!= C_STATE_UP
) {
1548 circuit
->circ_type
= circ_type
;
1549 circuit
->circ_type_config
= circ_type
;
1551 struct isis_area
*area
= circuit
->area
;
1553 isis_csm_state_change(ISIS_DISABLE
, circuit
, area
);
1554 circuit
->circ_type
= circ_type
;
1555 circuit
->circ_type_config
= circ_type
;
1556 isis_csm_state_change(ISIS_ENABLE
, circuit
, area
);
1560 int isis_circuit_mt_enabled_set(struct isis_circuit
*circuit
, uint16_t mtid
,
1563 struct isis_circuit_mt_setting
*setting
;
1565 setting
= circuit_get_mt_setting(circuit
, mtid
);
1566 if (setting
->enabled
!= enabled
) {
1567 setting
->enabled
= enabled
;
1569 lsp_regenerate_schedule(circuit
->area
,
1570 IS_LEVEL_1
| IS_LEVEL_2
, 0);
1576 int isis_if_new_hook(struct interface
*ifp
)
1581 int isis_if_delete_hook(struct interface
*ifp
)
1584 isis_circuit_del(ifp
->info
);
1589 static int isis_ifp_create(struct interface
*ifp
)
1591 struct isis_circuit
*circuit
= ifp
->info
;
1594 isis_circuit_enable(circuit
);
1596 hook_call(isis_if_new_hook
, ifp
);
1601 static int isis_ifp_up(struct interface
*ifp
)
1603 struct isis_circuit
*circuit
= ifp
->info
;
1606 isis_csm_state_change(IF_UP_FROM_Z
, circuit
, ifp
);
1611 static int isis_ifp_down(struct interface
*ifp
)
1613 struct isis_circuit
*circuit
= ifp
->info
;
1616 isis_csm_state_change(IF_DOWN_FROM_Z
, circuit
, ifp
);
1618 SET_FLAG(circuit
->flags
, ISIS_CIRCUIT_FLAPPED_AFTER_SPF
);
1624 static int isis_ifp_destroy(struct interface
*ifp
)
1626 struct isis_circuit
*circuit
= ifp
->info
;
1629 isis_circuit_disable(circuit
);
1634 void isis_circuit_init(void)
1636 /* Initialize Zebra interface data structure */
1637 hook_register_prio(if_add
, 0, isis_if_new_hook
);
1638 hook_register_prio(if_del
, 0, isis_if_delete_hook
);
1640 /* Install interface node */
1642 if_cmd_init(isis_interface_config_write
);
1644 if_cmd_init_default();
1646 if_zapi_callbacks(isis_ifp_create
, isis_ifp_up
,
1647 isis_ifp_down
, isis_ifp_destroy
);