]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_lfa.h
Merge pull request #7765 from gpnaveen/ospf_chaos_test
[mirror_frr.git] / isisd / isis_lfa.h
1 /*
2 * Copyright (C) 2020 NetDEF, Inc.
3 * Renato Westphal
4 *
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)
8 * any later version.
9 *
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
13 * more details.
14 *
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
18 */
19
20 #ifndef _FRR_ISIS_LFA_H
21 #define _FRR_ISIS_LFA_H
22
23 #include "lib/typesafe.h"
24 #include "lib/zclient.h"
25
26 PREDECL_RBTREE_UNIQ(lfa_tiebreaker_tree)
27 PREDECL_RBTREE_UNIQ(rlfa_tree)
28
29 enum lfa_tiebreaker_type {
30 LFA_TIEBREAKER_DOWNSTREAM = 0,
31 LFA_TIEBREAKER_LOWEST_METRIC,
32 LFA_TIEBREAKER_NODE_PROTECTING,
33 };
34
35 struct lfa_tiebreaker {
36 struct lfa_tiebreaker_tree_item entry;
37 uint8_t index;
38 enum lfa_tiebreaker_type type;
39 struct isis_area *area;
40 };
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,
44 lfa_tiebreaker_cmp)
45
46 struct rlfa {
47 struct rlfa_tree_item entry;
48 struct prefix prefix;
49 struct isis_vertex *vertex;
50 struct in_addr pq_address;
51 };
52 int rlfa_cmp(const struct rlfa *a, const struct rlfa *b);
53 DECLARE_RBTREE_UNIQ(rlfa_tree, struct rlfa, entry, rlfa_cmp)
54
55 enum isis_tilfa_sid_type {
56 TILFA_SID_PREFIX = 1,
57 TILFA_SID_ADJ,
58 };
59
60 struct isis_tilfa_sid {
61 enum isis_tilfa_sid_type type;
62 union {
63 struct {
64 uint32_t value;
65 bool remote;
66 uint8_t remote_sysid[ISIS_SYS_ID_LEN];
67 } index;
68 mpls_label_t label;
69 } value;
70 };
71
72 enum spf_prefix_priority {
73 SPF_PREFIX_PRIO_CRITICAL = 0,
74 SPF_PREFIX_PRIO_HIGH,
75 SPF_PREFIX_PRIO_MEDIUM,
76 SPF_PREFIX_PRIO_LOW,
77 SPF_PREFIX_PRIO_MAX,
78 };
79
80 struct spf_prefix_priority_acl {
81 char *name;
82 struct access_list *list_v4;
83 struct access_list *list_v6;
84 };
85
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;
90
91 /* Node's System ID. */
92 uint8_t sysid[ISIS_SYS_ID_LEN];
93
94 /* Local adjacencies over which this node is reachable. */
95 struct list *adjacencies;
96
97 /* Best metric of all adjacencies used to reach this node. */
98 uint32_t best_metric;
99
100 struct {
101 /* Node's forward SPT. */
102 struct isis_spftree *spftree;
103
104 /* Node's reverse SPT. */
105 struct isis_spftree *spftree_reverse;
106
107 /* Node's P-space. */
108 struct isis_spf_nodes p_space;
109 } lfa;
110 };
111
112 enum lfa_protection_type {
113 LFA_LINK_PROTECTION = 1,
114 LFA_NODE_PROTECTION,
115 };
116
117 struct lfa_protected_resource {
118 /* The protection type. */
119 enum lfa_protection_type type;
120
121 /* The protected adjacency (might be a pseudonode). */
122 uint8_t adjacency[ISIS_SYS_ID_LEN + 1];
123
124 /* List of nodes reachable over the protected interface. */
125 struct isis_spf_nodes nodes;
126 };
127
128 /* Forward declaration(s). */
129 struct isis_vertex;
130
131 /* Prototypes. */
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,
148 const char *ifname);
149 void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level,
150 const char *ifname);
151 bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level,
152 const char *ifname);
153 bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree,
154 const uint8_t *id);
155 bool isis_lfa_excise_node_check(const struct isis_spftree *spftree,
156 const uint8_t *id);
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,
170 uint32_t max_metric,
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);
181
182 #endif /* _FRR_ISIS_LFA_H */