blob: c84534c8ae79eae8fb9fec2516900037e057f7b5 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
Pablo Camarillofb380952016-12-07 18:34:18 +010015
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -070016/**
17 * @file
Pablo Camarillofb380952016-12-07 18:34:18 +010018 * @brief Segment Routing data structures definitions
19 *
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -070020 */
Pablo Camarillofb380952016-12-07 18:34:18 +010021
Pablo Camarillo5d73eec2017-04-24 17:51:56 +020022#ifndef included_vnet_srv6_h
23#define included_vnet_srv6_h
Ed Warnickecb9cada2015-12-08 15:45:58 -070024
25#include <vnet/vnet.h>
Pablo Camarillo5d73eec2017-04-24 17:51:56 +020026#include <vnet/srv6/sr_packet.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070027#include <vnet/ip/ip6_packet.h>
Pablo Camarillofb380952016-12-07 18:34:18 +010028#include <vnet/ethernet/ethernet.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070029
Ed Warnickecb9cada2015-12-08 15:45:58 -070030#include <stdlib.h>
31#include <string.h>
32
Pablo Camarillofb380952016-12-07 18:34:18 +010033#define IPv6_DEFAULT_HEADER_LENGTH 40
34#define IPv6_DEFAULT_HOP_LIMIT 64
35#define IPv6_DEFAULT_MAX_MASK_WIDTH 128
36
37#define SR_BEHAVIOR_END 1
38#define SR_BEHAVIOR_X 2
Pablo Camarillo7a4e0922017-06-06 15:18:12 +020039#define SR_BEHAVIOR_T 3
40#define SR_BEHAVIOR_D_FIRST 4 /* Unused. Separator in between regular and D */
41#define SR_BEHAVIOR_DX2 5
42#define SR_BEHAVIOR_DX6 6
43#define SR_BEHAVIOR_DX4 7
44#define SR_BEHAVIOR_DT6 8
45#define SR_BEHAVIOR_DT4 9
Tetsuya Murakamiec9cb962020-03-23 16:10:28 -070046#define SR_BEHAVIOR_END_UN_PERF 10
47#define SR_BEHAVIOR_END_UN 11
48#define SR_BEHAVIOR_LAST 12 /* Must always be the last one */
Pablo Camarillofb380952016-12-07 18:34:18 +010049
50#define SR_STEER_L2 2
51#define SR_STEER_IPV4 4
52#define SR_STEER_IPV6 6
53
54#define SR_FUNCTION_SIZE 4
55#define SR_ARGUMENT_SIZE 4
56
57#define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1
Ed Warnickecb9cada2015-12-08 15:45:58 -070058
Tetsuya Murakami1b81e6e2019-11-06 11:05:51 -080059/* *INDENT-OFF* */
60typedef struct
61{
62 ip6_header_t ip;
63 ip6_sr_header_t sr;
64} __attribute__ ((packed)) ip6srv_combo_header_t;
65/* *INDENT-ON* */
66
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -070067/**
Pablo Camarillofb380952016-12-07 18:34:18 +010068 * @brief SR Segment List (SID list)
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -070069 */
Keith Burns (alagalah)06c5ffd2016-08-06 08:32:45 -070070typedef struct
71{
Pablo Camarillofb380952016-12-07 18:34:18 +010072 ip6_address_t *segments; /**< SIDs (key) */
Ed Warnickecb9cada2015-12-08 15:45:58 -070073
Pablo Camarillofb380952016-12-07 18:34:18 +010074 u32 weight; /**< SID list weight (wECMP / UCMP) */
75
76 u8 *rewrite; /**< Precomputed rewrite header */
77 u8 *rewrite_bsid; /**< Precomputed rewrite header for bindingSID */
Ahmed Abdelsalamad8b82d2021-08-24 15:59:39 +000078 u8 policy_type;
Pablo Camarillofb380952016-12-07 18:34:18 +010079
Tetsuya Murakami6b354912021-01-31 16:38:56 -080080 u32 egress_fib_table; /**< Egress FIB table for encap packet */
81
Pablo Camarillofb380952016-12-07 18:34:18 +010082 dpo_id_t bsid_dpo; /**< DPO for Encaps/Insert for BSID */
83 dpo_id_t ip6_dpo; /**< DPO for Encaps/Insert IPv6 */
84 dpo_id_t ip4_dpo; /**< DPO for Encaps IPv6 */
Tetsuya Murakami70d8ef82019-12-04 18:57:46 -080085
86 u16 plugin;
87 void *plugin_mem;
Pablo Camarillofb380952016-12-07 18:34:18 +010088} ip6_sr_sl_t;
89
90/* SR policy types */
91#define SR_POLICY_TYPE_DEFAULT 0
92#define SR_POLICY_TYPE_SPRAY 1
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -070093/**
Pablo Camarillofb380952016-12-07 18:34:18 +010094 * @brief SR Policy
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -070095 */
Keith Burns (alagalah)06c5ffd2016-08-06 08:32:45 -070096typedef struct
97{
Pablo Camarillofb380952016-12-07 18:34:18 +010098 u32 *segments_lists; /**< SID lists indexes (vector) */
Ed Warnickecb9cada2015-12-08 15:45:58 -070099
Pablo Camarillofb380952016-12-07 18:34:18 +0100100 ip6_address_t bsid; /**< BindingSID (key) */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700101
Pablo Camarillofb380952016-12-07 18:34:18 +0100102 u8 type; /**< Type (default is 0) */
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200103 /* SR Policy specific DPO */
Pablo Camarillofb380952016-12-07 18:34:18 +0100104 /* IF Type = DEFAULT Then Load Balancer DPO among SID lists */
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200105 /* IF Type = SPRAY then Spray DPO with all SID lists */
Pablo Camarillofb380952016-12-07 18:34:18 +0100106 dpo_id_t bsid_dpo; /**< SR Policy specific DPO - BSID */
107 dpo_id_t ip4_dpo; /**< SR Policy specific DPO - IPv6 */
108 dpo_id_t ip6_dpo; /**< SR Policy specific DPO - IPv4 */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700109
Pablo Camarillofb380952016-12-07 18:34:18 +0100110 u32 fib_table; /**< FIB table */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700111
Pablo Camarillofb380952016-12-07 18:34:18 +0100112 u8 is_encap; /**< Mode (0 is SRH insert, 1 Encaps) */
Tetsuya Murakami70d8ef82019-12-04 18:57:46 -0800113
114 u16 plugin;
115 void *plugin_mem;
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700116} ip6_sr_policy_t;
117
Tetsuya Murakami70d8ef82019-12-04 18:57:46 -0800118typedef int (sr_p_plugin_callback_t) (ip6_sr_policy_t * sr);
119
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -0700120/**
Pablo Camarillofb380952016-12-07 18:34:18 +0100121 * @brief SR LocalSID
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -0700122 */
Keith Burns (alagalah)06c5ffd2016-08-06 08:32:45 -0700123typedef struct
124{
Pablo Camarillofb380952016-12-07 18:34:18 +0100125 ip6_address_t localsid; /**< LocalSID IPv6 address */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700126
Pablo Camarillo79bfd272019-12-18 17:13:13 +0000127 u16 localsid_prefix_len;
Tetsuya Murakami1b81e6e2019-11-06 11:05:51 -0800128
Pablo Camarillofb380952016-12-07 18:34:18 +0100129 char end_psp; /**< Combined with End.PSP? */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700130
Pablo Camarillofb380952016-12-07 18:34:18 +0100131 u16 behavior; /**< Behavior associated to this localsid */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700132
Pablo Camarillofb380952016-12-07 18:34:18 +0100133 union
134 {
135 u32 sw_if_index; /**< xconnect only */
136 u32 vrf_index; /**< vrf only */
137 };
138
139 u32 fib_table; /**< FIB table where localsid is registered */
140
141 u32 vlan_index; /**< VLAN tag (not an index) */
142
143 ip46_address_t next_hop; /**< Next_hop for xconnect usage only */
144
145 u32 nh_adj; /**< Next_adj for xconnect usage only */
146
Tetsuya Murakamiec9cb962020-03-23 16:10:28 -0700147 ip6_address_t usid_block;
148 ip6_address_t usid_block_mask;
149
150 u8 usid_index;
151 u8 usid_len;
152
153 u8 usid_next_index;
154 u8 usid_next_len;
155
Pablo Camarillofb380952016-12-07 18:34:18 +0100156 void *plugin_mem; /**< Memory to be used by the plugin callback functions */
157} ip6_sr_localsid_t;
158
159typedef int (sr_plugin_callback_t) (ip6_sr_localsid_t * localsid);
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700160
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -0700161/**
Pablo Camarillofb380952016-12-07 18:34:18 +0100162 * @brief SR LocalSID behavior registration
Keith Burns (alagalah)7214cf12016-08-08 15:56:50 -0700163 */
Keith Burns (alagalah)06c5ffd2016-08-06 08:32:45 -0700164typedef struct
165{
Pablo Camarillofb380952016-12-07 18:34:18 +0100166 u16 sr_localsid_function_number; /**< SR LocalSID plugin function (>SR_BEHAVIOR_LAST) */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700167
Pablo Camarillofb380952016-12-07 18:34:18 +0100168 u8 *function_name; /**< Function name. (key). */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700169
Pablo Camarillofb380952016-12-07 18:34:18 +0100170 u8 *keyword_str; /**< Behavior keyword (i.e. End.X) */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700171
Pablo Camarillofb380952016-12-07 18:34:18 +0100172 u8 *def_str; /**< Behavior definition (i.e. Endpoint with cross-connect) */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700173
Pablo Camarillofb380952016-12-07 18:34:18 +0100174 u8 *params_str; /**< Behavior parameters (i.e. <oif> <IP46next_hop>) */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700175
Tetsuya Murakami1b81e6e2019-11-06 11:05:51 -0800176 u8 prefix_length;
177
Pablo Camarillofb380952016-12-07 18:34:18 +0100178 dpo_type_t dpo; /**< DPO type registration */
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700179
Pablo Camarillofb380952016-12-07 18:34:18 +0100180 format_function_t *ls_format; /**< LocalSID format function */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700181
Pablo Camarillofb380952016-12-07 18:34:18 +0100182 unformat_function_t *ls_unformat; /**< LocalSID unformat function */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700183
Pablo Camarillofb380952016-12-07 18:34:18 +0100184 sr_plugin_callback_t *creation; /**< Function within plugin that will be called after localsid creation*/
Ed Warnickecb9cada2015-12-08 15:45:58 -0700185
Pablo Camarillofb380952016-12-07 18:34:18 +0100186 sr_plugin_callback_t *removal; /**< Function within plugin that will be called before localsid removal */
187} sr_localsid_fn_registration_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700188
Pablo Camarillofb380952016-12-07 18:34:18 +0100189/**
Tetsuya Murakami70d8ef82019-12-04 18:57:46 -0800190 * @brief SR Policy behavior registration
191 */
192typedef struct
193{
194 u16 sr_policy_function_number; /**< SR Policy plugin function */
195
196 u8 *function_name; /**< Function name. (key). */
197
198 u8 *keyword_str; /**< Behavior keyword (i.e. End.X) */
199
200 u8 *def_str; /**< Behavior definition (i.e. Endpoint with cross-connect) */
201
202 u8 *params_str; /**< Behavior parameters (i.e. <oif> <IP46next_hop>) */
203
204 u8 prefix_length;
205
206 dpo_type_t dpo; /**< DPO type registration */
207
208 format_function_t *ls_format; /**< LocalSID format function */
209
210 unformat_function_t *ls_unformat; /**< LocalSID unformat function */
211
212 sr_p_plugin_callback_t *creation; /**< Function within plugin that will be called after localsid creation*/
213
214 sr_p_plugin_callback_t *removal; /**< Function within plugin that will be called before localsid removal */
215} sr_policy_fn_registration_t;
216
217/**
Pablo Camarillofb380952016-12-07 18:34:18 +0100218 * @brief Steering db key
219 *
220 * L3 is IPv4/IPv6 + mask
221 * L2 is sf_if_index + vlan
222 */
223typedef struct
224{
225 union
226 {
227 struct
228 {
229 ip46_address_t prefix; /**< IP address of the prefix */
230 u32 mask_width; /**< Mask width of the prefix */
231 u32 fib_table; /**< VRF of the prefix */
232 } l3;
233 struct
234 {
235 u32 sw_if_index; /**< Incoming software interface */
236 } l2;
237 };
238 u8 traffic_type; /**< Traffic type (IPv4, IPv6, L2) */
Pablo Camarillo4521afa2017-03-16 10:43:05 +0100239 u8 padding[3];
Pablo Camarillofb380952016-12-07 18:34:18 +0100240} sr_steering_key_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700241
Pablo Camarillofb380952016-12-07 18:34:18 +0100242typedef struct
243{
244 sr_steering_key_t classify; /**< Traffic classification */
245 u32 sr_policy; /**< SR Policy index */
246} ip6_sr_steering_policy_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700247
Tetsuya Murakamiec9cb962020-03-23 16:10:28 -0700248typedef struct
249{
250 ip6_address_t address;
251 u16 pref_len;
252 u8 padding[2];
253} sr_localsid_key_t;
254
Pablo Camarillofb380952016-12-07 18:34:18 +0100255/**
256 * @brief Segment Routing main datastructure
257 */
258typedef struct
259{
Pablo Camarillofb380952016-12-07 18:34:18 +0100260 /* L2-input -> SR rewrite next index */
261 u32 l2_sr_policy_rewrite_index;
262
Pablo Camarillofb380952016-12-07 18:34:18 +0100263 /* SR SID lists */
264 ip6_sr_sl_t *sid_lists;
265
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200266 /* SRv6 policies */
Pablo Camarillofb380952016-12-07 18:34:18 +0100267 ip6_sr_policy_t *sr_policies;
268
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200269 /* Hash table mapping BindingSID to SRv6 policy */
Pablo Camarillo4521afa2017-03-16 10:43:05 +0100270 mhash_t sr_policies_index_hash;
Pablo Camarillofb380952016-12-07 18:34:18 +0100271
272 /* Pool of SR localsid instances */
273 ip6_sr_localsid_t *localsids;
274
Pablo Camarillo4521afa2017-03-16 10:43:05 +0100275 /* Hash table mapping LOC:FUNC to SR LocalSID instance */
276 mhash_t sr_localsids_index_hash;
Pablo Camarillofb380952016-12-07 18:34:18 +0100277
278 /* Pool of SR steer policies instances */
279 ip6_sr_steering_policy_t *steer_policies;
280
Pablo Camarillo4521afa2017-03-16 10:43:05 +0100281 /* Hash table mapping steering rules to SR steer instance */
282 mhash_t sr_steer_policies_hash;
Pablo Camarillofb380952016-12-07 18:34:18 +0100283
284 /* L2 steering ifaces - sr_policies */
285 u32 *sw_iface_sr_policies;
286
287 /* Spray DPO */
288 dpo_type_t sr_pr_spray_dpo_type;
289
290 /* Plugin functions */
291 sr_localsid_fn_registration_t *plugin_functions;
292
293 /* Find plugin function by name */
294 uword *plugin_functions_by_key;
295
Tetsuya Murakami70d8ef82019-12-04 18:57:46 -0800296 /* Plugin functions for Policy */
297 sr_policy_fn_registration_t *policy_plugin_functions;
298
299 /* Find plugin function by name */
300 uword *policy_plugin_functions_by_key;
301
Pablo Camarillofb380952016-12-07 18:34:18 +0100302 /* Counters */
303 vlib_combined_counter_main_t sr_ls_valid_counters;
304 vlib_combined_counter_main_t sr_ls_invalid_counters;
305
306 /* SR Policies FIBs */
307 u32 fib_table_ip6;
308 u32 fib_table_ip4;
309
310 /* convenience */
Keith Burns (alagalah)06c5ffd2016-08-06 08:32:45 -0700311 vlib_main_t *vlib_main;
312 vnet_main_t *vnet_main;
Filip Tehlare2fc0032021-06-22 13:00:40 +0000313 u16 msg_id_base;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700314} ip6_sr_main_t;
315
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200316extern ip6_sr_main_t sr_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700317
Pablo Camarillofb380952016-12-07 18:34:18 +0100318extern vlib_node_registration_t sr_policy_rewrite_encaps_node;
319extern vlib_node_registration_t sr_policy_rewrite_insert_node;
320extern vlib_node_registration_t sr_localsid_node;
321extern vlib_node_registration_t sr_localsid_d_node;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700322
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200323extern void sr_dpo_lock (dpo_id_t * dpo);
324extern void sr_dpo_unlock (dpo_id_t * dpo);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700325
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200326extern int
327sr_localsid_register_function (vlib_main_t * vm, u8 * fn_name,
328 u8 * keyword_str, u8 * def_str,
Tetsuya Murakami1b81e6e2019-11-06 11:05:51 -0800329 u8 * params_str, u8 prefix_length,
330 dpo_type_t * dpo,
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200331 format_function_t * ls_format,
332 unformat_function_t * ls_unformat,
333 sr_plugin_callback_t * creation_fn,
334 sr_plugin_callback_t * removal_fn);
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700335
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200336extern int
Tetsuya Murakami70d8ef82019-12-04 18:57:46 -0800337sr_policy_register_function (vlib_main_t * vm, u8 * fn_name,
338 u8 * keyword_str, u8 * def_str,
339 u8 * params_str, u8 prefix_length,
340 dpo_type_t * dpo,
341 format_function_t * ls_format,
342 unformat_function_t * ls_unformat,
343 sr_p_plugin_callback_t * creation_fn,
344 sr_p_plugin_callback_t * removal_fn);
345
Ahmed Abdelsalamad8b82d2021-08-24 15:59:39 +0000346extern int sr_policy_add (ip6_address_t *bsid, ip6_address_t *segments,
347 u32 weight, u8 type, u32 fib_table, u8 is_encap,
348 u16 plugin, void *plugin_mem);
Tetsuya Murakami1b81e6e2019-11-06 11:05:51 -0800349extern int sr_policy_mod (ip6_address_t * bsid, u32 index, u32 fib_table,
350 u8 operation, ip6_address_t * segments,
351 u32 sl_index, u32 weight);
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200352extern int sr_policy_del (ip6_address_t * bsid, u32 index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700353
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200354extern int
Pablo Camarillo79bfd272019-12-18 17:13:13 +0000355sr_cli_localsid (char is_del, ip6_address_t * localsid_addr,
356 u16 localsid_prefix_len, char end_psp, u8 behavior,
357 u32 sw_if_index, u32 vlan_index, u32 fib_table,
Tetsuya Murakamiec9cb962020-03-23 16:10:28 -0700358 ip46_address_t * nh_addr, int usid_len, void *ls_plugin_mem);
Pablo Camarillofb380952016-12-07 18:34:18 +0100359
Pablo Camarillo5d73eec2017-04-24 17:51:56 +0200360extern int
Pablo Camarillofb380952016-12-07 18:34:18 +0100361sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
362 u32 table_id, ip46_address_t * prefix, u32 mask_width,
363 u32 sw_if_index, u8 traffic_type);
Keith Burns (alagalah)52fc44d2016-03-25 09:38:50 -0700364
Pablo Camarillo1a5e3012017-11-16 16:02:50 +0100365extern void sr_set_source (ip6_address_t * address);
Ahmed Abdelsalam448bc812020-11-09 14:04:07 +0000366extern ip6_address_t *sr_get_encaps_source ();
Pablo Camarillo1a5e3012017-11-16 16:02:50 +0100367
Ignas Bačiuseeb5fb32019-10-03 17:15:38 +0300368extern void sr_set_hop_limit (u8 hop_limit);
369extern u8 sr_get_hop_limit (void);
370
Shwetha Bhandari78372a92017-01-18 12:43:54 +0530371/**
372 * @brief SR rewrite string computation for SRH insertion (inline)
373 *
374 * @param sl is a vector of IPv6 addresses composing the Segment List
375 *
376 * @return precomputed rewrite string for SRH insertion
377 */
378static inline u8 *
shwethabe146f132017-03-09 16:58:26 +0000379ip6_sr_compute_rewrite_string_insert (ip6_address_t * sl)
Shwetha Bhandari78372a92017-01-18 12:43:54 +0530380{
381 ip6_sr_header_t *srh;
382 ip6_address_t *addrp, *this_address;
383 u32 header_length = 0;
384 u8 *rs = NULL;
385
386 header_length = 0;
387 header_length += sizeof (ip6_sr_header_t);
388 header_length += (vec_len (sl) + 1) * sizeof (ip6_address_t);
389
390 vec_validate (rs, header_length - 1);
391
392 srh = (ip6_sr_header_t *) rs;
393 srh->type = ROUTING_HEADER_TYPE_SR;
394 srh->segments_left = vec_len (sl);
Ahmed Abdelsalambe837042019-06-20 11:18:57 +0000395 srh->last_entry = vec_len (sl);
Shwetha Bhandari78372a92017-01-18 12:43:54 +0530396 srh->length = ((sizeof (ip6_sr_header_t) +
397 ((vec_len (sl) + 1) * sizeof (ip6_address_t))) / 8) - 1;
398 srh->flags = 0x00;
Ahmed Abdelsalambe837042019-06-20 11:18:57 +0000399 srh->tag = 0x0000;
Shwetha Bhandari78372a92017-01-18 12:43:54 +0530400 addrp = srh->segments + vec_len (sl);
401 vec_foreach (this_address, sl)
402 {
Dave Barach178cf492018-11-13 16:34:13 -0500403 clib_memcpy_fast (addrp->as_u8, this_address->as_u8,
404 sizeof (ip6_address_t));
Shwetha Bhandari78372a92017-01-18 12:43:54 +0530405 addrp--;
406 }
407 return rs;
408}
409
Ed Warnickecb9cada2015-12-08 15:45:58 -0700410#endif /* included_vnet_sr_h */
Keith Burns (alagalah)06c5ffd2016-08-06 08:32:45 -0700411
412/*
413 * fd.io coding-style-patch-verification: ON
414 *
415 * Local Variables:
416 * eval: (c-set-style "gnu")
417 * End:
418 */