]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_lfa.h
Merge pull request #9543 from donaldsharp/actually_set_mpls_data
[mirror_frr.git] / isisd / isis_lfa.h
CommitLineData
c951ee6e
RW
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
e886416f 23#include "lib/typesafe.h"
16fe8cff 24#include "lib/zclient.h"
66b9a381
DL
25#include "lib/memory.h"
26
27DECLARE_MTYPE(ISIS_NEXTHOP_LABELS);
e886416f 28
960b9a53
DL
29PREDECL_RBTREE_UNIQ(lfa_tiebreaker_tree);
30PREDECL_RBTREE_UNIQ(rlfa_tree);
e886416f
RW
31
32enum lfa_tiebreaker_type {
33 LFA_TIEBREAKER_DOWNSTREAM = 0,
34 LFA_TIEBREAKER_LOWEST_METRIC,
35 LFA_TIEBREAKER_NODE_PROTECTING,
36};
37
38struct 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};
44int lfa_tiebreaker_cmp(const struct lfa_tiebreaker *a,
45 const struct lfa_tiebreaker *b);
46DECLARE_RBTREE_UNIQ(lfa_tiebreaker_tree, struct lfa_tiebreaker, entry,
960b9a53 47 lfa_tiebreaker_cmp);
e886416f 48
16fe8cff
RW
49struct rlfa {
50 struct rlfa_tree_item entry;
51 struct prefix prefix;
52 struct isis_vertex *vertex;
53 struct in_addr pq_address;
54};
55int rlfa_cmp(const struct rlfa *a, const struct rlfa *b);
960b9a53 56DECLARE_RBTREE_UNIQ(rlfa_tree, struct rlfa, entry, rlfa_cmp);
16fe8cff 57
c951ee6e
RW
58enum isis_tilfa_sid_type {
59 TILFA_SID_PREFIX = 1,
60 TILFA_SID_ADJ,
61};
62
63struct isis_tilfa_sid {
64 enum isis_tilfa_sid_type type;
65 union {
4c75f7c7
RW
66 struct {
67 uint32_t value;
68 bool remote;
69 uint8_t remote_sysid[ISIS_SYS_ID_LEN];
70 } index;
c951ee6e
RW
71 mpls_label_t label;
72 } value;
73};
74
e886416f
RW
75enum 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
83struct spf_prefix_priority_acl {
84 char *name;
85 struct access_list *list_v4;
86 struct access_list *list_v6;
87};
88
c951ee6e
RW
89RB_HEAD(isis_spf_nodes, isis_spf_node);
90RB_PROTOTYPE(isis_spf_nodes, isis_spf_node, entry, isis_spf_node_compare)
91struct 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
115enum lfa_protection_type {
116 LFA_LINK_PROTECTION = 1,
117 LFA_NODE_PROTECTION,
118};
119
120struct 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). */
132struct isis_vertex;
133
134/* Prototypes. */
135void isis_spf_node_list_init(struct isis_spf_nodes *nodes);
136void isis_spf_node_list_clear(struct isis_spf_nodes *nodes);
137struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes,
138 const uint8_t *sysid);
139struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes,
140 const uint8_t *sysid);
e886416f
RW
141void isis_lfa_tiebreakers_init(struct isis_area *area, int level);
142void isis_lfa_tiebreakers_clear(struct isis_area *area, int level);
143struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area,
144 int level, uint8_t index,
145 enum lfa_tiebreaker_type type);
146void isis_lfa_tiebreaker_delete(struct isis_area *area, int level,
147 struct lfa_tiebreaker *tie_b);
148void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level);
149void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level);
150void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level,
151 const char *ifname);
152void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level,
153 const char *ifname);
154bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level,
155 const char *ifname);
c951ee6e
RW
156bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree,
157 const uint8_t *id);
158bool isis_lfa_excise_node_check(const struct isis_spftree *spftree,
159 const uint8_t *id);
160struct isis_spftree *isis_spf_reverse_run(const struct isis_spftree *spftree);
161int isis_spf_run_neighbors(struct isis_spftree *spftree);
16fe8cff
RW
162int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa,
163 struct zapi_rlfa_response *response);
164void isis_rlfa_deactivate(struct isis_spftree *spftree, struct rlfa *rlfa);
165void isis_rlfa_list_init(struct isis_spftree *spftree);
166void isis_rlfa_list_clear(struct isis_spftree *spftree);
167void isis_rlfa_process_ldp_response(struct zapi_rlfa_response *response);
168void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info *info);
169void isis_rlfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex);
170struct 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);
e886416f
RW
175void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit,
176 struct isis_spftree *spftree,
177 struct lfa_protected_resource *resource);
c951ee6e 178void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree);
e886416f 179int isis_tilfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex);
c951ee6e
RW
180struct isis_spftree *
181isis_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 */