]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_sr.h
lib, ospfd, ospf6d, zebra: add OSPF opaque route attributes
[mirror_frr.git] / isisd / isis_sr.h
CommitLineData
26f6acaf 1/*
f2333421 2 * This is an implementation of Segment Routing for IS-IS as per RFC 8667
26f6acaf 3 *
f2333421 4 * Copyright (C) 2019 Orange http://www.orange.com
26f6acaf
RW
5 *
6 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
7 * Contributor: Renato Westphal <renato@opensourcerouting.org> for NetDEF
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _FRR_ISIS_SR_H
25#define _FRR_ISIS_SR_H
26
27#include "lib/linklist.h"
28#include "lib/mpls.h"
29#include "lib/nexthop.h"
30#include "lib/typesafe.h"
31
32#include "isisd/isis_tlvs.h"
33
34/*
35 * Segment Routing information is transported through the following Sub-TLVs:
36 *
37 * Sub-TLV Name Value TLVs
38 * ---------------------------------------------------------------------
39 * SID Label 1
40 *
41 * Prefix Segment Identifier 3 135, 235, 236 and 237
42 *
43 * Adjacency Segment Identifier 31 22, 23, 141, 222 and 223
44 * LAN Adjacency Segment Identifier 32 22, 23, 141, 222 and 223
45 *
46 * Segment Routing Capability 2 242
47 * Segment Routing Algorithm 19 242
48 * Node Maximum Stack Depth (MSD) 23 242
49 *
50 * Sub-TLV definitions, serialization and de-serialization are defined
51 * in isis_tlvs.[c,h].
52 */
53
54#define SRGB_LOWER_BOUND 16000
55#define SRGB_UPPER_BOUND 23999
d8391312
OD
56#define SRLB_LOWER_BOUND 15000
57#define SRLB_UPPER_BOUND 15999
26f6acaf 58
f2333421 59/* Segment Routing Data Base (SRDB) RB-Tree structure */
960b9a53 60PREDECL_RBTREE_UNIQ(srdb_prefix_cfg);
26f6acaf 61
d47d6089
RW
62/*
63 * Segment Routing Prefix-SID information.
64 *
65 * This structure is intended to be embedded inside other structures that
66 * might or might not contain Prefix-SID information.
67 */
68struct isis_sr_psid_info {
69 /* Prefix-SID Sub-TLV information. */
70 struct isis_prefix_sid sid;
71
72 /* Resolved input/output label. */
73 mpls_label_t label;
74
75 /* Indicates whether the Prefix-SID is present or not. */
76 bool present;
77};
78
d8391312
OD
79/* Segment Routing Local Block allocation */
80struct sr_local_block {
58fbcdf2 81 bool active;
d8391312
OD
82 uint32_t start;
83 uint32_t end;
84 uint32_t current;
85 uint32_t max_block;
86 uint64_t *used_mark;
87};
88#define SRLB_BLOCK_SIZE 64
89
f2333421 90/* Segment Routing Adjacency-SID type. */
26f6acaf
RW
91enum sr_adj_type {
92 ISIS_SR_ADJ_NORMAL = 0,
93 ISIS_SR_LAN_BACKUP,
94};
95
f2333421 96/* Segment Routing Adjacency. */
26f6acaf
RW
97struct sr_adjacency {
98 /* Adjacency type. */
99 enum sr_adj_type type;
100
054fda12
RW
101 /* Adjacency-SID input label. */
102 mpls_label_t input_label;
103
f2333421 104 /* Adjacency-SID nexthop information. */
26f6acaf
RW
105 struct {
106 int family;
107 union g_addr address;
26f6acaf
RW
108 } nexthop;
109
054fda12
RW
110 /* Adjacency-SID TI-LFA backup nexthops. */
111 struct list *backup_nexthops;
112
f2333421 113 /* (LAN-)Adjacency-SID Sub-TLV. */
26f6acaf
RW
114 union {
115 struct isis_adj_sid *adj_sid;
116 struct isis_lan_adj_sid *ladj_sid;
117 } u;
118
119 /* Back pointer to IS-IS adjacency. */
120 struct isis_adjacency *adj;
121};
122
f2333421 123/* SID type. NOTE: these values must be in sync with the YANG module. */
26f6acaf
RW
124enum sr_sid_value_type {
125 SR_SID_VALUE_TYPE_INDEX = 0,
126 SR_SID_VALUE_TYPE_ABSOLUTE = 1,
127};
128
b407c77a
OD
129#define IS_SID_VALUE(flag) CHECK_FLAG(flag, ISIS_PREFIX_SID_VALUE)
130
f2333421 131/* Last Hop Behavior. NOTE: these values must be in sync with the YANG module */
26f6acaf
RW
132enum sr_last_hop_behavior {
133 SR_LAST_HOP_BEHAVIOR_EXP_NULL = 0,
134 SR_LAST_HOP_BEHAVIOR_NO_PHP = 1,
135 SR_LAST_HOP_BEHAVIOR_PHP = 2,
136};
137
f2333421 138/* Segment Routing Prefix-SID configuration. */
26f6acaf 139struct sr_prefix_cfg {
f2333421 140 /* SRDB RB-tree entry. */
cab10e86 141 struct srdb_prefix_cfg_item entry;
26f6acaf
RW
142
143 /* IP prefix. */
144 struct prefix prefix;
145
146 /* SID value. */
147 uint32_t sid;
148
149 /* SID value type. */
150 enum sr_sid_value_type sid_type;
151
152 /* SID last hop behavior. */
153 enum sr_last_hop_behavior last_hop_behavior;
154
01983712
RW
155 /* Indicates whether the node flag must be explicitly unset. */
156 bool n_flag_clear;
157
26f6acaf
RW
158 /* Does this Prefix-SID refer to a loopback address (Node-SID)? */
159 bool node_sid;
160
161 /* Backpointer to IS-IS area. */
162 struct isis_area *area;
163};
164
f2333421 165/* Per-area IS-IS Segment Routing Data Base (SRDB). */
26f6acaf 166struct isis_sr_db {
f2333421 167 /* Global Operational status of Segment Routing. */
26f6acaf
RW
168 bool enabled;
169
58fbcdf2
OD
170 /* Thread timer to start Label Manager */
171 struct thread *t_start_lm;
172
f2333421 173 /* List of local Adjacency-SIDs. */
26f6acaf
RW
174 struct list *adj_sids;
175
58fbcdf2 176 /* Management of SRLB & SRGB allocation */
d8391312 177 struct sr_local_block srlb;
58fbcdf2 178 bool srgb_active;
d8391312 179
f2333421 180 /* Area Segment Routing configuration. */
26f6acaf
RW
181 struct {
182 /* Administrative status of Segment Routing. */
183 bool enabled;
184
185 /* Segment Routing Global Block lower & upper bound. */
186 uint32_t srgb_lower_bound;
187 uint32_t srgb_upper_bound;
188
d8391312
OD
189 /* Segment Routing Local Block lower & upper bound. */
190 uint32_t srlb_lower_bound;
191 uint32_t srlb_upper_bound;
192
26f6acaf
RW
193 /* Maximum SID Depth supported by the node. */
194 uint8_t msd;
195
196 /* Prefix-SID mappings. */
cab10e86 197 struct srdb_prefix_cfg_head prefix_sids;
26f6acaf
RW
198 } config;
199};
200
201/* Prototypes. */
d47d6089
RW
202extern struct isis_sr_block *isis_sr_find_srgb(struct lspdb_head *lspdb,
203 const uint8_t *sysid);
204extern mpls_label_t sr_prefix_in_label(struct isis_area *area,
205 struct isis_prefix_sid *psid,
206 bool local);
207extern mpls_label_t sr_prefix_out_label(struct lspdb_head *lspdb, int family,
208 struct isis_prefix_sid *psid,
209 const uint8_t *nh_sysid, bool last_hop);
26f6acaf
RW
210extern int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound,
211 uint32_t upper_bound);
d8391312
OD
212extern int isis_sr_cfg_srlb_update(struct isis_area *area, uint32_t lower_bound,
213 uint32_t upper_bound);
26f6acaf
RW
214extern struct sr_prefix_cfg *
215isis_sr_cfg_prefix_add(struct isis_area *area, const struct prefix *prefix);
216extern void isis_sr_cfg_prefix_del(struct sr_prefix_cfg *pcfg);
217extern struct sr_prefix_cfg *
218isis_sr_cfg_prefix_find(struct isis_area *area, union prefixconstptr prefix);
219extern void isis_sr_prefix_cfg2subtlv(const struct sr_prefix_cfg *pcfg,
220 bool external,
221 struct isis_prefix_sid *psid);
054fda12
RW
222extern void sr_adj_sid_add_single(struct isis_adjacency *adj, int family,
223 bool backup, struct list *nexthops);
224extern struct sr_adjacency *isis_sr_adj_sid_find(struct isis_adjacency *adj,
225 int family,
226 enum sr_adj_type type);
227extern void isis_area_delete_backup_adj_sids(struct isis_area *area, int level);
d47d6089
RW
228extern char *sr_op2str(char *buf, size_t size, mpls_label_t label_in,
229 mpls_label_t label_out);
26f6acaf
RW
230extern int isis_sr_start(struct isis_area *area);
231extern void isis_sr_stop(struct isis_area *area);
232extern void isis_sr_area_init(struct isis_area *area);
233extern void isis_sr_area_term(struct isis_area *area);
234extern void isis_sr_init(void);
235extern void isis_sr_term(void);
236
237#endif /* _FRR_ISIS_SR_H */