]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
c951ee6e RW |
2 | /* |
3 | * Copyright (C) 2020 NetDEF, Inc. | |
4 | * Renato Westphal | |
c951ee6e RW |
5 | */ |
6 | ||
7 | #ifndef _FRR_ISIS_LFA_H | |
8 | #define _FRR_ISIS_LFA_H | |
9 | ||
e886416f | 10 | #include "lib/typesafe.h" |
16fe8cff | 11 | #include "lib/zclient.h" |
66b9a381 DL |
12 | #include "lib/memory.h" |
13 | ||
14 | DECLARE_MTYPE(ISIS_NEXTHOP_LABELS); | |
e886416f | 15 | |
960b9a53 DL |
16 | PREDECL_RBTREE_UNIQ(lfa_tiebreaker_tree); |
17 | PREDECL_RBTREE_UNIQ(rlfa_tree); | |
e886416f RW |
18 | |
19 | enum lfa_tiebreaker_type { | |
20 | LFA_TIEBREAKER_DOWNSTREAM = 0, | |
21 | LFA_TIEBREAKER_LOWEST_METRIC, | |
22 | LFA_TIEBREAKER_NODE_PROTECTING, | |
23 | }; | |
24 | ||
25 | struct lfa_tiebreaker { | |
26 | struct lfa_tiebreaker_tree_item entry; | |
27 | uint8_t index; | |
28 | enum lfa_tiebreaker_type type; | |
29 | struct isis_area *area; | |
30 | }; | |
31 | int lfa_tiebreaker_cmp(const struct lfa_tiebreaker *a, | |
32 | const struct lfa_tiebreaker *b); | |
33 | DECLARE_RBTREE_UNIQ(lfa_tiebreaker_tree, struct lfa_tiebreaker, entry, | |
960b9a53 | 34 | lfa_tiebreaker_cmp); |
e886416f | 35 | |
16fe8cff RW |
36 | struct rlfa { |
37 | struct rlfa_tree_item entry; | |
38 | struct prefix prefix; | |
39 | struct isis_vertex *vertex; | |
40 | struct in_addr pq_address; | |
41 | }; | |
42 | int rlfa_cmp(const struct rlfa *a, const struct rlfa *b); | |
960b9a53 | 43 | DECLARE_RBTREE_UNIQ(rlfa_tree, struct rlfa, entry, rlfa_cmp); |
16fe8cff | 44 | |
c951ee6e RW |
45 | enum isis_tilfa_sid_type { |
46 | TILFA_SID_PREFIX = 1, | |
47 | TILFA_SID_ADJ, | |
48 | }; | |
49 | ||
50 | struct isis_tilfa_sid { | |
51 | enum isis_tilfa_sid_type type; | |
52 | union { | |
4c75f7c7 RW |
53 | struct { |
54 | uint32_t value; | |
55 | bool remote; | |
56 | uint8_t remote_sysid[ISIS_SYS_ID_LEN]; | |
57 | } index; | |
c951ee6e RW |
58 | mpls_label_t label; |
59 | } value; | |
60 | }; | |
61 | ||
e886416f RW |
62 | enum spf_prefix_priority { |
63 | SPF_PREFIX_PRIO_CRITICAL = 0, | |
64 | SPF_PREFIX_PRIO_HIGH, | |
65 | SPF_PREFIX_PRIO_MEDIUM, | |
66 | SPF_PREFIX_PRIO_LOW, | |
67 | SPF_PREFIX_PRIO_MAX, | |
68 | }; | |
69 | ||
70 | struct spf_prefix_priority_acl { | |
71 | char *name; | |
72 | struct access_list *list_v4; | |
73 | struct access_list *list_v6; | |
74 | }; | |
75 | ||
c951ee6e RW |
76 | RB_HEAD(isis_spf_nodes, isis_spf_node); |
77 | RB_PROTOTYPE(isis_spf_nodes, isis_spf_node, entry, isis_spf_node_compare) | |
78 | struct isis_spf_node { | |
79 | RB_ENTRY(isis_spf_node) entry; | |
80 | ||
81 | /* Node's System ID. */ | |
82 | uint8_t sysid[ISIS_SYS_ID_LEN]; | |
83 | ||
84 | /* Local adjacencies over which this node is reachable. */ | |
85 | struct list *adjacencies; | |
86 | ||
87 | /* Best metric of all adjacencies used to reach this node. */ | |
88 | uint32_t best_metric; | |
89 | ||
90 | struct { | |
91 | /* Node's forward SPT. */ | |
92 | struct isis_spftree *spftree; | |
93 | ||
94 | /* Node's reverse SPT. */ | |
95 | struct isis_spftree *spftree_reverse; | |
96 | ||
97 | /* Node's P-space. */ | |
98 | struct isis_spf_nodes p_space; | |
99 | } lfa; | |
100 | }; | |
101 | ||
102 | enum lfa_protection_type { | |
103 | LFA_LINK_PROTECTION = 1, | |
104 | LFA_NODE_PROTECTION, | |
105 | }; | |
106 | ||
107 | struct lfa_protected_resource { | |
108 | /* The protection type. */ | |
109 | enum lfa_protection_type type; | |
110 | ||
111 | /* The protected adjacency (might be a pseudonode). */ | |
112 | uint8_t adjacency[ISIS_SYS_ID_LEN + 1]; | |
113 | ||
114 | /* List of nodes reachable over the protected interface. */ | |
115 | struct isis_spf_nodes nodes; | |
116 | }; | |
117 | ||
118 | /* Forward declaration(s). */ | |
119 | struct isis_vertex; | |
120 | ||
121 | /* Prototypes. */ | |
122 | void isis_spf_node_list_init(struct isis_spf_nodes *nodes); | |
123 | void isis_spf_node_list_clear(struct isis_spf_nodes *nodes); | |
124 | struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes, | |
125 | const uint8_t *sysid); | |
126 | struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes, | |
127 | const uint8_t *sysid); | |
e886416f RW |
128 | void isis_lfa_tiebreakers_init(struct isis_area *area, int level); |
129 | void isis_lfa_tiebreakers_clear(struct isis_area *area, int level); | |
130 | struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area, | |
131 | int level, uint8_t index, | |
132 | enum lfa_tiebreaker_type type); | |
133 | void isis_lfa_tiebreaker_delete(struct isis_area *area, int level, | |
134 | struct lfa_tiebreaker *tie_b); | |
135 | void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level); | |
136 | void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level); | |
137 | void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, | |
138 | const char *ifname); | |
139 | void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level, | |
140 | const char *ifname); | |
141 | bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level, | |
142 | const char *ifname); | |
c951ee6e RW |
143 | bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree, |
144 | const uint8_t *id); | |
145 | bool isis_lfa_excise_node_check(const struct isis_spftree *spftree, | |
146 | const uint8_t *id); | |
147 | struct isis_spftree *isis_spf_reverse_run(const struct isis_spftree *spftree); | |
148 | int isis_spf_run_neighbors(struct isis_spftree *spftree); | |
16fe8cff RW |
149 | int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa, |
150 | struct zapi_rlfa_response *response); | |
151 | void isis_rlfa_deactivate(struct isis_spftree *spftree, struct rlfa *rlfa); | |
152 | void isis_rlfa_list_init(struct isis_spftree *spftree); | |
153 | void isis_rlfa_list_clear(struct isis_spftree *spftree); | |
154 | void isis_rlfa_process_ldp_response(struct zapi_rlfa_response *response); | |
155 | void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info *info); | |
156 | void isis_rlfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex); | |
157 | struct isis_spftree *isis_rlfa_compute(struct isis_area *area, | |
158 | struct isis_spftree *spftree, | |
159 | struct isis_spftree *spftree_reverse, | |
160 | uint32_t max_metric, | |
161 | struct lfa_protected_resource *resource); | |
e886416f RW |
162 | void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, |
163 | struct isis_spftree *spftree, | |
164 | struct lfa_protected_resource *resource); | |
c951ee6e | 165 | void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree); |
e886416f | 166 | int isis_tilfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex); |
c951ee6e RW |
167 | struct isis_spftree * |
168 | isis_tilfa_compute(struct isis_area *area, struct isis_spftree *spftree, | |
169 | struct isis_spftree *spftree_reverse, | |
170 | struct lfa_protected_resource *protected_resource); | |
171 | ||
172 | #endif /* _FRR_ISIS_LFA_H */ |