]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_lfa.h
Merge pull request #7206 from ckishimo/fix7086
[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 enum isis_tilfa_sid_type {
24 TILFA_SID_PREFIX = 1,
25 TILFA_SID_ADJ,
26 };
27
28 struct isis_tilfa_sid {
29 enum isis_tilfa_sid_type type;
30 union {
31 uint32_t index;
32 mpls_label_t label;
33 } value;
34 };
35
36 RB_HEAD(isis_spf_nodes, isis_spf_node);
37 RB_PROTOTYPE(isis_spf_nodes, isis_spf_node, entry, isis_spf_node_compare)
38 struct isis_spf_node {
39 RB_ENTRY(isis_spf_node) entry;
40
41 /* Node's System ID. */
42 uint8_t sysid[ISIS_SYS_ID_LEN];
43
44 /* Local adjacencies over which this node is reachable. */
45 struct list *adjacencies;
46
47 /* Best metric of all adjacencies used to reach this node. */
48 uint32_t best_metric;
49
50 struct {
51 /* Node's forward SPT. */
52 struct isis_spftree *spftree;
53
54 /* Node's reverse SPT. */
55 struct isis_spftree *spftree_reverse;
56
57 /* Node's P-space. */
58 struct isis_spf_nodes p_space;
59 } lfa;
60 };
61
62 enum lfa_protection_type {
63 LFA_LINK_PROTECTION = 1,
64 LFA_NODE_PROTECTION,
65 };
66
67 struct lfa_protected_resource {
68 /* The protection type. */
69 enum lfa_protection_type type;
70
71 /* The protected adjacency (might be a pseudonode). */
72 uint8_t adjacency[ISIS_SYS_ID_LEN + 1];
73
74 /* List of nodes reachable over the protected interface. */
75 struct isis_spf_nodes nodes;
76 };
77
78 /* Forward declaration(s). */
79 struct isis_vertex;
80
81 /* Prototypes. */
82 void isis_spf_node_list_init(struct isis_spf_nodes *nodes);
83 void isis_spf_node_list_clear(struct isis_spf_nodes *nodes);
84 struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes,
85 const uint8_t *sysid);
86 struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes,
87 const uint8_t *sysid);
88 bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree,
89 const uint8_t *id);
90 bool isis_lfa_excise_node_check(const struct isis_spftree *spftree,
91 const uint8_t *id);
92 struct isis_spftree *isis_spf_reverse_run(const struct isis_spftree *spftree);
93 int isis_spf_run_neighbors(struct isis_spftree *spftree);
94 void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree);
95 int isis_lfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex);
96 struct isis_spftree *
97 isis_tilfa_compute(struct isis_area *area, struct isis_spftree *spftree,
98 struct isis_spftree *spftree_reverse,
99 struct lfa_protected_resource *protected_resource);
100
101 #endif /* _FRR_ISIS_LFA_H */