]>
Commit | Line | Data |
---|---|---|
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 | |
77 | #define FLOOD_AREA 0x10 | |
78 | #define FLOOD_AS 0x20 | |
79 | #define EMULATED 0x80 | |
80 | ||
ead99d5f | 81 | #define IS_STD_TE(x) (x & STD_TE) |
16f1b9ee OD |
82 | #define IS_PSEUDO_TE(x) (x & PSEUDO_TE) |
83 | #define IS_INTER_AS(x) (x & INTER_AS) | |
84 | #define IS_EMULATED(x) (x & EMULATED) | |
85 | #define IS_FLOOD_AREA(x) (x & FLOOD_AREA) | |
86 | #define IS_FLOOD_AS(x) (x & FLOOD_AS) | |
87 | #define IS_INTER_AS_EMU(x) (x & INTER_AS & EMULATED) | |
88 | #define IS_INTER_AS_AS(x) (x & INTER_AS & FLOOD_AS) | |
89 | ||
90 | /* Flags to manage TE Link LSA */ | |
91 | #define LPFLG_LSA_INACTIVE 0x0 | |
92 | #define LPFLG_LSA_ACTIVE 0x1 | |
93 | #define LPFLG_LSA_ENGAGED 0x2 | |
94 | #define LPFLG_LOOKUP_DONE 0x4 | |
95 | #define LPFLG_LSA_FORCED_REFRESH 0x8 | |
96 | ||
718e3744 | 97 | /* |
98 | * Following section defines TLV body parts. | |
99 | */ | |
ead99d5f | 100 | |
16f1b9ee | 101 | /* Router Address TLV */ /* Mandatory */ |
718e3744 | 102 | #define TE_TLV_ROUTER_ADDR 1 |
d62a17ae | 103 | struct te_tlv_router_addr { |
ead99d5f | 104 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 105 | struct in_addr value; |
718e3744 | 106 | }; |
107 | ||
108 | /* Link TLV */ | |
109 | #define TE_TLV_LINK 2 | |
d62a17ae | 110 | struct te_tlv_link { |
ead99d5f | 111 | struct tlv_header header; |
d62a17ae | 112 | /* A set of link-sub-TLVs will follow. */ |
718e3744 | 113 | }; |
114 | ||
ead99d5f | 115 | /* Default TE TLV size */ |
16f1b9ee OD |
116 | #define TE_LINK_SUBTLV_DEF_SIZE 4 |
117 | ||
118 | /* Link Type Sub-TLV */ /* Mandatory */ | |
119 | #define TE_LINK_SUBTLV_LINK_TYPE 1 | |
120 | #define TE_LINK_SUBTLV_TYPE_SIZE 1 | |
d62a17ae | 121 | struct te_link_subtlv_link_type { |
ead99d5f | 122 | struct tlv_header header; /* Value length is 1 octet. */ |
d62a17ae | 123 | struct { |
718e3744 | 124 | #define LINK_TYPE_SUBTLV_VALUE_PTP 1 |
125 | #define LINK_TYPE_SUBTLV_VALUE_MA 2 | |
d62a17ae | 126 | u_char value; |
127 | u_char padding[3]; | |
128 | } link_type; | |
718e3744 | 129 | }; |
130 | ||
16f1b9ee OD |
131 | /* Link Sub-TLV: Link ID */ /* Mandatory */ |
132 | #define TE_LINK_SUBTLV_LINK_ID 2 | |
d62a17ae | 133 | struct te_link_subtlv_link_id { |
ead99d5f | 134 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 135 | struct in_addr value; /* Same as router-lsa's link-id. */ |
718e3744 | 136 | }; |
137 | ||
16f1b9ee OD |
138 | /* Link Sub-TLV: Local Interface IP Address */ /* Optional */ |
139 | #define TE_LINK_SUBTLV_LCLIF_IPADDR 3 | |
d62a17ae | 140 | struct te_link_subtlv_lclif_ipaddr { |
ead99d5f | 141 | struct tlv_header header; /* Value length is 4 x N octets. */ |
d62a17ae | 142 | struct in_addr value[1]; /* Local IP address(es). */ |
718e3744 | 143 | }; |
144 | ||
16f1b9ee OD |
145 | /* Link Sub-TLV: Remote Interface IP Address */ /* Optional */ |
146 | #define TE_LINK_SUBTLV_RMTIF_IPADDR 4 | |
d62a17ae | 147 | struct te_link_subtlv_rmtif_ipaddr { |
ead99d5f | 148 | struct tlv_header header; /* Value length is 4 x N octets. */ |
d62a17ae | 149 | struct in_addr value[1]; /* Neighbor's IP address(es). */ |
718e3744 | 150 | }; |
151 | ||
16f1b9ee OD |
152 | /* Link Sub-TLV: Traffic Engineering Metric */ /* Optional */ |
153 | #define TE_LINK_SUBTLV_TE_METRIC 5 | |
d62a17ae | 154 | struct te_link_subtlv_te_metric { |
ead99d5f | 155 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 156 | u_int32_t value; /* Link metric for TE purpose. */ |
718e3744 | 157 | }; |
158 | ||
16f1b9ee OD |
159 | /* Link Sub-TLV: Maximum Bandwidth */ /* Optional */ |
160 | #define TE_LINK_SUBTLV_MAX_BW 6 | |
d62a17ae | 161 | struct te_link_subtlv_max_bw { |
ead99d5f | 162 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 163 | float value; /* bytes/sec */ |
718e3744 | 164 | }; |
165 | ||
16f1b9ee OD |
166 | /* Link Sub-TLV: Maximum Reservable Bandwidth */ /* Optional */ |
167 | #define TE_LINK_SUBTLV_MAX_RSV_BW 7 | |
d62a17ae | 168 | struct te_link_subtlv_max_rsv_bw { |
ead99d5f | 169 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 170 | float value; /* bytes/sec */ |
718e3744 | 171 | }; |
172 | ||
16f1b9ee OD |
173 | /* Link Sub-TLV: Unreserved Bandwidth */ /* Optional */ |
174 | #define TE_LINK_SUBTLV_UNRSV_BW 8 | |
175 | #define TE_LINK_SUBTLV_UNRSV_SIZE 32 | |
d62a17ae | 176 | struct te_link_subtlv_unrsv_bw { |
ead99d5f | 177 | struct tlv_header header; /* Value length is 32 octets. */ |
d62a17ae | 178 | float value[MAX_CLASS_TYPE]; /* One for each priority level. */ |
718e3744 | 179 | }; |
180 | ||
16f1b9ee OD |
181 | /* Link Sub-TLV: Resource Class/Color */ /* Optional */ |
182 | #define TE_LINK_SUBTLV_RSC_CLSCLR 9 | |
d62a17ae | 183 | struct te_link_subtlv_rsc_clsclr { |
ead99d5f | 184 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 185 | u_int32_t value; /* Admin. group membership. */ |
718e3744 | 186 | }; |
187 | ||
16f1b9ee OD |
188 | /* For RFC6827 */ |
189 | /* Local and Remote TE Router ID */ | |
190 | #define TE_LINK_SUBTLV_LRRID 10 | |
191 | #define TE_LINK_SUBTLV_LRRID_SIZE 8 | |
d62a17ae | 192 | struct te_link_subtlv_lrrid { |
ead99d5f | 193 | struct tlv_header header; /* Value length is 8 octets. */ |
d62a17ae | 194 | struct in_addr local; /* Local TE Router Identifier */ |
195 | struct in_addr remote; /* Remote TE Router Identifier */ | |
16f1b9ee OD |
196 | }; |
197 | ||
198 | /* RFC4203: Link Local/Remote Identifiers */ | |
199 | #define TE_LINK_SUBTLV_LLRI 11 | |
200 | #define TE_LINK_SUBTLV_LLRI_SIZE 8 | |
d62a17ae | 201 | struct te_link_subtlv_llri { |
ead99d5f | 202 | struct tlv_header header; /* Value length is 8 octets. */ |
d62a17ae | 203 | u_int32_t local; /* Link Local Identifier */ |
204 | u_int32_t remote; /* Link Remote Identifier */ | |
16f1b9ee OD |
205 | }; |
206 | ||
d62a17ae | 207 | /* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13) |
208 | * (RFC6827bis) are not yet supported */ | |
16f1b9ee OD |
209 | /* SUBTLV 14-16 (RFC4203) are not yet supported */ |
210 | /* Bandwidth Constraints sub-TLV (17) (RFC4124) is not yet supported */ | |
b2d4d039 | 211 | /* SUBLV 18-20 are for OSPFv3 TE (RFC5329). see ospf6d */ |
16f1b9ee OD |
212 | |
213 | /* For RFC 5392 */ | |
214 | /* Remote AS Number sub-TLV */ | |
215 | #define TE_LINK_SUBTLV_RAS 21 | |
d62a17ae | 216 | struct te_link_subtlv_ras { |
ead99d5f | 217 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 218 | u_int32_t value; /* Remote AS number */ |
16f1b9ee OD |
219 | }; |
220 | ||
221 | /* IPv4 Remote ASBR ID Sub-TLV */ | |
222 | #define TE_LINK_SUBTLV_RIP 22 | |
d62a17ae | 223 | struct te_link_subtlv_rip { |
ead99d5f | 224 | struct tlv_header header; /* Value length is 4 octets. */ |
d62a17ae | 225 | struct in_addr value; /* Remote ASBR IP address */ |
16f1b9ee OD |
226 | }; |
227 | ||
228 | /* SUBTLV 24 is IPv6 Remote ASBR ID (RFC5392). see ospf6d */ | |
229 | ||
230 | /* SUBTLV 23 (RFC5330) and 25 (RFC6001) are not yet supported */ | |
231 | ||
232 | /* SUBTLV 26 (RFC7308) is not yet supported */ | |
233 | ||
234 | /* RFC7471 */ | |
235 | /* Link Sub-TLV: Average Link Delay */ /* Optional */ | |
236 | #define TE_LINK_SUBTLV_AV_DELAY 27 | |
d62a17ae | 237 | struct te_link_subtlv_av_delay { |
ead99d5f OD |
238 | struct tlv_header header; /* Value length is 4 bytes. */ |
239 | /* | |
240 | * delay in micro-seconds only 24 bits => 0 ... 16777215 | |
241 | * with Anomalous Bit as Upper most bit | |
242 | */ | |
243 | u_int32_t value; | |
16f1b9ee OD |
244 | }; |
245 | ||
246 | /* Link Sub-TLV: Low/High Link Delay */ | |
247 | #define TE_LINK_SUBTLV_MM_DELAY 28 | |
248 | #define TE_LINK_SUBTLV_MM_DELAY_SIZE 8 | |
d62a17ae | 249 | struct te_link_subtlv_mm_delay { |
ead99d5f OD |
250 | struct tlv_header header; /* Value length is 8 bytes. */ |
251 | /* | |
252 | * low delay in micro-seconds only 24 bits => 0 ... 16777215 | |
253 | * with Anomalous Bit (A) as Upper most bit | |
254 | */ | |
255 | u_int32_t low; | |
256 | /* high delay in micro-seconds only 24 bits => 0 ... 16777215 */ | |
257 | u_int32_t high; | |
16f1b9ee OD |
258 | }; |
259 | ||
260 | /* Link Sub-TLV: Link Delay Variation i.e. Jitter */ | |
261 | #define TE_LINK_SUBTLV_DELAY_VAR 29 | |
d62a17ae | 262 | struct te_link_subtlv_delay_var { |
ead99d5f OD |
263 | struct tlv_header header; /* Value length is 4 bytes. */ |
264 | /* interval in micro-seconds only 24 bits => 0 ... 16777215 */ | |
265 | u_int32_t value; | |
16f1b9ee OD |
266 | }; |
267 | ||
268 | /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */ | |
269 | #define TE_LINK_SUBTLV_PKT_LOSS 30 | |
d62a17ae | 270 | struct te_link_subtlv_pkt_loss { |
ead99d5f OD |
271 | struct tlv_header header; /* Value length is 4 bytes. */ |
272 | /* | |
273 | * in percentage of total traffic only 24 bits (2^24 - 2) | |
274 | * with Anomalous Bit as Upper most bit | |
275 | */ | |
276 | u_int32_t value; | |
16f1b9ee OD |
277 | }; |
278 | ||
279 | /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */ | |
280 | #define TE_LINK_SUBTLV_RES_BW 31 | |
d62a17ae | 281 | struct te_link_subtlv_res_bw { |
ead99d5f OD |
282 | struct tlv_header header; /* Value length is 4 bytes. */ |
283 | /* bandwidth in IEEE floating point format with units in bytes/second */ | |
284 | float value; | |
16f1b9ee OD |
285 | }; |
286 | ||
287 | /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */ | |
288 | #define TE_LINK_SUBTLV_AVA_BW 32 | |
d62a17ae | 289 | struct te_link_subtlv_ava_bw { |
ead99d5f OD |
290 | struct tlv_header header; /* Value length is 4 octets. */ |
291 | /* bandwidth in IEEE floating point format with units in bytes/second */ | |
292 | float value; | |
16f1b9ee OD |
293 | }; |
294 | ||
295 | /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */ | |
296 | #define TE_LINK_SUBTLV_USE_BW 33 | |
d62a17ae | 297 | struct te_link_subtlv_use_bw { |
ead99d5f OD |
298 | struct tlv_header header; /* Value length is 4 octets. */ |
299 | /* bandwidth in IEEE floating point format with units in bytes/second */ | |
300 | float value; | |
16f1b9ee OD |
301 | }; |
302 | ||
303 | #define TE_LINK_SUBTLV_MAX 34 /* Last SUBTLV + 1 */ | |
304 | ||
305 | /* Here are "non-official" architectural constants. */ | |
718e3744 | 306 | #define MPLS_TE_MINIMUM_BANDWIDTH 1.0 /* Reasonable? *//* XXX */ |
307 | ||
16f1b9ee | 308 | /* Mode for Inter-AS Opaque-LSA */ |
ead99d5f | 309 | enum inter_as_mode { Off, AS, Area }; |
16f1b9ee | 310 | |
d62a17ae | 311 | struct te_link_subtlv { |
ead99d5f | 312 | struct tlv_header header; |
d62a17ae | 313 | union { |
314 | u_int32_t link_type; | |
315 | struct in_addr link_id; | |
316 | struct in_addr lclif; | |
317 | struct in_addr rmtif; | |
318 | u_int32_t te_metric; | |
319 | float max_bw; | |
320 | float max_rsv_bw; | |
321 | float unrsv[8]; | |
322 | u_int32_t rsc_clsclr; | |
323 | u_int32_t llri[2]; | |
324 | u_int32_t ras; | |
325 | struct in_addr rip; | |
326 | struct in_addr lrrid[2]; | |
327 | u_int32_t av_delay; | |
328 | u_int32_t mm_delay; | |
329 | u_int32_t delay_var; | |
330 | u_int32_t pkt_loss; | |
331 | float res_bw; | |
332 | float ava_bw; | |
333 | float use_bw; | |
334 | } value; | |
16f1b9ee OD |
335 | }; |
336 | ||
337 | /* Following structure are internal use only. */ | |
d62a17ae | 338 | struct ospf_mpls_te { |
339 | /* Status of MPLS-TE: enable or disbale */ | |
32ab5cf4 | 340 | bool enabled; |
16f1b9ee | 341 | |
d62a17ae | 342 | /* RFC5392 */ |
343 | enum inter_as_mode inter_as; | |
344 | struct in_addr interas_areaid; | |
16f1b9ee | 345 | |
d62a17ae | 346 | /* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi). |
347 | */ | |
348 | struct list *iflist; | |
16f1b9ee | 349 | |
d62a17ae | 350 | /* Store Router-TLV in network byte order. */ |
351 | struct te_tlv_router_addr router_addr; | |
16f1b9ee OD |
352 | }; |
353 | ||
d62a17ae | 354 | struct mpls_te_link { |
355 | /* | |
356 | * According to MPLS-TE (draft) specification, 24-bit Opaque-ID field | |
357 | * is subdivided into 8-bit "unused" field and 16-bit "instance" field. | |
358 | * In this implementation, each Link-TLV has its own instance. | |
359 | */ | |
360 | u_int32_t instance; | |
361 | ||
362 | /* Reference pointer to a Zebra-interface. */ | |
363 | struct interface *ifp; | |
364 | ||
365 | /* Area info in which this MPLS-TE link belongs to. */ | |
366 | struct ospf_area *area; | |
367 | ||
368 | /* Flags to manage this link parameters. */ | |
369 | u_int32_t flags; | |
370 | ||
371 | /* Type of MPLS-TE link: RFC3630, RFC5392, RFC5392 emulated, RFC6827 */ | |
372 | u_int8_t type; | |
373 | ||
374 | /* Store Link-TLV in network byte order. */ | |
375 | /* RFC3630 & RFC6827 / RFC 6827 */ | |
376 | struct te_tlv_link link_header; | |
377 | struct te_link_subtlv_link_type link_type; | |
378 | struct te_link_subtlv_link_id link_id; | |
379 | struct te_link_subtlv_lclif_ipaddr lclif_ipaddr; | |
380 | struct te_link_subtlv_rmtif_ipaddr rmtif_ipaddr; | |
381 | struct te_link_subtlv_te_metric te_metric; | |
382 | struct te_link_subtlv_max_bw max_bw; | |
383 | struct te_link_subtlv_max_rsv_bw max_rsv_bw; | |
384 | struct te_link_subtlv_unrsv_bw unrsv_bw; | |
385 | struct te_link_subtlv_rsc_clsclr rsc_clsclr; | |
386 | /* RFC4203 */ | |
387 | struct te_link_subtlv_llri llri; | |
388 | /* RFC5392 */ | |
389 | struct te_link_subtlv_ras ras; | |
390 | struct te_link_subtlv_rip rip; | |
391 | /* RFC6827 */ | |
392 | struct te_link_subtlv_lrrid lrrid; | |
393 | /* RFC7471 */ | |
394 | struct te_link_subtlv_av_delay av_delay; | |
395 | struct te_link_subtlv_mm_delay mm_delay; | |
396 | struct te_link_subtlv_delay_var delay_var; | |
397 | struct te_link_subtlv_pkt_loss pkt_loss; | |
398 | struct te_link_subtlv_res_bw res_bw; | |
399 | struct te_link_subtlv_ava_bw ava_bw; | |
400 | struct te_link_subtlv_use_bw use_bw; | |
401 | ||
402 | struct in_addr adv_router; | |
403 | struct in_addr id; | |
16f1b9ee OD |
404 | }; |
405 | ||
718e3744 | 406 | /* Prototypes. */ |
d62a17ae | 407 | extern int ospf_mpls_te_init(void); |
408 | extern void ospf_mpls_te_term(void); | |
409 | extern struct ospf_mpls_te *get_ospf_mpls_te(void); | |
410 | extern void ospf_mpls_te_update_if(struct interface *); | |
2a39170c | 411 | extern void ospf_mpls_te_lsa_schedule(struct mpls_te_link *, enum lsa_opcode); |
d62a17ae | 412 | extern void set_linkparams_llri(struct mpls_te_link *, u_int32_t, u_int32_t); |
413 | extern void set_linkparams_lrrid(struct mpls_te_link *, struct in_addr, | |
414 | struct in_addr); | |
718e3744 | 415 | |
416 | #endif /* _ZEBRA_OSPF_MPLS_TE_H */ |