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"
24 #include "lib/zclient.h"
26 PREDECL_RBTREE_UNIQ(lfa_tiebreaker_tree
);
27 PREDECL_RBTREE_UNIQ(rlfa_tree
);
29 enum lfa_tiebreaker_type
{
30 LFA_TIEBREAKER_DOWNSTREAM
= 0,
31 LFA_TIEBREAKER_LOWEST_METRIC
,
32 LFA_TIEBREAKER_NODE_PROTECTING
,
35 struct lfa_tiebreaker
{
36 struct lfa_tiebreaker_tree_item entry
;
38 enum lfa_tiebreaker_type type
;
39 struct isis_area
*area
;
41 int lfa_tiebreaker_cmp(const struct lfa_tiebreaker
*a
,
42 const struct lfa_tiebreaker
*b
);
43 DECLARE_RBTREE_UNIQ(lfa_tiebreaker_tree
, struct lfa_tiebreaker
, entry
,
47 struct rlfa_tree_item entry
;
49 struct isis_vertex
*vertex
;
50 struct in_addr pq_address
;
52 int rlfa_cmp(const struct rlfa
*a
, const struct rlfa
*b
);
53 DECLARE_RBTREE_UNIQ(rlfa_tree
, struct rlfa
, entry
, rlfa_cmp
);
55 enum isis_tilfa_sid_type
{
60 struct isis_tilfa_sid
{
61 enum isis_tilfa_sid_type type
;
66 uint8_t remote_sysid
[ISIS_SYS_ID_LEN
];
72 enum spf_prefix_priority
{
73 SPF_PREFIX_PRIO_CRITICAL
= 0,
75 SPF_PREFIX_PRIO_MEDIUM
,
80 struct spf_prefix_priority_acl
{
82 struct access_list
*list_v4
;
83 struct access_list
*list_v6
;
86 RB_HEAD(isis_spf_nodes
, isis_spf_node
);
87 RB_PROTOTYPE(isis_spf_nodes
, isis_spf_node
, entry
, isis_spf_node_compare
)
88 struct isis_spf_node
{
89 RB_ENTRY(isis_spf_node
) entry
;
91 /* Node's System ID. */
92 uint8_t sysid
[ISIS_SYS_ID_LEN
];
94 /* Local adjacencies over which this node is reachable. */
95 struct list
*adjacencies
;
97 /* Best metric of all adjacencies used to reach this node. */
101 /* Node's forward SPT. */
102 struct isis_spftree
*spftree
;
104 /* Node's reverse SPT. */
105 struct isis_spftree
*spftree_reverse
;
107 /* Node's P-space. */
108 struct isis_spf_nodes p_space
;
112 enum lfa_protection_type
{
113 LFA_LINK_PROTECTION
= 1,
117 struct lfa_protected_resource
{
118 /* The protection type. */
119 enum lfa_protection_type type
;
121 /* The protected adjacency (might be a pseudonode). */
122 uint8_t adjacency
[ISIS_SYS_ID_LEN
+ 1];
124 /* List of nodes reachable over the protected interface. */
125 struct isis_spf_nodes nodes
;
128 /* Forward declaration(s). */
132 void isis_spf_node_list_init(struct isis_spf_nodes
*nodes
);
133 void isis_spf_node_list_clear(struct isis_spf_nodes
*nodes
);
134 struct isis_spf_node
*isis_spf_node_new(struct isis_spf_nodes
*nodes
,
135 const uint8_t *sysid
);
136 struct isis_spf_node
*isis_spf_node_find(const struct isis_spf_nodes
*nodes
,
137 const uint8_t *sysid
);
138 void isis_lfa_tiebreakers_init(struct isis_area
*area
, int level
);
139 void isis_lfa_tiebreakers_clear(struct isis_area
*area
, int level
);
140 struct lfa_tiebreaker
*isis_lfa_tiebreaker_add(struct isis_area
*area
,
141 int level
, uint8_t index
,
142 enum lfa_tiebreaker_type type
);
143 void isis_lfa_tiebreaker_delete(struct isis_area
*area
, int level
,
144 struct lfa_tiebreaker
*tie_b
);
145 void isis_lfa_excluded_ifaces_init(struct isis_circuit
*circuit
, int level
);
146 void isis_lfa_excluded_ifaces_clear(struct isis_circuit
*circuit
, int level
);
147 void isis_lfa_excluded_iface_add(struct isis_circuit
*circuit
, int level
,
149 void isis_lfa_excluded_iface_delete(struct isis_circuit
*circuit
, int level
,
151 bool isis_lfa_excluded_iface_check(struct isis_circuit
*circuit
, int level
,
153 bool isis_lfa_excise_adj_check(const struct isis_spftree
*spftree
,
155 bool isis_lfa_excise_node_check(const struct isis_spftree
*spftree
,
157 struct isis_spftree
*isis_spf_reverse_run(const struct isis_spftree
*spftree
);
158 int isis_spf_run_neighbors(struct isis_spftree
*spftree
);
159 int isis_rlfa_activate(struct isis_spftree
*spftree
, struct rlfa
*rlfa
,
160 struct zapi_rlfa_response
*response
);
161 void isis_rlfa_deactivate(struct isis_spftree
*spftree
, struct rlfa
*rlfa
);
162 void isis_rlfa_list_init(struct isis_spftree
*spftree
);
163 void isis_rlfa_list_clear(struct isis_spftree
*spftree
);
164 void isis_rlfa_process_ldp_response(struct zapi_rlfa_response
*response
);
165 void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info
*info
);
166 void isis_rlfa_check(struct isis_spftree
*spftree
, struct isis_vertex
*vertex
);
167 struct isis_spftree
*isis_rlfa_compute(struct isis_area
*area
,
168 struct isis_spftree
*spftree
,
169 struct isis_spftree
*spftree_reverse
,
171 struct lfa_protected_resource
*resource
);
172 void isis_lfa_compute(struct isis_area
*area
, struct isis_circuit
*circuit
,
173 struct isis_spftree
*spftree
,
174 struct lfa_protected_resource
*resource
);
175 void isis_spf_run_lfa(struct isis_area
*area
, struct isis_spftree
*spftree
);
176 int isis_tilfa_check(struct isis_spftree
*spftree
, struct isis_vertex
*vertex
);
177 struct isis_spftree
*
178 isis_tilfa_compute(struct isis_area
*area
, struct isis_spftree
*spftree
,
179 struct isis_spftree
*spftree_reverse
,
180 struct lfa_protected_resource
*protected_resource
);
182 #endif /* _FRR_ISIS_LFA_H */