2 * IS-IS Rout(e)ing protocol - isis_te.c
4 * This is an implementation of RFC5305, RFC 5307 and RFC 7810
6 * Copyright (C) 2014 Orange Labs
7 * http://www.orange.com
9 * This file is part of GNU Zebra.
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
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.
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
26 #ifndef _ZEBRA_ISIS_MPLS_TE_H
27 #define _ZEBRA_ISIS_MPLS_TE_H
30 * Traffic Engineering information are transport through LSP:
31 * - Extended IS Reachability TLV = 22
32 * - Traffic Engineering Router ID TLV = 134
33 * - Extended IP Reachability TLV = 135
34 * - Inter-AS Reachability Information TLV = 141
36 * and support following sub-TLV:
39 * _________________________________________________
40 * Administartive group (color) 3 RFC5305
41 * Link Local/Remote Identifiers 4 RFC5307
42 * IPv4 interface address 6 RFC5305
43 * IPv4 neighbor address 8 RFC5305
44 * Maximum link bandwidth 9 RFC5305
45 * Reservable link bandwidth 10 RFC5305
46 * Unreserved bandwidth 11 RFC5305
47 * TE Default metric 18 RFC5305
48 * Link Protection Type 20 RFC5307
49 * Interface Switching Capability 21 RFC5307
50 * Remote AS number 24 RFC5316
51 * IPv4 Remote ASBR identifier 25 RFC5316
55 /* NOTE: RFC5316 is not yet supported in this version */
57 /* Following define the type of TE link regarding the various RFC */
66 #define IS_STD_TE(x) (x & STD_TE)
67 #define IS_INTER_AS(x) (x & INTER_AS)
68 #define IS_EMULATED(x) (x & EMULATED)
69 #define IS_FLOOD_L1(x) (x & FLOOD_L1)
70 #define IS_FLOOD_L2(x) (x & FLOOD_L2)
71 #define IS_FLOOD_AS(x) (x & FLOOD_AS)
72 #define IS_INTER_AS_EMU(x) (x & INTER_AS & EMULATED)
73 #define IS_INTER_AS_AS(x) (x & INTER_AS & FLOOD_AS)
76 * Following section defines subTLV (tag, length, value) structures,
77 * used for Traffic Engineering.
79 struct subtlv_header
{
80 uint8_t type
; /* sub_TLV_XXX type (see above) */
81 uint8_t length
; /* Value portion only, in byte */
84 #define MAX_SUBTLV_SIZE 256
86 #define SUBTLV_HDR_SIZE 2 /* (sizeof (struct sub_tlv_header)) */
88 #define SUBTLV_SIZE(stlvh) (SUBTLV_HDR_SIZE + (stlvh)->length)
90 #define SUBTLV_HDR_TOP(lsph) (struct subtlv_header *)((char *)(lsph) + ISIS_LSP_HEADER_SIZE)
92 #define SUBTLV_HDR_NEXT(stlvh) (struct subtlv_header *)((char *)(stlvh) + SUBTLV_SIZE(stlvh))
94 #define SUBTLV_TYPE(stlvh) stlvh.header.type
95 #define SUBTLV_LEN(stlvh) stlvh.header.length
96 #define SUBTLV_VAL(stlvh) stlvh.value
97 #define SUBTLV_DATA(stlvh) stlvh + SUBTLV_HDR_SIZE
99 #define SUBTLV_DEF_SIZE 4
101 /* Link Sub-TLV: Resource Class/Color - RFC 5305 */
102 #define TE_SUBTLV_ADMIN_GRP 3
103 struct te_subtlv_admin_grp
{
104 struct subtlv_header header
; /* Value length is 4 octets. */
105 uint32_t value
; /* Admin. group membership. */
106 } __attribute__((__packed__
));
108 /* Link Local/Remote Identifiers - RFC 5307 */
109 #define TE_SUBTLV_LLRI 4
110 #define TE_SUBTLV_LLRI_SIZE 8
111 struct te_subtlv_llri
{
112 struct subtlv_header header
; /* Value length is 8 octets. */
113 uint32_t local
; /* Link Local Identifier */
114 uint32_t remote
; /* Link Remote Identifier */
115 } __attribute__((__packed__
));
117 /* Link Sub-TLV: Local Interface IP Address - RFC 5305 */
118 #define TE_SUBTLV_LOCAL_IPADDR 6
119 struct te_subtlv_local_ipaddr
{
120 struct subtlv_header header
; /* Value length is 4 x N octets. */
121 struct in_addr value
; /* Local IP address(es). */
122 } __attribute__((__packed__
));
124 /* Link Sub-TLV: Neighbor Interface IP Address - RFC 5305 */
125 #define TE_SUBTLV_RMT_IPADDR 8
126 struct te_subtlv_rmt_ipaddr
{
127 struct subtlv_header header
; /* Value length is 4 x N octets. */
128 struct in_addr value
; /* Neighbor's IP address(es). */
129 } __attribute__((__packed__
));
131 /* Link Sub-TLV: Maximum Bandwidth - RFC 5305 */
132 #define TE_SUBTLV_MAX_BW 9
133 struct te_subtlv_max_bw
{
134 struct subtlv_header header
; /* Value length is 4 octets. */
135 float value
; /* bytes/sec */
136 } __attribute__((__packed__
));
138 /* Link Sub-TLV: Maximum Reservable Bandwidth - RFC 5305 */
139 #define TE_SUBTLV_MAX_RSV_BW 10
140 struct te_subtlv_max_rsv_bw
{
141 struct subtlv_header header
; /* Value length is 4 octets. */
142 float value
; /* bytes/sec */
143 } __attribute__((__packed__
));
145 /* Link Sub-TLV: Unreserved Bandwidth - RFC 5305 */
146 #define TE_SUBTLV_UNRSV_BW 11
147 #define TE_SUBTLV_UNRSV_SIZE 32
148 struct te_subtlv_unrsv_bw
{
149 struct subtlv_header header
; /* Value length is 32 octets. */
150 float value
[8]; /* One for each priority level. */
151 } __attribute__((__packed__
));
153 /* Link Sub-TLV: Traffic Engineering Metric - RFC 5305 */
154 #define TE_SUBTLV_TE_METRIC 18
155 #define TE_SUBTLV_TE_METRIC_SIZE 3
156 struct te_subtlv_te_metric
{
157 struct subtlv_header header
; /* Value length is 4 octets. */
158 uint8_t value
[3]; /* Link metric for TE purpose. */
159 } __attribute__((__packed__
));
161 /* Remote AS Number sub-TLV - RFC5316 */
162 #define TE_SUBTLV_RAS 24
163 struct te_subtlv_ras
{
164 struct subtlv_header header
; /* Value length is 4 octets. */
165 uint32_t value
; /* Remote AS number */
166 } __attribute__((__packed__
));
168 /* IPv4 Remote ASBR ID Sub-TLV - RFC5316 */
169 #define TE_SUBTLV_RIP 25
170 struct te_subtlv_rip
{
171 struct subtlv_header header
; /* Value length is 4 octets. */
172 struct in_addr value
; /* Remote ASBR IP address */
173 } __attribute__((__packed__
));
176 /* TE Metric Extensions - RFC 7810 */
177 /* Link Sub-TLV: Average Link Delay */
178 #define TE_SUBTLV_AV_DELAY 33
179 struct te_subtlv_av_delay
{
180 struct subtlv_header header
; /* Value length is 4 bytes. */
181 uint32_t value
; /* Average delay in micro-seconds only 24 bits => 0 ...
183 with Anomalous Bit (A) as Upper most bit */
184 } __attribute__((__packed__
));
186 /* Link Sub-TLV: Low/High Link Delay */
187 #define TE_SUBTLV_MM_DELAY 34
188 #define TE_SUBTLV_MM_DELAY_SIZE 8
189 struct te_subtlv_mm_delay
{
190 struct subtlv_header header
; /* Value length is 8 bytes. */
191 uint32_t low
; /* low delay in micro-seconds only 24 bits => 0 ...
193 with Anomalous Bit (A) as Upper most bit */
194 uint32_t high
; /* high delay in micro-seconds only 24 bits => 0 ...
196 } __attribute__((__packed__
));
198 /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
199 #define TE_SUBTLV_DELAY_VAR 35
200 struct te_subtlv_delay_var
{
201 struct subtlv_header header
; /* Value length is 4 bytes. */
202 uint32_t value
; /* interval in micro-seconds only 24 bits => 0 ...
204 } __attribute__((__packed__
));
206 /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
207 #define TE_SUBTLV_PKT_LOSS 36
208 struct te_subtlv_pkt_loss
{
209 struct subtlv_header header
; /* Value length is 4 bytes. */
211 value
; /* in percentage of total traffic only 24 bits (2^24 - 2)
212 with Anomalous Bit (A) as Upper most bit */
213 } __attribute__((__packed__
));
215 /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
216 #define TE_SUBTLV_RES_BW 37
217 struct te_subtlv_res_bw
{
218 struct subtlv_header header
; /* Value length is 4 bytes. */
219 float value
; /* bandwidth in IEEE floating point format with units in
221 } __attribute__((__packed__
));
223 /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
224 #define TE_SUBTLV_AVA_BW 38
225 struct te_subtlv_ava_bw
{
226 struct subtlv_header header
; /* Value length is 4 octets. */
227 float value
; /* bandwidth in IEEE floating point format with units in
229 } __attribute__((__packed__
));
231 /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
232 #define TE_SUBTLV_USE_BW 39
233 struct te_subtlv_use_bw
{
234 struct subtlv_header header
; /* Value length is 4 octets. */
235 float value
; /* bandwidth in IEEE floating point format with units in
237 } __attribute__((__packed__
));
239 #define TE_SUBTLV_MAX 40 /* Last SUBTLV + 1 */
241 /* Following declaration concerns the MPLS-TE and LINk-TE management */
242 typedef enum _status_t
{ disable
, enable
, learn
} status_t
;
244 /* Mode for Inter-AS LSP */ /* TODO: Check how if LSP is flooded in RFC5316 */
245 typedef enum _interas_mode_t
{ off
, region
, as
, emulate
} interas_mode_t
;
247 #define IS_MPLS_TE(m) (m && m->status == enable)
249 /* Per area MPLS-TE parameters */
250 struct mpls_te_area
{
251 /* Status of MPLS-TE: enable or disable */
254 /* L1, L1-L2, L2-Only */
258 interas_mode_t inter_as
;
259 struct in_addr interas_areaid
;
261 /* MPLS_TE router ID */
262 struct in_addr router_id
;
265 /* Per Circuit MPLS-TE parameters */
266 struct mpls_te_circuit
{
268 /* Status of MPLS-TE on this interface */
271 /* Type of MPLS-TE circuit: STD_TE(RFC5305), INTER_AS(RFC5316),
272 * INTER_AS_EMU(RFC5316 emulated) */
275 /* Total size of sub_tlvs */
278 /* Store subTLV in network byte order. */
280 struct te_subtlv_admin_grp admin_grp
;
282 struct te_subtlv_llri llri
;
284 struct te_subtlv_local_ipaddr local_ipaddr
;
285 struct te_subtlv_rmt_ipaddr rmt_ipaddr
;
286 struct te_subtlv_max_bw max_bw
;
287 struct te_subtlv_max_rsv_bw max_rsv_bw
;
288 struct te_subtlv_unrsv_bw unrsv_bw
;
289 struct te_subtlv_te_metric te_metric
;
291 struct te_subtlv_ras ras
;
292 struct te_subtlv_rip rip
;
294 struct te_subtlv_av_delay av_delay
;
295 struct te_subtlv_mm_delay mm_delay
;
296 struct te_subtlv_delay_var delay_var
;
297 struct te_subtlv_pkt_loss pkt_loss
;
298 struct te_subtlv_res_bw res_bw
;
299 struct te_subtlv_ava_bw ava_bw
;
300 struct te_subtlv_use_bw use_bw
;
304 void isis_mpls_te_init(void);
305 struct mpls_te_circuit
*mpls_te_circuit_new(void);
307 void mpls_te_print_detail(struct sbuf
*buf
, int indent
, uint8_t *subtlvs
,
309 void set_circuitparams_local_ipaddr(struct mpls_te_circuit
*, struct in_addr
);
310 void set_circuitparams_rmt_ipaddr(struct mpls_te_circuit
*, struct in_addr
);
311 uint8_t subtlvs_len(struct mpls_te_circuit
*);
312 uint8_t add_te_subtlvs(uint8_t *, struct mpls_te_circuit
*);
313 uint8_t build_te_subtlvs(uint8_t *, struct isis_circuit
*);
314 void isis_link_params_update(struct isis_circuit
*, struct interface
*);
315 void isis_mpls_te_update(struct interface
*);
317 #endif /* _ZEBRA_ISIS_MPLS_TE_H */