isis_te.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*
  2. * IS-IS Rout(e)ing protocol - isis_te.c
  3. *
  4. * This is an implementation of RFC5305, RFC 5307 and draft-ietf-isis-te-metric-extensions-11
  5. *
  6. * Copyright (C) 2014 Orange Labs
  7. * http://www.orange.com
  8. *
  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.
  15. *
  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. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  23. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  24. * 02111-1307, USA.
  25. */
  26. #ifndef _ZEBRA_ISIS_MPLS_TE_H
  27. #define _ZEBRA_ISIS_MPLS_TE_H
  28. /*
  29. * Traffic Engineering information are transport through LSP:
  30. * - Extended IS Reachability TLV = 22
  31. * - Traffic Engineering Router ID TLV = 134
  32. * - Extended IP Reachability TLV = 135
  33. * - Inter-AS Reachability Information TLV = 141
  34. *
  35. * and support following sub-TLV:
  36. *
  37. * Name Value Status
  38. * _________________________________________________
  39. * Administartive group (color) 3 RFC5305
  40. * Link Local/Remote Identifiers 4 RFC5307
  41. * IPv4 interface address 6 RFC5305
  42. * IPv4 neighbor address 8 RFC5305
  43. * Maximum link bandwidth 9 RFC5305
  44. * Reservable link bandwidth 10 RFC5305
  45. * Unreserved bandwidth 11 RFC5305
  46. * TE Default metric 18 RFC5305
  47. * Link Protection Type 20 RFC5307
  48. * Interface Switching Capability 21 RFC5307
  49. * Remote AS number 24 RFC5316
  50. * IPv4 Remote ASBR identifier 25 RFC5316
  51. *
  52. */
  53. /* NOTE: RFC5316 is not yet supported in this version */
  54. /* Following define the type of TE link regarding the various RFC */
  55. #define STD_TE 0x01
  56. #define GMPLS 0x02
  57. #define INTER_AS 0x04
  58. #define FLOOD_L1 0x10
  59. #define FLOOD_L2 0x20
  60. #define FLOOD_AS 0x40
  61. #define EMULATED 0x80
  62. #define IS_STD_TE(x) (x & STD_TE)
  63. #define IS_INTER_AS(x) (x & INTER_AS)
  64. #define IS_EMULATED(x) (x & EMULATED)
  65. #define IS_FLOOD_L1(x) (x & FLOOD_L1)
  66. #define IS_FLOOD_L2(x) (x & FLOOD_L2)
  67. #define IS_FLOOD_AS(x) (x & FLOOD_AS)
  68. #define IS_INTER_AS_EMU(x) (x & INTER_AS & EMULATED)
  69. #define IS_INTER_AS_AS(x) (x & INTER_AS & FLOOD_AS)
  70. /*
  71. * Following section defines subTLV (tag, length, value) structures,
  72. * used for Traffic Engineering.
  73. */
  74. struct subtlv_header
  75. {
  76. u_char type; /* sub_TLV_XXX type (see above) */
  77. u_char length; /* Value portion only, in byte */
  78. };
  79. #define SUBTLV_HDR_SIZE 2 /* (sizeof (struct sub_tlv_header)) */
  80. #define SUBTLV_SIZE(stlvh) (SUBTLV_HDR_SIZE + (stlvh)->length)
  81. #define SUBTLV_HDR_TOP(lsph) (struct subtlv_header *)((char *)(lsph) + ISIS_LSP_HEADER_SIZE)
  82. #define SUBTLV_HDR_NEXT(stlvh) (struct subtlv_header *)((char *)(stlvh) + SUBTLV_SIZE(stlvh))
  83. #define SUBTLV_TYPE(stlvh) stlvh.header.type
  84. #define SUBTLV_LEN(stlvh) stlvh.header.length
  85. #define SUBTLV_VAL(stlvh) stlvh.value
  86. #define SUBTLV_DATA(stlvh) stlvh + SUBTLV_HDR_SIZE
  87. #define SUBTLV_DEF_SIZE 4
  88. /* Link Sub-TLV: Resource Class/Color - RFC 5305 */
  89. #define TE_SUBTLV_ADMIN_GRP 3
  90. struct te_subtlv_admin_grp
  91. {
  92. struct subtlv_header header; /* Value length is 4 octets. */
  93. u_int32_t value; /* Admin. group membership. */
  94. } __attribute__((__packed__));
  95. /* Link Local/Remote Identifiers - RFC 5307 */
  96. #define TE_SUBTLV_LLRI 4
  97. #define TE_SUBTLV_LLRI_SIZE 8
  98. struct te_subtlv_llri
  99. {
  100. struct subtlv_header header; /* Value length is 8 octets. */
  101. u_int32_t local; /* Link Local Identifier */
  102. u_int32_t remote; /* Link Remote Identifier */
  103. } __attribute__((__packed__));
  104. /* Link Sub-TLV: Local Interface IP Address - RFC 5305 */
  105. #define TE_SUBTLV_LOCAL_IPADDR 6
  106. struct te_subtlv_local_ipaddr
  107. {
  108. struct subtlv_header header; /* Value length is 4 x N octets. */
  109. struct in_addr value; /* Local IP address(es). */
  110. } __attribute__((__packed__));
  111. /* Link Sub-TLV: Neighbor Interface IP Address - RFC 5305 */
  112. #define TE_SUBTLV_RMT_IPADDR 8
  113. struct te_subtlv_rmt_ipaddr
  114. {
  115. struct subtlv_header header; /* Value length is 4 x N octets. */
  116. struct in_addr value; /* Neighbor's IP address(es). */
  117. } __attribute__((__packed__));
  118. /* Link Sub-TLV: Maximum Bandwidth - RFC 5305 */
  119. #define TE_SUBTLV_MAX_BW 9
  120. struct te_subtlv_max_bw
  121. {
  122. struct subtlv_header header; /* Value length is 4 octets. */
  123. float value; /* bytes/sec */
  124. } __attribute__((__packed__));
  125. /* Link Sub-TLV: Maximum Reservable Bandwidth - RFC 5305 */
  126. #define TE_SUBTLV_MAX_RSV_BW 10
  127. struct te_subtlv_max_rsv_bw
  128. {
  129. struct subtlv_header header; /* Value length is 4 octets. */
  130. float value; /* bytes/sec */
  131. } __attribute__((__packed__));
  132. /* Link Sub-TLV: Unreserved Bandwidth - RFC 5305 */
  133. #define TE_SUBTLV_UNRSV_BW 11
  134. #define TE_SUBTLV_UNRSV_SIZE 32
  135. struct te_subtlv_unrsv_bw
  136. {
  137. struct subtlv_header header; /* Value length is 32 octets. */
  138. float value[8]; /* One for each priority level. */
  139. } __attribute__((__packed__));
  140. /* Link Sub-TLV: Traffic Engineering Metric - RFC 5305 */
  141. #define TE_SUBTLV_TE_METRIC 18
  142. #define TE_SUBTLV_TE_METRIC_SIZE 3
  143. struct te_subtlv_te_metric
  144. {
  145. struct subtlv_header header; /* Value length is 4 octets. */
  146. u_char value[3]; /* Link metric for TE purpose. */
  147. } __attribute__((__packed__));
  148. /* Remote AS Number sub-TLV - RFC5316 */
  149. #define TE_SUBTLV_RAS 24
  150. struct te_subtlv_ras
  151. {
  152. struct subtlv_header header; /* Value length is 4 octets. */
  153. u_int32_t value; /* Remote AS number */
  154. } __attribute__((__packed__));
  155. /* IPv4 Remote ASBR ID Sub-TLV - RFC5316 */
  156. #define TE_SUBTLV_RIP 25
  157. struct te_subtlv_rip
  158. {
  159. struct subtlv_header header; /* Value length is 4 octets. */
  160. struct in_addr value; /* Remote ASBR IP address */
  161. } __attribute__((__packed__));
  162. /* draft-ietf-isis-te-metric-extensions-11.txt */
  163. /* Link Sub-TLV: Average Link Delay */
  164. #define TE_SUBTLV_AV_DELAY 33
  165. struct te_subtlv_av_delay
  166. {
  167. struct subtlv_header header; /* Value length is 4 bytes. */
  168. u_int32_t value; /* Average delay in micro-seconds only 24 bits => 0 ... 16777215
  169. with Anomalous Bit (A) as Upper most bit */
  170. } __attribute__((__packed__));
  171. /* Link Sub-TLV: Low/High Link Delay */
  172. #define TE_SUBTLV_MM_DELAY 34
  173. #define TE_SUBTLV_MM_DELAY_SIZE 8
  174. struct te_subtlv_mm_delay
  175. {
  176. struct subtlv_header header; /* Value length is 8 bytes. */
  177. u_int32_t low; /* low delay in micro-seconds only 24 bits => 0 ... 16777215
  178. with Anomalous Bit (A) as Upper most bit */
  179. u_int32_t high; /* high delay in micro-seconds only 24 bits => 0 ... 16777215 */
  180. } __attribute__((__packed__));
  181. /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
  182. #define TE_SUBTLV_DELAY_VAR 35
  183. struct te_subtlv_delay_var
  184. {
  185. struct subtlv_header header; /* Value length is 4 bytes. */
  186. u_int32_t value; /* interval in micro-seconds only 24 bits => 0 ... 16777215 */
  187. } __attribute__((__packed__));
  188. /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
  189. #define TE_SUBTLV_PKT_LOSS 36
  190. struct te_subtlv_pkt_loss
  191. {
  192. struct subtlv_header header; /* Value length is 4 bytes. */
  193. u_int32_t value; /* in percentage of total traffic only 24 bits (2^24 - 2)
  194. with Anomalous Bit (A) as Upper most bit */
  195. } __attribute__((__packed__));
  196. /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
  197. #define TE_SUBTLV_RES_BW 37
  198. struct te_subtlv_res_bw
  199. {
  200. struct subtlv_header header; /* Value length is 4 bytes. */
  201. float value; /* bandwidth in IEEE floating point format with units in bytes per second */
  202. } __attribute__((__packed__));
  203. /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
  204. #define TE_SUBTLV_AVA_BW 38
  205. struct te_subtlv_ava_bw
  206. {
  207. struct subtlv_header header; /* Value length is 4 octets. */
  208. float value; /* bandwidth in IEEE floating point format with units in bytes per second */
  209. } __attribute__((__packed__));
  210. /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
  211. #define TE_SUBTLV_USE_BW 39
  212. struct te_subtlv_use_bw
  213. {
  214. struct subtlv_header header; /* Value length is 4 octets. */
  215. float value; /* bandwidth in IEEE floating point format with units in bytes per second */
  216. } __attribute__((__packed__));
  217. #define TE_SUBTLV_MAX 40 /* Last SUBTLV + 1 */
  218. /* Following declaration concerns the MPLS-TE and LINk-TE management */
  219. typedef enum _status_t { disable, enable, learn } status_t;
  220. /* Mode for Inter-AS LSP */ /* TODO: Check how if LSP is flooded in RFC5316 */
  221. typedef enum _interas_mode_t { off, region, as, emulate } interas_mode_t;
  222. #define IS_MPLS_TE(m) (m.status == enable)
  223. #define IS_CIRCUIT_TE(c) (c->status == enable)
  224. /* Following structure are internal use only. */
  225. struct isis_mpls_te
  226. {
  227. /* Status of MPLS-TE: enable or disable */
  228. status_t status;
  229. /* L1, L1-L2, L2-Only */
  230. u_int8_t level;
  231. /* RFC5316 */
  232. interas_mode_t inter_as;
  233. struct in_addr interas_areaid;
  234. /* Circuit list on which TE are enable */
  235. struct list *cir_list;
  236. /* MPLS_TE router ID */
  237. struct in_addr router_id;
  238. };
  239. extern struct isis_mpls_te isisMplsTE;
  240. struct mpls_te_circuit
  241. {
  242. /* Status of MPLS-TE on this interface */
  243. status_t status;
  244. /* Type of MPLS-TE circuit: STD_TE(RFC5305), INTER_AS(RFC5316), INTER_AS_EMU(RFC5316 emulated) */
  245. u_int8_t type;
  246. /* Total size of sub_tlvs */
  247. u_char length;
  248. /* Store subTLV in network byte order. */
  249. /* RFC5305 */
  250. struct te_subtlv_admin_grp admin_grp;
  251. /* RFC5307 */
  252. struct te_subtlv_llri llri;
  253. /* RFC5305 */
  254. struct te_subtlv_local_ipaddr local_ipaddr;
  255. struct te_subtlv_rmt_ipaddr rmt_ipaddr;
  256. struct te_subtlv_max_bw max_bw;
  257. struct te_subtlv_max_rsv_bw max_rsv_bw;
  258. struct te_subtlv_unrsv_bw unrsv_bw;
  259. struct te_subtlv_te_metric te_metric;
  260. /* RFC5316 */
  261. struct te_subtlv_ras ras;
  262. struct te_subtlv_rip rip;
  263. /* draft-ietf-isis-te-metric-extension */
  264. struct te_subtlv_av_delay av_delay;
  265. struct te_subtlv_mm_delay mm_delay;
  266. struct te_subtlv_delay_var delay_var;
  267. struct te_subtlv_pkt_loss pkt_loss;
  268. struct te_subtlv_res_bw res_bw;
  269. struct te_subtlv_ava_bw ava_bw;
  270. struct te_subtlv_use_bw use_bw;
  271. };
  272. /* Prototypes. */
  273. void isis_mpls_te_init (void);
  274. struct mpls_te_circuit *mpls_te_circuit_new(void);
  275. void mpls_te_print_detail(struct vty *, struct te_is_neigh *);
  276. void set_circuitparams_local_ipaddr (struct mpls_te_circuit *, struct in_addr);
  277. void set_circuitparams_rmt_ipaddr (struct mpls_te_circuit *, struct in_addr);
  278. u_char subtlvs_len (struct mpls_te_circuit *);
  279. u_char add_te_subtlvs(u_char *, struct mpls_te_circuit *);
  280. u_char build_te_subtlvs(u_char *, struct isis_circuit *);
  281. void isis_link_params_update(struct isis_circuit *, struct interface *);
  282. void isis_mpls_te_update(struct interface *);
  283. void isis_mpls_te_config_write_router (struct vty *);
  284. #endif /* _ZEBRA_ISIS_MPLS_TE_H */