FD.io VPP  v18.07.1-19-g511ce25
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 (((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 (((u8 *) ip0_encap) - vec_len (ls0_mem->rewrite),
455  ls0_mem->rewrite, vec_len (ls0_mem->rewrite));
456  vlib_buffer_advance (b0, -(word) vec_len (ls0_mem->rewrite));
457 
458  ip0 = vlib_buffer_get_current (b0);
459 
460  /* Update inner IPv4 TTL and checksum */
461  u32 checksum0;
462  ip0_encap->ttl -= 1;
463  checksum0 = ip0_encap->checksum + clib_host_to_net_u16 (0x0100);
464  checksum0 += checksum0 >= 0xffff;
465  ip0_encap->checksum = checksum0;
466 
467  /* Update outer IPv6 length (in case it has changed) */
468  new_l0 = vec_len (ls0_mem->rewrite) - sizeof (ip6_header_t) +
469  clib_net_to_host_u16 (ip0_encap->length);
470  ip0->payload_length = clib_host_to_net_u16 (new_l0);
471  }
472 
473  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
474  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
475  {
477  vlib_add_trace (vm, node, b0, sizeof *tr);
478  tr->error = 0;
479 
480  if (next0 == SRV6_AS_REWRITE_NEXT_ERROR)
481  {
482  tr->error = 1;
483  }
484  else
485  {
487  sizeof tr->src.as_u8);
489  sizeof tr->dst.as_u8);
490  }
491  }
492 
493  /* Increment per-SID AS rewrite counters */
496  &(sm->invalid_counters) :
497  &(sm->valid_counters)),
498  vm->thread_index, ls0_mem->index,
500  b0));
501 
502  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
503  n_left_to_next, bi0, next0);
504 
505  cnt_packets++;
506  }
507 
508  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
509  }
510 
511  /* Update counters */
513  SRV6_AS_REWRITE_COUNTER_PROCESSED,
514  cnt_packets);
515 
516  return frame->n_vectors;
517 }
518 
519 /* *INDENT-OFF* */
521  .function = srv6_as4_rewrite_fn,
522  .name = "srv6-as4-rewrite",
523  .vector_size = sizeof (u32),
524  .format_trace = format_srv6_as_rewrite_trace,
525  .type = VLIB_NODE_TYPE_INTERNAL,
526  .n_errors = SRV6_AS_REWRITE_N_COUNTERS,
527  .error_strings = srv6_as_rewrite_counter_strings,
528  .n_next_nodes = SRV6_AS_REWRITE_N_NEXT,
529  .next_nodes = {
530  [SRV6_AS_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
531  [SRV6_AS_REWRITE_NEXT_ERROR] = "error-drop",
532  },
533 };
534 /* *INDENT-ON* */
535 
536 
537 /**
538  * @brief Graph node for applying a SR policy into an IPv6 packet. Encapsulation
539  */
540 static uword
542  vlib_node_runtime_t * node, vlib_frame_t * frame)
543 {
544  ip6_sr_main_t *srm = &sr_main;
546  u32 n_left_from, next_index, *from, *to_next;
547  u32 cnt_packets = 0;
548 
549  from = vlib_frame_vector_args (frame);
550  n_left_from = frame->n_vectors;
551  next_index = node->cached_next_index;
552 
553  while (n_left_from > 0)
554  {
555  u32 n_left_to_next;
556 
557  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
558 
559  /* TODO: Dual/quad loop */
560 
561  while (n_left_from > 0 && n_left_to_next > 0)
562  {
563  u32 bi0;
564  vlib_buffer_t *b0;
565  ip6_header_t *ip0 = 0, *ip0_encap = 0;
566  ip6_sr_localsid_t *ls0;
567  srv6_as_localsid_t *ls0_mem;
569  u16 new_l0 = 0;
570 
571  bi0 = from[0];
572  to_next[0] = bi0;
573  from += 1;
574  to_next += 1;
575  n_left_from -= 1;
576  n_left_to_next -= 1;
577 
578  b0 = vlib_get_buffer (vm, bi0);
579  ip0_encap = vlib_buffer_get_current (b0);
580  ls0 = pool_elt_at_index (srm->localsids,
582  (b0)->sw_if_index
583  [VLIB_RX]]);
584  ls0_mem = ls0->plugin_mem;
585 
586  if (PREDICT_FALSE (ls0_mem == NULL || ls0_mem->rewrite == NULL))
587  {
589  b0->error = node->errors[SRV6_AS_REWRITE_COUNTER_NO_RW];
590  }
591  else
592  {
594  (vec_len (ls0_mem->rewrite) + b0->current_data));
595 
596  clib_memcpy (((u8 *) ip0_encap) - vec_len (ls0_mem->rewrite),
597  ls0_mem->rewrite, vec_len (ls0_mem->rewrite));
598  vlib_buffer_advance (b0, -(word) vec_len (ls0_mem->rewrite));
599 
600  ip0 = vlib_buffer_get_current (b0);
601 
602  /* Update inner IPv6 hop limit */
603  ip0_encap->hop_limit -= 1;
604 
605  /* Update outer IPv6 length (in case it has changed) */
606  new_l0 = vec_len (ls0_mem->rewrite) +
607  clib_net_to_host_u16 (ip0_encap->payload_length);
608  ip0->payload_length = clib_host_to_net_u16 (new_l0);
609  }
610 
611  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
612  PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
613  {
615  vlib_add_trace (vm, node, b0, sizeof *tr);
616  tr->error = 0;
617 
618  if (next0 == SRV6_AS_REWRITE_NEXT_ERROR)
619  {
620  tr->error = 1;
621  }
622  else
623  {
625  sizeof tr->src.as_u8);
627  sizeof tr->dst.as_u8);
628  }
629  }
630 
631  /* Increment per-SID AS rewrite counters */
634  &(sm->invalid_counters) :
635  &(sm->valid_counters)),
636  vm->thread_index, ls0_mem->index,
638  b0));
639 
640  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
641  n_left_to_next, bi0, next0);
642 
643  cnt_packets++;
644  }
645 
646  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
647  }
648 
649  /* Update counters */
651  SRV6_AS_REWRITE_COUNTER_PROCESSED,
652  cnt_packets);
653 
654  return frame->n_vectors;
655 }
656 
657 /* *INDENT-OFF* */
659  .function = srv6_as6_rewrite_fn,
660  .name = "srv6-as6-rewrite",
661  .vector_size = sizeof (u32),
662  .format_trace = format_srv6_as_rewrite_trace,
663  .type = VLIB_NODE_TYPE_INTERNAL,
664  .n_errors = SRV6_AS_REWRITE_N_COUNTERS,
665  .error_strings = srv6_as_rewrite_counter_strings,
666  .n_next_nodes = SRV6_AS_REWRITE_N_NEXT,
667  .next_nodes = {
668  [SRV6_AS_REWRITE_NEXT_LOOKUP] = "ip6-lookup",
669  [SRV6_AS_REWRITE_NEXT_ERROR] = "error-drop",
670  },
671 };
672 /* *INDENT-ON* */
673 
674 /*
675 * fd.io coding-style-patch-verification: ON
676 *
677 * Local Variables:
678 * eval: (c-set-style "gnu")
679 * End:
680 */
ip6_sr_main_t sr_main
Definition: sr.c:31
#define CLIB_UNUSED(x)
Definition: clib.h:79
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:213
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
#define NULL
Definition: clib.h:55
srv6_as_rewrite_counters
Definition: node.c:73
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:52
u32 thread_index
Definition: main.h:179
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:541
static void * ip6_ext_next_header(ip6_ext_header_t *ext_hdr)
Definition: ip6_packet.h:494
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:451
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:250
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:347
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
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:104
#define static_always_inline
Definition: clib.h:93
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
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:464
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:108
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:202
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:105
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:364
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:135
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1168
#define ip6_ext_header_len(p)
Definition: ip6_packet.h:490
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:153
u16 n_vectors
Definition: node.h:380
u8 * rewrite
Headers to be rewritten.
Definition: as.h:42
format_function_t format_ip6_address
Definition: format.h:99
vlib_main_t * vm
Definition: buffer.c:294
#define clib_memcpy(a, b, c)
Definition: string.h:75
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:454
static u8 ip6_ext_hdr(u8 nexthdr)
Definition: ip6_packet.h:478
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:492
#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:215
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:55
struct _vlib_node_registration vlib_node_registration_t
Definition: defs.h:47
u16 payload_length
Definition: ip6_packet.h:338
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
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:267
u32 * sw_iface_localsid6
Retrieve local SID from iface.
Definition: as.h:63
#define vnet_buffer(b)
Definition: buffer.h:360
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:486
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:295
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:111
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:57
ip6_address_t dst
Definition: node.c:31
Definition: defs.h:46
ip6_address_t dst_address
Definition: ip6_packet.h:347