FD.io VPP  v21.01.1
Vector Packet Processing
l2_xcrw.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 <vnet/l2/l2_xcrw.h>
16 
17 /**
18  * @file
19  * General L2 / L3 cross-connect, used to set up
20  * "L2 interface <--> your-favorite-tunnel-encap" tunnels.
21  *
22  * We set up a typical L2 cross-connect or (future) bridge
23  * to hook L2 interface(s) up to the L3 stack in arbitrary ways.
24  *
25  * Each l2_xcrw adjacency specifies 3 things:
26  *
27  * 1. The next graph node (presumably in the L3 stack) to
28  * process the (L2 -> L3) packet
29  *
30  * 2. A new value for vnet_buffer(b)->sw_if_index[VLIB_TX]
31  * (i.e. a lookup FIB index),
32  *
33  * 3. A rewrite string to apply.
34  *
35  * Example: to cross-connect an L2 interface or (future) bridge
36  * to an mpls-o-gre tunnel, set up the L2 rewrite string as shown in
37  * mpls_gre_rewrite, and use "mpls-post-rewrite" to fix the
38  * GRE IP header checksum and length fields.
39  */
40 
41 typedef struct
42 {
46 
47 /* packet trace format function */
48 static u8 *
49 format_l2_xcrw_trace (u8 * s, va_list * args)
50 {
51  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
52  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
53  l2_xcrw_trace_t *t = va_arg (*args, l2_xcrw_trace_t *);
54 
55  s = format (s, "L2_XCRW: next index %d tx_fib_index %d",
56  t->next_index, t->tx_fib_index);
57  return s;
58 }
59 
61 
62 #ifndef CLIB_MARCH_VARIANT
64 #endif /* CLIB_MARCH_VARIANT */
65 
66 static char *l2_xcrw_error_strings[] = {
67 #define _(sym,string) string,
69 #undef _
70 };
71 
74 {
75  u32 n_left_from, *from, *to_next;
76  l2_xcrw_next_t next_index;
78  vlib_node_t *n = vlib_get_node (vm, l2_xcrw_node.index);
79  u32 node_counter_base_index = n->error_heap_index;
80  vlib_error_main_t *em = &vm->error_main;
81 
83  n_left_from = frame->n_vectors;
84  next_index = node->cached_next_index;
85 
86  while (n_left_from > 0)
87  {
88  u32 n_left_to_next;
89 
90  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
91 
92  while (n_left_from >= 4 && n_left_to_next >= 2)
93  {
94  u32 bi0, bi1;
95  vlib_buffer_t *b0, *b1;
96  u32 next0, next1;
97  u32 sw_if_index0, sw_if_index1;
98  l2_xcrw_adjacency_t *adj0, *adj1;
99 
100  /* Prefetch next iteration. */
101  {
102  vlib_buffer_t *p2, *p3;
103 
104  p2 = vlib_get_buffer (vm, from[2]);
105  p3 = vlib_get_buffer (vm, from[3]);
106 
107  vlib_prefetch_buffer_header (p2, LOAD);
108  vlib_prefetch_buffer_header (p3, LOAD);
109 
112  }
113 
114  /* speculatively enqueue b0 and b1 to the current next frame */
115  to_next[0] = bi0 = from[0];
116  to_next[1] = bi1 = from[1];
117  from += 2;
118  to_next += 2;
119  n_left_from -= 2;
120  n_left_to_next -= 2;
121 
122  b0 = vlib_get_buffer (vm, bi0);
123  b1 = vlib_get_buffer (vm, bi1);
124 
125  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
126  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
127 
128  adj0 = vec_elt_at_index (xcm->adj_by_sw_if_index, sw_if_index0);
129  adj1 = vec_elt_at_index (xcm->adj_by_sw_if_index, sw_if_index1);
130 
131  next0 = adj0->rewrite_header.next_index;
132  vnet_buffer (b0)->sw_if_index[VLIB_TX] =
133  adj0->rewrite_header.sw_if_index;
134 
135  next1 = adj1->rewrite_header.next_index;
136  vnet_buffer (b1)->sw_if_index[VLIB_TX] =
137  adj1->rewrite_header.sw_if_index;
138 
139  em->counters[node_counter_base_index + next1]++;
140 
141  if (PREDICT_TRUE (next0 > 0))
142  {
143  u8 *h0 = vlib_buffer_get_current (b0);
144  vnet_rewrite_one_header (adj0[0], h0,
145  adj0->rewrite_header.data_bytes);
146  vlib_buffer_advance (b0, -adj0->rewrite_header.data_bytes);
147  em->counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
148  }
149 
150  if (PREDICT_TRUE (next1 > 0))
151  {
152  u8 *h1 = vlib_buffer_get_current (b1);
153  vnet_rewrite_one_header (adj1[0], h1,
154  adj1->rewrite_header.data_bytes);
155  vlib_buffer_advance (b1, -adj1->rewrite_header.data_bytes);
156  em->counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
157  }
158 
159 
160  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
161  {
162  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
163  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
164  {
165  l2_xcrw_trace_t *t =
166  vlib_add_trace (vm, node, b0, sizeof (*t));
167  t->next_index = next0;
168  t->tx_fib_index = adj0->rewrite_header.sw_if_index;
169  }
170  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
171  && (b1->flags & VLIB_BUFFER_IS_TRACED)))
172  {
173  l2_xcrw_trace_t *t =
174  vlib_add_trace (vm, node, b1, sizeof (*t));
175  t->next_index = next1;
176  t->tx_fib_index = adj1->rewrite_header.sw_if_index;
177  }
178  }
179 
180  /* verify speculative enqueues, maybe switch current next frame */
181  vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
182  to_next, n_left_to_next,
183  bi0, bi1, next0, next1);
184  }
185 
186  while (n_left_from > 0 && n_left_to_next > 0)
187  {
188  u32 bi0;
189  vlib_buffer_t *b0;
190  u32 next0;
191  u32 sw_if_index0;
192  l2_xcrw_adjacency_t *adj0;
193 
194  /* speculatively enqueue b0 to the current next frame */
195  bi0 = from[0];
196  to_next[0] = bi0;
197  from += 1;
198  to_next += 1;
199  n_left_from -= 1;
200  n_left_to_next -= 1;
201 
202  b0 = vlib_get_buffer (vm, bi0);
203 
204  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
205 
206  adj0 = vec_elt_at_index (xcm->adj_by_sw_if_index, sw_if_index0);
207 
208  next0 = adj0->rewrite_header.next_index;
209  vnet_buffer (b0)->sw_if_index[VLIB_TX] =
210  adj0->rewrite_header.sw_if_index;
211 
212  if (PREDICT_TRUE (next0 > 0))
213  {
214  u8 *h0 = vlib_buffer_get_current (b0);
215  vnet_rewrite_one_header (adj0[0], h0,
216  adj0->rewrite_header.data_bytes);
217  vlib_buffer_advance (b0, -adj0->rewrite_header.data_bytes);
218  em->counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
219  }
220 
221  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
222  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
223  {
224  l2_xcrw_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
225  t->next_index = next0;
226  t->tx_fib_index = adj0->rewrite_header.sw_if_index;
227  }
228 
229  /* verify speculative enqueue, maybe switch current next frame */
230  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
231  to_next, n_left_to_next,
232  bi0, next0);
233  }
234 
235  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
236  }
237 
238  return frame->n_vectors;
239 }
240 
241 /* *INDENT-OFF* */
243  .name = "l2-xcrw",
244  .vector_size = sizeof (u32),
245  .format_trace = format_l2_xcrw_trace,
247 
248  .n_errors = ARRAY_LEN(l2_xcrw_error_strings),
249  .error_strings = l2_xcrw_error_strings,
250 
251  .n_next_nodes = L2_XCRW_N_NEXT,
252 
253  /* edit / add dispositions here */
254  .next_nodes = {
255  [L2_XCRW_NEXT_DROP] = "error-drop",
256  },
257 };
258 /* *INDENT-ON* */
259 
260 #ifndef CLIB_MARCH_VARIANT
261 clib_error_t *
263 {
265 
266  mp->vlib_main = vm;
267  mp->vnet_main = &vnet_main;
269 
270  return 0;
271 }
272 
274 
275 static u8 *
276 format_xcrw_name (u8 * s, va_list * args)
277 {
278  u32 dev_instance = va_arg (*args, u32);
279  return format (s, "xcrw%d", dev_instance);
280 }
281 
282 /* *INDENT-OFF* */
283 VNET_DEVICE_CLASS (xcrw_device_class,static) = {
284  .name = "Xcrw",
285  .format_device_name = format_xcrw_name,
286 };
287 /* *INDENT-ON* */
288 
289 /* Create a sham tunnel interface and return its sw_if_index */
290 static u32
292 {
293  vnet_main_t *vnm = vnet_get_main ();
294  static u32 instance;
295  u8 address[6];
296  u32 hw_if_index;
299 
300  /* mac address doesn't really matter */
301  clib_memset (address, 0, sizeof (address));
302  address[2] = 0x12;
303 
304  /* can returns error iff phy != 0 */
306  (vnm, xcrw_device_class.index, instance++, address, &hw_if_index,
307  /* flag change */ 0);
308 
309  hi = vnet_get_hw_interface (vnm, hw_if_index);
310  sw_if_index = hi->sw_if_index;
311  vnet_sw_interface_set_flags (vnm, sw_if_index,
313 
314  /* Output to the sham tunnel invokes the encap node */
315  hi->output_node_index = l2_xcrw_node.index;
316 
317  return sw_if_index;
318 }
319 
320 int
322  u32 l2_sw_if_index, u32 tx_fib_index,
323  u8 * rewrite, u32 next_node_index, int is_add)
324 {
327  l2_xcrw_tunnel_t *t;
328  uword *p;
329 
330  if (is_add)
331  {
332 
333  pool_get (xcm->tunnels, t);
334 
335  /* No interface allocated? Do it. Otherwise, set admin up */
336  if (t->tunnel_sw_if_index == 0)
338  else
341 
342  t->l2_sw_if_index = l2_sw_if_index;
343 
345 
347  clib_memset (a, 0, sizeof (*a));
348 
349  a->rewrite_header.sw_if_index = tx_fib_index;
350 
351  /*
352  * Add or find a dynamic disposition for the successor node,
353  * e.g. so we can ship pkts to mpls_post_rewrite...
354  */
355  a->rewrite_header.next_index =
356  vlib_node_add_next (vm, l2_xcrw_node.index, next_node_index);
357 
358  if (vec_len (rewrite))
359  vnet_rewrite_set_data (a[0], rewrite, vec_len (rewrite));
360 
361  set_int_l2_mode (vm, vnm, MODE_L2_XC, t->l2_sw_if_index, 0,
364  t->l2_sw_if_index, t - xcm->tunnels);
365  return 0;
366  }
367  else
368  {
369  p = hash_get (xcm->tunnel_index_by_l2_sw_if_index, l2_sw_if_index);
370  if (p == 0)
371  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
372 
373  t = pool_elt_at_index (xcm->tunnels, p[0]);
374 
376  /* Reset adj to drop traffic */
377  clib_memset (a, 0, sizeof (*a));
378 
379  set_int_l2_mode (vm, vnm, MODE_L3, t->l2_sw_if_index, 0,
380  L2_BD_PORT_TYPE_NORMAL, 0, 0);
381 
382  vnet_sw_interface_set_flags (vnm, t->tunnel_sw_if_index, 0 /* down */ );
383 
384  hash_unset (xcm->tunnel_index_by_l2_sw_if_index, l2_sw_if_index);
385  pool_put (xcm->tunnels, t);
386  }
387  return 0;
388 }
389 
390 
391 static clib_error_t *
393  unformat_input_t * input, vlib_cli_command_t * cmd)
394 {
395  unformat_input_t _line_input, *line_input = &_line_input;
396  int is_add = 1;
397  int is_ipv6 = 0; /* for fib id -> fib index mapping */
398  u32 tx_fib_id = ~0;
399  u32 tx_fib_index = ~0;
400  u32 next_node_index = ~0;
401  u32 l2_sw_if_index;
402  u8 *rw = 0;
403  vnet_main_t *vnm = vnet_get_main ();
404  int rv;
405  clib_error_t *error = NULL;
406 
407 
408  if (!unformat_user (input, unformat_line_input, line_input))
409  return 0;
410 
411  if (!unformat (line_input, "%U",
412  unformat_vnet_sw_interface, vnm, &l2_sw_if_index))
413  {
414  error = clib_error_return (0, "unknown input '%U'",
415  format_unformat_error, line_input);
416  goto done;
417  }
418 
419  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
420  {
421  if (unformat (line_input, "next %U",
422  unformat_vlib_node, vm, &next_node_index))
423  ;
424  else if (unformat (line_input, "tx-fib-id %d", &tx_fib_id))
425  ;
426  else if (unformat (line_input, "del"))
427  is_add = 0;
428  else if (unformat (line_input, "ipv6"))
429  is_ipv6 = 1;
430  else if (unformat (line_input, "rw %U", unformat_hex_string, &rw));
431  else
432  break;
433  }
434 
435  if (next_node_index == ~0)
436  {
437  error = clib_error_return (0, "next node not specified");
438  goto done;
439  }
440 
441  if (tx_fib_id != ~0)
442  {
443  uword *p;
444 
445  if (is_ipv6)
446  p = hash_get (ip6_main.fib_index_by_table_id, tx_fib_id);
447  else
448  p = hash_get (ip4_main.fib_index_by_table_id, tx_fib_id);
449 
450  if (p == 0)
451  {
452  error =
453  clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id);
454  goto done;
455  }
456 
457  tx_fib_index = p[0];
458  }
459 
460  rv = vnet_configure_l2_xcrw (vm, vnm, l2_sw_if_index, tx_fib_index,
461  rw, next_node_index, is_add);
462 
463  switch (rv)
464  {
465 
466  case 0:
467  break;
468 
469  case VNET_API_ERROR_INVALID_SW_IF_INDEX:
470  error = clib_error_return (0, "%U not cross-connected",
472  vnm, l2_sw_if_index);
473  goto done;
474 
475  default:
476  error = clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv);
477  goto done;
478  }
479 
480 done:
481  vec_free (rw);
482  unformat_free (line_input);
483 
484  return error;
485 }
486 
487 /*?
488  * Add or delete a Layer 2 to Layer 3 rewrite cross-connect. This is
489  * used to hook Layer 2 interface(s) up to the Layer 3 stack in
490  * arbitrary ways. For example, cross-connect an L2 interface or
491  * (future) bridge to an mpls-o-gre tunnel. Set up the L2 rewrite
492  * string as shown in mpls_gre_rewrite, and use \"mpls-post-rewrite\"
493  * to fix the GRE IP header checksum and length fields.
494  *
495  * @cliexpar
496  * @todo This is incomplete. This needs a detailed description and a
497  * practical example.
498 ?*/
499 /* *INDENT-OFF* */
500 VLIB_CLI_COMMAND (set_l2_xcrw_command, static) = {
501  .path = "set interface l2 xcrw",
502  .short_help =
503  "set interface l2 xcrw <interface> next <node-name>\n"
504  " [del] [tx-fib-id <id>] [ipv6] rw <hex-bytes>",
505  .function = set_l2_xcrw_command_fn,
506 };
507 /* *INDENT-ON* */
508 
509 #endif /* CLIB_MARCH_VARIANT */
510 
511 static u8 *
512 format_l2xcrw (u8 * s, va_list * args)
513 {
514  vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
515  l2_xcrw_tunnel_t *t = va_arg (*args, l2_xcrw_tunnel_t *);
517  vlib_main_t *vm = vlib_get_main ();
519  u8 *rewrite_string;
520 
521  if (t == 0)
522  {
523  s = format (s, "%-25s%s", "L2 interface", "Tunnel Details");
524  return s;
525  }
526 
527  s = format (s, "%-25U %U ",
530 
532 
533  s = format (s, "next %U ",
535  a->rewrite_header.next_index);
536 
537  if (a->rewrite_header.sw_if_index != ~0)
538  s = format (s, "tx fib index %d ", a->rewrite_header.sw_if_index);
539 
540  if (a->rewrite_header.data_bytes)
541  {
542  rewrite_string = (u8 *) (a + 1);
543  rewrite_string -= a->rewrite_header.data_bytes;
544  s = format (s, "rewrite data: %U ",
545  format_hex_bytes, rewrite_string,
546  a->rewrite_header.data_bytes);
547  }
548 
549  s = format (s, "\n");
550 
551  return s;
552 }
553 
554 
555 static clib_error_t *
557  unformat_input_t * input, vlib_cli_command_t * cmd)
558 {
559  vnet_main_t *vnm = vnet_get_main ();
561  l2_xcrw_tunnel_t *t;
562 
563  if (pool_elts (xcm->tunnels) == 0)
564  {
565  vlib_cli_output (vm, "No L2 / L3 rewrite cross-connects configured");
566  return 0;
567  }
568 
569  vlib_cli_output (vm, "%U", format_l2xcrw, 0, 0);
570 
571  /* *INDENT-OFF* */
572  pool_foreach (t, xcm->tunnels)
573  {
574  vlib_cli_output (vm, "%U", format_l2xcrw, vnm, t);
575  }
576  /* *INDENT-ON* */
577 
578  return 0;
579 }
580 
581 /*?
582  * Display a Layer 2 to Layer 3 rewrite cross-connect. This is used to
583  * hook Layer 2 interface(s) up to the Layer 3 stack in arbitrary ways.
584  *
585  * @todo This is incomplete. This needs a detailed description and a
586  * practical example.
587 ?*/
588 /* *INDENT-OFF* */
589 VLIB_CLI_COMMAND (show_l2xcrw_command, static) = {
590  .path = "show l2xcrw",
591  .short_help = "show l2xcrw",
592  .function = show_l2xcrw_command_fn,
593 };
594 /* *INDENT-ON* */
595 
596 /*
597  * fd.io coding-style-patch-verification: ON
598  *
599  * Local Variables:
600  * eval: (c-set-style "gnu")
601  * End:
602  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
#define vnet_rewrite_one_header(rw0, p0, most_likely_size)
Definition: rewrite.h:216
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
u32 error_heap_index
Definition: node.h:325
#define hash_set(h, key, value)
Definition: hash.h:255
static char * l2_xcrw_error_strings[]
Definition: l2_xcrw.c:66
#define CLIB_UNUSED(x)
Definition: clib.h:87
#define hash_unset(h, key)
Definition: hash.h:261
a
Definition: bitmap.h:544
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Definition: interface.c:519
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
u32 next_index
Definition: l2_xcrw.c:43
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:527
#define PREDICT_TRUE(x)
Definition: clib.h:122
u32 tx_fib_index
Definition: l2_xcrw.c:44
vlib_main_t * vlib_main
Definition: l2_xcrw.h:60
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
unformat_function_t unformat_hex_string
Definition: format.h:288
#define vnet_rewrite_set_data(rw, data, data_bytes)
Definition: rewrite.h:156
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
vlib_main_t * vm
Definition: in2out_ed.c:1580
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
Definition: node.h:203
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:251
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1173
unsigned char u8
Definition: types.h:56
static clib_error_t * show_l2xcrw_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: l2_xcrw.c:556
static u8 * format_l2xcrw(u8 *s, va_list *args)
Definition: l2_xcrw.c:512
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
description fragment has unexpected format
Definition: map.api:433
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:207
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 * format_hex_bytes(u8 *s, va_list *va)
Definition: std-formats.c:84
static u8 * format_xcrw_name(u8 *s, va_list *args)
Definition: l2_xcrw.c:276
clib_error_t * l2_xcrw_init(vlib_main_t *vm)
Definition: l2_xcrw.c:262
#define clib_error_return(e, args...)
Definition: error.h:99
format_function_t format_vlib_next_node_name
Definition: node_funcs.h:1223
unsigned int u32
Definition: types.h:88
u32 l2_sw_if_index
Definition: l2_xcrw.h:39
unformat_function_t unformat_line_input
Definition: format.h:282
vl_api_fib_path_type_t type
Definition: fib_types.api:123
Definition: cJSON.c:84
#define hash_get(h, key)
Definition: hash.h:249
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:546
l2_xcrw_tunnel_t * tunnels
Definition: l2_xcrw.h:54
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:133
vlib_error_main_t error_main
Definition: main.h:210
struct _unformat_input_t unformat_input_t
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:233
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:301
#define PREDICT_FALSE(x)
Definition: clib.h:121
vnet_main_t vnet_main
Definition: misc.c:43
ip6_main_t ip6_main
Definition: ip6_forward.c:2785
vnet_main_t * vnet_main
Definition: l2_xcrw.h:61
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
Definition: buffer_node.h:70
#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
#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
int vnet_configure_l2_xcrw(vlib_main_t *vm, vnet_main_t *vnm, u32 l2_sw_if_index, u32 tx_fib_index, u8 *rewrite, u32 next_node_index, int is_add)
Definition: l2_xcrw.c:321
uword * fib_index_by_table_id
Definition: ip6.h:137
u64 * counters
Definition: error.h:62
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:170
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
#define foreach_l2_xcrw_error
Definition: l2_xcrw.h:70
u8 data[]
Packet data.
Definition: buffer.h:181
#define ARRAY_LEN(x)
Definition: clib.h:67
l2_xcrw_next_t
Definition: l2_xcrw.h:64
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
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1580
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:158
#define hash_create(elts, value_bytes)
Definition: hash.h:696
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:696
manual_print typedef address
Definition: ip_types.api:96
static u8 * format_l2_xcrw_trace(u8 *s, va_list *args)
Definition: l2_xcrw.c:49
u32 set_int_l2_mode(vlib_main_t *vm, vnet_main_t *vnet_main, u32 mode, u32 sw_if_index, u32 bd_index, l2_bd_port_type_t port_type, u32 shg, u32 xc_sw_if_index)
Set the subinterface to run in l2 or l3 mode.
Definition: l2_input.c:256
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:252
#define MODE_L2_XC
Definition: l2_input.h:284
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
vl_api_ip4_address_t hi
Definition: arp.api:37
VNET_DEVICE_CLASS(xcrw_device_class, static)
Definition: defs.h:47
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:348
u32 instance
Definition: gre.api:51
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 unformat_free(unformat_input_t *i)
Definition: format.h:162
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:297
vlib_node_registration_t l2_xcrw_node
(constructor) VLIB_REGISTER_NODE (l2_xcrw_node)
Definition: l2_xcrw.c:242
static u32 create_xcrw_interface(vlib_main_t *vm)
Definition: l2_xcrw.c:291
unformat_function_t unformat_vlib_node
Definition: node_funcs.h:1228
#define vnet_buffer(b)
Definition: buffer.h:417
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
u32 tunnel_sw_if_index
Definition: l2_xcrw.h:42
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:85
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
bool is_ipv6
Definition: dhcp.api:202
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:302
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
l2_xcrw_adjacency_t * adj_by_sw_if_index
Definition: l2_xcrw.h:51
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
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
Definition: defs.h:46
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
#define MODE_L3
Definition: l2_input.h:282
l2_xcrw_main_t l2_xcrw_main
Definition: l2_xcrw.c:63
uword * tunnel_index_by_l2_sw_if_index
Definition: l2_xcrw.h:57
static clib_error_t * set_l2_xcrw_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: l2_xcrw.c:392
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127