]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_te.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfd / ospf_te.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * This is an implementation of RFC3630, RFC5392 & RFC6827
4 * Copyright (C) 2001 KDD R&D Laboratories, Inc.
5 * http://www.kddlabs.co.jp/
6 *
7 * Copyright (C) 2012 Orange Labs
8 * http://www.orange.com
9 */
10
11 /* Add support of RFC7471 */
12 /* Add support of RFC5392 */
13 /* Add support of RFC6827 (partial) */
14
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
35 #define MAX_LEGAL_TE_INSTANCE_NUM (0xffff)
36 #define LEGAL_TE_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
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
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
62 #define EMULATED 0x10
63
64 #define IS_STD_TE(x) (x & STD_TE)
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)
68
69 /* Flags to manage TE Link LSA */
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)
78
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
86 /*
87 * Following section defines TLV body parts.
88 */
89
90 /* Router Address TLV */ /* Mandatory */
91 #define TE_TLV_ROUTER_ADDR 1
92 struct te_tlv_router_addr {
93 struct tlv_header header; /* Value length is 4 octets. */
94 struct in_addr value;
95 };
96
97 /* Link TLV */
98 #define TE_TLV_LINK 2
99 struct te_tlv_link {
100 struct tlv_header header;
101 /* A set of link-sub-TLVs will follow. */
102 };
103
104 /* Default TE TLV size */
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
110 struct te_link_subtlv_link_type {
111 struct tlv_header header; /* Value length is 1 octet. */
112 struct {
113 #define LINK_TYPE_SUBTLV_VALUE_PTP 1
114 #define LINK_TYPE_SUBTLV_VALUE_MA 2
115 uint8_t value;
116 uint8_t padding[3];
117 } link_type;
118 };
119
120 /* Link Sub-TLV: Link ID */ /* Mandatory */
121 #define TE_LINK_SUBTLV_LINK_ID 2
122 struct te_link_subtlv_link_id {
123 struct tlv_header header; /* Value length is 4 octets. */
124 struct in_addr value; /* Same as router-lsa's link-id. */
125 };
126
127 /* Link Sub-TLV: Local Interface IP Address */ /* Optional */
128 #define TE_LINK_SUBTLV_LCLIF_IPADDR 3
129 struct te_link_subtlv_lclif_ipaddr {
130 struct tlv_header header; /* Value length is 4 x N octets. */
131 struct in_addr value[1]; /* Local IP address(es). */
132 };
133
134 /* Link Sub-TLV: Remote Interface IP Address */ /* Optional */
135 #define TE_LINK_SUBTLV_RMTIF_IPADDR 4
136 struct te_link_subtlv_rmtif_ipaddr {
137 struct tlv_header header; /* Value length is 4 x N octets. */
138 struct in_addr value[1]; /* Neighbor's IP address(es). */
139 };
140
141 /* Link Sub-TLV: Traffic Engineering Metric */ /* Optional */
142 #define TE_LINK_SUBTLV_TE_METRIC 5
143 struct te_link_subtlv_te_metric {
144 struct tlv_header header; /* Value length is 4 octets. */
145 uint32_t value; /* Link metric for TE purpose. */
146 };
147
148 /* Link Sub-TLV: Maximum Bandwidth */ /* Optional */
149 #define TE_LINK_SUBTLV_MAX_BW 6
150 struct te_link_subtlv_max_bw {
151 struct tlv_header header; /* Value length is 4 octets. */
152 float value; /* bytes/sec */
153 };
154
155 /* Link Sub-TLV: Maximum Reservable Bandwidth */ /* Optional */
156 #define TE_LINK_SUBTLV_MAX_RSV_BW 7
157 struct te_link_subtlv_max_rsv_bw {
158 struct tlv_header header; /* Value length is 4 octets. */
159 float value; /* bytes/sec */
160 };
161
162 /* Link Sub-TLV: Unreserved Bandwidth */ /* Optional */
163 #define TE_LINK_SUBTLV_UNRSV_BW 8
164 #define TE_LINK_SUBTLV_UNRSV_SIZE 32
165 struct te_link_subtlv_unrsv_bw {
166 struct tlv_header header; /* Value length is 32 octets. */
167 float value[MAX_CLASS_TYPE]; /* One for each priority level. */
168 };
169
170 /* Link Sub-TLV: Resource Class/Color */ /* Optional */
171 #define TE_LINK_SUBTLV_RSC_CLSCLR 9
172 struct te_link_subtlv_rsc_clsclr {
173 struct tlv_header header; /* Value length is 4 octets. */
174 uint32_t value; /* Admin. group membership. */
175 };
176
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
181 struct te_link_subtlv_lrrid {
182 struct tlv_header header; /* Value length is 8 octets. */
183 struct in_addr local; /* Local TE Router Identifier */
184 struct in_addr remote; /* Remote TE Router Identifier */
185 };
186
187 /* RFC4203: Link Local/Remote Identifiers */
188 #define TE_LINK_SUBTLV_LLRI 11
189 #define TE_LINK_SUBTLV_LLRI_SIZE 8
190 struct te_link_subtlv_llri {
191 struct tlv_header header; /* Value length is 8 octets. */
192 uint32_t local; /* Link Local Identifier */
193 uint32_t remote; /* Link Remote Identifier */
194 };
195
196 /* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13)
197 * (RFC6827bis) are not yet supported */
198 /* SUBTLV 14-16 (RFC4203) are not yet supported */
199 /* Bandwidth Constraints sub-TLV (17) (RFC4124) is not yet supported */
200 /* SUBLV 18-20 are for OSPFv3 TE (RFC5329). see ospf6d */
201
202 /* For RFC 5392 */
203 /* Remote AS Number sub-TLV */
204 #define TE_LINK_SUBTLV_RAS 21
205 struct te_link_subtlv_ras {
206 struct tlv_header header; /* Value length is 4 octets. */
207 uint32_t value; /* Remote AS number */
208 };
209
210 /* IPv4 Remote ASBR ID Sub-TLV */
211 #define TE_LINK_SUBTLV_RIP 22
212 struct te_link_subtlv_rip {
213 struct tlv_header header; /* Value length is 4 octets. */
214 struct in_addr value; /* Remote ASBR IP address */
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
226 struct te_link_subtlv_av_delay {
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 */
232 uint32_t value;
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
238 struct te_link_subtlv_mm_delay {
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 */
244 uint32_t low;
245 /* high delay in micro-seconds only 24 bits => 0 ... 16777215 */
246 uint32_t high;
247 };
248
249 /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
250 #define TE_LINK_SUBTLV_DELAY_VAR 29
251 struct te_link_subtlv_delay_var {
252 struct tlv_header header; /* Value length is 4 bytes. */
253 /* interval in micro-seconds only 24 bits => 0 ... 16777215 */
254 uint32_t value;
255 };
256
257 /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
258 #define TE_LINK_SUBTLV_PKT_LOSS 30
259 struct te_link_subtlv_pkt_loss {
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 */
265 uint32_t value;
266 };
267
268 /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
269 #define TE_LINK_SUBTLV_RES_BW 31
270 struct te_link_subtlv_res_bw {
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;
274 };
275
276 /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
277 #define TE_LINK_SUBTLV_AVA_BW 32
278 struct te_link_subtlv_ava_bw {
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;
282 };
283
284 /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
285 #define TE_LINK_SUBTLV_USE_BW 33
286 struct te_link_subtlv_use_bw {
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;
290 };
291
292 #define TE_LINK_SUBTLV_MAX 34 /* Last SUBTLV + 1 */
293
294 /* Here are "non-official" architectural constants. */
295 #define MPLS_TE_MINIMUM_BANDWIDTH 1.0 /* Reasonable? *//* XXX */
296
297 /* Mode for Inter-AS Opaque-LSA */
298 enum inter_as_mode { Off, AS, Area };
299
300 struct te_link_subtlv {
301 struct tlv_header header;
302 union {
303 uint32_t link_type;
304 struct in_addr link_id;
305 struct in_addr lclif;
306 struct in_addr rmtif;
307 uint32_t te_metric;
308 float max_bw;
309 float max_rsv_bw;
310 float unrsv[8];
311 uint32_t rsc_clsclr;
312 uint32_t llri[2];
313 uint32_t ras;
314 struct in_addr rip;
315 struct in_addr lrrid[2];
316 uint32_t av_delay;
317 uint32_t mm_delay;
318 uint32_t delay_var;
319 uint32_t pkt_loss;
320 float res_bw;
321 float ava_bw;
322 float use_bw;
323 } value;
324 };
325
326 /* Following structure are internal use only. */
327 struct ospf_mpls_te {
328 /* Status of MPLS-TE: enable or disable */
329 bool enabled;
330
331 /* Traffic Engineering Database i.e. Link State */
332 struct ls_ted *ted;
333 bool export;
334
335 /* RFC5392 */
336 enum inter_as_mode inter_as;
337 struct in_addr interas_areaid;
338
339 /* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi).
340 */
341 struct list *iflist;
342
343 /* Store Router-TLV in network byte order. */
344 struct te_tlv_router_addr router_addr;
345 };
346
347 struct 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 */
353 uint32_t instance;
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. */
362 uint32_t flags;
363
364 /* Type of MPLS-TE link: RFC3630, RFC5392, RFC5392 emulated, RFC6827 */
365 uint8_t type;
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;
397 };
398
399 /* Prototypes. */
400 extern int ospf_mpls_te_init(void);
401 extern void ospf_mpls_te_term(void);
402 extern void ospf_mpls_te_finish(void);
403 extern struct ospf_mpls_te *get_ospf_mpls_te(void);
404 extern void ospf_mpls_te_update_if(struct interface *);
405 extern void ospf_mpls_te_lsa_schedule(struct mpls_te_link *, enum lsa_opcode);
406 extern void set_linkparams_llri(struct mpls_te_link *, uint32_t, uint32_t);
407 extern void set_linkparams_lrrid(struct mpls_te_link *, struct in_addr,
408 struct in_addr);
409
410 struct 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 */
419 extern int ospf_te_sync_ted(struct zapi_opaque_reg_info dst);
420
421 #endif /* _ZEBRA_OSPF_MPLS_TE_H */