]> git.proxmox.com Git - mirror_frr.git/blame - pathd/path_pcep.h
pathd: Handle PCInitiated messages, thread controller. (2/4)
[mirror_frr.git] / pathd / path_pcep.h
CommitLineData
efba0985
SM
1/*
2 * Copyright (C) 2020 NetDEF, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef _PATH_PCEP_H_
20#define _PATH_PCEP_H_
21
22#include <stdbool.h>
23#include <debug.h>
24#include <netinet/tcp.h>
c7479286 25#include "memory.h"
74971473
JG
26#include "pceplib/pcep_utils_logging.h"
27#include "pceplib/pcep_pcc_api.h"
efba0985
SM
28#include "mpls.h"
29#include "pathd/pathd.h"
c7479286
DL
30
31DECLARE_MTYPE(PCEP);
efba0985
SM
32
33#define PCEP_DEFAULT_PORT 4189
34#define MAX_PCC 32
35#define MAX_PCE 32
36#define MAX_TAG_SIZE 50
37#define PCEP_DEBUG_MODE_BASIC 0x01
38#define PCEP_DEBUG_MODE_PATH 0x02
39#define PCEP_DEBUG_MODE_PCEP 0x04
40#define PCEP_DEBUG_MODE_PCEPLIB 0x08
41#define PCEP_DEBUG(fmt, ...) \
42 do { \
43 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC)) \
44 DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
45 } while (0)
46#define PCEP_DEBUG_PATH(fmt, ...) \
47 do { \
48 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH)) \
49 DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
50 } while (0)
51#define PCEP_DEBUG_PCEP(fmt, ...) \
52 do { \
53 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP)) \
54 DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
55 } while (0)
56#define PCEP_DEBUG_PCEPLIB(priority, fmt, ...) \
57 do { \
58 switch (priority) { \
59 case LOG_DEBUG: \
60 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
61 PCEP_DEBUG_MODE_PCEPLIB)) \
62 DEBUGD(&pcep_g->dbg, "pcep: " fmt, \
63 ##__VA_ARGS__); \
64 break; \
65 case LOG_INFO: \
66 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
67 PCEP_DEBUG_MODE_PCEPLIB)) \
68 DEBUGI(&pcep_g->dbg, "pcep: " fmt, \
69 ##__VA_ARGS__); \
70 break; \
71 case LOG_NOTICE: \
72 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
73 PCEP_DEBUG_MODE_PCEPLIB)) \
74 DEBUGN(&pcep_g->dbg, "pcep: " fmt, \
75 ##__VA_ARGS__); \
76 break; \
77 case LOG_WARNING: \
78 case LOG_ERR: \
79 default: \
80 zlog(priority, "pcep: " fmt, ##__VA_ARGS__); \
81 break; \
82 } \
83 } while (0)
84
85struct pcep_config_group_opts {
86 char name[64];
2a034138 87 char tcp_md5_auth[PCEP_MD5SIG_MAXKEYLEN];
efba0985
SM
88 struct ipaddr source_ip;
89 short source_port;
90 bool draft07;
91 bool pce_initiated;
92 int keep_alive_seconds;
93 int min_keep_alive_seconds;
94 int max_keep_alive_seconds;
95 int dead_timer_seconds;
96 int min_dead_timer_seconds;
97 int max_dead_timer_seconds;
98 int pcep_request_time_seconds;
99 int session_timeout_inteval_seconds;
100 int delegation_timeout_seconds;
101};
102
103struct pce_opts {
104 struct ipaddr addr;
105 short port;
106 char pce_name[64];
107 struct pcep_config_group_opts config_opts;
108 uint8_t precedence; /* Multi-PCE precedence */
109};
110
111struct pcc_opts {
112 struct ipaddr addr;
113 short port;
114 short msd;
115};
116
117/* Encapsulate the pce_opts with needed CLI information */
118struct pce_opts_cli {
119 struct pce_opts pce_opts;
120 char config_group_name[64];
121 /* These are the values configured in the pcc-peer sub-commands.
122 * These need to be stored for later merging. Notice, it could
123 * be that not all of them are set. */
124 struct pcep_config_group_opts pce_config_group_opts;
125 /* The pce_opts->config_opts will be a merge of the default values,
126 * optional config_group values (which overwrite default values),
127 * and any values configured in the pce sub-commands (which overwrite
128 * both default and config_group values). This flag indicates of the
129 * values need to be merged or not. */
130 bool merged;
131};
132
133struct lsp_nb_key {
134 uint32_t color;
135 struct ipaddr endpoint;
136 uint32_t preference;
137};
138
139struct sid_mpls {
140 mpls_label_t label;
141 uint8_t traffic_class;
142 bool is_bottom;
143 uint8_t ttl;
144};
145
146struct pcep_caps {
147 bool is_stateful;
148 /* If we know the objective functions supported by the PCE.
149 * If we don't know, it doesn't mean the PCE doesn't support any */
150 bool supported_ofs_are_known;
151 /* Defined if we know which objective funtions are supported by the PCE.
152 * One bit per objective function, the bit index being equal to
153 * enum pcep_objfun_type values: bit 0 is not used, bit 1 is
154 * PCEP_OBJFUN_MCP, up to bit 17 that is PCEP_OBJFUN_MSN */
155 uint32_t supported_ofs;
156};
157
158union sid {
159 uint32_t value;
160 struct sid_mpls mpls;
161};
162
163struct nai {
164 /* NAI type */
165 enum pcep_sr_subobj_nai type;
166 /* Local IP address*/
167 struct ipaddr local_addr;
168 /* Local interface identifier if the NAI is an unnumbered adjacency */
169 uint32_t local_iface;
170 /* Remote address if the NAI is an adjacency */
171 struct ipaddr remote_addr;
172 /* Remote interface identifier if the NAI is an unnumbered adjacency */
173 uint32_t remote_iface;
174};
175
176struct path_hop {
177 /* Pointer to the next hop in the path */
178 struct path_hop *next;
179 /* Indicateif this ia a loose or strict hop */
180 bool is_loose;
181 /* Indicate if there is an SID for the hop */
182 bool has_sid;
183 /* Indicate if the hop as a MPLS label */
184 bool is_mpls;
185 /* Indicate if the MPLS label has extra attributes (TTL, class..)*/
186 bool has_attribs;
187 /* Hop's SID if available */
188 union sid sid;
189 /* Indicate if there is a NAI for this hop */
190 bool has_nai;
191 /* NAI if available */
192 struct nai nai;
193};
194
195struct path_metric {
196 /* Pointer to the next metric */
197 struct path_metric *next;
198 /* The metric type */
199 enum pcep_metric_types type;
200 /* If the metric should be enforced */
201 bool enforce;
202 /* If the metric value is bound (a maximum) */
203 bool is_bound;
204 /* If the metric value is computed */
205 bool is_computed;
206 /* The metric value */
207 float value;
208};
209
210struct path {
211 /* Both the nbkey and the plspid are keys comming from the PCC,
212 but the PCE is only using the plspid. The missing key is looked up by
213 the PCC so we always have both */
214
215 /* The northbound key identifying this path */
216 struct lsp_nb_key nbkey;
217 /* The generated unique PLSP identifier for this path.
218 See draft-ietf-pce-stateful-pce */
219 uint32_t plsp_id;
220
221 /* The transport address the path is comming from, PCE or PCC*/
222 struct ipaddr sender;
223 /* The pcc protocol address, must be the same family as the endpoint */
224 struct ipaddr pcc_addr;
225
226 /* The identifier of the PCC the path is for/from. If 0 it is undefined,
227 meaning it hasn't be set yet or is for all the PCC */
228 int pcc_id;
229
230 /* The origin of the path creation */
231 enum srte_protocol_origin create_origin;
232 /* The origin of the path modification */
233 enum srte_protocol_origin update_origin;
234 /* The identifier of the entity that originated the path */
235 const char *originator;
236 /* The type of the path, for PCE initiated or updated path it is always
237 SRTE_CANDIDATE_TYPE_DYNAMIC */
238 enum srte_candidate_type type;
239
240 /* The following data comes from either the PCC or the PCE if available
241 */
242
243 /* Path's binding SID */
244 mpls_label_t binding_sid;
245 /* The name of the path */
246 const char *name;
247 /* The request identifier from the PCE, when getting a path from the
248 PCE. See draft-ietf-pce-stateful-pce */
249 uint32_t srp_id;
250 /* The request identifier from the PCC , when getting a path from the
251 PCE after a computation request. See rfc5440, section-7.4 */
252 uint32_t req_id;
253 /* The operational status of the path */
254 enum pcep_lsp_operational_status status;
255 /* If true, the receiver (PCC) must remove the path.
256 See draft-ietf-pce-pce-initiated-lsp */
257 bool do_remove;
258 /* Indicate the given path was removed by the PCC.
259 See draft-ietf-pce-stateful-pce, section-7.3, flag R */
260 bool was_removed;
261 /* Indicate the path is part of the synchronization process.
262 See draft-ietf-pce-stateful-pce, section-7.3, flag S */
263 bool is_synching;
264 /* Indicate if the path bandwidth requirment is defined */
265 bool has_bandwidth;
266 /* Indicate if the bandwidth requirment should be enforced */
267 bool enforce_bandwidth;
268 /* Path required bandwidth if defined */
269 float bandwidth;
270 /* Specify the list of hop defining the path */
271 struct path_hop *first_hop;
272 /* Specify the list of metrics */
273 struct path_metric *first_metric;
274 /* Indicate if the path has a PCC-defined objective function */
275 bool has_pcc_objfun;
276 /* Indicate the PCC-defined objective function is required */
277 bool enforce_pcc_objfun;
278 /* PCC-defined Objective Function */
279 enum objfun_type pcc_objfun;
280 /* Indicate if the path has a PCE-defined objective function */
281 bool has_pce_objfun;
282 /* PCE-defined Objective Function */
283 enum objfun_type pce_objfun;
284 /* Indicate if some affinity filters are defined */
285 bool has_affinity_filters;
286 /* Affinity attribute filters indexed by enum affinity_filter_type - 1
287 */
288 uint32_t affinity_filters[MAX_AFFINITY_FILTER_TYPE];
289
290 /* The following data need to be specialized for a given PCE */
291
292 /* Indicate the path is delegated to the PCE.
293 See draft-ietf-pce-stateful-pce, section-7.3, flag D */
294 bool is_delegated;
295 /* Indicate if the PCE wants the path to get active.
296 See draft-ietf-pce-stateful-pce, section-7.3, flag A */
297 bool go_active;
298 /* Indicate the given path was created by the PCE,
299 See draft-ietf-pce-pce-initiated-lsp, section-5.3.1, flag C */
300 bool was_created;
301
302 /* The following data is defined for comnputation replies */
303
304 /* Indicate that no path could be computed */
305 bool no_path;
306};
307
308struct pcep_glob {
309 struct debug dbg;
310 struct thread_master *master;
311 struct frr_pthread *fpt;
312 uint8_t num_pce_opts_cli;
313 struct pce_opts_cli *pce_opts_cli[MAX_PCE];
314 uint8_t num_config_group_opts;
315 struct pcep_config_group_opts *config_group_opts[MAX_PCE];
316};
317
318extern struct pcep_glob *pcep_g;
319
320/* Path Helper Functions */
321struct path *pcep_new_path(void);
322struct path_hop *pcep_new_hop(void);
323struct path_metric *pcep_new_metric(void);
324struct path *pcep_copy_path(struct path *path);
325void pcep_free_path(struct path *path);
326
327
328#endif // _PATH_PCEP_H_