FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
sr_mpls.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates. Licensed under the Apache
3  * License, Version 2.0 (the "License"); you may not use this file except in
4  * compliance with the License. You may obtain a copy of the License at:
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11  * License for the specific language governing permissions and limitations
12  * under the License.
13  */
14 
15 /**
16  * @file
17  * @brief Segment Routing MPLS data structures definitions
18  *
19  */
20 
21 #ifndef included_vnet_srmpls_h
22 #define included_vnet_srmpls_h
23 
24 #include <vnet/vnet.h>
25 #include <vnet/mpls/packet.h>
26 #include <vnet/fib/mpls_fib.h>
27 #include <vnet/ip/ip.h>
28 #include <vnet/ip/lookup.h>
29 #include <vnet/dpo/dpo.h>
30 #include <vnet/dpo/replicate_dpo.h>
31 
32 #include <stdlib.h>
33 #include <string.h>
34 
35 /* SR policy types */
36 #define SR_POLICY_TYPE_DEFAULT 0
37 #define SR_POLICY_TYPE_SPRAY 1
38 
39 #define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1
40 
41 #define SR_STEER_IPV4 4
42 #define SR_STEER_IPV6 6
43 
44 #define SR_TE_CO_BITS_00 0
45 #define SR_TE_CO_BITS_01 1
46 #define SR_TE_CO_BITS_10 2
47 #define SR_TE_CO_BITS_11 3
48 
49 /**
50  * @brief SR Segment List (SID list)
51  */
52 typedef struct
53 {
54  /* SIDs (key) */
56 
57  /* SID list weight (wECMP / UCMP) */
59 
60 } mpls_sr_sl_t;
61 
62 typedef struct
63 {
64  u32 *segments_lists; /**< Pool of SID lists indexes */
65 
66  mpls_label_t bsid; /**< BindingSID (key) */
67 
68  u8 type; /**< Type (default is 0) */
69  /* SR Policy specific DPO */
70  /* IF Type = DEFAULT Then Load Balancer DPO among SID lists */
71  /* IF Type = SPRAY then Spray DPO with all SID lists */
72 
73  ip46_address_t endpoint; /**< Optional NH for SR TE */
75  u32 color; /**< Optional color for SR TE */
77 
78 /**
79  * @brief Steering db key
80  *
81  * L3 is IPv4/IPv6 + mask
82  */
83 typedef struct
84 {
85  ip46_address_t prefix; /**< IP address of the prefix */
86  u32 mask_width; /**< Mask width of the prefix */
87  u32 fib_table; /**< VRF of the prefix */
88  u8 traffic_type; /**< Traffic type (IPv4, IPv6, L2) */
89  u8 padding[3];
91 
92 typedef struct
93 {
94  sr_mpls_steering_key_t classify; /**< Traffic classification */
95  mpls_label_t bsid; /**< SR Policy index */
96  ip46_address_t next_hop; /**< SR TE NH */
97  char nh_type;
98  u32 *color; /**< Vector of SR TE colors */
99  char co_bits; /**< Color-Only bits */
102 
103 /**
104  * @brief Segment Routing main datastructure
105  */
106 typedef struct
107 {
108  /* SR SID lists */
110 
111  /* SR MPLS policies */
113 
114  /* Hash table mapping BindingSID to SR MPLS policy */
116 
117  /* Pool of SR steer policies instances */
119 
120  /* MHash table mapping steering rules to SR steer instance */
122 
123  /** SR TE **/
124  /* Hash table mapping (Color->Endpoint->BSID) for SR policies */
126  /* SR TE (internal) fib table (Endpoint, Color) */
128  /* Pool of (Endpoint, Color) hidden labels */
130 
131  /* convenience */
135 
137 
138 extern int
140  u8 behavior, u32 weight);
141 
142 extern int
143 sr_mpls_policy_mod (mpls_label_t bsid, u8 operation,
144  mpls_label_t * segments, u32 sl_index, u32 weight);
145 
146 extern int sr_mpls_policy_del (mpls_label_t bsid);
147 
148 extern int
150  ip46_address_t * endpoint,
151  u8 endpoint_type, u32 color);
152 
153 extern int
155  ip46_address_t * prefix, u32 mask_width,
156  u8 traffic_type, ip46_address_t * next_hop,
157  u8 nh_type, u32 color, char co_bits,
158  mpls_label_t vpn_label);
159 
160 extern int
161 sr_mpls_steering_policy_del (ip46_address_t * prefix,
162  u32 mask_width, u8 traffic_type, u32 table_id,
163  u32 color);
164 
165 extern u32 find_or_create_internal_label (ip46_address_t endpoint, u32 color);
166 
167 extern void internal_label_lock (ip46_address_t endpoint, u32 color);
168 
169 extern void internal_label_unlock (ip46_address_t endpoint, u32 color);
170 
171 #endif /* included_vnet_sr_mpls_h */
172 
173 /*
174  * fd.io coding-style-patch-verification: ON
175  *
176  * Local Variables: eval: (c-set-style "gnu") End:
177  */
Definition: mhash.h:46
u8 traffic_type
Traffic type (IPv4, IPv6, L2)
Definition: sr_mpls.h:88
vlib_main_t * vlib_main
Definition: sr_mpls.h:132
u32 * color
Vector of SR TE colors.
Definition: sr_mpls.h:98
ip46_address_t next_hop
SR TE NH.
Definition: sr_mpls.h:96
Definitions for all things IP (v4|v6) unicast and multicast lookup related.
ip46_address_t prefix
IP address of the prefix.
Definition: sr_mpls.h:85
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:24
u32 padding
Definition: vhost-user.h:77
mhash_t sr_steer_policies_hash
Definition: sr_mpls.h:121
SR Segment List (SID list)
Definition: sr_mpls.h:52
u32 fib_table
VRF of the prefix.
Definition: sr_mpls.h:87
int sr_mpls_policy_add(mpls_label_t bsid, mpls_label_t *segments, u8 behavior, u32 weight)
Create a new SR policy.
mpls_sr_sl_t * sid_lists
Definition: sr_mpls.h:109
mpls_sr_steering_policy_t * steer_policies
Definition: sr_mpls.h:118
mpls_label_t bsid
BindingSID (key)
Definition: sr_mpls.h:66
int sr_mpls_steering_policy_del(ip46_address_t *prefix, u32 mask_width, u8 traffic_type, u32 table_id, u32 color)
Delete steering rule for an SR-MPLS policy.
mpls_label_t vpn_label
Definition: sr_mpls.h:100
uint32_t mask_width(const boost::asio::ip::address &addr)
Get the prefix mask length of a host route from the boost address.
Definition: prefix.cpp:229
sr_mpls_steering_key_t classify
Traffic classification.
Definition: sr_mpls.h:94
u32 mask_width
Mask width of the prefix.
Definition: sr_mpls.h:86
mpls_sr_policy_t * sr_policies
Definition: sr_mpls.h:112
Segment Routing main datastructure.
Definition: sr_mpls.h:106
unsigned int u32
Definition: types.h:88
void internal_label_lock(ip46_address_t endpoint, u32 color)
lock the label for (NH, C) endpoint might be NULL or ANY NULL = 0, ANY=~0
int sr_mpls_policy_del(mpls_label_t bsid)
Delete a SR policy.
ip46_address_t endpoint
Optional NH for SR TE.
Definition: sr_mpls.h:73
vnet_main_t * vnet_main
Definition: sr_mpls.h:133
uword * sr_policies_index_hash
Definition: sr_mpls.h:115
u32 find_or_create_internal_label(ip46_address_t endpoint, u32 color)
find the corresponding label for (endpoint, color) and lock it endpoint might be NULL or ANY NULL = 0...
mpls_label_t bsid
SR Policy index.
Definition: sr_mpls.h:95
u64 uword
Definition: types.h:112
mhash_t sr_policies_c2e2eclabel_hash
SR TE.
Definition: sr_mpls.h:125
u32 * ec_labels
Definition: sr_mpls.h:129
u32 color
Optional color for SR TE.
Definition: sr_mpls.h:75
unsigned char u8
Definition: types.h:56
int sr_mpls_policy_assign_endpoint_color(mpls_label_t bsid, ip46_address_t *endpoint, u8 endpoint_type, u32 color)
Update the Endpoint,Color tuple of an SR policy.
char co_bits
Color-Only bits.
Definition: sr_mpls.h:99
u8 type
Type (default is 0)
Definition: sr_mpls.h:68
mpls_label_t * segments
Definition: sr_mpls.h:55
u32 * segments_lists
Pool of SID lists indexes.
Definition: sr_mpls.h:64
int sr_mpls_policy_mod(mpls_label_t bsid, u8 operation, mpls_label_t *segments, u32 sl_index, u32 weight)
Modify an existing SR policy.
Steering db key.
Definition: sr_mpls.h:83
mpls_sr_main_t sr_mpls_main
int sr_mpls_steering_policy_add(mpls_label_t bsid, u32 table_id, ip46_address_t *prefix, u32 mask_width, u8 traffic_type, ip46_address_t *next_hop, u8 nh_type, u32 color, char co_bits, mpls_label_t vpn_label)
Steer traffic L3 traffic through a given SR-MPLS policy.
u32 fib_table_EC
Definition: sr_mpls.h:127
void internal_label_unlock(ip46_address_t endpoint, u32 color)
Release lock on label for (endpoint, color) endpoint might be NULL or ANY NULL = 0, ANY=~0.
u32 weight
Definition: sr_mpls.h:58