]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_lfa.h
Merge pull request #8305 from donaldsharp/bgp_ll_ifp_change
[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 #include "lib/memory.h"
26
27 DECLARE_MTYPE(ISIS_NEXTHOP_LABELS);
28
29 PREDECL_RBTREE_UNIQ(lfa_tiebreaker_tree);
30 PREDECL_RBTREE_UNIQ(rlfa_tree);
31
32 enum lfa_tiebreaker_type {
33 LFA_TIEBREAKER_DOWNSTREAM = 0,
34 LFA_TIEBREAKER_LOWEST_METRIC,
35 LFA_TIEBREAKER_NODE_PROTECTING,
36 };
37
38 struct lfa_tiebreaker {
39 struct lfa_tiebreaker_tree_item entry;
40 uint8_t index;
41 enum lfa_tiebreaker_type type;
42 struct isis_area *area;
43 };
44 int lfa_tiebreaker_cmp(const struct lfa_tiebreaker *a,
45 const struct lfa_tiebreaker *b);
46 DECLARE_RBTREE_UNIQ(lfa_tiebreaker_tree, struct lfa_tiebreaker, entry,
47 lfa_tiebreaker_cmp);
48
49 struct rlfa {
50 struct rlfa_tree_item entry;
51 struct prefix prefix;
52 struct isis_vertex *vertex;
53 struct in_addr pq_address;
54 };
55 int rlfa_cmp(const struct rlfa *a, const struct rlfa *b);
56 DECLARE_RBTREE_UNIQ(rlfa_tree, struct rlfa, entry, rlfa_cmp);
57
58 enum isis_tilfa_sid_type {
59 TILFA_SID_PREFIX = 1,
60 TILFA_SID_ADJ,
61 };
62
63 struct isis_tilfa_sid {
64 enum isis_tilfa_sid_type type;
65 union {
66 struct {
67 uint32_t value;
68 bool remote;
69 uint8_t remote_sysid[ISIS_SYS_ID_LEN];
70 } index;
71 mpls_label_t label;
72 } value;
73 };
74
75 enum spf_prefix_priority {
76 SPF_PREFIX_PRIO_CRITICAL = 0,
77 SPF_PREFIX_PRIO_HIGH,
78 SPF_PREFIX_PRIO_MEDIUM,
79 SPF_PREFIX_PRIO_LOW,
80 SPF_PREFIX_PRIO_MAX,
81 };
82
83 struct spf_prefix_priority_acl {
84 char *name;
85 struct access_list *list_v4;
86 struct access_list *list_v6;
87 };
88
89 RB_HEAD(isis_spf_nodes, isis_spf_node);
90 RB_PROTOTYPE(isis_spf_nodes, isis_spf_node, entry, isis_spf_node_compare)
91 struct isis_spf_node {
92 RB_ENTRY(isis_spf_node) entry;
93
94 /* Node's System ID. */
95 uint8_t sysid[ISIS_SYS_ID_LEN];
96
97 /* Local adjacencies over which this node is reachable. */
98 struct list *adjacencies;
99
100 /* Best metric of all adjacencies used to reach this node. */
101 uint32_t best_metric;
102
103 struct {
104 /* Node's forward SPT. */
105 struct isis_spftree *spftree;
106
107 /* Node's reverse SPT. */
108 struct isis_spftree *spftree_reverse;
109
110 /* Node's P-space. */
111 struct isis_spf_nodes p_space;
112 } lfa;
113 };
114
115 enum lfa_protection_type {
116 LFA_LINK_PROTECTION = 1,
117 LFA_NODE_PROTECTION,
118 };
119
120 struct lfa_protected_resource {
121 /* The protection type. */
122 enum lfa_protection_type type;
123
124 /* The protected adjacency (might be a pseudonode). */
125 uint8_t adjacency[ISIS_SYS_ID_LEN + 1];
126
127 /* List of nodes reachable over the protected interface. */
128 struct isis_spf_nodes nodes;
129 };
130
131 /* Forward declaration(s). */
132 struct isis_vertex;
133
134 /* Prototypes. */
135 void isis_spf_node_list_init(struct isis_spf_nodes *nodes);
136 void isis_spf_node_list_clear(struct isis_spf_nodes *nodes);
137 struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes,
138 const uint8_t *sysid);
139 struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes,
140 const uint8_t *sysid);
141 void isis_lfa_tiebreakers_init(struct isis_area *area, int level);
142 void isis_lfa_tiebreakers_clear(struct isis_area *area, int level);
143 struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area,
144 int level, uint8_t index,
145 enum lfa_tiebreaker_type type);
146 void isis_lfa_tiebreaker_delete(struct isis_area *area, int level,
147 struct lfa_tiebreaker *tie_b);
148 void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level);
149 void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level);
150 void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level,
151 const char *ifname);
152 void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level,
153 const char *ifname);
154 bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level,
155 const char *ifname);
156 bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree,
157 const uint8_t *id);
158 bool isis_lfa_excise_node_check(const struct isis_spftree *spftree,
159 const uint8_t *id);
160 struct isis_spftree *isis_spf_reverse_run(const struct isis_spftree *spftree);
161 int isis_spf_run_neighbors(struct isis_spftree *spftree);
162 int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa,
163 struct zapi_rlfa_response *response);
164 void isis_rlfa_deactivate(struct isis_spftree *spftree, struct rlfa *rlfa);
165 void isis_rlfa_list_init(struct isis_spftree *spftree);
166 void isis_rlfa_list_clear(struct isis_spftree *spftree);
167 void isis_rlfa_process_ldp_response(struct zapi_rlfa_response *response);
168 void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info *info);
169 void isis_rlfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex);
170 struct isis_spftree *isis_rlfa_compute(struct isis_area *area,
171 struct isis_spftree *spftree,
172 struct isis_spftree *spftree_reverse,
173 uint32_t max_metric,
174 struct lfa_protected_resource *resource);
175 void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit,
176 struct isis_spftree *spftree,
177 struct lfa_protected_resource *resource);
178 void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree);
179 int isis_tilfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex);
180 struct isis_spftree *
181 isis_tilfa_compute(struct isis_area *area, struct isis_spftree *spftree,
182 struct isis_spftree *spftree_reverse,
183 struct lfa_protected_resource *protected_resource);
184
185 #endif /* _FRR_ISIS_LFA_H */