]>
Commit | Line | Data |
---|---|---|
54d48ea1 | 1 | /* |
2 | * Zebra MPLS Data structures and definitions | |
3 | * Copyright (C) 2015 Cumulus Networks, Inc. | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
54d48ea1 | 20 | */ |
21 | ||
22 | #ifndef _ZEBRA_MPLS_H | |
23 | #define _ZEBRA_MPLS_H | |
24 | ||
25 | #include "prefix.h" | |
26 | #include "table.h" | |
27 | #include "queue.h" | |
28 | #include "hash.h" | |
29 | #include "jhash.h" | |
30 | #include "nexthop.h" | |
31 | #include "vty.h" | |
32 | #include "memory.h" | |
33 | #include "mpls.h" | |
34 | #include "zebra/zserv.h" | |
939fba27 | 35 | #include "zebra/zebra_vrf.h" |
54d48ea1 | 36 | |
37 | ||
38 | /* Definitions and macros. */ | |
39 | ||
d62a17ae | 40 | #define NHLFE_FAMILY(nhlfe) \ |
41 | (((nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6 \ | |
42 | || (nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) \ | |
43 | ? AF_INET6 \ | |
44 | : AF_INET) | |
54d48ea1 | 45 | |
54d48ea1 | 46 | /* Typedefs */ |
47 | ||
48 | typedef struct zebra_ile_t_ zebra_ile_t; | |
49 | typedef struct zebra_snhlfe_t_ zebra_snhlfe_t; | |
50 | typedef struct zebra_slsp_t_ zebra_slsp_t; | |
51 | typedef struct zebra_nhlfe_t_ zebra_nhlfe_t; | |
52 | typedef struct zebra_lsp_t_ zebra_lsp_t; | |
f31e084c | 53 | typedef struct zebra_fec_t_ zebra_fec_t; |
54d48ea1 | 54 | |
54d48ea1 | 55 | /* |
56 | * (Outgoing) nexthop label forwarding entry configuration | |
57 | */ | |
d62a17ae | 58 | struct zebra_snhlfe_t_ { |
59 | /* Nexthop information */ | |
60 | enum nexthop_types_t gtype; | |
61 | union g_addr gate; | |
62 | char *ifname; | |
63 | ifindex_t ifindex; | |
54d48ea1 | 64 | |
d62a17ae | 65 | /* Out label. */ |
66 | mpls_label_t out_label; | |
54d48ea1 | 67 | |
d62a17ae | 68 | /* Backpointer to base entry. */ |
69 | zebra_slsp_t *slsp; | |
54d48ea1 | 70 | |
d62a17ae | 71 | /* Pointers to more outgoing information for same in-label */ |
72 | zebra_snhlfe_t *next; | |
73 | zebra_snhlfe_t *prev; | |
54d48ea1 | 74 | }; |
75 | ||
76 | /* | |
77 | * (Outgoing) nexthop label forwarding entry | |
78 | */ | |
d62a17ae | 79 | struct zebra_nhlfe_t_ { |
80 | /* Type of entry - static etc. */ | |
81 | enum lsp_types_t type; | |
54d48ea1 | 82 | |
d62a17ae | 83 | /* Nexthop information (with outgoing label) */ |
84 | struct nexthop *nexthop; | |
54d48ea1 | 85 | |
d62a17ae | 86 | /* Backpointer to base entry. */ |
87 | zebra_lsp_t *lsp; | |
54d48ea1 | 88 | |
d62a17ae | 89 | /* Runtime info - flags, pointers etc. */ |
d7c0a89a | 90 | uint32_t flags; |
54d48ea1 | 91 | #define NHLFE_FLAG_CHANGED (1 << 0) |
92 | #define NHLFE_FLAG_SELECTED (1 << 1) | |
93 | #define NHLFE_FLAG_MULTIPATH (1 << 2) | |
94 | #define NHLFE_FLAG_DELETED (1 << 3) | |
95 | #define NHLFE_FLAG_INSTALLED (1 << 4) | |
96 | ||
d62a17ae | 97 | zebra_nhlfe_t *next; |
98 | zebra_nhlfe_t *prev; | |
d7c0a89a | 99 | uint8_t distance; |
54d48ea1 | 100 | }; |
101 | ||
102 | /* | |
103 | * Incoming label entry | |
104 | */ | |
d62a17ae | 105 | struct zebra_ile_t_ { |
106 | mpls_label_t in_label; | |
54d48ea1 | 107 | }; |
108 | ||
109 | /* | |
110 | * Label swap entry static configuration. | |
111 | */ | |
d62a17ae | 112 | struct zebra_slsp_t_ { |
113 | /* Incoming label */ | |
114 | zebra_ile_t ile; | |
54d48ea1 | 115 | |
d62a17ae | 116 | /* List of outgoing nexthop static configuration */ |
117 | zebra_snhlfe_t *snhlfe_list; | |
54d48ea1 | 118 | }; |
119 | ||
120 | /* | |
121 | * Label swap entry (ile -> list of nhlfes) | |
122 | */ | |
d62a17ae | 123 | struct zebra_lsp_t_ { |
124 | /* Incoming label */ | |
125 | zebra_ile_t ile; | |
54d48ea1 | 126 | |
d62a17ae | 127 | /* List of NHLFE, pointer to best and num equal-cost. */ |
128 | zebra_nhlfe_t *nhlfe_list; | |
129 | zebra_nhlfe_t *best_nhlfe; | |
d7c0a89a | 130 | uint32_t num_ecmp; |
54d48ea1 | 131 | |
d62a17ae | 132 | /* Flags */ |
d7c0a89a | 133 | uint32_t flags; |
54d48ea1 | 134 | #define LSP_FLAG_SCHEDULED (1 << 0) |
135 | #define LSP_FLAG_INSTALLED (1 << 1) | |
136 | #define LSP_FLAG_CHANGED (1 << 2) | |
137 | ||
d62a17ae | 138 | /* Address-family of NHLFE - saved here for delete. All NHLFEs */ |
139 | /* have to be of the same AF */ | |
d7c0a89a | 140 | uint8_t addr_family; |
54d48ea1 | 141 | }; |
142 | ||
f31e084c DS |
143 | /* |
144 | * FEC to label binding. | |
145 | */ | |
d62a17ae | 146 | struct zebra_fec_t_ { |
147 | /* FEC (prefix) */ | |
148 | struct route_node *rn; | |
f31e084c | 149 | |
d62a17ae | 150 | /* In-label - either statically bound or derived from label block. */ |
151 | mpls_label_t label; | |
f31e084c | 152 | |
d62a17ae | 153 | /* Label index (into global label block), if valid */ |
d7c0a89a | 154 | uint32_t label_index; |
28d58fd7 | 155 | |
d62a17ae | 156 | /* Flags. */ |
d7c0a89a | 157 | uint32_t flags; |
f31e084c | 158 | #define FEC_FLAG_CONFIGURED (1 << 0) |
5aba114a | 159 | |
d62a17ae | 160 | /* Clients interested in this FEC. */ |
161 | struct list *client_list; | |
f31e084c | 162 | }; |
54d48ea1 | 163 | |
7758e3f3 | 164 | /* Function declarations. */ |
165 | ||
1b6d5c7e VV |
166 | /* |
167 | * Add/update global label block. | |
168 | */ | |
d7c0a89a QY |
169 | int zebra_mpls_label_block_add(struct zebra_vrf *zvrf, uint32_t start_label, |
170 | uint32_t end_label); | |
1b6d5c7e VV |
171 | |
172 | /* | |
173 | * Delete global label block. | |
174 | */ | |
d62a17ae | 175 | int zebra_mpls_label_block_del(struct zebra_vrf *vrf); |
1b6d5c7e VV |
176 | |
177 | /* | |
178 | * Display MPLS global label block configuration (VTY command handler). | |
179 | */ | |
d62a17ae | 180 | int zebra_mpls_write_label_block_config(struct vty *vty, struct zebra_vrf *vrf); |
1b6d5c7e | 181 | |
a64448ba DS |
182 | /* |
183 | * Install dynamic LSP entry. | |
184 | */ | |
d62a17ae | 185 | int zebra_mpls_lsp_install(struct zebra_vrf *zvrf, struct route_node *rn, |
186 | struct route_entry *re); | |
a64448ba DS |
187 | |
188 | /* | |
d62a17ae | 189 | * Uninstall dynamic LSP entry, if any. |
a64448ba | 190 | */ |
d62a17ae | 191 | int zebra_mpls_lsp_uninstall(struct zebra_vrf *zvrf, struct route_node *rn, |
192 | struct route_entry *re); | |
a64448ba | 193 | |
d4cb23d7 MS |
194 | /* Add an NHLFE to an LSP, return the newly-added object */ |
195 | zebra_nhlfe_t *zebra_mpls_lsp_add_nhlfe(zebra_lsp_t *lsp, | |
196 | enum lsp_types_t lsp_type, | |
197 | enum nexthop_types_t gtype, | |
198 | union g_addr *gate, | |
199 | ifindex_t ifindex, | |
200 | mpls_label_t out_label); | |
201 | ||
202 | /* Free an allocated NHLFE */ | |
203 | void zebra_mpls_nhlfe_del(zebra_nhlfe_t *nhlfe); | |
204 | ||
d62a17ae | 205 | int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p, |
57592a53 AD |
206 | uint32_t label, uint32_t label_index, |
207 | struct zserv *client); | |
5aba114a DS |
208 | |
209 | /* | |
210 | * Deregistration from a client for the label binding for a FEC. The FEC | |
211 | * itself is deleted if no other registered clients exist and there is no | |
212 | * label bound to the FEC. | |
213 | */ | |
d62a17ae | 214 | int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p, |
215 | struct zserv *client); | |
5aba114a | 216 | |
f31e084c DS |
217 | /* |
218 | * Return FEC (if any) to which this label is bound. | |
219 | * Note: Only works for per-prefix binding and when the label is not | |
220 | * implicit-null. | |
221 | * TODO: Currently walks entire table, can optimize later with another | |
222 | * hash.. | |
223 | */ | |
d62a17ae | 224 | zebra_fec_t *zebra_mpls_fec_for_label(struct zebra_vrf *zvrf, |
225 | mpls_label_t label); | |
f31e084c DS |
226 | |
227 | /* | |
228 | * Inform if specified label is currently bound to a FEC or not. | |
229 | */ | |
d62a17ae | 230 | int zebra_mpls_label_already_bound(struct zebra_vrf *zvrf, mpls_label_t label); |
f31e084c DS |
231 | |
232 | /* | |
5aba114a | 233 | * Add static FEC to label binding. If there are clients registered for this |
a64448ba DS |
234 | * FEC, notify them. If there are labeled routes for this FEC, install the |
235 | * label forwarding entry. | |
f31e084c | 236 | */ |
d62a17ae | 237 | int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p, |
238 | mpls_label_t in_label); | |
f31e084c DS |
239 | |
240 | /* | |
5aba114a DS |
241 | * Remove static FEC to label binding. If there are no clients registered |
242 | * for this FEC, delete the FEC; else notify clients. | |
28d58fd7 VV |
243 | * Note: Upon delete of static binding, if label index exists for this FEC, |
244 | * client may need to be updated with derived label. | |
f31e084c | 245 | */ |
d62a17ae | 246 | int zebra_mpls_static_fec_del(struct zebra_vrf *zvrf, struct prefix *p); |
f31e084c DS |
247 | |
248 | /* | |
249 | * Display MPLS FEC to label binding configuration (VTY command handler). | |
250 | */ | |
d62a17ae | 251 | int zebra_mpls_write_fec_config(struct vty *vty, struct zebra_vrf *zvrf); |
f31e084c DS |
252 | |
253 | /* | |
254 | * Display MPLS FEC to label binding (VTY command handler). | |
255 | */ | |
d62a17ae | 256 | void zebra_mpls_print_fec_table(struct vty *vty, struct zebra_vrf *zvrf); |
f31e084c DS |
257 | |
258 | /* | |
259 | * Display MPLS FEC to label binding for a specific FEC (VTY command handler). | |
260 | */ | |
d62a17ae | 261 | void zebra_mpls_print_fec(struct vty *vty, struct zebra_vrf *zvrf, |
262 | struct prefix *p); | |
f31e084c | 263 | |
ce549947 RW |
264 | /* |
265 | * Install/uninstall a FEC-To-NHLFE (FTN) binding. | |
266 | */ | |
d62a17ae | 267 | int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type, |
268 | struct prefix *prefix, enum nexthop_types_t gtype, | |
d7c0a89a | 269 | union g_addr *gate, ifindex_t ifindex, uint8_t distance, |
d62a17ae | 270 | mpls_label_t out_label); |
ce549947 RW |
271 | |
272 | /* | |
273 | * Install/update a NHLFE for an LSP in the forwarding table. This may be | |
274 | * a new LSP entry or a new NHLFE for an existing in-label or an update of | |
275 | * the out-label for an existing NHLFE (update case). | |
276 | */ | |
d62a17ae | 277 | int mpls_lsp_install(struct zebra_vrf *zvrf, enum lsp_types_t type, |
278 | mpls_label_t in_label, mpls_label_t out_label, | |
279 | enum nexthop_types_t gtype, union g_addr *gate, | |
280 | ifindex_t ifindex); | |
ce549947 RW |
281 | |
282 | /* | |
283 | * Uninstall a particular NHLFE in the forwarding table. If this is | |
284 | * the only NHLFE, the entire LSP forwarding entry has to be deleted. | |
285 | */ | |
d62a17ae | 286 | int mpls_lsp_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type, |
287 | mpls_label_t in_label, enum nexthop_types_t gtype, | |
288 | union g_addr *gate, ifindex_t ifindex); | |
ce549947 RW |
289 | |
290 | /* | |
291 | * Uninstall all LDP NHLFEs for a particular LSP forwarding entry. | |
292 | * If no other NHLFEs exist, the entry would be deleted. | |
293 | */ | |
e3b78da8 | 294 | void mpls_ldp_lsp_uninstall_all(struct hash_bucket *bucket, void *ctxt); |
ce549947 RW |
295 | |
296 | /* | |
297 | * Uninstall all LDP FEC-To-NHLFE (FTN) bindings of the given address-family. | |
298 | */ | |
d62a17ae | 299 | void mpls_ldp_ftn_uninstall_all(struct zebra_vrf *zvrf, int afi); |
ce549947 | 300 | |
cf9b9f77 OD |
301 | /* |
302 | * Uninstall all Segment Routing NHLFEs for a particular LSP forwarding entry. | |
303 | * If no other NHLFEs exist, the entry would be deleted. | |
304 | */ | |
e3b78da8 | 305 | void mpls_sr_lsp_uninstall_all(struct hash_bucket *bucket, void *ctxt); |
cf9b9f77 | 306 | |
1c1cf002 | 307 | #if defined(HAVE_CUMULUS) |
7758e3f3 | 308 | /* |
309 | * Check that the label values used in LSP creation are consistent. The | |
310 | * main criteria is that if there is ECMP, the label operation must still | |
311 | * be consistent - i.e., all paths either do a swap or do PHP. This is due | |
312 | * to current HW restrictions. | |
313 | */ | |
d62a17ae | 314 | int zebra_mpls_lsp_label_consistent(struct zebra_vrf *zvrf, |
315 | mpls_label_t in_label, | |
316 | mpls_label_t out_label, | |
317 | enum nexthop_types_t gtype, | |
318 | union g_addr *gate, ifindex_t ifindex); | |
1c1cf002 | 319 | #endif /* HAVE_CUMULUS */ |
7758e3f3 | 320 | |
321 | /* | |
322 | * Add static LSP entry. This may be the first entry for this incoming label | |
323 | * or an additional nexthop; an existing entry may also have outgoing label | |
324 | * changed. | |
325 | * Note: The label operation (swap or PHP) is common for the LSP entry (all | |
326 | * NHLFEs). | |
327 | */ | |
d62a17ae | 328 | int zebra_mpls_static_lsp_add(struct zebra_vrf *zvrf, mpls_label_t in_label, |
329 | mpls_label_t out_label, | |
330 | enum nexthop_types_t gtype, union g_addr *gate, | |
331 | ifindex_t ifindex); | |
7758e3f3 | 332 | |
333 | /* | |
334 | * Delete static LSP entry. This may be the delete of one particular | |
335 | * NHLFE for this incoming label or the delete of the entire entry (i.e., | |
336 | * all NHLFEs). | |
337 | * NOTE: Delete of the only NHLFE will also end up deleting the entire | |
338 | * LSP configuration. | |
339 | */ | |
d62a17ae | 340 | int zebra_mpls_static_lsp_del(struct zebra_vrf *zvrf, mpls_label_t in_label, |
341 | enum nexthop_types_t gtype, union g_addr *gate, | |
342 | ifindex_t ifindex); | |
7758e3f3 | 343 | |
d37f4d6c MS |
344 | /* |
345 | * Process LSP update results from zebra dataplane. | |
346 | */ | |
347 | /* Forward ref of dplane update context type */ | |
348 | struct zebra_dplane_ctx; | |
349 | ||
350 | void zebra_mpls_lsp_dplane_result(struct zebra_dplane_ctx *ctx); | |
351 | ||
40c7bdb0 | 352 | /* |
353 | * Schedule all MPLS label forwarding entries for processing. | |
354 | * Called upon changes that may affect one or more of them such as | |
355 | * interface or nexthop state changes. | |
356 | */ | |
d62a17ae | 357 | void zebra_mpls_lsp_schedule(struct zebra_vrf *zvrf); |
40c7bdb0 | 358 | |
3ab18ff2 | 359 | /* |
360 | * Display MPLS label forwarding table for a specific LSP | |
361 | * (VTY command handler). | |
362 | */ | |
d62a17ae | 363 | void zebra_mpls_print_lsp(struct vty *vty, struct zebra_vrf *zvrf, |
9f049418 | 364 | mpls_label_t label, bool use_json); |
3ab18ff2 | 365 | |
366 | /* | |
367 | * Display MPLS label forwarding table (VTY command handler). | |
368 | */ | |
d62a17ae | 369 | void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf, |
9f049418 | 370 | bool use_json); |
3ab18ff2 | 371 | |
7758e3f3 | 372 | /* |
373 | * Display MPLS LSP configuration of all static LSPs (VTY command handler). | |
374 | */ | |
d62a17ae | 375 | int zebra_mpls_write_lsp_config(struct vty *vty, struct zebra_vrf *zvrf); |
7758e3f3 | 376 | |
84915b0a | 377 | /* |
378 | * Called when VRF becomes inactive, cleans up information but keeps | |
379 | * the table itself. | |
380 | * NOTE: Currently supported only for default VRF. | |
381 | */ | |
382 | void zebra_mpls_cleanup_tables(struct zebra_vrf *zvrf); | |
383 | ||
40c7bdb0 | 384 | /* |
385 | * Called upon process exiting, need to delete LSP forwarding | |
386 | * entries from the kernel. | |
387 | * NOTE: Currently supported only for default VRF. | |
388 | */ | |
d62a17ae | 389 | void zebra_mpls_close_tables(struct zebra_vrf *zvrf); |
40c7bdb0 | 390 | |
7758e3f3 | 391 | /* |
392 | * Allocate MPLS tables for this VRF. | |
393 | * NOTE: Currently supported only for default VRF. | |
394 | */ | |
d62a17ae | 395 | void zebra_mpls_init_tables(struct zebra_vrf *zvrf); |
7758e3f3 | 396 | |
397 | /* | |
398 | * Global MPLS initialization. | |
399 | */ | |
d62a17ae | 400 | void zebra_mpls_init(void); |
7758e3f3 | 401 | |
fe6c7157 RW |
402 | /* |
403 | * MPLS VTY. | |
404 | */ | |
d62a17ae | 405 | void zebra_mpls_vty_init(void); |
fe6c7157 | 406 | |
40c7bdb0 | 407 | /* Inline functions. */ |
408 | ||
409 | /* | |
410 | * Distance (priority) definition for LSP NHLFE. | |
411 | */ | |
d7c0a89a | 412 | static inline uint8_t lsp_distance(enum lsp_types_t type) |
40c7bdb0 | 413 | { |
0492eea0 RW |
414 | switch (type) { |
415 | case ZEBRA_LSP_STATIC: | |
d62a17ae | 416 | return (route_distance(ZEBRA_ROUTE_STATIC)); |
0492eea0 RW |
417 | case ZEBRA_LSP_LDP: |
418 | return (route_distance(ZEBRA_ROUTE_LDP)); | |
419 | case ZEBRA_LSP_BGP: | |
420 | return (route_distance(ZEBRA_ROUTE_BGP)); | |
339e36d2 DS |
421 | case ZEBRA_LSP_NONE: |
422 | case ZEBRA_LSP_SHARP: | |
423 | case ZEBRA_LSP_SR: | |
0492eea0 RW |
424 | return 150; |
425 | } | |
339e36d2 DS |
426 | |
427 | /* | |
428 | * For some reason certain compilers do not believe | |
429 | * that all the cases have been handled. And | |
430 | * WTF does this work differently than when I removed | |
431 | * the default case???? | |
432 | */ | |
433 | return 150; | |
40c7bdb0 | 434 | } |
435 | ||
436 | /* | |
437 | * Map RIB type to LSP type. Used when labeled-routes from BGP | |
438 | * are converted into LSPs. | |
439 | */ | |
d62a17ae | 440 | static inline enum lsp_types_t lsp_type_from_re_type(int re_type) |
40c7bdb0 | 441 | { |
d62a17ae | 442 | switch (re_type) { |
443 | case ZEBRA_ROUTE_STATIC: | |
444 | return ZEBRA_LSP_STATIC; | |
445 | case ZEBRA_ROUTE_BGP: | |
446 | return ZEBRA_LSP_BGP; | |
339e36d2 DS |
447 | case ZEBRA_ROUTE_SHARP: |
448 | return ZEBRA_LSP_SHARP; | |
d62a17ae | 449 | default: |
450 | return ZEBRA_LSP_NONE; | |
451 | } | |
40c7bdb0 | 452 | } |
453 | ||
805444ce RW |
454 | /* |
455 | * Map LSP type to RIB type. | |
456 | */ | |
457 | static inline int re_type_from_lsp_type(enum lsp_types_t lsp_type) | |
458 | { | |
459 | switch (lsp_type) { | |
460 | case ZEBRA_LSP_STATIC: | |
461 | return ZEBRA_ROUTE_STATIC; | |
462 | case ZEBRA_LSP_LDP: | |
463 | return ZEBRA_ROUTE_LDP; | |
464 | case ZEBRA_LSP_BGP: | |
465 | return ZEBRA_ROUTE_BGP; | |
cf9b9f77 | 466 | case ZEBRA_LSP_SR: |
7726c479 | 467 | return ZEBRA_ROUTE_OSPF; |
805444ce | 468 | case ZEBRA_LSP_NONE: |
805444ce | 469 | return ZEBRA_ROUTE_KERNEL; |
339e36d2 DS |
470 | case ZEBRA_LSP_SHARP: |
471 | return ZEBRA_ROUTE_SHARP; | |
805444ce | 472 | } |
339e36d2 DS |
473 | |
474 | /* | |
475 | * For some reason certain compilers do not believe | |
476 | * that all the cases have been handled. And | |
477 | * WTF does this work differently than when I removed | |
478 | * the default case???? | |
479 | */ | |
480 | return ZEBRA_ROUTE_KERNEL; | |
805444ce RW |
481 | } |
482 | ||
3ab18ff2 | 483 | /* NHLFE type as printable string. */ |
d62a17ae | 484 | static inline const char *nhlfe_type2str(enum lsp_types_t lsp_type) |
3ab18ff2 | 485 | { |
d62a17ae | 486 | switch (lsp_type) { |
487 | case ZEBRA_LSP_STATIC: | |
488 | return "Static"; | |
489 | case ZEBRA_LSP_LDP: | |
490 | return "LDP"; | |
491 | case ZEBRA_LSP_BGP: | |
492 | return "BGP"; | |
cf9b9f77 OD |
493 | case ZEBRA_LSP_SR: |
494 | return "SR"; | |
339e36d2 DS |
495 | case ZEBRA_LSP_SHARP: |
496 | return "SHARP"; | |
497 | case ZEBRA_LSP_NONE: | |
d62a17ae | 498 | return "Unknown"; |
499 | } | |
339e36d2 DS |
500 | |
501 | /* | |
502 | * For some reason certain compilers do not believe | |
503 | * that all the cases have been handled. And | |
504 | * WTF does this work differently than when I removed | |
505 | * the default case???? | |
506 | */ | |
507 | return "Unknown"; | |
3ab18ff2 | 508 | } |
509 | ||
d62a17ae | 510 | static inline void mpls_mark_lsps_for_processing(struct zebra_vrf *zvrf) |
939fba27 | 511 | { |
d62a17ae | 512 | if (!zvrf) |
513 | return; | |
939fba27 | 514 | |
d62a17ae | 515 | zvrf->mpls_flags |= MPLS_FLAG_SCHEDULE_LSPS; |
939fba27 | 516 | } |
517 | ||
d62a17ae | 518 | static inline void mpls_unmark_lsps_for_processing(struct zebra_vrf *zvrf) |
939fba27 | 519 | { |
d62a17ae | 520 | if (!zvrf) |
521 | return; | |
939fba27 | 522 | |
d62a17ae | 523 | zvrf->mpls_flags &= ~MPLS_FLAG_SCHEDULE_LSPS; |
939fba27 | 524 | } |
525 | ||
d62a17ae | 526 | static inline int mpls_should_lsps_be_processed(struct zebra_vrf *zvrf) |
939fba27 | 527 | { |
d62a17ae | 528 | if (!zvrf) |
529 | return 0; | |
939fba27 | 530 | |
d62a17ae | 531 | return ((zvrf->mpls_flags & MPLS_FLAG_SCHEDULE_LSPS) ? 1 : 0); |
939fba27 | 532 | } |
533 | ||
fe6c7157 RW |
534 | /* Global variables. */ |
535 | extern int mpls_enabled; | |
536 | ||
54d48ea1 | 537 | #endif /*_ZEBRA_MPLS_H */ |