FD.io VPP  v21.01.1
Vector Packet Processing
node.c
Go to the documentation of this file.
1 /*
2  * node.c
3  *
4  * Copyright (c) 2015 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 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vppinfra/error.h>
21 #include <srv6-ad/ad.h>
22 
23 
24 /******************************* Packet tracing *******************************/
25 
26 typedef struct
27 {
30 
31 typedef struct
32 {
34  ip6_address_t src, dst;
36 
37 static u8 *
38 format_srv6_ad_localsid_trace (u8 * s, va_list * args)
39 {
40  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
41  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
43 
44  return format (s, "SRv6-AD-localsid: localsid_index %d", t->localsid_index);
45 }
46 
47 static u8 *
48 format_srv6_ad_rewrite_trace (u8 * s, va_list * args)
49 {
50  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
51  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
52  srv6_ad_rewrite_trace_t *t = va_arg (*args, srv6_ad_rewrite_trace_t *);
53 
54  if (PREDICT_FALSE (t->error != 0))
55  {
56  return format (s, "SRv6-AD-rewrite: cache is empty");
57  }
58 
59  return format (s, "SRv6-AD-rewrite: src %U dst %U",
61 }
62 
63 
64 /***************************** Nodes registration *****************************/
65 
68 
69 
70 /****************************** Packet counters *******************************/
71 
72 #define foreach_srv6_ad_rewrite_counter \
73 _(PROCESSED, "srv6-ad rewritten packets") \
74 _(NO_RW, "(Error) No header for rewriting.")
75 
76 typedef enum
77 {
78 #define _(sym,str) SRV6_AD_REWRITE_COUNTER_##sym,
80 #undef _
83 
85 #define _(sym,string) string,
87 #undef _
88 };
89 
90 
91 /********************************* Next nodes *********************************/
92 
93 typedef enum
94 {
101 
102 typedef enum
103 {
108 
109 
110 /******************************* Local SID node *******************************/
111 
112 /**
113  * @brief Function doing SRH processing for AD behavior
114  */
117  ip6_header_t * ip0,
118  ip6_sr_header_t * sr0,
119  ip6_sr_localsid_t * ls0, u32 * next0)
120 {
121  ip6_address_t *new_dst0;
122  u16 total_size;
123  ip6_ext_header_t *next_ext_header;
124  u8 next_hdr;
125  srv6_ad_localsid_t *ls0_mem;
126 
127  if (PREDICT_FALSE (ip0->protocol != IP_PROTOCOL_IPV6_ROUTE ||
128  sr0->type != ROUTING_HEADER_TYPE_SR))
129  {
130  return;
131  }
132 
133  if (PREDICT_FALSE (sr0->segments_left == 0))
134  {
135  return;
136  }
137 
138  /* Decrement Segments Left and update Destination Address */
139  sr0->segments_left -= 1;
140  new_dst0 = (ip6_address_t *) (sr0->segments) + sr0->segments_left;
141  ip0->dst_address.as_u64[0] = new_dst0->as_u64[0];
142  ip0->dst_address.as_u64[1] = new_dst0->as_u64[1];
143 
144  /* Compute the total size of the IPv6 header and extensions */
145  total_size = sizeof (ip6_header_t);
146  next_ext_header = (ip6_ext_header_t *) (ip0 + 1);
147  next_hdr = ip0->protocol;
148 
149  while (ip6_ext_hdr (next_hdr))
150  {
151  total_size += ip6_ext_header_len (next_ext_header);
152  next_hdr = next_ext_header->next_hdr;
153  next_ext_header = ip6_ext_next_header (next_ext_header);
154  }
155 
156  /* Make sure next header is valid */
157  if (PREDICT_FALSE (next_hdr != IP_PROTOCOL_IPV6 &&
158  next_hdr != IP_PROTOCOL_IP_IN_IP &&
159  next_hdr != IP_PROTOCOL_IP6_ETHERNET))
160  {
161  return;
162  }
163 
164  /* Retrieve SID memory */
165  ls0_mem = ls0->plugin_mem;
166 
167  /* Cache IP header and extensions */
168  if (PREDICT_FALSE (total_size > ls0_mem->rw_len))
169  {
170  vec_validate (ls0_mem->rewrite, total_size - 1);
171  }
172  clib_memcpy_fast (ls0_mem->rewrite, ip0, total_size);
173  ls0_mem->rw_len = total_size;
174 
175  /* Remove IP header and extensions */
176  vlib_buffer_advance (b0, total_size);
177 
178  if (next_hdr == IP_PROTOCOL_IP6_ETHERNET)
179  {
180  /* Set output interface */
181  vnet_buffer (b0)->sw_if_index[VLIB_TX] = ls0_mem->sw_if_index_out;
182 
183  /* Set next node to interface-output */
185  }
186  else
187  {
188  /* Set Xconnect adjacency to VNF */
189  vnet_buffer (b0)->ip.adj_index[VLIB_TX] = ls0_mem->nh_adj;
190 
191  /* Set next node to ip-rewrite */
192  *next0 = (next_hdr == IP_PROTOCOL_IPV6) ?
194  }
195 }
196 
197 /**
198  * @brief SRv6 AD Localsid graph node
199  */
200 static uword
203 {
204  ip6_sr_main_t *sm = &sr_main;
205  u32 n_left_from, next_index, *from, *to_next;
206  u32 cnt_packets = 0;
207 
208  from = vlib_frame_vector_args (frame);
209  n_left_from = frame->n_vectors;
210  next_index = node->cached_next_index;
211 
212  while (n_left_from > 0)
213  {
214  u32 n_left_to_next;
215 
216  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
217 
218  /* TODO: Dual/quad loop */
219 
220  while (n_left_from > 0 && n_left_to_next > 0)
221  {
222  u32 bi0;
223  vlib_buffer_t *b0;
224  ip6_header_t *ip0 = 0;
225  ip6_sr_header_t *sr0;
226  ip6_sr_localsid_t *ls0;
228 
229  bi0 = from[0];
230  to_next[0] = bi0;
231  from += 1;
232  to_next += 1;
233  n_left_from -= 1;
234  n_left_to_next -= 1;
235 
236  b0 = vlib_get_buffer (vm, bi0);
237  ip0 = vlib_buffer_get_current (b0);
238  sr0 = (ip6_sr_header_t *) (ip0 + 1);
239 
240  /* Lookup the SR End behavior based on IP DA (adj) */
241  ls0 = pool_elt_at_index (sm->localsids,
242  vnet_buffer (b0)->ip.adj_index[VLIB_TX]);
243 
244  /* SRH processing */
245  end_ad_processing (b0, ip0, sr0, ls0, &next0);
246 
247  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
248  {
250  vlib_add_trace (vm, node, b0, sizeof *tr);
251  tr->localsid_index = ls0 - sm->localsids;
252  }
253 
254  /* This increments the SRv6 per LocalSID counters. */
257  &(sm->sr_ls_invalid_counters) :
258  &(sm->sr_ls_valid_counters)),
259  vm->thread_index,
260  ls0 - sm->localsids, 1,
262  b0));
263 
264  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
265  n_left_to_next, bi0, next0);
266 
267  cnt_packets++;
268  }
269 
270  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
271  }
272 
273  return frame->n_vectors;
274 }
275 
276 /* *INDENT-OFF* */
278  .function = srv6_ad_localsid_fn,
279  .name = "srv6-ad-localsid",
280  .vector_size = sizeof (u32),
281  .format_trace = format_srv6_ad_localsid_trace,
283  .n_next_nodes = SRV6_AD_LOCALSID_N_NEXT,
284  .next_nodes = {
285  [SRV6_AD_LOCALSID_NEXT_REWRITE4] = "ip4-rewrite",
286  [SRV6_AD_LOCALSID_NEXT_REWRITE6] = "ip6-rewrite",
287  [SRV6_AD_LOCALSID_NEXT_INTERFACE] = "interface-output",
288  [SRV6_AD_LOCALSID_NEXT_ERROR] = "error-drop",
289  },
290 };
291 /* *INDENT-ON* */
292 
293 
294 /******************************* Rewriting node *******************************/
295 
296 /**
297  * @brief Graph node for applying a SR policy into an IPv6 packet. Encapsulation
298  */
299 static uword
302 {
303  ip6_sr_main_t *srm = &sr_main;
305  u32 n_left_from, next_index, *from, *to_next;
306  u32 cnt_packets = 0;
307 
308  from = vlib_frame_vector_args (frame);
309  n_left_from = frame->n_vectors;
310  next_index = node->cached_next_index;
311 
312  while (n_left_from > 0)
313  {
314  u32 n_left_to_next;
315 
316  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
317 
318  /* TODO: Dual/quad loop */
319 
320  while (n_left_from > 0 && n_left_to_next > 0)
321  {
322  u32 bi0;
323  vlib_buffer_t *b0;
324  ethernet_header_t *en0;
325  ip6_header_t *ip0 = 0;
326  ip6_sr_localsid_t *ls0;
327  srv6_ad_localsid_t *ls0_mem;
329 
330  bi0 = from[0];
331  to_next[0] = bi0;
332  from += 1;
333  to_next += 1;
334  n_left_from -= 1;
335  n_left_to_next -= 1;
336 
337  b0 = vlib_get_buffer (vm, bi0);
338  en0 = vlib_buffer_get_current (b0);
339  ls0 = pool_elt_at_index (srm->localsids,
341  (b0)->sw_if_index
342  [VLIB_RX]]);
343  ls0_mem = ls0->plugin_mem;
344 
345  if (PREDICT_FALSE (ls0_mem == NULL || ls0_mem->rewrite == NULL))
346  {
348  b0->error = node->errors[SRV6_AD_REWRITE_COUNTER_NO_RW];
349  }
350  else
351  {
353  (ls0_mem->rw_len + b0->current_data));
354 
355  clib_memcpy_fast (((u8 *) en0) - ls0_mem->rw_len,
356  ls0_mem->rewrite, ls0_mem->rw_len);
357  vlib_buffer_advance (b0, -(word) ls0_mem->rw_len);
358 
359  ip0 = vlib_buffer_get_current (b0);
360 
361  ip0->payload_length =
362  clib_host_to_net_u16 (b0->current_length -
363  sizeof (ip6_header_t));
364  }
365 
366  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
367  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
368  {
370  vlib_add_trace (vm, node, b0, sizeof *tr);
371  tr->error = 0;
372 
373  if (next0 == SRV6_AD_REWRITE_NEXT_ERROR)
374  {
375  tr->error = 1;
376  }
377  else
378  {
379  clib_memcpy_fast (tr->src.as_u8, ip0->src_address.as_u8,
380  sizeof tr->src.as_u8);
381  clib_memcpy_fast (tr->dst.as_u8, ip0->dst_address.as_u8,
382  sizeof tr->dst.as_u8);
383  }
384  }
385 
386  /* Increment per-SID AD rewrite counters */
389  &(sm->invalid_counters) :
390  &(sm->valid_counters)),
391  vm->thread_index, ls0_mem->index,
393  b0));
394 
395  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
396  n_left_to_next, bi0, next0);
397 
398  cnt_packets++;
399  }
400 
401  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
402  }
403 
404  /* Update counters */
406  SRV6_AD_REWRITE_COUNTER_PROCESSED,
407  cnt_packets);
408 
409  return frame->n_vectors;
410 }
411 
412 /* *INDENT-OFF* */
414  .function = srv6_ad2_rewrite_fn,
415  .name = "srv6-ad2-rewrite",
416  .vector_size = sizeof (u32),
417  .format_trace = format_srv6_ad_rewrite_trace,
419  .n_errors = SRV6_AD_REWRITE_N_COUNTERS,
420  .error_strings = srv6_ad_rewrite_counter_strings,
421  .n_next_nodes = SRV6_AD_REWRITE_N_NEXT,
422  .next_nodes = {
423  [SRV6_AD_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
424  [SRV6_AD_REWRITE_NEXT_ERROR] = "error-drop",
425  },
426 };
427 /* *INDENT-ON* */
428 
429 
430 /**
431  * @brief Graph node for applying a SR policy into an IPv6 packet. Encapsulation
432  */
433 static uword
436 {
437  ip6_sr_main_t *srm = &sr_main;
439  u32 n_left_from, next_index, *from, *to_next;
440  u32 cnt_packets = 0;
441 
442  from = vlib_frame_vector_args (frame);
443  n_left_from = frame->n_vectors;
444  next_index = node->cached_next_index;
445 
446  while (n_left_from > 0)
447  {
448  u32 n_left_to_next;
449 
450  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
451 
452  /* TODO: Dual/quad loop */
453 
454  while (n_left_from > 0 && n_left_to_next > 0)
455  {
456  u32 bi0;
457  vlib_buffer_t *b0;
458  ip4_header_t *ip0_encap = 0;
459  ip6_header_t *ip0 = 0;
460  ip6_sr_localsid_t *ls0;
461  srv6_ad_localsid_t *ls0_mem;
463  u16 new_l0 = 0;
464 
465  bi0 = from[0];
466  to_next[0] = bi0;
467  from += 1;
468  to_next += 1;
469  n_left_from -= 1;
470  n_left_to_next -= 1;
471 
472  b0 = vlib_get_buffer (vm, bi0);
473  ip0_encap = vlib_buffer_get_current (b0);
474  ls0 = pool_elt_at_index (srm->localsids,
476  (b0)->sw_if_index
477  [VLIB_RX]]);
478  ls0_mem = ls0->plugin_mem;
479 
480  if (PREDICT_FALSE (ls0_mem == NULL || ls0_mem->rewrite == NULL))
481  {
483  b0->error = node->errors[SRV6_AD_REWRITE_COUNTER_NO_RW];
484  }
485  else
486  {
488  (ls0_mem->rw_len + b0->current_data));
489 
490  clib_memcpy_fast (((u8 *) ip0_encap) - ls0_mem->rw_len,
491  ls0_mem->rewrite, ls0_mem->rw_len);
492  vlib_buffer_advance (b0, -(word) ls0_mem->rw_len);
493 
494  ip0 = vlib_buffer_get_current (b0);
495 
496  /* Update inner IPv4 TTL and checksum */
497  u32 checksum0;
498  ip0_encap->ttl -= 1;
499  checksum0 = ip0_encap->checksum + clib_host_to_net_u16 (0x0100);
500  checksum0 += checksum0 >= 0xffff;
501  ip0_encap->checksum = checksum0;
502 
503  /* Update outer IPv6 length (in case it has changed) */
504  new_l0 = ls0_mem->rw_len - sizeof (ip6_header_t) +
505  clib_net_to_host_u16 (ip0_encap->length);
506  ip0->payload_length = clib_host_to_net_u16 (new_l0);
507  }
508 
509  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
510  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
511  {
513  vlib_add_trace (vm, node, b0, sizeof *tr);
514  tr->error = 0;
515 
516  if (next0 == SRV6_AD_REWRITE_NEXT_ERROR)
517  {
518  tr->error = 1;
519  }
520  else
521  {
522  clib_memcpy_fast (tr->src.as_u8, ip0->src_address.as_u8,
523  sizeof tr->src.as_u8);
524  clib_memcpy_fast (tr->dst.as_u8, ip0->dst_address.as_u8,
525  sizeof tr->dst.as_u8);
526  }
527  }
528 
529  /* Increment per-SID AD rewrite counters */
532  &(sm->invalid_counters) :
533  &(sm->valid_counters)),
534  vm->thread_index, ls0_mem->index,
536  b0));
537 
538  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
539  n_left_to_next, bi0, next0);
540 
541  cnt_packets++;
542  }
543 
544  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
545  }
546 
547  /* Update counters */
549  SRV6_AD_REWRITE_COUNTER_PROCESSED,
550  cnt_packets);
551 
552  return frame->n_vectors;
553 }
554 
555 /* *INDENT-OFF* */
557  .function = srv6_ad4_rewrite_fn,
558  .name = "srv6-ad4-rewrite",
559  .vector_size = sizeof (u32),
560  .format_trace = format_srv6_ad_rewrite_trace,
562  .n_errors = SRV6_AD_REWRITE_N_COUNTERS,
563  .error_strings = srv6_ad_rewrite_counter_strings,
564  .n_next_nodes = SRV6_AD_REWRITE_N_NEXT,
565  .next_nodes = {
566  [SRV6_AD_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
567  [SRV6_AD_REWRITE_NEXT_ERROR] = "error-drop",
568  },
569 };
570 /* *INDENT-ON* */
571 
572 
573 /**
574  * @brief Graph node for applying a SR policy into an IPv6 packet. Encapsulation
575  */
576 static uword
579 {
580  ip6_sr_main_t *srm = &sr_main;
582  u32 n_left_from, next_index, *from, *to_next;
583  u32 cnt_packets = 0;
584 
585  from = vlib_frame_vector_args (frame);
586  n_left_from = frame->n_vectors;
587  next_index = node->cached_next_index;
588 
589  while (n_left_from > 0)
590  {
591  u32 n_left_to_next;
592 
593  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
594 
595  /* TODO: Dual/quad loop */
596 
597  while (n_left_from > 0 && n_left_to_next > 0)
598  {
599  u32 bi0;
600  vlib_buffer_t *b0;
601  ip6_header_t *ip0 = 0, *ip0_encap = 0;
602  ip6_sr_localsid_t *ls0;
603  srv6_ad_localsid_t *ls0_mem;
605  u16 new_l0 = 0;
606 
607  bi0 = from[0];
608  to_next[0] = bi0;
609  from += 1;
610  to_next += 1;
611  n_left_from -= 1;
612  n_left_to_next -= 1;
613 
614  b0 = vlib_get_buffer (vm, bi0);
615  ip0_encap = vlib_buffer_get_current (b0);
616  ls0 = pool_elt_at_index (srm->localsids,
618  (b0)->sw_if_index
619  [VLIB_RX]]);
620  ls0_mem = ls0->plugin_mem;
621 
622  if (PREDICT_FALSE (ls0_mem == NULL || ls0_mem->rewrite == NULL))
623  {
625  b0->error = node->errors[SRV6_AD_REWRITE_COUNTER_NO_RW];
626  }
627  else
628  {
630  (ls0_mem->rw_len + b0->current_data));
631 
632  clib_memcpy_fast (((u8 *) ip0_encap) - ls0_mem->rw_len,
633  ls0_mem->rewrite, ls0_mem->rw_len);
634  vlib_buffer_advance (b0, -(word) ls0_mem->rw_len);
635 
636  ip0 = vlib_buffer_get_current (b0);
637 
638  /* Update inner IPv6 hop limit */
639  ip0_encap->hop_limit -= 1;
640 
641  /* Update outer IPv6 length (in case it has changed) */
642  new_l0 = ls0_mem->rw_len +
643  clib_net_to_host_u16 (ip0_encap->payload_length);
644  ip0->payload_length = clib_host_to_net_u16 (new_l0);
645  }
646 
647  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
648  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
649  {
651  vlib_add_trace (vm, node, b0, sizeof *tr);
652  tr->error = 0;
653 
654  if (next0 == SRV6_AD_REWRITE_NEXT_ERROR)
655  {
656  tr->error = 1;
657  }
658  else
659  {
660  clib_memcpy_fast (tr->src.as_u8, ip0->src_address.as_u8,
661  sizeof tr->src.as_u8);
662  clib_memcpy_fast (tr->dst.as_u8, ip0->dst_address.as_u8,
663  sizeof tr->dst.as_u8);
664  }
665  }
666 
667  /* Increment per-SID AD rewrite counters */
670  &(sm->invalid_counters) :
671  &(sm->valid_counters)),
672  vm->thread_index, ls0_mem->index,
674  b0));
675 
676  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
677  n_left_to_next, bi0, next0);
678 
679  cnt_packets++;
680  }
681 
682  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
683  }
684 
685  /* Update counters */
687  SRV6_AD_REWRITE_COUNTER_PROCESSED,
688  cnt_packets);
689 
690  return frame->n_vectors;
691 }
692 
693 /* *INDENT-OFF* */
695  .function = srv6_ad6_rewrite_fn,
696  .name = "srv6-ad6-rewrite",
697  .vector_size = sizeof (u32),
698  .format_trace = format_srv6_ad_rewrite_trace,
700  .n_errors = SRV6_AD_REWRITE_N_COUNTERS,
701  .error_strings = srv6_ad_rewrite_counter_strings,
702  .n_next_nodes = SRV6_AD_REWRITE_N_NEXT,
703  .next_nodes = {
704  [SRV6_AD_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
705  [SRV6_AD_REWRITE_NEXT_ERROR] = "error-drop",
706  },
707 };
708 /* *INDENT-ON* */
709 
710 /*
711  * fd.io coding-style-patch-verification: ON
712  *
713  * Local Variables:
714  * eval: (c-set-style "gnu")
715  * End:
716 */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:124
ip6_sr_main_t sr_main
Definition: sr.c:31
#define CLIB_UNUSED(x)
Definition: clib.h:87
vlib_node_registration_t srv6_ad2_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_ad2_rewrite_node)
Definition: node.c:413
#define IP_PROTOCOL_IP6_ETHERNET
Definition: mobile.h:37
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
Definition: counter.h:239
SR LocalSID.
Definition: sr.h:120
srv6_ad_rewrite_next_t
Definition: node.c:102
srv6_ad_rewrite_counters
Definition: node.c:76
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:110
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
u32 * sw_iface_localsid4
Retrieve local SID from iface.
Definition: ad.h:60
static u8 * format_srv6_ad_localsid_trace(u8 *s, va_list *args)
Definition: node.c:38
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:51
u32 thread_index
Definition: main.h:250
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
static uword srv6_ad2_rewrite_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Graph node for applying a SR policy into an IPv6 packet.
Definition: node.c:300
static void * ip6_ext_next_header(ip6_ext_header_t *ext_hdr)
Definition: ip6_packet.h:518
vlib_main_t * vm
Definition: in2out_ed.c:1580
#define ROUTING_HEADER_TYPE_SR
Definition: sr_packet.h:117
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:470
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:402
vlib_combined_counter_main_t sr_ls_invalid_counters
Definition: sr.h:301
vlib_combined_counter_main_t sr_ls_valid_counters
Definition: sr.h:300
ip6_address_t src_address
Definition: ip6_packet.h:310
unsigned char u8
Definition: types.h:56
vlib_node_registration_t srv6_ad4_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_ad4_rewrite_node)
Definition: node.c:66
#define static_always_inline
Definition: clib.h:109
i64 word
Definition: types.h:111
vlib_combined_counter_main_t invalid_counters
Invalid rewrite counters.
Definition: ad.h:66
vlib_node_registration_t srv6_ad6_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_ad6_rewrite_node)
Definition: node.c:67
description fragment has unexpected format
Definition: map.api:433
unsigned int u32
Definition: types.h:88
u32 nh_adj
Adjacency index for out.
Definition: ad.h:38
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:136
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:546
vlib_node_registration_t srv6_ad_localsid_node
(constructor) VLIB_REGISTER_NODE (srv6_ad_localsid_node)
Definition: node.c:277
u32 sw_if_index_out
Outgoing iface to proxied dev.
Definition: ad.h:37
unsigned short u16
Definition: types.h:57
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:233
u32 rw_len
Number of bits to be rewritten.
Definition: ad.h:42
static uword srv6_ad4_rewrite_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Graph node for applying a SR policy into an IPv6 packet.
Definition: node.c:434
#define PREDICT_FALSE(x)
Definition: clib.h:121
u8 * rewrite
Headers to be rewritten.
Definition: ad.h:43
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:224
vl_api_address_t dst
Definition: gre.api:55
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:391
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1231
static char * srv6_ad_rewrite_counter_strings[]
Definition: node.c:84
#define ip6_ext_header_len(p)
Definition: ip6_packet.h:514
ip6_sr_localsid_t * localsids
Definition: sr.h:270
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:170
u16 n_vectors
Definition: node.h:397
format_function_t format_ip6_address
Definition: format.h:91
static uword srv6_ad6_rewrite_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Graph node for applying a SR policy into an IPv6 packet.
Definition: node.c:577
static_always_inline void end_ad_processing(vlib_buffer_t *b0, ip6_header_t *ip0, ip6_sr_header_t *sr0, ip6_sr_localsid_t *ls0, u32 *next0)
Function doing SRH processing for AD behavior.
Definition: node.c:116
ip6_address_t src
Definition: node.c:34
static u8 * format_srv6_ad_rewrite_trace(u8 *s, va_list *args)
Definition: node.c:48
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:483
static u8 ip6_ext_hdr(u8 nexthdr)
Definition: ip6_packet.h:493
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1580
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:511
#define ASSERT(truth)
ip6_address_t dst
Definition: node.c:34
void * plugin_mem
Memory to be used by the plugin callback functions.
Definition: sr.h:153
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:252
static uword srv6_ad_localsid_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
SRv6 AD Localsid graph node.
Definition: node.c:201
u32 * sw_iface_localsid2
Retrieve local SID from iface.
Definition: ad.h:59
struct _vlib_node_registration vlib_node_registration_t
#define foreach_srv6_ad_rewrite_counter
Definition: node.c:72
Definition: defs.h:47
vlib_combined_counter_main_t valid_counters
Valid rewrite counters.
Definition: ad.h:65
u32 * sw_iface_localsid6
Retrieve local SID from iface.
Definition: ad.h:61
u16 payload_length
Definition: ip6_packet.h:301
vl_api_address_t ip
Definition: l2.api:501
ip6_address_t segments[0]
Definition: sr_packet.h:149
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: in2out_ed.c:1581
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:297
srv6_ad_localsid_next_t
Definition: node.c:93
#define vnet_buffer(b)
Definition: buffer.h:417
Segment Routing main datastructure.
Definition: sr.h:255
u16 flags
Copy of main node flags.
Definition: node.h:501
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:634
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:302
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:85
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
Definition: defs.h:46
ip6_address_t dst_address
Definition: ip6_packet.h:310