]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_lfa.h
Merge pull request #6950 from opensourcerouting/bfd-distributed-v3
[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
25 PREDECL_RBTREE_UNIQ(lfa_tiebreaker_tree)
26
27 enum lfa_tiebreaker_type {
28 LFA_TIEBREAKER_DOWNSTREAM = 0,
29 LFA_TIEBREAKER_LOWEST_METRIC,
30 LFA_TIEBREAKER_NODE_PROTECTING,
31 };
32
33 struct lfa_tiebreaker {
34 struct lfa_tiebreaker_tree_item entry;
35 uint8_t index;
36 enum lfa_tiebreaker_type type;
37 struct isis_area *area;
38 };
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,
42 lfa_tiebreaker_cmp)
43
44 enum isis_tilfa_sid_type {
45 TILFA_SID_PREFIX = 1,
46 TILFA_SID_ADJ,
47 };
48
49 struct isis_tilfa_sid {
50 enum isis_tilfa_sid_type type;
51 union {
52 struct {
53 uint32_t value;
54 bool remote;
55 uint8_t remote_sysid[ISIS_SYS_ID_LEN];
56 } index;
57 mpls_label_t label;
58 } value;
59 };
60
61 enum spf_prefix_priority {
62 SPF_PREFIX_PRIO_CRITICAL = 0,
63 SPF_PREFIX_PRIO_HIGH,
64 SPF_PREFIX_PRIO_MEDIUM,
65 SPF_PREFIX_PRIO_LOW,
66 SPF_PREFIX_PRIO_MAX,
67 };
68
69 struct spf_prefix_priority_acl {
70 char *name;
71 struct access_list *list_v4;
72 struct access_list *list_v6;
73 };
74
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;
79
80 /* Node's System ID. */
81 uint8_t sysid[ISIS_SYS_ID_LEN];
82
83 /* Local adjacencies over which this node is reachable. */
84 struct list *adjacencies;
85
86 /* Best metric of all adjacencies used to reach this node. */
87 uint32_t best_metric;
88
89 struct {
90 /* Node's forward SPT. */
91 struct isis_spftree *spftree;
92
93 /* Node's reverse SPT. */
94 struct isis_spftree *spftree_reverse;
95
96 /* Node's P-space. */
97 struct isis_spf_nodes p_space;
98 } lfa;
99 };
100
101 enum lfa_protection_type {
102 LFA_LINK_PROTECTION = 1,
103 LFA_NODE_PROTECTION,
104 };
105
106 struct lfa_protected_resource {
107 /* The protection type. */
108 enum lfa_protection_type type;
109
110 /* The protected adjacency (might be a pseudonode). */
111 uint8_t adjacency[ISIS_SYS_ID_LEN + 1];
112
113 /* List of nodes reachable over the protected interface. */
114 struct isis_spf_nodes nodes;
115 };
116
117 /* Forward declaration(s). */
118 struct isis_vertex;
119
120 /* Prototypes. */
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,
137 const char *ifname);
138 void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level,
139 const char *ifname);
140 bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level,
141 const char *ifname);
142 bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree,
143 const uint8_t *id);
144 bool isis_lfa_excise_node_check(const struct isis_spftree *spftree,
145 const uint8_t *id);
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);
157
158 #endif /* _FRR_ISIS_LFA_H */