2 * Copyright (C) 2020 NetDEF, Inc.
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)
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
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
24 #include <netinet/tcp.h>
25 #include <pcep_utils_logging.h>
26 #include <pcep_pcc_api.h>
28 #include "pathd/pathd.h"
29 #include "pathd/path_pcep_memory.h"
31 #define PCEP_DEFAULT_PORT 4189
34 #define MAX_TAG_SIZE 50
35 #define PCEP_DEBUG_MODE_BASIC 0x01
36 #define PCEP_DEBUG_MODE_PATH 0x02
37 #define PCEP_DEBUG_MODE_PCEP 0x04
38 #define PCEP_DEBUG_MODE_PCEPLIB 0x08
39 #define PCEP_DEBUG(fmt, ...) \
41 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC)) \
42 DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
44 #define PCEP_DEBUG_PATH(fmt, ...) \
46 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH)) \
47 DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
49 #define PCEP_DEBUG_PCEP(fmt, ...) \
51 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP)) \
52 DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
54 #define PCEP_DEBUG_PCEPLIB(priority, fmt, ...) \
58 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
59 PCEP_DEBUG_MODE_PCEPLIB)) \
60 DEBUGD(&pcep_g->dbg, "pcep: " fmt, \
64 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
65 PCEP_DEBUG_MODE_PCEPLIB)) \
66 DEBUGI(&pcep_g->dbg, "pcep: " fmt, \
70 if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
71 PCEP_DEBUG_MODE_PCEPLIB)) \
72 DEBUGN(&pcep_g->dbg, "pcep: " fmt, \
78 zlog(priority, "pcep: " fmt, ##__VA_ARGS__); \
83 struct pcep_config_group_opts
{
85 char tcp_md5_auth
[TCP_MD5SIG_MAXKEYLEN
];
86 struct ipaddr source_ip
;
90 int keep_alive_seconds
;
91 int min_keep_alive_seconds
;
92 int max_keep_alive_seconds
;
93 int dead_timer_seconds
;
94 int min_dead_timer_seconds
;
95 int max_dead_timer_seconds
;
96 int pcep_request_time_seconds
;
97 int session_timeout_inteval_seconds
;
98 int delegation_timeout_seconds
;
105 struct pcep_config_group_opts config_opts
;
106 uint8_t precedence
; /* Multi-PCE precedence */
115 /* Encapsulate the pce_opts with needed CLI information */
116 struct pce_opts_cli
{
117 struct pce_opts pce_opts
;
118 char config_group_name
[64];
119 /* These are the values configured in the pcc-peer sub-commands.
120 * These need to be stored for later merging. Notice, it could
121 * be that not all of them are set. */
122 struct pcep_config_group_opts pce_config_group_opts
;
123 /* The pce_opts->config_opts will be a merge of the default values,
124 * optional config_group values (which overwrite default values),
125 * and any values configured in the pce sub-commands (which overwrite
126 * both default and config_group values). This flag indicates of the
127 * values need to be merged or not. */
133 struct ipaddr endpoint
;
139 uint8_t traffic_class
;
146 /* If we know the objective functions supported by the PCE.
147 * If we don't know, it doesn't mean the PCE doesn't support any */
148 bool supported_ofs_are_known
;
149 /* Defined if we know which objective funtions are supported by the PCE.
150 * One bit per objective function, the bit index being equal to
151 * enum pcep_objfun_type values: bit 0 is not used, bit 1 is
152 * PCEP_OBJFUN_MCP, up to bit 17 that is PCEP_OBJFUN_MSN */
153 uint32_t supported_ofs
;
158 struct sid_mpls mpls
;
163 enum pcep_sr_subobj_nai type
;
164 /* Local IP address*/
165 struct ipaddr local_addr
;
166 /* Local interface identifier if the NAI is an unnumbered adjacency */
167 uint32_t local_iface
;
168 /* Remote address if the NAI is an adjacency */
169 struct ipaddr remote_addr
;
170 /* Remote interface identifier if the NAI is an unnumbered adjacency */
171 uint32_t remote_iface
;
175 /* Pointer to the next hop in the path */
176 struct path_hop
*next
;
177 /* Indicateif this ia a loose or strict hop */
179 /* Indicate if there is an SID for the hop */
181 /* Indicate if the hop as a MPLS label */
183 /* Indicate if the MPLS label has extra attributes (TTL, class..)*/
185 /* Hop's SID if available */
187 /* Indicate if there is a NAI for this hop */
189 /* NAI if available */
194 /* Pointer to the next metric */
195 struct path_metric
*next
;
196 /* The metric type */
197 enum pcep_metric_types type
;
198 /* If the metric should be enforced */
200 /* If the metric value is bound (a maximum) */
202 /* If the metric value is computed */
204 /* The metric value */
209 /* Both the nbkey and the plspid are keys comming from the PCC,
210 but the PCE is only using the plspid. The missing key is looked up by
211 the PCC so we always have both */
213 /* The northbound key identifying this path */
214 struct lsp_nb_key nbkey
;
215 /* The generated unique PLSP identifier for this path.
216 See draft-ietf-pce-stateful-pce */
219 /* The transport address the path is comming from, PCE or PCC*/
220 struct ipaddr sender
;
221 /* The pcc protocol address, must be the same family as the endpoint */
222 struct ipaddr pcc_addr
;
224 /* The identifier of the PCC the path is for/from. If 0 it is undefined,
225 meaning it hasn't be set yet or is for all the PCC */
228 /* The origin of the path creation */
229 enum srte_protocol_origin create_origin
;
230 /* The origin of the path modification */
231 enum srte_protocol_origin update_origin
;
232 /* The identifier of the entity that originated the path */
233 const char *originator
;
234 /* The type of the path, for PCE initiated or updated path it is always
235 SRTE_CANDIDATE_TYPE_DYNAMIC */
236 enum srte_candidate_type type
;
238 /* The following data comes from either the PCC or the PCE if available
241 /* Path's binding SID */
242 mpls_label_t binding_sid
;
243 /* The name of the path */
245 /* The request identifier from the PCE, when getting a path from the
246 PCE. See draft-ietf-pce-stateful-pce */
248 /* The request identifier from the PCC , when getting a path from the
249 PCE after a computation request. See rfc5440, section-7.4 */
251 /* The operational status of the path */
252 enum pcep_lsp_operational_status status
;
253 /* If true, the receiver (PCC) must remove the path.
254 See draft-ietf-pce-pce-initiated-lsp */
256 /* Indicate the given path was removed by the PCC.
257 See draft-ietf-pce-stateful-pce, section-7.3, flag R */
259 /* Indicate the path is part of the synchronization process.
260 See draft-ietf-pce-stateful-pce, section-7.3, flag S */
262 /* Indicate if the path bandwidth requirment is defined */
264 /* Indicate if the bandwidth requirment should be enforced */
265 bool enforce_bandwidth
;
266 /* Path required bandwidth if defined */
268 /* Specify the list of hop defining the path */
269 struct path_hop
*first_hop
;
270 /* Specify the list of metrics */
271 struct path_metric
*first_metric
;
272 /* Indicate if the path has a PCC-defined objective function */
274 /* Indicate the PCC-defined objective function is required */
275 bool enforce_pcc_objfun
;
276 /* PCC-defined Objective Function */
277 enum objfun_type pcc_objfun
;
278 /* Indicate if the path has a PCE-defined objective function */
280 /* PCE-defined Objective Function */
281 enum objfun_type pce_objfun
;
282 /* Indicate if some affinity filters are defined */
283 bool has_affinity_filters
;
284 /* Affinity attribute filters indexed by enum affinity_filter_type - 1
286 uint32_t affinity_filters
[MAX_AFFINITY_FILTER_TYPE
];
288 /* The following data need to be specialized for a given PCE */
290 /* Indicate the path is delegated to the PCE.
291 See draft-ietf-pce-stateful-pce, section-7.3, flag D */
293 /* Indicate if the PCE wants the path to get active.
294 See draft-ietf-pce-stateful-pce, section-7.3, flag A */
296 /* Indicate the given path was created by the PCE,
297 See draft-ietf-pce-pce-initiated-lsp, section-5.3.1, flag C */
300 /* The following data is defined for comnputation replies */
302 /* Indicate that no path could be computed */
308 struct thread_master
*master
;
309 struct frr_pthread
*fpt
;
310 uint8_t num_pce_opts_cli
;
311 struct pce_opts_cli
*pce_opts_cli
[MAX_PCE
];
312 uint8_t num_config_group_opts
;
313 struct pcep_config_group_opts
*config_group_opts
[MAX_PCE
];
316 extern struct pcep_glob
*pcep_g
;
318 /* Path Helper Functions */
319 struct path
*pcep_new_path(void);
320 struct path_hop
*pcep_new_hop(void);
321 struct path_metric
*pcep_new_metric(void);
322 struct path
*pcep_copy_path(struct path
*path
);
323 void pcep_free_path(struct path
*path
);
326 #endif // _PATH_PCEP_H_