FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
sr_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * sr_api.c - ipv6 segment routing api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vnet/srv6/sr.h>
22 #include <vlibmemory/api.h>
23 
24 #include <vnet/interface.h>
25 #include <vnet/api_errno.h>
26 #include <vnet/feature/feature.h>
27 #include <vnet/fib/fib_table.h>
28 #include <vnet/ip/ip_types_api.h>
29 
30 #include <vnet/format_fns.h>
31 #include <vnet/srv6/sr.api_enum.h>
32 #include <vnet/srv6/sr.api_types.h>
33 
34 #define REPLY_MSG_ID_BASE sr_main.msg_id_base
36 
39 {
40  vl_api_sr_localsid_add_del_reply_t *rmp;
41  int rv = 0;
42  ip46_address_t prefix;
43  ip6_address_t localsid;
44 /*
45  * int sr_cli_localsid (char is_del, ip6_address_t *localsid_addr,
46  * char end_psp, u8 behavior, u32 sw_if_index, u32 vlan_index, u32 fib_table,
47  * ip46_address_t *nh_addr, void *ls_plugin_mem)
48  */
49  if (mp->behavior == SR_BEHAVIOR_X ||
50  mp->behavior == SR_BEHAVIOR_DX6 ||
53 
54  ip6_address_decode (mp->localsid, &localsid);
56 
57  rv = sr_cli_localsid (mp->is_del,
58  &localsid, 128,
59  mp->end_psp,
60  mp->behavior,
61  ntohl (mp->sw_if_index),
62  ntohl (mp->vlan_index),
63  ntohl (mp->fib_table), &prefix, 0, NULL);
64 
66  REPLY_MACRO (VL_API_SR_LOCALSID_ADD_DEL_REPLY);
67 }
68 
69 static void
71 {
72  vl_api_sr_policy_add_reply_t *rmp;
73  ip6_address_t *segments = 0, *seg;
74  ip6_address_t bsid_addr;
75 
76  int i;
77  for (i = 0; i < mp->sids.num_sids; i++)
78  {
79  vec_add2 (segments, seg, 1);
80  ip6_address_decode (mp->sids.sids[i], seg);
81  }
82 
83  ip6_address_decode (mp->bsid_addr, &bsid_addr);
84 
85 /*
86  * sr_policy_add (ip6_address_t *bsid, ip6_address_t *segments,
87  * u32 weight, u8 behavior, u32 fib_table, u8 is_encap,
88  * u16 behavior, void *plugin_mem)
89  */
90  int rv = 0;
91  rv = sr_policy_add (&bsid_addr,
92  segments,
93  ntohl (mp->sids.weight),
94  mp->is_spray, ntohl (mp->fib_table), mp->is_encap, 0,
95  NULL);
96  vec_free (segments);
97 
98  REPLY_MACRO (VL_API_SR_POLICY_ADD_REPLY);
99 }
100 
101 static void
103 {
104  vl_api_sr_policy_mod_reply_t *rmp;
105  ip6_address_t *segments = 0, *seg;
106  ip6_address_t bsid_addr;
107 
108  int i;
109  for (i = 0; i < mp->sids.num_sids; i++)
110  {
111  vec_add2 (segments, seg, 1);
112  ip6_address_decode (mp->sids.sids[i], seg);
113  }
114 
115  ip6_address_decode (mp->bsid_addr, &bsid_addr);
116 
117  int rv = 0;
118 /*
119  * int
120  * sr_policy_mod(ip6_address_t *bsid, u32 index, u32 fib_table,
121  * u8 operation, ip6_address_t *segments, u32 sl_index,
122  * u32 weight, u8 is_encap)
123  */
124  rv = sr_policy_mod (&bsid_addr,
125  ntohl (mp->sr_policy_index),
126  ntohl (mp->fib_table),
127  mp->operation,
128  segments, ntohl (mp->sl_index),
129  ntohl (mp->sids.weight));
130  vec_free (segments);
131 
132  REPLY_MACRO (VL_API_SR_POLICY_MOD_REPLY);
133 }
134 
135 static void
137 {
138  vl_api_sr_policy_del_reply_t *rmp;
139  int rv = 0;
140  ip6_address_t bsid_addr;
141 /*
142  * int
143  * sr_policy_del (ip6_address_t *bsid, u32 index)
144  */
145  ip6_address_decode (mp->bsid_addr, &bsid_addr);
146  rv = sr_policy_del (&bsid_addr, ntohl (mp->sr_policy_index));
147 
148  REPLY_MACRO (VL_API_SR_POLICY_DEL_REPLY);
149 }
150 
151 static void
153 {
154  vl_api_sr_set_encap_source_reply_t *rmp;
155  int rv = 0;
156  ip6_address_t encaps_source;
157 
158  ip6_address_decode (mp->encaps_source, &encaps_source);
159  sr_set_source (&encaps_source);
160 
161  REPLY_MACRO (VL_API_SR_SET_ENCAP_SOURCE_REPLY);
162 }
163 
164 static void
166 {
167  vl_api_sr_set_encap_hop_limit_reply_t *rmp;
168  int rv = 0;
169 
170  if (mp->hop_limit == 0)
171  rv = VNET_API_ERROR_INVALID_VALUE;
172  else
174 
175  REPLY_MACRO (VL_API_SR_SET_ENCAP_HOP_LIMIT_REPLY);
176 }
177 
180 {
181  vl_api_sr_steering_add_del_reply_t *rmp;
182  int rv = 0;
183  ip6_address_t bsid_addr;
184  ip46_address_t prefix_addr;
185 /*
186  * int
187  * sr_steering_policy(int is_del, ip6_address_t *bsid, u32 sr_policy_index,
188  * u32 table_id, ip46_address_t *prefix, u32 mask_width, u32 sw_if_index,
189  * u8 traffic_type)
190  */
191 
192  ip6_address_decode (mp->bsid_addr, &bsid_addr);
193  ip_address_decode (&mp->prefix.address, &prefix_addr);
194 
195  if (mp->traffic_type == SR_STEER_L2)
197 
199  &bsid_addr,
200  ntohl (mp->sr_policy_index),
201  ntohl (mp->table_id),
202  &prefix_addr,
203  mp->prefix.len,
204  ntohl (mp->sw_if_index), mp->traffic_type);
205 
207  REPLY_MACRO (VL_API_SR_STEERING_ADD_DEL_REPLY);
208 }
209 
210 static void send_sr_localsid_details
212 {
214 
215  rmp = vl_msg_api_alloc (sizeof (*rmp));
216  clib_memset (rmp, 0, sizeof (*rmp));
217  rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SR_LOCALSIDS_DETAILS);
218  ip6_address_encode (&t->localsid, rmp->addr);
219  rmp->end_psp = t->end_psp;
220  rmp->behavior = htons (t->behavior);
221  rmp->fib_table = htonl (t->fib_table);
222  rmp->vlan_index = htonl (t->vlan_index);
224 
225  if (t->behavior == SR_BEHAVIOR_T || t->behavior == SR_BEHAVIOR_DT6)
228  else if (t->behavior == SR_BEHAVIOR_DT4)
231  else
232  rmp->xconnect_iface_or_vrf_table = htonl (t->sw_if_index);
233 
234  rmp->context = context;
235 
236  vl_api_send_msg (reg, (u8 *) rmp);
237 }
238 
241 {
243  ip6_sr_main_t *sm = &sr_main;
245 
247  if (!reg)
248  return;
249 
250  /* *INDENT-OFF* */
251  pool_foreach (t, sm->localsids)
252  {
253  send_sr_localsid_details(t, reg, mp->context);
254  }
255  /* *INDENT-ON* */
256 }
257 
258 static void send_sr_policies_details
260 {
262  ip6_sr_main_t *sm = &sr_main;
263 
264  u32 *sl_index, slidx = 0;
265  ip6_sr_sl_t *segment_list = 0;
266  ip6_address_t *segment;
267  vl_api_srv6_sid_list_t *api_sid_list;
268 
269  rmp = vl_msg_api_alloc (sizeof (*rmp) +
270  vec_len (t->segments_lists) *
271  sizeof (vl_api_srv6_sid_list_t));
272  clib_memset (rmp, 0,
273  (sizeof (*rmp) +
274  vec_len (t->segments_lists) *
275  sizeof (vl_api_srv6_sid_list_t)));
276 
277  rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SR_POLICIES_DETAILS);
278  ip6_address_encode (&t->bsid, rmp->bsid);
279  rmp->is_encap = t->is_encap;
280  rmp->is_spray = t->type;
281  rmp->fib_table = htonl (t->fib_table);
283 
284  /* Fill in all the segments lists */
286  {
287  segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
288 
289  api_sid_list = &rmp->sid_lists[sl_index - t->segments_lists];
290 
291  api_sid_list->num_sids = vec_len (segment_list->segments);
292  api_sid_list->weight = htonl (segment_list->weight);
293  slidx = 0;
294  vec_foreach (segment, segment_list->segments)
295  {
296  ip6_address_encode (segment, api_sid_list->sids[slidx++]);
297  }
298  }
299 
300  rmp->context = context;
301  vl_api_send_msg (reg, (u8 *) rmp);
302 }
303 
304 static void
306 {
308  ip6_sr_main_t *sm = &sr_main;
309  ip6_sr_policy_t *t;
310 
312  if (!reg)
313  return;
314 
315  /* *INDENT-OFF* */
316  pool_foreach (t, sm->sr_policies)
317  {
318  send_sr_policies_details(t, reg, mp->context);
319  }
320  /* *INDENT-ON* */
321 }
322 
323 
324 
327 {
329  ip6_sr_main_t *sm = &sr_main;
330 
331  u32 *sl_index, slidx = 0;
332  ip6_sr_sl_t *segment_list = 0;
333  ip6_address_t *segment;
334  vl_api_srv6_sid_list_with_sl_index_t *api_sid_list;
335 
336  rmp = vl_msg_api_alloc (sizeof (*rmp) +
337  vec_len (t->segments_lists) *
338  sizeof (vl_api_srv6_sid_list_with_sl_index_t));
339  clib_memset (rmp, 0,
340  (sizeof (*rmp) +
341  vec_len (t->segments_lists) *
342  sizeof (vl_api_srv6_sid_list_with_sl_index_t)));
343 
344  rmp->_vl_msg_id =
345  ntohs (REPLY_MSG_ID_BASE + VL_API_SR_POLICIES_WITH_SL_INDEX_DETAILS);
346  ip6_address_encode (&t->bsid, rmp->bsid);
347  rmp->is_encap = t->is_encap;
348  rmp->is_spray = t->type;
349  rmp->fib_table = htonl (t->fib_table);
351 
352  /* Fill in all the segments lists */
354  {
355  segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
356 
357  api_sid_list = &rmp->sid_lists[sl_index - t->segments_lists];
358  api_sid_list->sl_index = htonl (*sl_index);
359  api_sid_list->num_sids = vec_len (segment_list->segments);
360  api_sid_list->weight = htonl (segment_list->weight);
361  slidx = 0;
362  vec_foreach (segment, segment_list->segments)
363  {
364  ip6_address_encode (segment, api_sid_list->sids[slidx++]);
365  }
366  }
367 
368  rmp->context = context;
369  vl_api_send_msg (reg, (u8 *) rmp);
370 }
371 
372 static void
375 {
377  ip6_sr_main_t *sm = &sr_main;
378  ip6_sr_policy_t *t;
379 
381  if (!reg)
382  return;
383 
384  /* *INDENT-OFF* */
385  pool_foreach (t, sm->sr_policies)
386  {
388  }
389  /* *INDENT-ON* */
390 }
391 
394 {
396  ip6_sr_main_t *sm = &sr_main;
397 
398  rmp = vl_msg_api_alloc (sizeof (*rmp));
399  clib_memset (rmp, 0, sizeof (*rmp));
400  rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SR_STEERING_POL_DETAILS);
401 
402  //Get the SR policy BSID
403  ip6_sr_policy_t *p;
405  ip6_address_encode (&p->bsid, rmp->bsid);
406 
407  //Get the steering
409  rmp->fib_table = htonl (t->classify.l3.fib_table);
411  &rmp->prefix.address);
412  rmp->prefix.len = t->classify.l3.mask_width;
413 
414  rmp->sw_if_index = htonl (t->classify.l2.sw_if_index);
415 
416  rmp->context = context;
417  vl_api_send_msg (reg, (u8 *) rmp);
418 }
419 
422 {
424  ip6_sr_main_t *sm = &sr_main;
426 
428  if (!reg)
429  return;
430 
431  /* *INDENT-OFF* */
433  {
435  }
436  /* *INDENT-ON* */
437 }
438 
439 #include <vnet/srv6/sr.api.c>
440 static clib_error_t *
442 {
443  /*
444  * Set up the (msg_name, crc, message-id) table
445  */
447 
448  return 0;
449 }
450 
452 
453 /*
454  * fd.io coding-style-patch-verification: ON
455  *
456  * Local Variables:
457  * eval: (c-set-style "gnu")
458  * End:
459  */
vl_api_sr_policy_mod_t::sr_policy_index
u32 sr_policy_index
Definition: sr.api:104
vl_api_sr_policies_details_t::sid_lists
vl_api_srv6_sid_list_t sid_lists[num_sid_lists]
Definition: sr.api:217
SR_BEHAVIOR_DT6
#define SR_BEHAVIOR_DT6
Definition: sr.h:44
sr_api_hookup
static clib_error_t * sr_api_hookup(vlib_main_t *vm)
Definition: sr_api.c:441
vl_api_sr_localsids_details_t::xconnect_nh_addr
vl_api_address_t xconnect_nh_addr
Definition: sr.api:194
ip6_sr_localsid_t::end_psp
char end_psp
Combined with End.PSP?
Definition: sr.h:129
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
ip6_sr_policy_t::is_encap
u8 is_encap
Mode (0 is SRH insert, 1 Encaps)
Definition: sr.h:112
vl_api_sr_steering_add_del_t::traffic_type
vl_api_sr_steer_t traffic_type
Definition: sr.api:173
api.h
vl_api_sr_localsid_add_del_t_handler
static void vl_api_sr_localsid_add_del_t_handler(vl_api_sr_localsid_add_del_t *mp)
Definition: sr_api.c:38
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vl_api_sr_policy_mod_t::sl_index
u32 sl_index
Definition: sr.api:107
vl_api_sr_policy_mod_t
IPv6 SR policy modification.
Definition: sr.api:99
fib_table_get_table_id
u32 fib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: fib_table.c:1100
vl_api_sr_policies_with_sl_index_details_t
Definition: sr.api:232
vl_api_sr_policy_add_t_handler
static void vl_api_sr_policy_add_t_handler(vl_api_sr_policy_add_t *mp)
Definition: sr_api.c:70
vl_api_sr_localsid_add_del_t::nh_addr
vl_api_address_t nh_addr
Definition: sr.api:63
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
ip6_sr_localsid_t
SR LocalSID.
Definition: sr.h:123
sl_index
u32 sl_index
Definition: sr.api:35
vl_api_sr_policy_del_t
IPv6 SR policy deletion.
Definition: sr.api:118
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: sr_api.c:34
vl_api_sr_localsids_details_t::behavior
vl_api_sr_behavior_t behavior
Definition: sr.api:191
vl_api_sr_policies_with_sl_index_details_t::sid_lists
vl_api_srv6_sid_list_with_sl_index_t sid_lists[num_sid_lists]
Definition: sr.api:240
SR_BEHAVIOR_X
#define SR_BEHAVIOR_X
Definition: sr.h:38
vl_api_sr_policies_with_sl_index_details_t::is_encap
bool is_encap
Definition: sr.api:237
ip6_sr_localsid_t::sw_if_index
u32 sw_if_index
xconnect only
Definition: sr.h:135
fib_table.h
ip6_sr_localsid_t::next_hop
ip46_address_t next_hop
Next_hop for xconnect usage only.
Definition: sr.h:143
ip6_sr_main_t::steer_policies
ip6_sr_steering_policy_t * steer_policies
Definition: sr.h:279
sr_steering_key_t::l2
struct sr_steering_key_t::@547::@550 l2
ip6_address_decode
void ip6_address_decode(const vl_api_ip6_address_t in, ip6_address_t *out)
Definition: ip_types_api.c:129
vl_api_sr_steering_add_del_t::prefix
vl_api_prefix_t prefix
Definition: sr.api:171
vl_api_sr_policies_with_sl_index_details_t::is_spray
bool is_spray
Definition: sr.api:236
send_sr_policies_details_with_sl_index
static void send_sr_policies_details_with_sl_index(ip6_sr_policy_t *t, vl_api_registration_t *reg, u32 context)
Definition: sr_api.c:326
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_sr_steering_add_del_t_handler
static void vl_api_sr_steering_add_del_t_handler(vl_api_sr_steering_add_del_t *mp)
Definition: sr_api.c:179
vl_api_sr_policies_dump_t::context
u32 context
Definition: sr.api:205
vl_api_sr_localsids_dump_t::client_index
u32 client_index
Definition: sr.api:182
vl_api_sr_localsids_dump_t::context
u32 context
Definition: sr.api:183
vl_api_sr_steering_pol_details_t::prefix
vl_api_prefix_t prefix
Definition: sr.api:259
SR_BEHAVIOR_T
#define SR_BEHAVIOR_T
Definition: sr.h:39
sr_cli_localsid
int sr_cli_localsid(char is_del, ip6_address_t *localsid_addr, u16 localsid_prefix_len, char end_psp, u8 behavior, u32 sw_if_index, u32 vlan_index, u32 fib_table, ip46_address_t *nh_addr, int usid_len, void *ls_plugin_mem)
SR localsid add/del.
Definition: sr_localsid.c:77
vl_api_sr_set_encap_hop_limit_t
IPv6 SR Set SRv6 encapsulation hop-limit.
Definition: sr.api:144
vl_api_sr_policy_mod_t::bsid_addr
vl_api_ip6_address_t bsid_addr
Definition: sr.api:103
ip6_sr_localsid_t::vlan_index
u32 vlan_index
VLAN tag (not an index)
Definition: sr.h:141
vl_api_sr_localsids_details_t::fib_table
u32 fib_table
Definition: sr.api:192
send_sr_policies_details
static void send_sr_policies_details(ip6_sr_policy_t *t, vl_api_registration_t *reg, u32 context)
Definition: sr_api.c:259
vl_api_sr_localsid_add_del_t::behavior
vl_api_sr_behavior_t behavior
Definition: sr.api:59
ip6_sr_steering_policy_t::classify
sr_steering_key_t classify
Traffic classification.
Definition: sr.h:244
vl_api_sr_localsid_add_del_t::sw_if_index
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: sr.api:60
vl_api_sr_policies_details_t::is_encap
bool is_encap
Definition: sr.api:214
ip_address_decode
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Decode/Encode for struct/union types.
Definition: ip_types_api.c:172
vl_api_sr_policies_with_sl_index_dump_t::client_index
u32 client_index
Definition: sr.api:226
ip6_sr_policy_t
SR Policy.
Definition: sr.h:96
vl_api_sr_policy_mod_t::fib_table
u32 fib_table
Definition: sr.api:105
sr.h
Segment Routing data structures definitions.
vl_api_sr_policies_details_t::num_sid_lists
u8 num_sid_lists
Definition: sr.api:216
vl_api_sr_policies_with_sl_index_details_t::num_sid_lists
u8 num_sid_lists
Definition: sr.api:239
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
SR_STEER_L2
#define SR_STEER_L2
Definition: sr.h:50
vl_api_sr_policy_add_t::fib_table
u32 fib_table
Definition: sr.api:84
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vl_api_sr_steering_add_del_t::is_del
bool is_del[default=false]
Definition: sr.api:167
vl_api_sr_policies_with_sl_index_dump_t_handler
static void vl_api_sr_policies_with_sl_index_dump_t_handler(vl_api_sr_policies_with_sl_index_dump_t *mp)
Definition: sr_api.c:374
vl_api_sr_steering_pol_details_t::fib_table
u32 fib_table
Definition: sr.api:258
vl_api_sr_policy_del_t::bsid_addr
vl_api_ip6_address_t bsid_addr
Definition: sr.api:122
vl_api_sr_steering_pol_details_t::bsid
vl_api_ip6_address_t bsid
Definition: sr.api:261
vl_api_sr_policy_add_t::bsid_addr
vl_api_ip6_address_t bsid_addr
Definition: sr.api:80
feature.h
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
sr_steering_key_t::traffic_type
u8 traffic_type
Traffic type (IPv4, IPv6, L2)
Definition: sr.h:238
ip6_sr_sl_t
SR Segment List (SID list)
Definition: sr.h:70
ip6_address_encode
void ip6_address_encode(const ip6_address_t *in, vl_api_ip6_address_t out)
Definition: ip_types_api.c:123
vl_api_sr_steering_pol_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: sr.api:260
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(sr_api_hookup)
vl_api_sr_steering_add_del_t::sr_policy_index
u32 sr_policy_index
Definition: sr.api:169
vl_api_sr_steering_add_del_t::table_id
u32 table_id
Definition: sr.api:170
vl_api_sr_policies_with_sl_index_details_t::bsid
vl_api_ip6_address_t bsid
Definition: sr.api:235
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
vl_api_sr_set_encap_hop_limit_t_handler
static void vl_api_sr_set_encap_hop_limit_t_handler(vl_api_sr_set_encap_hop_limit_t *mp)
Definition: sr_api.c:165
sr_policy_mod
int sr_policy_mod(ip6_address_t *bsid, u32 index, u32 fib_table, u8 operation, ip6_address_t *segments, u32 sl_index, u32 weight)
Modify an existing SR policy.
Definition: sr_policy_rewrite.c:832
sr_policy_del
int sr_policy_del(ip6_address_t *bsid, u32 index)
Delete a SR policy.
Definition: sr_policy_rewrite.c:724
SR_BEHAVIOR_DX6
#define SR_BEHAVIOR_DX6
Definition: sr.h:42
ip6_sr_policy_t::segments_lists
u32 * segments_lists
SID lists indexes (vector)
Definition: sr.h:98
vl_api_sr_steering_pol_dump_t_handler
static void vl_api_sr_steering_pol_dump_t_handler(vl_api_sr_policies_dump_t *mp)
Definition: sr_api.c:421
vl_api_sr_localsids_dump_t_handler
static void vl_api_sr_localsids_dump_t_handler(vl_api_sr_localsids_dump_t *mp)
Definition: sr_api.c:240
vl_api_sr_localsid_add_del_t::fib_table
u32 fib_table
Definition: sr.api:62
sr_set_source
void sr_set_source(ip6_address_t *address)
Definition: sr_policy_rewrite.c:117
vl_api_sr_policy_mod_t_handler
static void vl_api_sr_policy_mod_t_handler(vl_api_sr_policy_mod_t *mp)
Definition: sr_api.c:102
ip6_sr_steering_policy_t::sr_policy
u32 sr_policy
SR Policy index.
Definition: sr.h:245
interface.h
vl_api_sr_localsids_details_t::xconnect_iface_or_vrf_table
u32 xconnect_iface_or_vrf_table
Definition: sr.api:195
ip6_sr_sl_t::weight
u32 weight
SID list weight (wECMP / UCMP)
Definition: sr.h:74
vl_api_sr_steering_add_del_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: sr.api:172
vl_api_sr_localsid_add_del_t::end_psp
bool end_psp
Definition: sr.api:58
send_sr_steering_pol_details
static void send_sr_steering_pol_details(ip6_sr_steering_policy_t *t, vl_api_registration_t *reg, u32 context)
Definition: sr_api.c:393
vl_api_sr_localsids_details_t::end_psp
bool end_psp
Definition: sr.api:190
send_sr_localsid_details
static void send_sr_localsid_details(ip6_sr_localsid_t *t, vl_api_registration_t *reg, u32 context)
Definition: sr_api.c:211
sr_steering_policy
int sr_steering_policy(int is_del, ip6_address_t *bsid, u32 sr_policy_index, u32 table_id, ip46_address_t *prefix, u32 mask_width, u32 sw_if_index, u8 traffic_type)
Steer traffic L2 and L3 traffic through a given SR policy.
Definition: sr_steering.c:60
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
sr_main
ip6_sr_main_t sr_main
Definition: sr.c:31
ip6_sr_main_t::localsids
ip6_sr_localsid_t * localsids
Definition: sr.h:273
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
vl_api_sr_policy_add_t
IPv6 SR policy add.
Definition: sr.api:76
vl_api_sr_steering_pol_details_t::context
u32 context
Definition: sr.api:256
vl_api_sr_localsid_add_del_t::localsid
vl_api_ip6_address_t localsid
Definition: sr.api:57
vl_api_sr_policies_with_sl_index_details_t::context
u32 context
Definition: sr.api:234
vl_api_sr_steering_add_del_t::bsid_addr
vl_api_ip6_address_t bsid_addr
Definition: sr.api:168
ip6_sr_main_t
Segment Routing main datastructure.
Definition: sr.h:258
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
ip6_sr_policy_t::bsid
ip6_address_t bsid
BindingSID (key)
Definition: sr.h:100
vl_api_sr_policies_dump_t_handler
static void vl_api_sr_policies_dump_t_handler(vl_api_sr_policies_dump_t *mp)
Definition: sr_api.c:305
vl_api_sr_policies_details_t::bsid
vl_api_ip6_address_t bsid
Definition: sr.api:212
vl_api_sr_set_encap_source_t
IPv6 SR Set SRv6 encapsulation source.
Definition: sr.api:132
SR_BEHAVIOR_DX2
#define SR_BEHAVIOR_DX2
Definition: sr.h:41
ip6_sr_policy_t::type
u8 type
Type (default is 0)
Definition: sr.h:102
vl_api_sr_policy_del_t_handler
static void vl_api_sr_policy_del_t_handler(vl_api_sr_policy_del_t *mp)
Definition: sr_api.c:136
format_fns.h
ip6_sr_localsid_t::localsid
ip6_address_t localsid
LocalSID IPv6 address.
Definition: sr.h:125
vl_api_sr_policy_add_t::is_encap
bool is_encap
Definition: sr.api:82
ip6_sr_sl_t::segments
ip6_address_t * segments
SIDs (key)
Definition: sr.h:72
u32
unsigned int u32
Definition: types.h:88
sr_set_hop_limit
void sr_set_hop_limit(u8 hop_limit)
Definition: sr_policy_rewrite.c:154
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
vl_api_sr_localsids_details_t
Definition: sr.api:186
vl_api_sr_policy_del_t::sr_policy_index
u32 sr_policy_index
Definition: sr.api:123
api_helper_macros.h
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
vl_api_sr_policies_dump_t
Dump the list of SR policies.
Definition: sr.api:202
vl_api_sr_policies_with_sl_index_dump_t::context
u32 context
Definition: sr.api:227
vl_api_sr_set_encap_hop_limit_t::hop_limit
u8 hop_limit
Definition: sr.api:148
vl_api_sr_steering_add_del_t
IPv6 SR steering add/del.
Definition: sr.api:163
vl_api_sr_steering_pol_details_t
Definition: sr.api:254
vl_api_sr_policies_with_sl_index_dump_t
Dump the list of SR policies along with actual segment list index on VPP.
Definition: sr.api:224
vl_api_sr_policies_details_t::is_spray
bool is_spray
Definition: sr.api:213
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
sr_policy_add
int sr_policy_add(ip6_address_t *bsid, ip6_address_t *segments, u32 weight, u8 type, u32 fib_table, u8 is_encap, u16 plugin, void *plugin_mem)
Create a new SR policy.
Definition: sr_policy_rewrite.c:636
vl_api_sr_policy_mod_t::sids
vl_api_srv6_sid_list_t sids
Definition: sr.api:109
vl_api_sr_localsids_details_t::vlan_index
u32 vlan_index
Definition: sr.api:193
ip_address_encode
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
Definition: ip_types_api.c:206
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vl_api_sr_set_encap_source_t_handler
static void vl_api_sr_set_encap_source_t_handler(vl_api_sr_set_encap_source_t *mp)
Definition: sr_api.c:152
vl_api_sr_localsid_add_del_t::is_del
bool is_del[default=false]
Definition: sr.api:56
vl_api_sr_policies_dump_t::client_index
u32 client_index
Definition: sr.api:204
i
int i
Definition: flowhash_template.h:376
SR_BEHAVIOR_DT4
#define SR_BEHAVIOR_DT4
Definition: sr.h:45
vl_api_sr_policies_details_t::context
u32 context
Definition: sr.api:211
ip6_sr_policy_t::fib_table
u32 fib_table
FIB table.
Definition: sr.h:110
ip6_sr_main_t::sr_policies
ip6_sr_policy_t * sr_policies
Definition: sr.h:267
vl_api_sr_policy_add_t::is_spray
bool is_spray
Definition: sr.api:83
vl_api_sr_policy_add_t::sids
vl_api_srv6_sid_list_t sids
Definition: sr.api:85
context
u32 context
Definition: ip.api:852
rv
int __clib_unused rv
Definition: application.c:491
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
vl_api_sr_localsids_dump_t
Dump the list of SR LocalSIDs.
Definition: sr.api:180
vl_api_sr_set_encap_source_t::encaps_source
vl_api_ip6_address_t encaps_source
Definition: sr.api:136
vl_api_sr_policy_mod_t::operation
vl_api_sr_policy_op_t operation
Definition: sr.api:106
vnet.h
vl_api_sr_policies_details_t::fib_table
u32 fib_table
Definition: sr.api:215
api_errno.h
vl_api_sr_localsids_details_t::addr
vl_api_ip6_address_t addr
Definition: sr.api:189
ip6_sr_steering_policy_t
Definition: sr.h:242
vl_api_sr_localsid_add_del_t
IPv6 SR LocalSID add/del request.
Definition: sr.api:52
ip6_sr_main_t::sid_lists
ip6_sr_sl_t * sid_lists
Definition: sr.h:264
SR_BEHAVIOR_DX4
#define SR_BEHAVIOR_DX4
Definition: sr.h:43
ip6_sr_localsid_t::behavior
u16 behavior
Behavior associated to this localsid.
Definition: sr.h:131
sr_steering_key_t::l3
struct sr_steering_key_t::@547::@549 l3
ip6_sr_localsid_t::fib_table
u32 fib_table
FIB table where localsid is registered.
Definition: sr.h:139
vl_api_sr_policies_details_t
Definition: sr.api:209
ip_types_api.h
vl_api_sr_steering_pol_details_t::traffic_type
vl_api_sr_steer_t traffic_type
Definition: sr.api:257
vl_api_sr_localsid_add_del_t::vlan_index
u32 vlan_index
Definition: sr.api:61
vl_api_sr_localsids_details_t::context
u32 context
Definition: sr.api:188
vl_api_sr_policies_with_sl_index_details_t::fib_table
u32 fib_table
Definition: sr.api:238
prefix
vl_api_prefix_t prefix
Definition: ip.api:175
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199