FD.io VPP  v18.07-34-g55fbdb9
Vector Packet Processing
sr_steering.c
Go to the documentation of this file.
1 /*
2  * sr_steering.c: ipv6 segment routing steering into SR policy
3  *
4  * Copyright (c) 2016 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /**
19  * @file
20  * @brief Packet steering into SR Policies
21  *
22  * This file is in charge of handling the FIB appropiatly to steer packets
23  * through SR Policies as defined in 'sr_policy_rewrite.c'. Notice that here
24  * we are only doing steering. SR policy application is done in
25  * sr_policy_rewrite.c
26  *
27  * Supports:
28  * - Steering of IPv6 traffic Destination Address based
29  * - Steering of IPv4 traffic Destination Address based
30  * - Steering of L2 frames, interface based (sw interface)
31  */
32 
33 #include <vlib/vlib.h>
34 #include <vnet/vnet.h>
35 #include <vnet/srv6/sr.h>
36 #include <vnet/ip/ip.h>
37 #include <vnet/srv6/sr_packet.h>
38 #include <vnet/ip/ip6_packet.h>
39 #include <vnet/fib/ip6_fib.h>
40 #include <vnet/dpo/dpo.h>
41 
42 #include <vppinfra/error.h>
43 #include <vppinfra/elog.h>
44 
45 /**
46  * @brief Steer traffic L2 and L3 traffic through a given SR policy
47  *
48  * @param is_del
49  * @param bsid is the bindingSID of the SR Policy (alt to sr_policy_index)
50  * @param sr_policy is the index of the SR Policy (alt to bsid)
51  * @param table_id is the VRF where to install the FIB entry for the BSID
52  * @param prefix is the IPv4/v6 address for L3 traffic type
53  * @param mask_width is the mask for L3 traffic type
54  * @param sw_if_index is the incoming interface for L2 traffic
55  * @param traffic_type describes the type of traffic
56  *
57  * @return 0 if correct, else error
58  */
59 int
60 sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
61  u32 table_id, ip46_address_t * prefix, u32 mask_width,
62  u32 sw_if_index, u8 traffic_type)
63 {
64  ip6_sr_main_t *sm = &sr_main;
66  ip6_sr_steering_policy_t *steer_pl;
67  fib_prefix_t pfx = { 0 };
68 
69  ip6_sr_policy_t *sr_policy = 0;
70  uword *p = 0;
71 
72  memset (&key, 0, sizeof (sr_steering_key_t));
73 
74  /* Compute the steer policy key */
75  if (traffic_type == SR_STEER_IPV4 || traffic_type == SR_STEER_IPV6)
76  {
77  key.l3.prefix.as_u64[0] = prefix->as_u64[0];
78  key.l3.prefix.as_u64[1] = prefix->as_u64[1];
79  key.l3.mask_width = mask_width;
80  key.l3.fib_table = (table_id != (u32) ~ 0 ? table_id : 0);
81  }
82  else if (traffic_type == SR_STEER_L2)
83  {
84  key.l2.sw_if_index = sw_if_index;
85 
86  /* Sanitise the SW_IF_INDEX */
88  sw_if_index))
89  return -3;
90 
92  vnet_get_sw_interface (sm->vnet_main, sw_if_index);
94  return -3;
95  }
96  else
97  return -1;
98 
99  key.traffic_type = traffic_type;
100 
101  /* Search for the item */
102  p = mhash_get (&sm->sr_steer_policies_hash, &key);
103 
104  if (p)
105  {
106  /* Retrieve Steer Policy function */
107  steer_pl = pool_elt_at_index (sm->steer_policies, p[0]);
108 
109  if (is_del)
110  {
111  if (steer_pl->classify.traffic_type == SR_STEER_IPV6)
112  {
113  /* Remove FIB entry */
115  pfx.fp_len = steer_pl->classify.l3.mask_width;
116  pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
117 
120  steer_pl->classify.l3.fib_table),
121  &pfx, FIB_SOURCE_SR);
122  }
123  else if (steer_pl->classify.traffic_type == SR_STEER_IPV4)
124  {
125  /* Remove FIB entry */
127  pfx.fp_len = steer_pl->classify.l3.mask_width;
128  pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
129 
132  steer_pl->classify.l3.fib_table), &pfx,
133  FIB_SOURCE_SR);
134  }
135  else if (steer_pl->classify.traffic_type == SR_STEER_L2)
136  {
137  /* Remove HW redirection */
138  vnet_feature_enable_disable ("device-input",
139  "sr-policy-rewrite-encaps-l2",
140  sw_if_index, 0, 0, 0);
141  sm->sw_iface_sr_policies[sw_if_index] = ~(u32) 0;
142 
143  /* Remove promiscous mode from interface */
144  vnet_main_t *vnm = vnet_get_main ();
146  ethernet_interface_t *eif =
147  ethernet_get_interface (em, sw_if_index);
148 
149  if (!eif)
150  goto cleanup_error_redirection;
151 
152  ethernet_set_flags (vnm, sw_if_index, 0);
153  }
154 
155  /* Delete SR steering policy entry */
156  pool_put (sm->steer_policies, steer_pl);
158 
159  /* If no more SR policies or steering policies */
160  if (!pool_elts (sm->sr_policies) && !pool_elts (sm->steer_policies))
161  {
166  sm->fib_table_ip6 = (u32) ~ 0;
167  sm->fib_table_ip4 = (u32) ~ 0;
168  }
169 
170  return 0;
171  }
172  else /* It means user requested to update an existing SR steering policy */
173  {
174  /* Retrieve SR steering policy */
175  if (bsid)
176  {
177  p = mhash_get (&sm->sr_policies_index_hash, bsid);
178  if (p)
179  sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
180  else
181  return -2;
182  }
183  else
184  sr_policy = pool_elt_at_index (sm->sr_policies, sr_policy_index);
185 
186  if (!sr_policy)
187  return -2;
188 
189  steer_pl->sr_policy = sr_policy - sm->sr_policies;
190 
191  /* Remove old FIB/hw redirection and create a new one */
192  if (steer_pl->classify.traffic_type == SR_STEER_IPV6)
193  {
194  /* Remove FIB entry */
196  pfx.fp_len = steer_pl->classify.l3.mask_width;
197  pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
198 
201  steer_pl->classify.l3.fib_table),
202  &pfx, FIB_SOURCE_SR);
203 
204  /* Create a new one */
205  goto update_fib;
206  }
207  else if (steer_pl->classify.traffic_type == SR_STEER_IPV4)
208  {
209  /* Remove FIB entry */
211  pfx.fp_len = steer_pl->classify.l3.mask_width;
212  pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
213 
216  steer_pl->classify.l3.fib_table),
217  &pfx, FIB_SOURCE_SR);
218 
219  /* Create a new one */
220  goto update_fib;
221  }
222  else if (steer_pl->classify.traffic_type == SR_STEER_L2)
223  {
224  /* Update L2-HW redirection */
225  goto update_fib;
226  }
227  }
228  }
229  else
230  /* delete; steering policy does not exist; complain */
231  if (is_del)
232  return -4;
233 
234  /* Retrieve SR policy */
235  if (bsid)
236  {
237  p = mhash_get (&sm->sr_policies_index_hash, bsid);
238  if (p)
239  sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
240  else
241  return -2;
242  }
243  else
244  sr_policy = pool_elt_at_index (sm->sr_policies, sr_policy_index);
245 
246  /* Create a new steering policy */
247  pool_get (sm->steer_policies, steer_pl);
248  memset (steer_pl, 0, sizeof (*steer_pl));
249 
250  if (traffic_type == SR_STEER_IPV4 || traffic_type == SR_STEER_IPV6)
251  {
252  clib_memcpy (&steer_pl->classify.l3.prefix, prefix,
253  sizeof (ip46_address_t));
254  steer_pl->classify.l3.mask_width = mask_width;
255  steer_pl->classify.l3.fib_table =
256  (table_id != (u32) ~ 0 ? table_id : 0);
257  steer_pl->classify.traffic_type = traffic_type;
258  }
259  else if (traffic_type == SR_STEER_L2)
260  {
261  steer_pl->classify.l2.sw_if_index = sw_if_index;
262  steer_pl->classify.traffic_type = traffic_type;
263  }
264  else
265  {
266  /* Incorrect API usage. Should never get here */
267  pool_put (sm->steer_policies, steer_pl);
269  return -1;
270  }
271  steer_pl->sr_policy = sr_policy - sm->sr_policies;
272 
273  /* Create and store key */
274  mhash_set (&sm->sr_steer_policies_hash, &key, steer_pl - sm->steer_policies,
275  NULL);
276 
277  if (traffic_type == SR_STEER_L2)
278  {
279  if (!sr_policy->is_encap)
280  goto cleanup_error_encap;
281 
283  ("device-input", "sr-pl-rewrite-encaps-l2", sw_if_index, 1, 0, 0))
284  goto cleanup_error_redirection;
285 
286  /* Set promiscous mode on interface */
287  vnet_main_t *vnm = vnet_get_main ();
289  ethernet_interface_t *eif = ethernet_get_interface (em, sw_if_index);
290 
291  if (!eif)
292  goto cleanup_error_redirection;
293 
294  ethernet_set_flags (vnm, sw_if_index,
296  }
297  else if (traffic_type == SR_STEER_IPV4)
298  if (!sr_policy->is_encap)
299  goto cleanup_error_encap;
300 
301 update_fib:
302  /* FIB API calls - Recursive route through the BindingSID */
303  if (traffic_type == SR_STEER_IPV6)
304  {
306  pfx.fp_len = steer_pl->classify.l3.mask_width;
307  pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
308 
310  (table_id !=
311  (u32) ~ 0 ?
312  table_id : 0)),
313  &pfx, FIB_SOURCE_SR,
316  (ip46_address_t *) & sr_policy->bsid, ~0,
317  sm->fib_table_ip6, 1, NULL,
319  }
320  else if (traffic_type == SR_STEER_IPV4)
321  {
323  pfx.fp_len = steer_pl->classify.l3.mask_width;
324  pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
325 
327  (table_id !=
328  (u32) ~ 0 ?
329  table_id : 0)),
330  &pfx, FIB_SOURCE_SR,
333  (ip46_address_t *) & sr_policy->bsid, ~0,
334  sm->fib_table_ip4, 1, NULL,
336  }
337  else if (traffic_type == SR_STEER_L2)
338  {
339  if (sw_if_index < vec_len (sm->sw_iface_sr_policies))
340  sm->sw_iface_sr_policies[sw_if_index] = steer_pl->sr_policy;
341  else
342  {
345  - vec_len (sm->sw_iface_sr_policies)));
346  sm->sw_iface_sr_policies[sw_if_index] = steer_pl->sr_policy;
347  }
348  }
349 
350  return 0;
351 
352 cleanup_error_encap:
353  pool_put (sm->steer_policies, steer_pl);
355  return -5;
356 
357 cleanup_error_redirection:
358  pool_put (sm->steer_policies, steer_pl);
360  return -3;
361 }
362 
363 static clib_error_t *
365  vlib_cli_command_t * cmd)
366 {
367  vnet_main_t *vnm = vnet_get_main ();
368 
369  int is_del = 0;
370 
371  ip46_address_t prefix;
372  u32 dst_mask_width = 0;
373  u32 sw_if_index = (u32) ~ 0;
374  u8 traffic_type = 0;
375  u32 fib_table = (u32) ~ 0;
376 
377  ip6_address_t bsid;
378  u32 sr_policy_index = (u32) ~ 0;
379 
380  u8 sr_policy_set = 0;
381 
382  memset (&prefix, 0, sizeof (ip46_address_t));
383 
384  int rv;
386  {
387  if (unformat (input, "del"))
388  is_del = 1;
389  else if (!traffic_type
390  && unformat (input, "l3 %U/%d", unformat_ip6_address,
391  &prefix.ip6, &dst_mask_width))
392  traffic_type = SR_STEER_IPV6;
393  else if (!traffic_type
394  && unformat (input, "l3 %U/%d", unformat_ip4_address,
395  &prefix.ip4, &dst_mask_width))
396  traffic_type = SR_STEER_IPV4;
397  else if (!traffic_type
398  && unformat (input, "l2 %U", unformat_vnet_sw_interface, vnm,
399  &sw_if_index))
400  traffic_type = SR_STEER_L2;
401  else if (!sr_policy_set
402  && unformat (input, "via index %d", &sr_policy_index))
403  sr_policy_set = 1;
404  else if (!sr_policy_set
405  && unformat (input, "via bsid %U",
406  unformat_ip6_address, &bsid))
407  sr_policy_set = 1;
408  else if (fib_table == (u32) ~ 0
409  && unformat (input, "fib-table %d", &fib_table));
410  else
411  break;
412  }
413 
414  if (!traffic_type)
415  return clib_error_return (0, "No L2/L3 traffic specified");
416  if (!sr_policy_set)
417  return clib_error_return (0, "No SR policy specified");
418 
419  /* Make sure that the prefixes are clean */
420  if (traffic_type == SR_STEER_IPV4)
421  {
422  u32 mask =
423  (dst_mask_width ? (0xFFFFFFFFu >> (32 - dst_mask_width)) : 0);
424  prefix.ip4.as_u32 &= mask;
425  }
426  else if (traffic_type == SR_STEER_IPV6)
427  {
428  ip6_address_t mask;
429  ip6_address_mask_from_width (&mask, dst_mask_width);
430  ip6_address_mask (&prefix.ip6, &mask);
431  }
432 
433  rv =
434  sr_steering_policy (is_del, (sr_policy_index == ~(u32) 0 ? &bsid : NULL),
435  sr_policy_index, fib_table, &prefix, dst_mask_width,
436  sw_if_index, traffic_type);
437 
438  switch (rv)
439  {
440  case 0:
441  break;
442  case 1:
443  return 0;
444  case -1:
445  return clib_error_return (0, "Incorrect API usage.");
446  case -2:
447  return clib_error_return (0,
448  "The requested SR policy could not be located. Review the BSID/index.");
449  case -3:
450  return clib_error_return (0,
451  "Unable to do SW redirect. Incorrect interface.");
452  case -4:
453  return clib_error_return (0,
454  "The requested SR steering policy could not be deleted.");
455  case -5:
456  return clib_error_return (0,
457  "The SR policy is not an encapsulation one.");
458  default:
459  return clib_error_return (0, "BUG: sr steer policy returns %d", rv);
460  }
461  return 0;
462 }
463 
464 /* *INDENT-OFF* */
465 VLIB_CLI_COMMAND (sr_steer_policy_command, static) = {
466  .path = "sr steer",
467  .short_help = "sr steer (del) [l3 <ip_addr/mask>|l2 <sf_if>] "
468  "via [index <sr_policy_index>|bsid <bsid_ip6_addr>] "
469  "(fib-table <fib_table_index>)",
470  .long_help =
471  "\tSteer a L2 or L3 traffic through an existing SR policy.\n"
472  "\tExamples:\n"
473  "\t\tsr steer l3 2001::/64 via sr_policy index 5\n"
474  "\t\tsr steer l3 2001::/64 via sr_policy bsid 2010::9999:1\n"
475  "\t\tsr steer l2 GigabitEthernet0/5/0 via sr_policy index 5\n"
476  "\t\tsr steer del l3 2001::/64 via sr_policy index 5\n",
477  .function = sr_steer_policy_command_fn,
478 };
479 /* *INDENT-ON* */
480 
481 static clib_error_t *
483  unformat_input_t * input,
484  vlib_cli_command_t * cmd)
485 {
486  ip6_sr_main_t *sm = &sr_main;
487  ip6_sr_steering_policy_t **steer_policies = 0;
488  ip6_sr_steering_policy_t *steer_pl;
489 
490  vnet_main_t *vnm = vnet_get_main ();
491 
492  ip6_sr_policy_t *pl = 0;
493  int i;
494 
495  vlib_cli_output (vm, "SR steering policies:");
496  /* *INDENT-OFF* */
497  pool_foreach (steer_pl, sm->steer_policies, ({vec_add1(steer_policies, steer_pl);}));
498  /* *INDENT-ON* */
499  vlib_cli_output (vm, "Traffic\t\tSR policy BSID");
500  for (i = 0; i < vec_len (steer_policies); i++)
501  {
502  steer_pl = steer_policies[i];
503  pl = pool_elt_at_index (sm->sr_policies, steer_pl->sr_policy);
504  if (steer_pl->classify.traffic_type == SR_STEER_L2)
505  {
506  vlib_cli_output (vm, "L2 %U\t%U",
508  steer_pl->classify.l2.sw_if_index,
509  format_ip6_address, &pl->bsid);
510  }
511  else if (steer_pl->classify.traffic_type == SR_STEER_IPV4)
512  {
513  vlib_cli_output (vm, "L3 %U/%d\t%U",
515  &steer_pl->classify.l3.prefix.ip4,
516  steer_pl->classify.l3.mask_width,
517  format_ip6_address, &pl->bsid);
518  }
519  else if (steer_pl->classify.traffic_type == SR_STEER_IPV6)
520  {
521  vlib_cli_output (vm, "L3 %U/%d\t%U",
523  &steer_pl->classify.l3.prefix.ip6,
524  steer_pl->classify.l3.mask_width,
525  format_ip6_address, &pl->bsid);
526  }
527  }
528  return 0;
529 }
530 
531 /* *INDENT-OFF* */
532 VLIB_CLI_COMMAND (show_sr_steering_policies_command, static) = {
533  .path = "show sr steering-policies",
534  .short_help = "show sr steering-policies",
536 };
537 /* *INDENT-ON* */
538 
539 clib_error_t *
541 {
542  ip6_sr_main_t *sm = &sr_main;
543 
544  /* Init memory for function keys */
545  mhash_init (&sm->sr_steer_policies_hash, sizeof (uword),
546  sizeof (sr_steering_key_t));
547 
548  sm->sw_iface_sr_policies = 0;
549 
550  sm->vnet_main = vnet_get_main ();
551 
552  return 0;
553 }
554 
555 /* *INDENT-OFF* */
557 /* *INDENT-ON* */
558 
559 /* *INDENT-OFF* */
560 VNET_FEATURE_INIT (sr_pl_rewrite_encaps_l2, static) =
561 {
562  .arc_name = "device-input",
563  .node_name = "sr-pl-rewrite-encaps-l2",
564  .runs_before = VNET_FEATURES ("ethernet-input"),
565 };
566 /* *INDENT-ON* */
567 
568 /*
569 * fd.io coding-style-patch-verification: ON
570 *
571 * Local Variables:
572 * eval: (c-set-style "gnu")
573 * End:
574 */
static void ip6_address_mask(ip6_address_t *a, ip6_address_t *mask)
Definition: ip6_packet.h:241
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:197
ip6_sr_main_t sr_main
Definition: sr.c:31
fib_node_index_t fib_table_entry_path_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
Definition: fib_table.c:522
#define SR_STEER_IPV6
Definition: sr_mpls.h:42
#define SR_STEER_IPV4
Definition: sr_mpls.h:41
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
vnet_interface_main_t interface_main
Definition: vnet.h:56
static clib_error_t * sr_steer_policy_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: sr_steering.c:364
#define NULL
Definition: clib.h:55
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
Definition: mhash.c:353
int i
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:228
ip6_sr_steering_policy_t * steer_policies
Definition: sr.h:210
format_function_t format_vnet_sw_if_index_name
unsigned char u8
Definition: types.h:56
#define pool_len(p)
Number of elements in pool vector.
Definition: pool.h:140
static clib_error_t * show_sr_steering_policies_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: sr_steering.c:482
VNET_FEATURE_INIT(sr_pl_rewrite_encaps_l2, static)
u32 * sw_iface_sr_policies
Definition: sr.h:216
struct sr_steering_key_t::@317::@320 l2
Definition: fib_entry.h:283
ethernet_main_t ethernet_main
Definition: init.c:45
format_function_t format_ip4_address
Definition: format.h:81
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:443
unformat_function_t unformat_ip4_address
Definition: format.h:76
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:156
Aggregrate type for a prefix.
Definition: fib_types.h:188
#define clib_error_return(e, args...)
Definition: error.h:99
struct sr_steering_key_t::@317::@319 l3
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:240
unsigned int u32
Definition: types.h:88
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1056
u16 fp_len
The mask length.
Definition: fib_types.h:192
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:464
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:211
struct _unformat_input_t unformat_input_t
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:274
sr_steering_key_t classify
Traffic classification.
Definition: sr.h:182
static uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
Definition: mhash.h:117
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
Definition: fib_table.c:1228
u8 is_encap
Mode (0 is SRH insert, 1 Encaps)
Definition: sr.h:96
u32 sr_policy
SR Policy index.
Definition: sr.h:183
unformat_function_t unformat_ip6_address
Definition: format.h:97
vnet_main_t * vnet_main
Definition: sr.h:237
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
Definition: mhash.c:168
format_function_t format_ip6_address
Definition: format.h:99
vlib_main_t * vm
Definition: buffer.c:294
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:242
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:853
#define clib_memcpy(a, b, c)
Definition: string.h:75
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:147
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:271
Steering db key.
Definition: sr.h:161
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
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
static uword * mhash_get(mhash_t *h, const void *key)
Definition: mhash.h:110
#define VNET_FEATURES(...)
Definition: feature.h:391
mhash_t sr_policies_index_hash
Definition: sr.h:201
clib_error_t * sr_steering_init(vlib_main_t *vm)
Definition: sr_steering.c:540
SRv6 and SR-MPLS.
Definition: fib_entry.h:58
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:872
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip6_sr_policy_t * sr_policies
Definition: sr.h:198
mhash_t sr_steer_policies_hash
Definition: sr.h:213
SR Policy.
Definition: sr.h:80
u64 uword
Definition: types.h:112
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:802
typedef prefix
Definition: ip_types.api:40
static void ip6_address_mask_from_width(ip6_address_t *a, u32 width)
Definition: ip6_packet.h:257
Segment Routing data structures definitions.
Segment Routing main datastructure.
Definition: sr.h:189
vnet_sw_interface_type_t type
Definition: interface.h:656
u8 traffic_type
Traffic type (IPv4, IPv6, L2)
Definition: sr.h:176
u32 fib_table_ip4
Definition: sr.h:233
#define SR_STEER_L2
Definition: sr.h:48
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:681
u32 fib_table_ip6
Definition: sr.h:232
ip6_address_t bsid
BindingSID (key)
Definition: sr.h:84
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:233
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:367
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128