]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_te.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfd / ospf_te.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/*
16f1b9ee 3 * This is an implementation of RFC3630, RFC5392 & RFC6827
718e3744 4 * Copyright (C) 2001 KDD R&D Laboratories, Inc.
5 * http://www.kddlabs.co.jp/
6 *
16f1b9ee
OD
7 * Copyright (C) 2012 Orange Labs
8 * http://www.orange.com
718e3744 9 */
10
16f1b9ee
OD
11/* Add support of RFC7471 */
12/* Add support of RFC5392 */
13/* Add support of RFC6827 (partial) */
14
718e3744 15#ifndef _ZEBRA_OSPF_MPLS_TE_H
16#define _ZEBRA_OSPF_MPLS_TE_H
17
18/*
19 * Opaque LSA's link state ID for Traffic Engineering is
20 * structured as follows.
21 *
22 * 24 16 8 0
23 * +--------+--------+--------+--------+
24 * | 1 | MBZ |........|........|
25 * +--------+--------+--------+--------+
26 * |<-Type->|<Resv'd>|<-- Instance --->|
27 *
28 *
29 * Type: IANA has assigned '1' for Traffic Engineering.
30 * MBZ: Reserved, must be set to zero.
31 * Instance: User may select an arbitrary 16-bit value.
32 *
33 */
34
703819a9 35#define MAX_LEGAL_TE_INSTANCE_NUM (0xffff)
16f1b9ee 36#define LEGAL_TE_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
718e3744 37
38/*
39 * 24 16 8 0
40 * +--------+--------+--------+--------+ ---
41 * | LS age |Options | 10 | A
42 * +--------+--------+--------+--------+ |
43 * | 1 | 0 | Instance | |
44 * +--------+--------+--------+--------+ |
45 * | Advertising router | | Standard (Opaque) LSA header;
46 * +--------+--------+--------+--------+ | Only type-10 is used.
47 * | LS sequence number | |
48 * +--------+--------+--------+--------+ |
49 * | LS checksum | Length | V
50 * +--------+--------+--------+--------+ ---
51 * | Type | Length | A
52 * +--------+--------+--------+--------+ | TLV part for TE; Values might be
53 * | Values ... | V structured as a set of sub-TLVs.
54 * +--------+--------+--------+--------+ ---
55 */
56
16f1b9ee
OD
57/* Following define the type of TE link regarding the various RFC */
58#define STD_TE 0x01
59#define GMPLS 0x02
60#define INTER_AS 0x04
61#define PSEUDO_TE 0x08
2efd7e2b 62#define EMULATED 0x10
16f1b9ee 63
2efd7e2b 64#define IS_STD_TE(x) (x & STD_TE)
16f1b9ee
OD
65#define IS_PSEUDO_TE(x) (x & PSEUDO_TE)
66#define IS_INTER_AS(x) (x & INTER_AS)
67#define IS_EMULATED(x) (x & EMULATED)
16f1b9ee
OD
68
69/* Flags to manage TE Link LSA */
2efd7e2b
OD
70#define LPFLG_LSA_INACTIVE 0x00
71#define LPFLG_LSA_ACTIVE 0x01
72#define LPFLG_LSA_ENGAGED 0x02
73#define LPFLG_LOOKUP_DONE 0x04
74#define LPFLG_LSA_FORCED_REFRESH 0x08
75#define LPFLG_LSA_FLOOD_AS 0x10
76
77#define IS_FLOOD_AS(x) (x & LPFLG_LSA_FLOOD_AS)
16f1b9ee 78
fd3c7692
OD
79/* Macro to log debug message */
80#define ote_debug(...) \
81 do { \
82 if (IS_DEBUG_OSPF_TE) \
83 zlog_debug(__VA_ARGS__); \
84 } while (0)
85
718e3744 86/*
87 * Following section defines TLV body parts.
88 */
ead99d5f 89
16f1b9ee 90/* Router Address TLV */ /* Mandatory */
718e3744 91#define TE_TLV_ROUTER_ADDR 1
d62a17ae 92struct te_tlv_router_addr {
ead99d5f 93 struct tlv_header header; /* Value length is 4 octets. */
d62a17ae 94 struct in_addr value;
718e3744 95};
96
97/* Link TLV */
98#define TE_TLV_LINK 2
d62a17ae 99struct te_tlv_link {
ead99d5f 100 struct tlv_header header;
d62a17ae 101 /* A set of link-sub-TLVs will follow. */
718e3744 102};
103
ead99d5f 104/* Default TE TLV size */
16f1b9ee
OD
105#define TE_LINK_SUBTLV_DEF_SIZE 4
106
107/* Link Type Sub-TLV */ /* Mandatory */
108#define TE_LINK_SUBTLV_LINK_TYPE 1
109#define TE_LINK_SUBTLV_TYPE_SIZE 1
d62a17ae 110struct te_link_subtlv_link_type {
ead99d5f 111 struct tlv_header header; /* Value length is 1 octet. */
d62a17ae 112 struct {
718e3744 113#define LINK_TYPE_SUBTLV_VALUE_PTP 1
114#define LINK_TYPE_SUBTLV_VALUE_MA 2
d7c0a89a
QY
115 uint8_t value;
116 uint8_t padding[3];
d62a17ae 117 } link_type;
718e3744 118};
119
16f1b9ee
OD
120/* Link Sub-TLV: Link ID */ /* Mandatory */
121#define TE_LINK_SUBTLV_LINK_ID 2
d62a17ae 122struct te_link_subtlv_link_id {
ead99d5f 123 struct tlv_header header; /* Value length is 4 octets. */
996c9314 124 struct in_addr value; /* Same as router-lsa's link-id. */
718e3744 125};
126
16f1b9ee
OD
127/* Link Sub-TLV: Local Interface IP Address */ /* Optional */
128#define TE_LINK_SUBTLV_LCLIF_IPADDR 3
d62a17ae 129struct te_link_subtlv_lclif_ipaddr {
ead99d5f 130 struct tlv_header header; /* Value length is 4 x N octets. */
996c9314 131 struct in_addr value[1]; /* Local IP address(es). */
718e3744 132};
133
16f1b9ee
OD
134/* Link Sub-TLV: Remote Interface IP Address */ /* Optional */
135#define TE_LINK_SUBTLV_RMTIF_IPADDR 4
d62a17ae 136struct te_link_subtlv_rmtif_ipaddr {
ead99d5f 137 struct tlv_header header; /* Value length is 4 x N octets. */
996c9314 138 struct in_addr value[1]; /* Neighbor's IP address(es). */
718e3744 139};
140
16f1b9ee
OD
141/* Link Sub-TLV: Traffic Engineering Metric */ /* Optional */
142#define TE_LINK_SUBTLV_TE_METRIC 5
d62a17ae 143struct te_link_subtlv_te_metric {
ead99d5f 144 struct tlv_header header; /* Value length is 4 octets. */
d7c0a89a 145 uint32_t value; /* Link metric for TE purpose. */
718e3744 146};
147
16f1b9ee
OD
148/* Link Sub-TLV: Maximum Bandwidth */ /* Optional */
149#define TE_LINK_SUBTLV_MAX_BW 6
d62a17ae 150struct te_link_subtlv_max_bw {
ead99d5f 151 struct tlv_header header; /* Value length is 4 octets. */
996c9314 152 float value; /* bytes/sec */
718e3744 153};
154
16f1b9ee
OD
155/* Link Sub-TLV: Maximum Reservable Bandwidth */ /* Optional */
156#define TE_LINK_SUBTLV_MAX_RSV_BW 7
d62a17ae 157struct te_link_subtlv_max_rsv_bw {
ead99d5f 158 struct tlv_header header; /* Value length is 4 octets. */
996c9314 159 float value; /* bytes/sec */
718e3744 160};
161
16f1b9ee
OD
162/* Link Sub-TLV: Unreserved Bandwidth */ /* Optional */
163#define TE_LINK_SUBTLV_UNRSV_BW 8
164#define TE_LINK_SUBTLV_UNRSV_SIZE 32
d62a17ae 165struct te_link_subtlv_unrsv_bw {
996c9314 166 struct tlv_header header; /* Value length is 32 octets. */
d62a17ae 167 float value[MAX_CLASS_TYPE]; /* One for each priority level. */
718e3744 168};
169
16f1b9ee
OD
170/* Link Sub-TLV: Resource Class/Color */ /* Optional */
171#define TE_LINK_SUBTLV_RSC_CLSCLR 9
d62a17ae 172struct te_link_subtlv_rsc_clsclr {
ead99d5f 173 struct tlv_header header; /* Value length is 4 octets. */
d7c0a89a 174 uint32_t value; /* Admin. group membership. */
718e3744 175};
176
16f1b9ee
OD
177/* For RFC6827 */
178/* Local and Remote TE Router ID */
179#define TE_LINK_SUBTLV_LRRID 10
180#define TE_LINK_SUBTLV_LRRID_SIZE 8
d62a17ae 181struct te_link_subtlv_lrrid {
ead99d5f 182 struct tlv_header header; /* Value length is 8 octets. */
996c9314
LB
183 struct in_addr local; /* Local TE Router Identifier */
184 struct in_addr remote; /* Remote TE Router Identifier */
16f1b9ee
OD
185};
186
187/* RFC4203: Link Local/Remote Identifiers */
188#define TE_LINK_SUBTLV_LLRI 11
189#define TE_LINK_SUBTLV_LLRI_SIZE 8
d62a17ae 190struct te_link_subtlv_llri {
ead99d5f 191 struct tlv_header header; /* Value length is 8 octets. */
d7c0a89a
QY
192 uint32_t local; /* Link Local Identifier */
193 uint32_t remote; /* Link Remote Identifier */
16f1b9ee
OD
194};
195
d62a17ae 196/* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13)
197 * (RFC6827bis) are not yet supported */
16f1b9ee
OD
198/* SUBTLV 14-16 (RFC4203) are not yet supported */
199/* Bandwidth Constraints sub-TLV (17) (RFC4124) is not yet supported */
b2d4d039 200/* SUBLV 18-20 are for OSPFv3 TE (RFC5329). see ospf6d */
16f1b9ee
OD
201
202/* For RFC 5392 */
203/* Remote AS Number sub-TLV */
204#define TE_LINK_SUBTLV_RAS 21
d62a17ae 205struct te_link_subtlv_ras {
ead99d5f 206 struct tlv_header header; /* Value length is 4 octets. */
d7c0a89a 207 uint32_t value; /* Remote AS number */
16f1b9ee
OD
208};
209
210/* IPv4 Remote ASBR ID Sub-TLV */
211#define TE_LINK_SUBTLV_RIP 22
d62a17ae 212struct te_link_subtlv_rip {
ead99d5f 213 struct tlv_header header; /* Value length is 4 octets. */
996c9314 214 struct in_addr value; /* Remote ASBR IP address */
16f1b9ee
OD
215};
216
217/* SUBTLV 24 is IPv6 Remote ASBR ID (RFC5392). see ospf6d */
218
219/* SUBTLV 23 (RFC5330) and 25 (RFC6001) are not yet supported */
220
221/* SUBTLV 26 (RFC7308) is not yet supported */
222
223/* RFC7471 */
224/* Link Sub-TLV: Average Link Delay */ /* Optional */
225#define TE_LINK_SUBTLV_AV_DELAY 27
d62a17ae 226struct te_link_subtlv_av_delay {
ead99d5f
OD
227 struct tlv_header header; /* Value length is 4 bytes. */
228 /*
229 * delay in micro-seconds only 24 bits => 0 ... 16777215
230 * with Anomalous Bit as Upper most bit
231 */
d7c0a89a 232 uint32_t value;
16f1b9ee
OD
233};
234
235/* Link Sub-TLV: Low/High Link Delay */
236#define TE_LINK_SUBTLV_MM_DELAY 28
237#define TE_LINK_SUBTLV_MM_DELAY_SIZE 8
d62a17ae 238struct te_link_subtlv_mm_delay {
ead99d5f
OD
239 struct tlv_header header; /* Value length is 8 bytes. */
240 /*
241 * low delay in micro-seconds only 24 bits => 0 ... 16777215
242 * with Anomalous Bit (A) as Upper most bit
243 */
d7c0a89a 244 uint32_t low;
ead99d5f 245 /* high delay in micro-seconds only 24 bits => 0 ... 16777215 */
d7c0a89a 246 uint32_t high;
16f1b9ee
OD
247};
248
249/* Link Sub-TLV: Link Delay Variation i.e. Jitter */
250#define TE_LINK_SUBTLV_DELAY_VAR 29
d62a17ae 251struct te_link_subtlv_delay_var {
ead99d5f
OD
252 struct tlv_header header; /* Value length is 4 bytes. */
253 /* interval in micro-seconds only 24 bits => 0 ... 16777215 */
d7c0a89a 254 uint32_t value;
16f1b9ee
OD
255};
256
257/* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
258#define TE_LINK_SUBTLV_PKT_LOSS 30
d62a17ae 259struct te_link_subtlv_pkt_loss {
ead99d5f
OD
260 struct tlv_header header; /* Value length is 4 bytes. */
261 /*
262 * in percentage of total traffic only 24 bits (2^24 - 2)
263 * with Anomalous Bit as Upper most bit
264 */
d7c0a89a 265 uint32_t value;
16f1b9ee
OD
266};
267
268/* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
269#define TE_LINK_SUBTLV_RES_BW 31
d62a17ae 270struct te_link_subtlv_res_bw {
ead99d5f
OD
271 struct tlv_header header; /* Value length is 4 bytes. */
272 /* bandwidth in IEEE floating point format with units in bytes/second */
273 float value;
16f1b9ee
OD
274};
275
276/* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
277#define TE_LINK_SUBTLV_AVA_BW 32
d62a17ae 278struct te_link_subtlv_ava_bw {
ead99d5f
OD
279 struct tlv_header header; /* Value length is 4 octets. */
280 /* bandwidth in IEEE floating point format with units in bytes/second */
281 float value;
16f1b9ee
OD
282};
283
284/* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
285#define TE_LINK_SUBTLV_USE_BW 33
d62a17ae 286struct te_link_subtlv_use_bw {
ead99d5f
OD
287 struct tlv_header header; /* Value length is 4 octets. */
288 /* bandwidth in IEEE floating point format with units in bytes/second */
289 float value;
16f1b9ee
OD
290};
291
292#define TE_LINK_SUBTLV_MAX 34 /* Last SUBTLV + 1 */
293
294/* Here are "non-official" architectural constants. */
718e3744 295#define MPLS_TE_MINIMUM_BANDWIDTH 1.0 /* Reasonable? *//* XXX */
296
16f1b9ee 297/* Mode for Inter-AS Opaque-LSA */
ead99d5f 298enum inter_as_mode { Off, AS, Area };
16f1b9ee 299
d62a17ae 300struct te_link_subtlv {
ead99d5f 301 struct tlv_header header;
d62a17ae 302 union {
d7c0a89a 303 uint32_t link_type;
d62a17ae 304 struct in_addr link_id;
305 struct in_addr lclif;
306 struct in_addr rmtif;
d7c0a89a 307 uint32_t te_metric;
d62a17ae 308 float max_bw;
309 float max_rsv_bw;
310 float unrsv[8];
d7c0a89a
QY
311 uint32_t rsc_clsclr;
312 uint32_t llri[2];
313 uint32_t ras;
d62a17ae 314 struct in_addr rip;
315 struct in_addr lrrid[2];
d7c0a89a
QY
316 uint32_t av_delay;
317 uint32_t mm_delay;
318 uint32_t delay_var;
319 uint32_t pkt_loss;
d62a17ae 320 float res_bw;
321 float ava_bw;
322 float use_bw;
323 } value;
16f1b9ee
OD
324};
325
326/* Following structure are internal use only. */
d62a17ae 327struct ospf_mpls_te {
f173deb3 328 /* Status of MPLS-TE: enable or disable */
32ab5cf4 329 bool enabled;
16f1b9ee 330
f173deb3
OD
331 /* Traffic Engineering Database i.e. Link State */
332 struct ls_ted *ted;
333 bool export;
334
d62a17ae 335 /* RFC5392 */
336 enum inter_as_mode inter_as;
337 struct in_addr interas_areaid;
16f1b9ee 338
d62a17ae 339 /* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi).
340 */
341 struct list *iflist;
16f1b9ee 342
d62a17ae 343 /* Store Router-TLV in network byte order. */
344 struct te_tlv_router_addr router_addr;
16f1b9ee
OD
345};
346
d62a17ae 347struct mpls_te_link {
348 /*
349 * According to MPLS-TE (draft) specification, 24-bit Opaque-ID field
350 * is subdivided into 8-bit "unused" field and 16-bit "instance" field.
351 * In this implementation, each Link-TLV has its own instance.
352 */
d7c0a89a 353 uint32_t instance;
d62a17ae 354
355 /* Reference pointer to a Zebra-interface. */
356 struct interface *ifp;
357
358 /* Area info in which this MPLS-TE link belongs to. */
359 struct ospf_area *area;
360
361 /* Flags to manage this link parameters. */
d7c0a89a 362 uint32_t flags;
d62a17ae 363
364 /* Type of MPLS-TE link: RFC3630, RFC5392, RFC5392 emulated, RFC6827 */
d7c0a89a 365 uint8_t type;
d62a17ae 366
367 /* Store Link-TLV in network byte order. */
368 /* RFC3630 & RFC6827 / RFC 6827 */
369 struct te_tlv_link link_header;
370 struct te_link_subtlv_link_type link_type;
371 struct te_link_subtlv_link_id link_id;
372 struct te_link_subtlv_lclif_ipaddr lclif_ipaddr;
373 struct te_link_subtlv_rmtif_ipaddr rmtif_ipaddr;
374 struct te_link_subtlv_te_metric te_metric;
375 struct te_link_subtlv_max_bw max_bw;
376 struct te_link_subtlv_max_rsv_bw max_rsv_bw;
377 struct te_link_subtlv_unrsv_bw unrsv_bw;
378 struct te_link_subtlv_rsc_clsclr rsc_clsclr;
379 /* RFC4203 */
380 struct te_link_subtlv_llri llri;
381 /* RFC5392 */
382 struct te_link_subtlv_ras ras;
383 struct te_link_subtlv_rip rip;
384 /* RFC6827 */
385 struct te_link_subtlv_lrrid lrrid;
386 /* RFC7471 */
387 struct te_link_subtlv_av_delay av_delay;
388 struct te_link_subtlv_mm_delay mm_delay;
389 struct te_link_subtlv_delay_var delay_var;
390 struct te_link_subtlv_pkt_loss pkt_loss;
391 struct te_link_subtlv_res_bw res_bw;
392 struct te_link_subtlv_ava_bw ava_bw;
393 struct te_link_subtlv_use_bw use_bw;
394
395 struct in_addr adv_router;
396 struct in_addr id;
16f1b9ee
OD
397};
398
718e3744 399/* Prototypes. */
d62a17ae 400extern int ospf_mpls_te_init(void);
401extern void ospf_mpls_te_term(void);
bcf4475e 402extern void ospf_mpls_te_finish(void);
d62a17ae 403extern struct ospf_mpls_te *get_ospf_mpls_te(void);
404extern void ospf_mpls_te_update_if(struct interface *);
2a39170c 405extern void ospf_mpls_te_lsa_schedule(struct mpls_te_link *, enum lsa_opcode);
d7c0a89a 406extern void set_linkparams_llri(struct mpls_te_link *, uint32_t, uint32_t);
d62a17ae 407extern void set_linkparams_lrrid(struct mpls_te_link *, struct in_addr,
408 struct in_addr);
718e3744 409
f173deb3
OD
410struct zapi_opaque_reg_info;
411/**
412 * Call when a client send a Link State Sync message. In turn, OSPF will send
413 * the contain of the Link State Data base.
414 *
415 * @param info ZAPI Opaque message information
416 *
417 * @return 0 on success, -1 otherwise
418 */
419extern int ospf_te_sync_ted(struct zapi_opaque_reg_info dst);
420
718e3744 421#endif /* _ZEBRA_OSPF_MPLS_TE_H */