2 * Copyright (C) 2020 NetDEF, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef _FRR_ISIS_LFA_H
21 #define _FRR_ISIS_LFA_H
23 #include "lib/typesafe.h"
25 PREDECL_RBTREE_UNIQ(lfa_tiebreaker_tree
)
27 enum lfa_tiebreaker_type
{
28 LFA_TIEBREAKER_DOWNSTREAM
= 0,
29 LFA_TIEBREAKER_LOWEST_METRIC
,
30 LFA_TIEBREAKER_NODE_PROTECTING
,
33 struct lfa_tiebreaker
{
34 struct lfa_tiebreaker_tree_item entry
;
36 enum lfa_tiebreaker_type type
;
37 struct isis_area
*area
;
39 int lfa_tiebreaker_cmp(const struct lfa_tiebreaker
*a
,
40 const struct lfa_tiebreaker
*b
);
41 DECLARE_RBTREE_UNIQ(lfa_tiebreaker_tree
, struct lfa_tiebreaker
, entry
,
44 enum isis_tilfa_sid_type
{
49 struct isis_tilfa_sid
{
50 enum isis_tilfa_sid_type type
;
55 uint8_t remote_sysid
[ISIS_SYS_ID_LEN
];
61 enum spf_prefix_priority
{
62 SPF_PREFIX_PRIO_CRITICAL
= 0,
64 SPF_PREFIX_PRIO_MEDIUM
,
69 struct spf_prefix_priority_acl
{
71 struct access_list
*list_v4
;
72 struct access_list
*list_v6
;
75 RB_HEAD(isis_spf_nodes
, isis_spf_node
);
76 RB_PROTOTYPE(isis_spf_nodes
, isis_spf_node
, entry
, isis_spf_node_compare
)
77 struct isis_spf_node
{
78 RB_ENTRY(isis_spf_node
) entry
;
80 /* Node's System ID. */
81 uint8_t sysid
[ISIS_SYS_ID_LEN
];
83 /* Local adjacencies over which this node is reachable. */
84 struct list
*adjacencies
;
86 /* Best metric of all adjacencies used to reach this node. */
90 /* Node's forward SPT. */
91 struct isis_spftree
*spftree
;
93 /* Node's reverse SPT. */
94 struct isis_spftree
*spftree_reverse
;
97 struct isis_spf_nodes p_space
;
101 enum lfa_protection_type
{
102 LFA_LINK_PROTECTION
= 1,
106 struct lfa_protected_resource
{
107 /* The protection type. */
108 enum lfa_protection_type type
;
110 /* The protected adjacency (might be a pseudonode). */
111 uint8_t adjacency
[ISIS_SYS_ID_LEN
+ 1];
113 /* List of nodes reachable over the protected interface. */
114 struct isis_spf_nodes nodes
;
117 /* Forward declaration(s). */
121 void isis_spf_node_list_init(struct isis_spf_nodes
*nodes
);
122 void isis_spf_node_list_clear(struct isis_spf_nodes
*nodes
);
123 struct isis_spf_node
*isis_spf_node_new(struct isis_spf_nodes
*nodes
,
124 const uint8_t *sysid
);
125 struct isis_spf_node
*isis_spf_node_find(const struct isis_spf_nodes
*nodes
,
126 const uint8_t *sysid
);
127 void isis_lfa_tiebreakers_init(struct isis_area
*area
, int level
);
128 void isis_lfa_tiebreakers_clear(struct isis_area
*area
, int level
);
129 struct lfa_tiebreaker
*isis_lfa_tiebreaker_add(struct isis_area
*area
,
130 int level
, uint8_t index
,
131 enum lfa_tiebreaker_type type
);
132 void isis_lfa_tiebreaker_delete(struct isis_area
*area
, int level
,
133 struct lfa_tiebreaker
*tie_b
);
134 void isis_lfa_excluded_ifaces_init(struct isis_circuit
*circuit
, int level
);
135 void isis_lfa_excluded_ifaces_clear(struct isis_circuit
*circuit
, int level
);
136 void isis_lfa_excluded_iface_add(struct isis_circuit
*circuit
, int level
,
138 void isis_lfa_excluded_iface_delete(struct isis_circuit
*circuit
, int level
,
140 bool isis_lfa_excluded_iface_check(struct isis_circuit
*circuit
, int level
,
142 bool isis_lfa_excise_adj_check(const struct isis_spftree
*spftree
,
144 bool isis_lfa_excise_node_check(const struct isis_spftree
*spftree
,
146 struct isis_spftree
*isis_spf_reverse_run(const struct isis_spftree
*spftree
);
147 int isis_spf_run_neighbors(struct isis_spftree
*spftree
);
148 void isis_lfa_compute(struct isis_area
*area
, struct isis_circuit
*circuit
,
149 struct isis_spftree
*spftree
,
150 struct lfa_protected_resource
*resource
);
151 void isis_spf_run_lfa(struct isis_area
*area
, struct isis_spftree
*spftree
);
152 int isis_tilfa_check(struct isis_spftree
*spftree
, struct isis_vertex
*vertex
);
153 struct isis_spftree
*
154 isis_tilfa_compute(struct isis_area
*area
, struct isis_spftree
*spftree
,
155 struct isis_spftree
*spftree_reverse
,
156 struct lfa_protected_resource
*protected_resource
);
158 #endif /* _FRR_ISIS_LFA_H */