FD.io VPP  v19.01.2-3-gf61a1a8
Vector Packet Processing
as.c
Go to the documentation of this file.
1 /*
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  */
15 /*
16  *------------------------------------------------------------------
17  * as.c - SRv6 Static Proxy (AS) function
18  *------------------------------------------------------------------
19  */
20 
21 #include <vnet/vnet.h>
22 #include <vnet/adj/adj.h>
23 #include <vnet/plugin/plugin.h>
24 #include <vpp/app/version.h>
25 #include <srv6-as/as.h>
26 
27 #define SID_CREATE_IFACE_FEATURE_ERROR -1
28 #define SID_CREATE_INVALID_IFACE_TYPE -3
29 #define SID_CREATE_INVALID_IFACE_INDEX -4
30 #define SID_CREATE_INVALID_ADJ_INDEX -5
31 
32 unsigned char function_name[] = "SRv6-AS-plugin";
33 unsigned char keyword_str[] = "End.AS";
34 unsigned char def_str[] =
35  "Endpoint with static proxy to SR-unaware appliance";
36 unsigned char params_str[] =
37  "nh <next-hop> oif <iface-out> iif <iface-in> src <src-addr> next <sid> [next <sid> ...]";
38 
39 
40 static inline u8 *
42  u8 protocol)
43 {
44  u8 *rewrite_str = NULL;
45  u32 rewrite_len = IPv6_DEFAULT_HEADER_LENGTH;
46 
47  u8 num_sids = vec_len (sid_list);
48  u32 sr_hdr_len = 0;
49 
50  if (num_sids > 1)
51  {
52  sr_hdr_len =
53  sizeof (ip6_sr_header_t) + num_sids * sizeof (ip6_address_t);
54  rewrite_len += sr_hdr_len;
55  }
56 
57  vec_validate (rewrite_str, rewrite_len - 1);
58 
59  /* Fill IP header */
60  ip6_header_t *iph = (ip6_header_t *) rewrite_str;
62  clib_host_to_net_u32 (0 | ((6 & 0xF) << 28));
63  iph->src_address = src_addr;
64  iph->dst_address = sid_list[0];
65  iph->payload_length = sr_hdr_len;
67 
68  if (num_sids > 1)
69  {
70  /* Set Next Header value to Routing Extension */
71  iph->protocol = IP_PROTOCOL_IPV6_ROUTE;
72 
73  /* Fill SR header */
74  ip6_sr_header_t *srh = (ip6_sr_header_t *) (iph + 1);
75  srh->protocol = protocol;
76  srh->length = sr_hdr_len / 8 - 1;
78  srh->segments_left = num_sids - 1;
79  srh->first_segment = num_sids - 1;
80  srh->flags = 0x00;
81  srh->reserved = 0x00;
82 
83  /* Fill segment list */
84  ip6_address_t *this_address;
85  ip6_address_t *addrp = srh->segments + srh->first_segment;
86  vec_foreach (this_address, sid_list)
87  {
88  *addrp = *this_address;
89  addrp--;
90  }
91  }
92  else
93  {
94  /* Set Next Header value to inner protocol */
95  iph->protocol = protocol;
96  }
97 
98  return rewrite_str;
99 }
100 
101 static inline void
103 {
104  vec_free (ls_mem->rewrite);
105  vec_free (ls_mem->sid_list);
106  clib_mem_free (ls_mem);
107 }
108 
109 
110 /*****************************************/
111 /* SRv6 LocalSID instantiation and removal functions */
112 static int
114 {
115  ip6_sr_main_t *srm = &sr_main;
117  srv6_as_localsid_t *ls_mem = localsid->plugin_mem;
118  u32 localsid_index = localsid - srm->localsids;
119 
120  /* Step 1: Prepare xconnect adjacency for sending packets to the VNF */
121 
122  /* Retrieve the adjacency corresponding to the (OIF, next_hop) */
123  adj_index_t nh_adj_index = ADJ_INDEX_INVALID;
124  if (ls_mem->inner_type != AS_TYPE_L2)
125  {
126  if (ls_mem->inner_type == AS_TYPE_IP4)
127  nh_adj_index = adj_nbr_add_or_lock (FIB_PROTOCOL_IP4,
128  VNET_LINK_IP4, &ls_mem->nh_addr,
129  ls_mem->sw_if_index_out);
130  else if (ls_mem->inner_type == AS_TYPE_IP6)
131  nh_adj_index = adj_nbr_add_or_lock (FIB_PROTOCOL_IP6,
132  VNET_LINK_IP6, &ls_mem->nh_addr,
133  ls_mem->sw_if_index_out);
134  if (nh_adj_index == ADJ_INDEX_INVALID)
135  {
136  free_ls_mem (ls_mem);
138  }
139  }
140 
141  ls_mem->nh_adj = nh_adj_index;
142 
143 
144  /* Step 2: Prepare inbound policy for packets returning from the VNF */
145 
146  /* Make sure the provided incoming interface index is valid */
148  ls_mem->sw_if_index_in))
149  {
150  adj_unlock (ls_mem->nh_adj);
151  free_ls_mem (ls_mem);
153  }
154 
155  /* Retrieve associated interface structure */
157  ls_mem->sw_if_index_in);
159  {
160  adj_unlock (ls_mem->nh_adj);
161  free_ls_mem (ls_mem);
163  }
164 
165  if (ls_mem->inner_type == AS_TYPE_L2)
166  {
167  /* Enable End.AS2 rewrite node for this interface */
168  int ret =
169  vnet_feature_enable_disable ("device-input", "srv6-as2-rewrite",
170  ls_mem->sw_if_index_in, 1, 0, 0);
171  if (ret != 0)
172  {
173  free_ls_mem (ls_mem);
175  }
176 
177  /* Set interface in promiscuous mode */
178  vnet_main_t *vnm = vnet_get_main ();
179  ethernet_set_flags (vnm, ls_mem->sw_if_index_in,
181 
182  /* Prepare rewrite string */
183  ls_mem->rewrite = prepare_rewrite (ls_mem->src_addr, ls_mem->sid_list,
184  IP_PROTOCOL_IP6_NONXT);
185 
186  /* Associate local SID index to this interface (resize vector if needed) */
187  if (ls_mem->sw_if_index_in >= vec_len (sm->sw_iface_localsid2))
188  {
191  - vec_len (sm->sw_iface_localsid2)));
192  }
193  sm->sw_iface_localsid2[ls_mem->sw_if_index_in] = localsid_index;
194  }
195  else if (ls_mem->inner_type == AS_TYPE_IP4)
196  {
197  /* Enable End.AS4 rewrite node for this interface */
198  int ret =
199  vnet_feature_enable_disable ("ip4-unicast", "srv6-as4-rewrite",
200  ls_mem->sw_if_index_in, 1, 0, 0);
201  if (ret != 0)
202  {
203  adj_unlock (ls_mem->nh_adj);
204  free_ls_mem (ls_mem);
206  }
207 
208  /* Prepare rewrite string */
209  ls_mem->rewrite = prepare_rewrite (ls_mem->src_addr, ls_mem->sid_list,
210  IP_PROTOCOL_IP_IN_IP);
211 
212  /* Associate local SID index to this interface (resize vector if needed) */
213  if (ls_mem->sw_if_index_in >= vec_len (sm->sw_iface_localsid4))
214  {
217  - vec_len (sm->sw_iface_localsid4)));
218  }
219  sm->sw_iface_localsid4[ls_mem->sw_if_index_in] = localsid_index;
220  }
221  else if (ls_mem->inner_type == AS_TYPE_IP6)
222  {
223  /* Enable End.AS6 rewrite node for this interface */
224  int ret =
225  vnet_feature_enable_disable ("ip6-unicast", "srv6-as6-rewrite",
226  ls_mem->sw_if_index_in, 1, 0, 0);
227  if (ret != 0)
228  {
229  adj_unlock (ls_mem->nh_adj);
230  free_ls_mem (ls_mem);
232  }
233 
234  /* Prepare rewrite string */
235  ls_mem->rewrite = prepare_rewrite (ls_mem->src_addr, ls_mem->sid_list,
236  IP_PROTOCOL_IPV6);
237 
238  /* Associate local SID index to this interface (resize vector if needed) */
239  if (ls_mem->sw_if_index_in >= vec_len (sm->sw_iface_localsid6))
240  {
243  - vec_len (sm->sw_iface_localsid6)));
244  }
245  sm->sw_iface_localsid6[ls_mem->sw_if_index_in] = localsid_index;
246  }
247 
248  /* Step 3: Initialize rewrite counters */
249  srv6_as_localsid_t **ls_p;
250  pool_get (sm->sids, ls_p);
251  *ls_p = ls_mem;
252  ls_mem->index = ls_p - sm->sids;
253 
256 
259 
260  return 0;
261 }
262 
263 static int
265 {
267  srv6_as_localsid_t *ls_mem = localsid->plugin_mem;
268 
269  if (ls_mem->inner_type == AS_TYPE_L2)
270  {
271  /* Disable End.AS2 rewrite node for this interface */
272  int ret;
273  ret = vnet_feature_enable_disable ("device-input", "srv6-as2-rewrite",
274  ls_mem->sw_if_index_in, 0, 0, 0);
275  if (ret != 0)
276  return -1;
277 
278  /* Disable promiscuous mode on the interface */
279  vnet_main_t *vnm = vnet_get_main ();
280  ethernet_set_flags (vnm, ls_mem->sw_if_index_in, 0);
281 
282  /* Remove local SID index from interface table */
283  sm->sw_iface_localsid2[ls_mem->sw_if_index_in] = ~(u32) 0;
284  }
285  else if (ls_mem->inner_type == AS_TYPE_IP4)
286  {
287  /* Disable End.AS4 rewrite node for this interface */
288  int ret;
289  ret = vnet_feature_enable_disable ("ip4-unicast", "srv6-as4-rewrite",
290  ls_mem->sw_if_index_in, 0, 0, 0);
291  if (ret != 0)
292  return -1;
293 
294  /* Remove local SID index from interface table */
295  sm->sw_iface_localsid4[ls_mem->sw_if_index_in] = ~(u32) 0;
296  }
297  else if (ls_mem->inner_type == AS_TYPE_IP6)
298  {
299  /* Disable End.AS6 rewrite node for this interface */
300  int ret;
301  ret = vnet_feature_enable_disable ("ip6-unicast", "srv6-as6-rewrite",
302  ls_mem->sw_if_index_in, 0, 0, 0);
303  if (ret != 0)
304  return -1;
305 
306  /* Remove local SID index from interface table */
307  sm->sw_iface_localsid6[ls_mem->sw_if_index_in] = ~(u32) 0;
308  }
309 
310 
311  /* Unlock (OIF, NHOP) adjacency (from sr_localsid.c:103) */
312  adj_unlock (ls_mem->nh_adj);
313 
314  /* Delete SID entry */
315  pool_put (sm->sids, pool_elt_at_index (sm->sids, ls_mem->index));
316 
317  /* Clean up local SID memory */
318  free_ls_mem (ls_mem);
319 
320  return 0;
321 }
322 
323 /**********************************/
324 /* SRv6 LocalSID format functions */
325 /*
326  * Prints nicely the parameters of a localsid
327  * Example: print "Table 5"
328  */
329 u8 *
330 format_srv6_as_localsid (u8 * s, va_list * args)
331 {
332  srv6_as_localsid_t *ls_mem = va_arg (*args, void *);
333 
334  vnet_main_t *vnm = vnet_get_main ();
336 
337  if (ls_mem->inner_type == AS_TYPE_IP4)
338  {
339  s =
340  format (s, "Next-hop:\t%U\n\t", format_ip4_address,
341  &ls_mem->nh_addr.ip4);
342  }
343  else if (ls_mem->inner_type == AS_TYPE_IP6)
344  {
345  s =
346  format (s, "Next-hop:\t%U\n\t", format_ip6_address,
347  &ls_mem->nh_addr.ip6);
348  }
349 
350  s = format (s, "Outgoing iface:\t%U\n", format_vnet_sw_if_index_name, vnm,
351  ls_mem->sw_if_index_out);
352  s = format (s, "\tIncoming iface:\t%U\n", format_vnet_sw_if_index_name, vnm,
353  ls_mem->sw_if_index_in);
354  s = format (s, "\tSource address:\t%U\n", format_ip6_address,
355  &ls_mem->src_addr);
356 
357  s = format (s, "\tSegment list:\t< ");
359  vec_foreach (addr, ls_mem->sid_list)
360  {
361  s = format (s, "%U, ", format_ip6_address, addr);
362  }
363  s = format (s, "\b\b >\n");
364 
365  vlib_counter_t valid, invalid;
366  vlib_get_combined_counter (&(sm->valid_counters), ls_mem->index, &valid);
368  &invalid);
369  s =
370  format (s, "\tGood rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
371  valid.packets, valid.bytes);
372  s =
373  format (s, "\tBad rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
374  invalid.packets, invalid.bytes);
375 
376  return s;
377 }
378 
379 /*
380  * Process the parameters of a localsid
381  * Example: process from:
382  * sr localsid address cafe::1 behavior new_srv6_localsid 5
383  * everything from behavior on... so in this case 'new_srv6_localsid 5'
384  * Notice that it MUST match the keyword_str and params_str defined above.
385  */
386 uword
388 {
389  void **plugin_mem_p = va_arg (*args, void **);
390  srv6_as_localsid_t *ls_mem;
391 
392  vnet_main_t *vnm = vnet_get_main ();
393 
394  u8 inner_type = AS_TYPE_L2;
395  ip46_address_t nh_addr;
396  u32 sw_if_index_out;
397  u32 sw_if_index_in;
398  ip6_address_t src_addr;
399  ip6_address_t next_sid;
400  ip6_address_t *sid_list = NULL;
401 
402  u8 params = 0;
403 #define PARAM_AS_NH (1 << 0)
404 #define PARAM_AS_OIF (1 << 1)
405 #define PARAM_AS_IIF (1 << 2)
406 #define PARAM_AS_SRC (1 << 3)
407 
408  if (!unformat (input, "end.as"))
409  return 0;
410 
412  {
413  if (!(params & PARAM_AS_NH) && unformat (input, "nh %U",
415  &nh_addr.ip4))
416  {
417  inner_type = AS_TYPE_IP4;
418  params |= PARAM_AS_NH;
419  }
420  if (!(params & PARAM_AS_NH) && unformat (input, "nh %U",
422  &nh_addr.ip6))
423  {
424  inner_type = AS_TYPE_IP6;
425  params |= PARAM_AS_NH;
426  }
427  else if (!(params & PARAM_AS_OIF) && unformat (input, "oif %U",
429  vnm, &sw_if_index_out))
430  {
431  params |= PARAM_AS_OIF;
432  }
433  else if (!(params & PARAM_AS_IIF) && unformat (input, "iif %U",
435  vnm, &sw_if_index_in))
436  {
437  params |= PARAM_AS_IIF;
438  }
439  else if (!(params & PARAM_AS_SRC) && unformat (input, "src %U",
441  &src_addr))
442  {
443  params |= PARAM_AS_SRC;
444  }
445  else if (unformat (input, "next %U", unformat_ip6_address, &next_sid))
446  {
447  vec_add1 (sid_list, next_sid);
448  }
449  else
450  {
451  break;
452  }
453  }
454 
455  /* Make sure that all parameters are supplied */
456  u8 params_chk = (PARAM_AS_OIF | PARAM_AS_IIF | PARAM_AS_SRC);
457  if ((params & params_chk) != params_chk || sid_list == NULL)
458  {
459  vec_free (sid_list);
460  return 0;
461  }
462 
463  /* Allocate and initialize memory block for local SID parameters */
464  ls_mem = clib_mem_alloc_aligned_at_offset (sizeof *ls_mem, 0, 0, 1);
465  clib_memset (ls_mem, 0, sizeof *ls_mem);
466  *plugin_mem_p = ls_mem;
467 
468  /* Set local SID parameters */
469  ls_mem->inner_type = inner_type;
470  if (inner_type == AS_TYPE_IP4)
471  ls_mem->nh_addr.ip4 = nh_addr.ip4;
472  else if (inner_type == AS_TYPE_IP6)
473  ls_mem->nh_addr.ip6 = nh_addr.ip6;
474  ls_mem->sw_if_index_out = sw_if_index_out;
475  ls_mem->sw_if_index_in = sw_if_index_in;
476  ls_mem->src_addr = src_addr;
477  ls_mem->sid_list = sid_list;
478 
479  return 1;
480 }
481 
482 /*************************/
483 /* SRv6 LocalSID FIB DPO */
484 static u8 *
485 format_srv6_as_dpo (u8 * s, va_list * args)
486 {
487  index_t index = va_arg (*args, index_t);
488  CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
489 
490  return (format (s, "SR: static_proxy_index:[%u]", index));
491 }
492 
493 void
495 {
496 }
497 
498 void
500 {
501 }
502 
503 const static dpo_vft_t srv6_as_vft = {
505  .dv_unlock = srv6_as_dpo_unlock,
506  .dv_format = format_srv6_as_dpo,
507 };
508 
509 const static char *const srv6_as_ip6_nodes[] = {
510  "srv6-as-localsid",
511  NULL,
512 };
513 
514 const static char *const *const srv6_as_nodes[DPO_PROTO_NUM] = {
516 };
517 
518 /**********************/
519 static clib_error_t *
521 {
523  int rv = 0;
524 
525  sm->vlib_main = vm;
526  sm->vnet_main = vnet_get_main ();
527 
528  /* Create DPO */
530 
531  /* Register SRv6 LocalSID */
534  keyword_str,
535  def_str,
536  params_str,
537  &sm->srv6_as_dpo_type,
542  if (rv < 0)
543  clib_error_return (0, "SRv6 LocalSID function could not be registered.");
544  else
545  sm->srv6_localsid_behavior_id = rv;
546 
547  return 0;
548 }
549 
550 /* *INDENT-OFF* */
551 VNET_FEATURE_INIT (srv6_as2_rewrite, static) =
552 {
553  .arc_name = "device-input",
554  .node_name = "srv6-as2-rewrite",
555  .runs_before = VNET_FEATURES ("ethernet-input"),
556 };
557 
558 VNET_FEATURE_INIT (srv6_as4_rewrite, static) =
559 {
560  .arc_name = "ip4-unicast",
561  .node_name = "srv6-as4-rewrite",
562  .runs_before = 0,
563 };
564 
565 VNET_FEATURE_INIT (srv6_as6_rewrite, static) =
566 {
567  .arc_name = "ip6-unicast",
568  .node_name = "srv6-as6-rewrite",
569  .runs_before = 0,
570 };
571 
573 
575  .version = VPP_BUILD_VER,
576  .description = "Static Segment Routing for IPv6 (SRv6) Proxy",
577 };
578 /* *INDENT-ON* */
579 
580 /*
581 * fd.io coding-style-patch-verification: ON
582 *
583 * Local Variables:
584 * eval: (c-set-style "gnu")
585 * End:
586 */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
ip6_sr_main_t sr_main
Definition: sr.c:31
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:404
unsigned char function_name[]
Definition: as.c:32
#define PARAM_AS_IIF
#define PARAM_AS_OIF
#define CLIB_UNUSED(x)
Definition: clib.h:82
A virtual function table regisitered for a DPO type.
Definition: dpo.h:399
static u8 * prepare_rewrite(ip6_address_t src_addr, ip6_address_t *sid_list, u8 protocol)
Definition: as.c:41
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
Definition: counter.c:106
static void * clib_mem_alloc_aligned_at_offset(uword size, uword align, uword align_offset, int os_out_of_memory_on_failure)
Definition: mem.h:81
SR LocalSID.
Definition: sr.h:102
u32 * sw_iface_localsid4
Retrieve local SID from iface.
Definition: as.h:62
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
u32 srv6_localsid_behavior_id
SRv6 LocalSID behavior number.
Definition: as.h:59
vnet_interface_main_t interface_main
Definition: vnet.h:56
srv6_as_main_t srv6_as_main
Definition: as.h:71
#define AS_TYPE_IP6
Definition: as.h:28
#define NULL
Definition: clib.h:58
void srv6_as_dpo_lock(dpo_id_t *dpo)
Definition: as.c:494
u32 * sw_iface_localsid2
Retrieve local SID from iface.
Definition: as.h:61
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:525
Combined counter to hold both packets and byte differences.
Definition: counter_types.h:26
dpo_type_t srv6_as_dpo_type
DPO type.
Definition: as.h:57
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define IPv6_DEFAULT_HEADER_LENGTH
Definition: sr.h:33
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
unformat_function_t unformat_vnet_sw_interface
#define ROUTING_HEADER_TYPE_SR
Definition: sr_packet.h:116
static clib_error_t * srv6_as_init(vlib_main_t *vm)
Definition: as.c:520
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
vhost_vring_addr_t addr
Definition: vhost_user.h:121
ip6_address_t src_address
Definition: ip6_packet.h:378
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
u8 * format_srv6_as_localsid(u8 *s, va_list *args)
Definition: as.c:330
static int srv6_as_localsid_removal_fn(ip6_sr_localsid_t *localsid)
Definition: as.c:264
void srv6_as_dpo_unlock(dpo_id_t *dpo)
Definition: as.c:499
format_function_t format_ip4_address
Definition: format.h:75
unformat_function_t unformat_ip4_address
Definition: format.h:70
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u8 inner_type
Definition: as.h:39
#define clib_error_return(e, args...)
Definition: error.h:99
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:318
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:242
#define AS_TYPE_IP4
Definition: as.h:27
srv6_as_localsid_t ** sids
Pool of AS SID pointers.
Definition: as.h:65
unsigned int u32
Definition: types.h:88
#define PARAM_AS_SRC
uword unformat_srv6_as_localsid(unformat_input_t *input, va_list *args)
Definition: as.c:387
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
Definition: dpo.c:341
static u8 * format_srv6_as_dpo(u8 *s, va_list *args)
Definition: as.c:485
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:168
u32 nh_adj
Adjacency index for out.
Definition: as.h:38
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
Definition: adj_types.h:36
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:511
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
Definition: counter.h:285
counter_t packets
packet counter
Definition: counter_types.h:28
static const char *const *const srv6_as_nodes[DPO_PROTO_NUM]
Definition: as.c:514
struct _unformat_input_t unformat_input_t
VLIB_PLUGIN_REGISTER()
vnet_main_t * vnet_main
[convenience] vnet main
Definition: as.h:55
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
ip6_address_t * sid_list
SID list to be restored.
Definition: as.h:44
unsigned char params_str[]
Definition: as.c:36
unformat_function_t unformat_ip6_address
Definition: format.h:91
ip6_sr_localsid_t * localsids
Definition: sr.h:204
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
static void free_ls_mem(srv6_as_localsid_t *ls_mem)
Definition: as.c:102
u8 * rewrite
Headers to be rewritten.
Definition: as.h:42
format_function_t format_ip6_address
Definition: format.h:93
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
Definition: counter.h:259
vlib_main_t * vm
Definition: buffer.c:301
static const char *const srv6_as_ip6_nodes[]
Definition: as.c:509
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
unsigned char keyword_str[]
Definition: as.c:33
ip6_address_t src_addr
Source address to be restored.
Definition: as.h:43
unsigned char def_str[]
Definition: as.c:34
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:174
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:283
#define SID_CREATE_IFACE_FEATURE_ERROR
Definition: as.c:27
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
u32 sw_if_index_out
Outgoing iface to proxied dev.
Definition: as.h:37
void * plugin_mem
Memory to be used by the plugin callback functions.
Definition: sr.h:124
vlib_combined_counter_main_t invalid_counters
Invalid rewrite counters.
Definition: as.h:68
u32 sw_if_index_in
Incoming iface from proxied dev.
Definition: as.h:41
static void clib_mem_free(void *p)
Definition: mem.h:205
#define SID_CREATE_INVALID_IFACE_TYPE
Definition: as.c:28
#define AS_TYPE_L2
Definition: as.h:26
#define VNET_FEATURES(...)
Definition: feature.h:435
ip46_address_t nh_addr
Proxied device address.
Definition: as.h:36
counter_t bytes
byte counter
Definition: counter_types.h:29
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:365
#define SID_CREATE_INVALID_IFACE_INDEX
Definition: as.c:29
VNET_FEATURE_INIT(srv6_as2_rewrite, static)
#define DPO_PROTO_NUM
Definition: dpo.h:70
u16 payload_length
Definition: ip6_packet.h:369
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip6_address_t segments[0]
Definition: sr_packet.h:148
u64 uword
Definition: types.h:112
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:830
vlib_main_t * vlib_main
[convenience] vlib main
Definition: as.h:54
u32 * sw_iface_localsid6
Retrieve local SID from iface.
Definition: as.h:63
vlib_combined_counter_main_t valid_counters
Valid rewrite counters.
Definition: as.h:67
Segment Routing main datastructure.
Definition: sr.h:189
vnet_sw_interface_type_t type
Definition: interface.h:704
int sr_localsid_register_function(vlib_main_t *vm, u8 *fn_name, u8 *keyword_str, u8 *def_str, u8 *params_str, dpo_type_t *dpo, format_function_t *ls_format, unformat_function_t *ls_unformat, sr_plugin_callback_t *creation_fn, sr_plugin_callback_t *removal_fn)
SR LocalSID plugin registry.
Definition: sr_localsid.c:1525
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
Definition: adj_nbr.c:218
#define vec_foreach(var, vec)
Vector iterator.
#define IPv6_DEFAULT_HOP_LIMIT
Definition: sr.h:34
#define SID_CREATE_INVALID_ADJ_INDEX
Definition: as.c:30
#define PARAM_AS_NH
static int srv6_as_localsid_creation_fn(ip6_sr_localsid_t *localsid)
Definition: as.c:113
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:274
ip6_address_t dst_address
Definition: ip6_packet.h:378
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:371