1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * This is an implementation of RFC4970 Router Information
4 * with support of RFC5088 PCE Capabilites announcement
5 * and support of draft-ietf-ospf-segment-routing-extensions-18
6 * for Segment Routing Capabilities announcement
9 * Module name: Router Information
10 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
11 * Copyright (C) 2012 - 2017 Orange Labs http://www.orange.com/
14 #ifndef _ZEBRA_OSPF_ROUTER_INFO_H
15 #define _ZEBRA_OSPF_ROUTER_INFO_H
18 * Opaque LSA's link state ID for Router Information is
19 * structured as follows.
22 * +--------+--------+--------+--------+
23 * | 4 | MBZ |........|........|
24 * +--------+--------+--------+--------+
25 * |<-Type->|<Resv'd>|<-- Instance --->|
28 * Type: IANA has assigned '4' for Router Information.
29 * MBZ: Reserved, must be set to zero.
30 * Instance: User may select an arbitrary 16-bit value.
36 * +--------+--------+--------+--------+ ---
37 * | LS age |Options | 9,10,11| A
38 * +--------+--------+--------+--------+ |
39 * | 4 | 0 | Instance | |
40 * +--------+--------+--------+--------+ |
41 * | Advertising router | | Standard (Opaque) LSA header;
42 * +--------+--------+--------+--------+ | Type 9,10 or 11 are used.
43 * | LS sequence number | |
44 * +--------+--------+--------+--------+ |
45 * | LS checksum | Length | V
46 * +--------+--------+--------+--------+ ---
47 * | Type | Length | A TLV part for Router Information;
48 * +--------+--------+--------+--------+ | Values might be
49 * | Values ... | V structured as a set of sub-TLVs.
50 * +--------+--------+--------+--------+ ---
54 * Following section defines TLV body parts.
57 /* Up to now, 11 code points have been assigned to Router Information */
58 /* Only type 1 Router Capabilities and 6 PCE are supported with this code */
59 #define RI_IANA_MAX_TYPE 11
61 /* RFC4970: Router Information Capabilities TLV */ /* Mandatory */
62 #define RI_TLV_CAPABILITIES 1
63 #define RI_TLV_CAPABILITIES_SIZE 4
64 struct ri_tlv_router_cap
{
65 struct tlv_header header
; /* Value length is 4 bytes. */
69 /* Capabilities bits are left align */
70 #define RI_GRACE_RESTART 0x80000000
71 #define RI_GRACE_HELPER 0x40000000
72 #define RI_STUB_SUPPORT 0x20000000
73 #define RI_TE_SUPPORT 0x10000000
74 #define RI_P2P_OVER_LAN 0x08000000
75 #define RI_TE_EXPERIMENTAL 0x04000000
77 #define RI_TLV_LENGTH 4
79 /* RFC5088: PCE Capabilities TLV */ /* Optional */
84 struct tlv_header header
;
85 /* A set of PCE-sub-TLVs will follow. */
88 /* PCE Address Sub-TLV */ /* Mandatory */
89 #define RI_PCE_SUBTLV_ADDRESS 1
90 struct ri_pce_subtlv_address
{
91 /* Type = 1; Length is 8 (IPv4) or 20 (IPv6) bytes. */
92 struct tlv_header header
;
93 #define PCE_ADDRESS_IPV4_SIZE 8
94 #define PCE_ADDRESS_IPV6_SIZE 20
96 uint16_t type
; /* Address type: 1 = IPv4, 2 = IPv6 */
97 #define PCE_ADDRESS_IPV4 1
98 #define PCE_ADDRESS_IPV6 2
100 struct in_addr value
; /* PCE address */
104 /* PCE Path-Scope Sub-TLV */ /* Mandatory */
105 #define RI_PCE_SUBTLV_PATH_SCOPE 2
106 #define RI_PCE_SUBTLV_PATH_SCOPE_SIZE 4
107 struct ri_pce_subtlv_path_scope
{
108 struct tlv_header header
; /* Type = 2; Length = 4 bytes. */
110 * L, R, Rd, S, Sd, Y, PrefL, PrefR, PrefS and PrefY bits:
116 /* PCE Domain Sub-TLV */ /* Optional */
117 #define PCE_DOMAIN_TYPE_AREA 1
118 #define PCE_DOMAIN_TYPE_AS 2
120 #define RI_PCE_SUBTLV_DOMAIN 3
121 #define RI_PCE_SUBTLV_DOMAIN_SIZE 8
122 struct ri_pce_subtlv_domain
{
123 struct tlv_header header
; /* Type = 3; Length = 8 bytes. */
124 uint16_t type
; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
129 /* PCE Neighbor Sub-TLV */ /* Mandatory if R or S bit is set */
130 #define RI_PCE_SUBTLV_NEIGHBOR 4
131 #define RI_PCE_SUBTLV_NEIGHBOR_SIZE 8
132 struct ri_pce_subtlv_neighbor
{
133 struct tlv_header header
; /* Type = 4; Length = 8 bytes. */
134 uint16_t type
; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
139 /* PCE Capabilities Flags Sub-TLV */ /* Optional */
140 #define RI_PCE_SUBTLV_CAP_FLAG 5
141 #define RI_PCE_SUBTLV_CAP_FLAG_SIZE 4
143 #define PCE_CAP_GMPLS_LINK 0x0001
144 #define PCE_CAP_BIDIRECTIONAL 0x0002
145 #define PCE_CAP_DIVERSE_PATH 0x0004
146 #define PCE_CAP_LOAD_BALANCE 0x0008
147 #define PCE_CAP_SYNCHRONIZED 0x0010
148 #define PCE_CAP_OBJECTIVES 0x0020
149 #define PCE_CAP_ADDITIVE 0x0040
150 #define PCE_CAP_PRIORIZATION 0x0080
151 #define PCE_CAP_MULTIPLE_REQ 0x0100
153 struct ri_pce_subtlv_cap_flag
{
154 struct tlv_header header
; /* Type = 5; Length = n x 4 bytes. */
158 /* Structure to share flooding scope info for Segment Routing */
164 /* Flags to manage the Router Information LSA. */
165 #define RIFLG_LSA_INACTIVE 0x0
166 #define RIFLG_LSA_ENGAGED 0x1
167 #define RIFLG_LSA_FORCED_REFRESH 0x2
169 /* Store Router Information PCE TLV and SubTLV in network byte order. */
170 struct ospf_pce_info
{
172 struct ri_tlv_pce pce_header
;
173 struct ri_pce_subtlv_address pce_address
;
174 struct ri_pce_subtlv_path_scope pce_scope
;
175 struct list
*pce_domain
;
176 struct list
*pce_neighbor
;
177 struct ri_pce_subtlv_cap_flag pce_cap_flag
;
181 * Store Router Information Segment Routing TLV and SubTLV
182 * in network byte order
184 struct ospf_ri_sr_info
{
186 /* Algorithms supported by the node */
187 struct ri_sr_tlv_sr_algorithm algo
;
189 * Segment Routing Global Block i.e. label range
190 * Only one range supported in this code
192 struct ri_sr_tlv_sid_label_range srgb
;
194 * Segment Routing Local Block.
195 * Only one block is authorized - see section 3.3
197 struct ri_sr_tlv_sid_label_range srlb
;
198 /* Maximum SID Depth supported by the node */
199 struct ri_sr_tlv_node_msd msd
;
202 /* Store area information to flood LSA per area */
203 struct ospf_ri_area_info
{
207 /* area pointer if flooding is Type 10 Null if flooding is AS scope */
208 struct ospf_area
*area
;
211 /* Following structure are internal use only. */
212 struct ospf_router_info
{
217 /* LSA flags are only used when scope is AS flooding */
220 /* List of area info to flood RI LSA */
221 struct list
*area_info
;
223 /* Store Router Information Capabilities LSA */
224 struct ri_tlv_router_cap router_cap
;
226 /* Store PCE capability LSA */
227 struct ospf_pce_info pce_info
;
229 /* Store SR capability LSA */
230 struct ospf_ri_sr_info sr_info
;
234 extern int ospf_router_info_init(void);
235 extern void ospf_router_info_term(void);
236 extern void ospf_router_info_finish(void);
237 extern int ospf_router_info_enable(void);
238 extern void ospf_router_info_update_sr(bool enable
, struct sr_node
*self
);
239 extern struct scope_info
ospf_router_info_get_flooding_scope(void);
240 #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */