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