FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
node.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 #include <vlib/vlib.h>
16 #include <vnet/vnet.h>
17 #include <vppinfra/error.h>
18 #include <srv6-as/as.h>
19 
20 
21 /******************************* Packet tracing *******************************/
22 
23 typedef struct
24 {
27 
28 typedef struct
29 {
33 
34 static u8 *
35 format_srv6_as_localsid_trace (u8 * s, va_list * args)
36 {
37  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
38  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
40 
41  return format (s, "SRv6-AS-localsid: localsid_index %d", t->localsid_index);
42 }
43 
44 static u8 *
45 format_srv6_as_rewrite_trace (u8 * s, va_list * args)
46 {
47  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
48  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
49  srv6_as_rewrite_trace_t *t = va_arg (*args, srv6_as_rewrite_trace_t *);
50 
51  if (PREDICT_FALSE (t->error != 0))
52  {
53  return format (s, "SRv6-AS-rewrite: cache is empty");
54  }
55 
56  return format (s, "SRv6-AS-rewrite: src %U dst %U",
58 }
59 
60 
61 /***************************** Nodes registration *****************************/
62 
65 
66 
67 /****************************** Packet counters *******************************/
68 
69 #define foreach_srv6_as_rewrite_counter \
70 _(PROCESSED, "srv6-as rewritten packets") \
71 _(NO_RW, "(Error) No header for rewriting.")
72 
73 typedef enum
74 {
75 #define _(sym,str) SRV6_AS_REWRITE_COUNTER_##sym,
77 #undef _
80 
82 #define _(sym,string) string,
84 #undef _
85 };
86 
87 
88 /********************************* Next nodes *********************************/
89 
90 typedef enum
91 {
98 
99 typedef enum
100 {
105 
106 
107 /******************************* Local SID node *******************************/
108 
109 /**
110  * @brief Function doing SRH processing for AS behavior
111  */
114  ip6_header_t * ip0,
115  srv6_as_localsid_t * ls0_mem, u32 * next0)
116 {
117  u16 encap_len;
118  ip6_ext_header_t *ext_hdr;
119  u8 hdr_type;
120 
121  /* Compute encapsulation headers length */
122  encap_len = sizeof (ip6_header_t);
123  ext_hdr = (ip6_ext_header_t *) (ip0 + 1);
124  hdr_type = ip0->protocol;
125 
126  while (ip6_ext_hdr (hdr_type))
127  {
128  encap_len += ip6_ext_header_len (ext_hdr);
129  hdr_type = ext_hdr->next_hdr;
130  ext_hdr = ip6_ext_next_header (ext_hdr);
131  }
132 
133  /* Make sure next header is valid */
134  if (PREDICT_FALSE (hdr_type != IP_PROTOCOL_IPV6 &&
135  hdr_type != IP_PROTOCOL_IP_IN_IP &&
136  hdr_type != IP_PROTOCOL_IP6_NONXT))
137  {
138  return;
139  }
140 
141  /* Remove IP header and extensions */
142  vlib_buffer_advance (b0, encap_len);
143 
144  if (hdr_type == IP_PROTOCOL_IP6_NONXT)
145  {
146  /* Set output interface */
147  vnet_buffer (b0)->sw_if_index[VLIB_TX] = ls0_mem->sw_if_index_out;
148 
149  /* Set next node to interface-output */
151  }
152  else
153  {
154  /* Set Xconnect adjacency to VNF */
155  vnet_buffer (b0)->ip.adj_index[VLIB_TX] = ls0_mem->nh_adj;
156 
157  /* Set next node to ip-rewrite */
158  *next0 = (hdr_type == IP_PROTOCOL_IPV6) ?
160  }
161 }
162 
163 /**
164  * @brief SRv6 AS Localsid graph node
165  */
166 static uword
168  vlib_node_runtime_t * node, vlib_frame_t * frame)
169 {
170  ip6_sr_main_t *sm = &sr_main;
171  u32 n_left_from, next_index, *from, *to_next;
172  u32 cnt_packets = 0;
173 
174  from = vlib_frame_vector_args (frame);
175  n_left_from = frame->n_vectors;
176  next_index = node->cached_next_index;
177 
178  while (n_left_from > 0)
179  {
180  u32 n_left_to_next;
181 
182  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
183 
184  /* TODO: Dual/quad loop */
185 
186  while (n_left_from > 0 && n_left_to_next > 0)
187  {
188  u32 bi0;
189  vlib_buffer_t *b0;
190  ip6_header_t *ip0 = 0;
191  ip6_sr_localsid_t *ls0;
193 
194  bi0 = from[0];
195  to_next[0] = bi0;
196  from += 1;
197  to_next += 1;
198  n_left_from -= 1;
199  n_left_to_next -= 1;
200 
201  b0 = vlib_get_buffer (vm, bi0);
202  ip0 = vlib_buffer_get_current (b0);
203 
204  /* Lookup the SR End behavior based on IP DA (adj) */
205  ls0 = pool_elt_at_index (sm->localsids,
206  vnet_buffer (b0)->ip.adj_index[VLIB_TX]);
207 
208  /* SRH processing */
209  end_as_processing (b0, ip0, ls0->plugin_mem, &next0);
210 
211  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
212  {
214  vlib_add_trace (vm, node, b0, sizeof *tr);
215  tr->localsid_index = ls0 - sm->localsids;
216  }
217 
218  /* This increments the SRv6 per LocalSID counters. */
221  &(sm->sr_ls_invalid_counters) :
222  &(sm->sr_ls_valid_counters)),
223  vm->thread_index,
224  ls0 - sm->localsids, 1,
226  b0));
227 
228  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
229  n_left_to_next, bi0, next0);
230 
231  cnt_packets++;
232  }
233 
234  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
235  }
236 
237  return frame->n_vectors;
238 }
239 
240 /* *INDENT-OFF* */
242  .function = srv6_as_localsid_fn,
243  .name = "srv6-as-localsid",
244  .vector_size = sizeof (u32),
245  .format_trace = format_srv6_as_localsid_trace,
246  .type = VLIB_NODE_TYPE_INTERNAL,
247  .n_next_nodes = SRV6_AS_LOCALSID_N_NEXT,
248  .next_nodes = {
249  [SRV6_AS_LOCALSID_NEXT_REWRITE4] = "ip4-rewrite",
250  [SRV6_AS_LOCALSID_NEXT_REWRITE6] = "ip6-rewrite",
251  [SRV6_AS_LOCALSID_NEXT_INTERFACE] = "interface-output",
252  [SRV6_AS_LOCALSID_NEXT_ERROR] = "error-drop",
253  },
254 };
255 /* *INDENT-ON* */
256 
257 
258 /******************************* Rewriting node *******************************/
259 
260 /**
261  * @brief Graph node for applying a SR policy into an IPv6 packet. Encapsulation
262  */
263 static uword
265  vlib_node_runtime_t * node, vlib_frame_t * frame)
266 {
267  ip6_sr_main_t *srm = &sr_main;
269  u32 n_left_from, next_index, *from, *to_next;
270  u32 cnt_packets = 0;
271 
272  from = vlib_frame_vector_args (frame);
273  n_left_from = frame->n_vectors;
274  next_index = node->cached_next_index;
275 
276  while (n_left_from > 0)
277  {
278  u32 n_left_to_next;
279 
280  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
281 
282  /* TODO: Dual/quad loop */
283 
284  while (n_left_from > 0 && n_left_to_next > 0)
285  {
286  u32 bi0;
287  vlib_buffer_t *b0;
288  ethernet_header_t *en0;
289  ip6_header_t *ip0 = 0;
290  ip6_sr_localsid_t *ls0;
291  srv6_as_localsid_t *ls0_mem;
293 
294  bi0 = from[0];
295  to_next[0] = bi0;
296  from += 1;
297  to_next += 1;
298  n_left_from -= 1;
299  n_left_to_next -= 1;
300 
301  b0 = vlib_get_buffer (vm, bi0);
302  en0 = vlib_buffer_get_current (b0);
303  ls0 = pool_elt_at_index (srm->localsids,
305  (b0)->sw_if_index
306  [VLIB_RX]]);
307  ls0_mem = ls0->plugin_mem;
308 
309  if (PREDICT_FALSE (ls0_mem == NULL || ls0_mem->rewrite == NULL))
310  {
312  b0->error = node->errors[SRV6_AS_REWRITE_COUNTER_NO_RW];
313  }
314  else
315  {
317  (vec_len (ls0_mem->rewrite) + b0->current_data));
318 
319  clib_memcpy_fast (((u8 *) en0) - vec_len (ls0_mem->rewrite),
320  ls0_mem->rewrite, vec_len (ls0_mem->rewrite));
321  vlib_buffer_advance (b0, -(word) vec_len (ls0_mem->rewrite));
322 
323  ip0 = vlib_buffer_get_current (b0);
324 
325  ip0->payload_length =
326  clib_host_to_net_u16 (b0->current_length -
327  sizeof (ip6_header_t));
328  }
329 
330  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
331  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
332  {
334  vlib_add_trace (vm, node, b0, sizeof *tr);
335  tr->error = 0;
336 
337  if (next0 == SRV6_AS_REWRITE_NEXT_ERROR)
338  {
339  tr->error = 1;
340  }
341  else
342  {
344  sizeof tr->src.as_u8);
346  sizeof tr->dst.as_u8);
347  }
348  }
349 
350  /* Increment per-SID AS rewrite counters */
353  &(sm->invalid_counters) :
354  &(sm->valid_counters)),
355  vm->thread_index, ls0_mem->index,
357  b0));
358 
359  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
360  n_left_to_next, bi0, next0);
361 
362  cnt_packets++;
363  }
364 
365  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
366  }
367 
368  /* Update counters */
370  SRV6_AS_REWRITE_COUNTER_PROCESSED,
371  cnt_packets);
372 
373  return frame->n_vectors;
374 }
375 
376 /* *INDENT-OFF* */
378  .function = srv6_as2_rewrite_fn,
379  .name = "srv6-as2-rewrite",
380  .vector_size = sizeof (u32),
381  .format_trace = format_srv6_as_rewrite_trace,
382  .type = VLIB_NODE_TYPE_INTERNAL,
383  .n_errors = SRV6_AS_REWRITE_N_COUNTERS,
384  .error_strings = srv6_as_rewrite_counter_strings,
385  .n_next_nodes = SRV6_AS_REWRITE_N_NEXT,
386  .next_nodes = {
387  [SRV6_AS_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
388  [SRV6_AS_REWRITE_NEXT_ERROR] = "error-drop",
389  },
390 };
391 /* *INDENT-ON* */
392 
393 
394 /**
395  * @brief Graph node for applying a SR policy into an IPv6 packet. Encapsulation
396  */
397 static uword
399  vlib_node_runtime_t * node, vlib_frame_t * frame)
400 {
401  ip6_sr_main_t *srm = &sr_main;
403  u32 n_left_from, next_index, *from, *to_next;
404  u32 cnt_packets = 0;
405 
406  from = vlib_frame_vector_args (frame);
407  n_left_from = frame->n_vectors;
408  next_index = node->cached_next_index;
409 
410  while (n_left_from > 0)
411  {
412  u32 n_left_to_next;
413 
414  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
415 
416  /* TODO: Dual/quad loop */
417 
418  while (n_left_from > 0 && n_left_to_next > 0)
419  {
420  u32 bi0;
421  vlib_buffer_t *b0;
422  ip4_header_t *ip0_encap = 0;
423  ip6_header_t *ip0 = 0;
424  ip6_sr_localsid_t *ls0;
425  srv6_as_localsid_t *ls0_mem;
427  u16 new_l0 = 0;
428 
429  bi0 = from[0];
430  to_next[0] = bi0;
431  from += 1;
432  to_next += 1;
433  n_left_from -= 1;
434  n_left_to_next -= 1;
435 
436  b0 = vlib_get_buffer (vm, bi0);
437  ip0_encap = vlib_buffer_get_current (b0);
438  ls0 = pool_elt_at_index (srm->localsids,
440  (b0)->sw_if_index
441  [VLIB_RX]]);
442  ls0_mem = ls0->plugin_mem;
443 
444  if (PREDICT_FALSE (ls0_mem == NULL || ls0_mem->rewrite == NULL))
445  {
447  b0->error = node->errors[SRV6_AS_REWRITE_COUNTER_NO_RW];
448  }
449  else
450  {
452  (vec_len (ls0_mem->rewrite) + b0->current_data));
453 
454  clib_memcpy_fast (((u8 *) ip0_encap) -
455  vec_len (ls0_mem->rewrite), ls0_mem->rewrite,
456  vec_len (ls0_mem->rewrite));
457  vlib_buffer_advance (b0, -(word) vec_len (ls0_mem->rewrite));
458 
459  ip0 = vlib_buffer_get_current (b0);
460 
461  /* Update inner IPv4 TTL and checksum */
462  u32 checksum0;
463  ip0_encap->ttl -= 1;
464  checksum0 = ip0_encap->checksum + clib_host_to_net_u16 (0x0100);
465  checksum0 += checksum0 >= 0xffff;
466  ip0_encap->checksum = checksum0;
467 
468  /* Update outer IPv6 length (in case it has changed) */
469  new_l0 = vec_len (ls0_mem->rewrite) - sizeof (ip6_header_t) +
470  clib_net_to_host_u16 (ip0_encap->length);
471  ip0->payload_length = clib_host_to_net_u16 (new_l0);
472  }
473 
474  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
475  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
476  {
478  vlib_add_trace (vm, node, b0, sizeof *tr);
479  tr->error = 0;
480 
481  if (next0 == SRV6_AS_REWRITE_NEXT_ERROR)
482  {
483  tr->error = 1;
484  }
485  else
486  {
488  sizeof tr->src.as_u8);
490  sizeof tr->dst.as_u8);
491  }
492  }
493 
494  /* Increment per-SID AS rewrite counters */
497  &(sm->invalid_counters) :
498  &(sm->valid_counters)),
499  vm->thread_index, ls0_mem->index,
501  b0));
502 
503  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
504  n_left_to_next, bi0, next0);
505 
506  cnt_packets++;
507  }
508 
509  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
510  }
511 
512  /* Update counters */
514  SRV6_AS_REWRITE_COUNTER_PROCESSED,
515  cnt_packets);
516 
517  return frame->n_vectors;
518 }
519 
520 /* *INDENT-OFF* */
522  .function = srv6_as4_rewrite_fn,
523  .name = "srv6-as4-rewrite",
524  .vector_size = sizeof (u32),
525  .format_trace = format_srv6_as_rewrite_trace,
526  .type = VLIB_NODE_TYPE_INTERNAL,
527  .n_errors = SRV6_AS_REWRITE_N_COUNTERS,
528  .error_strings = srv6_as_rewrite_counter_strings,
529  .n_next_nodes = SRV6_AS_REWRITE_N_NEXT,
530  .next_nodes = {
531  [SRV6_AS_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
532  [SRV6_AS_REWRITE_NEXT_ERROR] = "error-drop",
533  },
534 };
535 /* *INDENT-ON* */
536 
537 
538 /**
539  * @brief Graph node for applying a SR policy into an IPv6 packet. Encapsulation
540  */
541 static uword
543  vlib_node_runtime_t * node, vlib_frame_t * frame)
544 {
545  ip6_sr_main_t *srm = &sr_main;
547  u32 n_left_from, next_index, *from, *to_next;
548  u32 cnt_packets = 0;
549 
550  from = vlib_frame_vector_args (frame);
551  n_left_from = frame->n_vectors;
552  next_index = node->cached_next_index;
553 
554  while (n_left_from > 0)
555  {
556  u32 n_left_to_next;
557 
558  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
559 
560  /* TODO: Dual/quad loop */
561 
562  while (n_left_from > 0 && n_left_to_next > 0)
563  {
564  u32 bi0;
565  vlib_buffer_t *b0;
566  ip6_header_t *ip0 = 0, *ip0_encap = 0;
567  ip6_sr_localsid_t *ls0;
568  srv6_as_localsid_t *ls0_mem;
570  u16 new_l0 = 0;
571 
572  bi0 = from[0];
573  to_next[0] = bi0;
574  from += 1;
575  to_next += 1;
576  n_left_from -= 1;
577  n_left_to_next -= 1;
578 
579  b0 = vlib_get_buffer (vm, bi0);
580  ip0_encap = vlib_buffer_get_current (b0);
581  ls0 = pool_elt_at_index (srm->localsids,
583  (b0)->sw_if_index
584  [VLIB_RX]]);
585  ls0_mem = ls0->plugin_mem;
586 
587  if (PREDICT_FALSE (ls0_mem == NULL || ls0_mem->rewrite == NULL))
588  {
590  b0->error = node->errors[SRV6_AS_REWRITE_COUNTER_NO_RW];
591  }
592  else
593  {
595  (vec_len (ls0_mem->rewrite) + b0->current_data));
596 
597  clib_memcpy_fast (((u8 *) ip0_encap) -
598  vec_len (ls0_mem->rewrite), ls0_mem->rewrite,
599  vec_len (ls0_mem->rewrite));
600  vlib_buffer_advance (b0, -(word) vec_len (ls0_mem->rewrite));
601 
602  ip0 = vlib_buffer_get_current (b0);
603 
604  /* Update inner IPv6 hop limit */
605  ip0_encap->hop_limit -= 1;
606 
607  /* Update outer IPv6 length (in case it has changed) */
608  new_l0 = vec_len (ls0_mem->rewrite) +
609  clib_net_to_host_u16 (ip0_encap->payload_length);
610  ip0->payload_length = clib_host_to_net_u16 (new_l0);
611  }
612 
613  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
614  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
615  {
617  vlib_add_trace (vm, node, b0, sizeof *tr);
618  tr->error = 0;
619 
620  if (next0 == SRV6_AS_REWRITE_NEXT_ERROR)
621  {
622  tr->error = 1;
623  }
624  else
625  {
627  sizeof tr->src.as_u8);
629  sizeof tr->dst.as_u8);
630  }
631  }
632 
633  /* Increment per-SID AS rewrite counters */
636  &(sm->invalid_counters) :
637  &(sm->valid_counters)),
638  vm->thread_index, ls0_mem->index,
640  b0));
641 
642  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
643  n_left_to_next, bi0, next0);
644 
645  cnt_packets++;
646  }
647 
648  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
649  }
650 
651  /* Update counters */
653  SRV6_AS_REWRITE_COUNTER_PROCESSED,
654  cnt_packets);
655 
656  return frame->n_vectors;
657 }
658 
659 /* *INDENT-OFF* */
661  .function = srv6_as6_rewrite_fn,
662  .name = "srv6-as6-rewrite",
663  .vector_size = sizeof (u32),
664  .format_trace = format_srv6_as_rewrite_trace,
665  .type = VLIB_NODE_TYPE_INTERNAL,
666  .n_errors = SRV6_AS_REWRITE_N_COUNTERS,
667  .error_strings = srv6_as_rewrite_counter_strings,
668  .n_next_nodes = SRV6_AS_REWRITE_N_NEXT,
669  .next_nodes = {
670  [SRV6_AS_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
671  [SRV6_AS_REWRITE_NEXT_ERROR] = "error-drop",
672  },
673 };
674 /* *INDENT-ON* */
675 
676 /*
677 * fd.io coding-style-patch-verification: ON
678 *
679 * Local Variables:
680 * eval: (c-set-style "gnu")
681 * End:
682 */
u32 sw_if_index
Definition: ipsec_gre.api:37
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:82
static_always_inline void end_as_processing(vlib_buffer_t *b0, ip6_header_t *ip0, srv6_as_localsid_t *ls0_mem, u32 *next0)
Function doing SRH processing for AS behavior.
Definition: node.c:113
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:220
SR LocalSID.
Definition: sr.h:102
u32 * sw_iface_localsid4
Retrieve local SID from iface.
Definition: as.h:62
vlib_node_registration_t srv6_as_localsid_node
(constructor) VLIB_REGISTER_NODE (srv6_as_localsid_node)
Definition: node.c:241
u8 as_u8[16]
Definition: ip6_packet.h:48
srv6_as_main_t srv6_as_main
Definition: as.h:71
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
#define NULL
Definition: clib.h:58
srv6_as_rewrite_counters
Definition: node.c:73
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:51
u32 thread_index
Definition: main.h:197
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
u32 * sw_iface_localsid2
Retrieve local SID from iface.
Definition: as.h:61
static uword srv6_as6_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:542
static void * ip6_ext_next_header(ip6_ext_header_t *ext_hdr)
Definition: ip6_packet.h:552
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
vl_api_ip4_address_t dst
Definition: ipsec_gre.api:39
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:468
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:366
vlib_combined_counter_main_t sr_ls_invalid_counters
Definition: sr.h:229
vlib_combined_counter_main_t sr_ls_valid_counters
Definition: sr.h:228
ip6_address_t src_address
Definition: ip6_packet.h:385
unsigned char u8
Definition: types.h:56
static uword srv6_as_localsid_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
SRv6 AS Localsid graph node.
Definition: node.c:167
#define static_always_inline
Definition: clib.h:99
i64 word
Definition: types.h:111
vlib_node_registration_t srv6_as6_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_as6_rewrite_node)
Definition: node.c:64
srv6_as_localsid_next_t
Definition: node.c:90
unsigned int u32
Definition: types.h:88
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:136
u32 nh_adj
Adjacency index for out.
Definition: as.h:38
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
unsigned short u16
Definition: types.h:57
#define foreach_srv6_as_rewrite_counter
Definition: node.c:69
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
static uword srv6_as2_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:264
#define PREDICT_FALSE(x)
Definition: clib.h:111
static u8 * format_srv6_as_rewrite_trace(u8 *s, va_list *args)
Definition: node.c:45
#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:218
#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:338
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1150
#define ip6_ext_header_len(p)
Definition: ip6_packet.h:548
ip6_sr_localsid_t * localsids
Definition: sr.h:204
vlib_node_registration_t srv6_as4_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_as4_rewrite_node)
Definition: node.c:63
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:395
u8 * rewrite
Headers to be rewritten.
Definition: as.h:42
format_function_t format_ip6_address
Definition: format.h:93
vlib_main_t * vm
Definition: buffer.c:312
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:458
static u8 ip6_ext_hdr(u8 nexthdr)
Definition: ip6_packet.h:527
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:513
#define ASSERT(truth)
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
static u8 * format_srv6_as_localsid_trace(u8 *s, va_list *args)
Definition: node.c:35
vlib_node_registration_t srv6_as2_rewrite_node
(constructor) VLIB_REGISTER_NODE (srv6_as2_rewrite_node)
Definition: node.c:377
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:248
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:57
struct _vlib_node_registration vlib_node_registration_t
Definition: defs.h:47
u16 payload_length
Definition: ip6_packet.h:376
static char * srv6_as_rewrite_counter_strings[]
Definition: node.c:81
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
srv6_as_rewrite_next_t
Definition: node.c:99
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:244
u32 * sw_iface_localsid6
Retrieve local SID from iface.
Definition: as.h:63
#define vnet_buffer(b)
Definition: buffer.h:369
vlib_combined_counter_main_t valid_counters
Valid rewrite counters.
Definition: as.h:67
ip6_address_t src
Definition: node.c:31
Segment Routing main datastructure.
Definition: sr.h:189
u16 flags
Copy of main node flags.
Definition: node.h:507
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:301
static uword srv6_as4_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:398
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
ip6_address_t dst
Definition: node.c:31
Definition: defs.h:46
ip6_address_t dst_address
Definition: ip6_packet.h:385