FD.io VPP  v16.12-rc0-308-g931be3a
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 
63 
64 static char *l2_xcrw_error_strings[] = {
65 #define _(sym,string) string,
67 #undef _
68 };
69 
70 static uword
72  vlib_node_runtime_t * node, vlib_frame_t * frame)
73 {
74  u32 n_left_from, *from, *to_next;
75  l2_xcrw_next_t next_index;
77  vlib_node_t *n = vlib_get_node (vm, l2_xcrw_node.index);
78  u32 node_counter_base_index = n->error_heap_index;
79  vlib_error_main_t *em = &vm->error_main;
80 
81  from = vlib_frame_vector_args (frame);
82  n_left_from = frame->n_vectors;
83  next_index = node->cached_next_index;
84 
85  while (n_left_from > 0)
86  {
87  u32 n_left_to_next;
88 
89  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
90 
91  while (n_left_from >= 4 && n_left_to_next >= 2)
92  {
93  u32 bi0, bi1;
94  vlib_buffer_t *b0, *b1;
95  u32 next0, next1;
96  u32 sw_if_index0, sw_if_index1;
97  l2_xcrw_adjacency_t *adj0, *adj1;
98 
99  /* Prefetch next iteration. */
100  {
101  vlib_buffer_t *p2, *p3;
102 
103  p2 = vlib_get_buffer (vm, from[2]);
104  p3 = vlib_get_buffer (vm, from[3]);
105 
106  vlib_prefetch_buffer_header (p2, LOAD);
107  vlib_prefetch_buffer_header (p3, LOAD);
108 
111  }
112 
113  /* speculatively enqueue b0 and b1 to the current next frame */
114  to_next[0] = bi0 = from[0];
115  to_next[1] = bi1 = from[1];
116  from += 2;
117  to_next += 2;
118  n_left_from -= 2;
119  n_left_to_next -= 2;
120 
121  b0 = vlib_get_buffer (vm, bi0);
122  b1 = vlib_get_buffer (vm, bi1);
123 
124  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
125  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
126 
127  adj0 = vec_elt_at_index (xcm->adj_by_sw_if_index, sw_if_index0);
128  adj1 = vec_elt_at_index (xcm->adj_by_sw_if_index, sw_if_index1);
129 
130  next0 = adj0->rewrite_header.next_index;
131  vnet_buffer (b0)->sw_if_index[VLIB_TX] =
132  adj0->rewrite_header.sw_if_index;
133 
134  next1 = adj1->rewrite_header.next_index;
135  vnet_buffer (b1)->sw_if_index[VLIB_TX] =
136  adj1->rewrite_header.sw_if_index;
137 
138  em->counters[node_counter_base_index + next1]++;
139 
140  if (PREDICT_TRUE (next0 > 0))
141  {
142  u8 *h0 = vlib_buffer_get_current (b0);
143  vnet_rewrite_one_header (adj0[0], h0,
144  adj0->rewrite_header.data_bytes);
145  vlib_buffer_advance (b0, -adj0->rewrite_header.data_bytes);
146  em->counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
147  }
148 
149  if (PREDICT_TRUE (next1 > 0))
150  {
151  u8 *h1 = vlib_buffer_get_current (b1);
152  vnet_rewrite_one_header (adj1[0], h1,
153  adj1->rewrite_header.data_bytes);
154  vlib_buffer_advance (b1, -adj1->rewrite_header.data_bytes);
155  em->counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
156  }
157 
158 
159  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
160  {
162  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
163  {
164  l2_xcrw_trace_t *t =
165  vlib_add_trace (vm, node, b0, sizeof (*t));
166  t->next_index = next0;
167  t->tx_fib_index = adj0->rewrite_header.sw_if_index;
168  }
170  && (b1->flags & VLIB_BUFFER_IS_TRACED)))
171  {
172  l2_xcrw_trace_t *t =
173  vlib_add_trace (vm, node, b1, sizeof (*t));
174  t->next_index = next1;
175  t->tx_fib_index = adj1->rewrite_header.sw_if_index;
176  }
177  }
178 
179  /* verify speculative enqueues, maybe switch current next frame */
180  vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
181  to_next, n_left_to_next,
182  bi0, bi1, next0, next1);
183  }
184 
185  while (n_left_from > 0 && n_left_to_next > 0)
186  {
187  u32 bi0;
188  vlib_buffer_t *b0;
189  u32 next0;
190  u32 sw_if_index0;
191  l2_xcrw_adjacency_t *adj0;
192 
193  /* speculatively enqueue b0 to the current next frame */
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 
203  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
204 
205  adj0 = vec_elt_at_index (xcm->adj_by_sw_if_index, sw_if_index0);
206 
207  next0 = adj0->rewrite_header.next_index;
208  vnet_buffer (b0)->sw_if_index[VLIB_TX] =
209  adj0->rewrite_header.sw_if_index;
210 
211  if (PREDICT_TRUE (next0 > 0))
212  {
213  u8 *h0 = vlib_buffer_get_current (b0);
214  vnet_rewrite_one_header (adj0[0], h0,
215  adj0->rewrite_header.data_bytes);
216  vlib_buffer_advance (b0, -adj0->rewrite_header.data_bytes);
217  em->counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
218  }
219 
221  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
222  {
223  l2_xcrw_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
224  t->next_index = next0;
225  t->tx_fib_index = adj0->rewrite_header.sw_if_index;
226  }
227 
228  /* verify speculative enqueue, maybe switch current next frame */
229  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
230  to_next, n_left_to_next,
231  bi0, next0);
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* */
241 VLIB_REGISTER_NODE (l2_xcrw_node, static) = {
242  .function = l2_xcrw_node_fn,
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 
262 {
264 
265  mp->vlib_main = vm;
266  mp->vnet_main = &vnet_main;
268 
269  return 0;
270 }
271 
273 
274 static uword
276  vlib_node_runtime_t * node, vlib_frame_t * frame)
277 {
278  clib_warning ("you shouldn't be here, leaking buffers...");
279  return frame->n_vectors;
280 }
281 
282 static u8 *
283 format_xcrw_name (u8 * s, va_list * args)
284 {
285  u32 dev_instance = va_arg (*args, u32);
286  return format (s, "xcrw%d", dev_instance);
287 }
288 
289 /* *INDENT-OFF* */
290 VNET_DEVICE_CLASS (xcrw_device_class,static) = {
291  .name = "Xcrw",
292  .format_device_name = format_xcrw_name,
293  .tx_function = dummy_interface_tx,
294 };
295 /* *INDENT-ON* */
296 
297 /* Create a sham tunnel interface and return its sw_if_index */
298 static u32
300 {
301  vnet_main_t *vnm = vnet_get_main ();
302  static u32 instance;
303  u8 address[6];
304  u32 hw_if_index;
306  u32 sw_if_index;
307 
308  /* mac address doesn't really matter */
309  memset (address, 0, sizeof (address));
310  address[2] = 0x12;
311 
312  /* can returns error iff phy != 0 */
314  (vnm, xcrw_device_class.index, instance++, address, &hw_if_index,
315  /* flag change */ 0);
316 
317  hi = vnet_get_hw_interface (vnm, hw_if_index);
318  sw_if_index = hi->sw_if_index;
319  vnet_sw_interface_set_flags (vnm, sw_if_index,
321 
322  /* Output to the sham tunnel invokes the encap node */
323  hi->output_node_index = l2_xcrw_node.index;
324 
325  return sw_if_index;
326 }
327 
328 int
330  u32 l2_sw_if_index, u32 tx_fib_index,
331  u8 * rewrite, u32 next_node_index, int is_add)
332 {
335  l2_xcrw_tunnel_t *t;
336  uword *p;
337 
338  if (is_add)
339  {
340 
341  pool_get (xcm->tunnels, t);
342 
343  /* No interface allocated? Do it. Otherwise, set admin up */
344  if (t->tunnel_sw_if_index == 0)
346  else
349 
350  t->l2_sw_if_index = l2_sw_if_index;
351 
353 
355  memset (a, 0, sizeof (*a));
356 
357  a->rewrite_header.sw_if_index = tx_fib_index;
358 
359  /*
360  * Add or find a dynamic disposition for the successor node,
361  * e.g. so we can ship pkts to mpls_post_rewrite...
362  */
363  a->rewrite_header.next_index =
364  vlib_node_add_next (vm, l2_xcrw_node.index, next_node_index);
365 
366  if (vec_len (rewrite))
367  vnet_rewrite_set_data (a[0], rewrite, vec_len (rewrite));
368 
369  set_int_l2_mode (vm, vnm, MODE_L2_XC, t->l2_sw_if_index, 0, 0, 0,
370  t->tunnel_sw_if_index);
372  t->l2_sw_if_index, t - xcm->tunnels);
373  return 0;
374  }
375  else
376  {
377  p = hash_get (xcm->tunnel_index_by_l2_sw_if_index, l2_sw_if_index);
378  if (p == 0)
379  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
380 
381  t = pool_elt_at_index (xcm->tunnels, p[0]);
382 
384  /* Reset adj to drop traffic */
385  memset (a, 0, sizeof (*a));
386 
387  set_int_l2_mode (vm, vnm, MODE_L3, t->l2_sw_if_index, 0, 0, 0, 0);
388 
389  vnet_sw_interface_set_flags (vnm, t->tunnel_sw_if_index, 0 /* down */ );
390 
391  hash_unset (xcm->tunnel_index_by_l2_sw_if_index, l2_sw_if_index);
392  pool_put (xcm->tunnels, t);
393  }
394  return 0;
395 }
396 
397 
398 static clib_error_t *
400  unformat_input_t * input, vlib_cli_command_t * cmd)
401 {
402  unformat_input_t _line_input, *line_input = &_line_input;
403  int is_add = 1;
404  int is_ipv6 = 0; /* for fib id -> fib index mapping */
405  u32 tx_fib_id = ~0;
406  u32 tx_fib_index = ~0;
407  u32 next_node_index = ~0;
408  u32 l2_sw_if_index;
409  u8 *rw = 0;
410  vnet_main_t *vnm = vnet_get_main ();
411  int rv;
412 
413 
414  if (!unformat_user (input, unformat_line_input, line_input))
415  return 0;
416 
417  if (!unformat (line_input, "%U",
418  unformat_vnet_sw_interface, vnm, &l2_sw_if_index))
419  return clib_error_return (0, "unknown input '%U'",
420  format_unformat_error, line_input);
421 
422  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
423  {
424  if (unformat (line_input, "next %U",
425  unformat_vlib_node, vm, &next_node_index))
426  ;
427  else if (unformat (line_input, "tx-fib-id %d", &tx_fib_id))
428  ;
429  else if (unformat (line_input, "del"))
430  is_add = 0;
431  else if (unformat (line_input, "ipv6"))
432  is_ipv6 = 1;
433  else if (unformat (line_input, "rw %U", unformat_hex_string, &rw));
434  else
435  break;
436  }
437 
438  if (next_node_index == ~0)
439  return clib_error_return (0, "next node not specified");
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  return clib_error_return (0, "nonexistent tx_fib_id %d", tx_fib_id);
452 
453  tx_fib_index = p[0];
454  }
455 
456  rv = vnet_configure_l2_xcrw (vm, vnm, l2_sw_if_index, tx_fib_index,
457  rw, next_node_index, is_add);
458 
459  switch (rv)
460  {
461 
462  case 0:
463  break;
464 
465  case VNET_API_ERROR_INVALID_SW_IF_INDEX:
466  return clib_error_return (0, "%U not cross-connected",
468  vnm, l2_sw_if_index);
469  default:
470  return clib_error_return (0, "vnet_configure_l2_xcrw returned %d", rv);
471  }
472 
473  vec_free (rw);
474 
475  return 0;
476 }
477 
478 /*?
479  * Add or delete a Layer 2 to Layer 3 rewrite cross-connect. This is
480  * used to hook Layer 2 interface(s) up to the Layer 3 stack in
481  * arbitrary ways. For example, cross-connect an L2 interface or
482  * (future) bridge to an mpls-o-gre tunnel. Set up the L2 rewrite
483  * string as shown in mpls_gre_rewrite, and use \"mpls-post-rewrite\"
484  * to fix the GRE IP header checksum and length fields.
485  *
486  * @cliexpar
487  * @todo This is incomplete. This needs a detailed description and a
488  * practical example.
489 ?*/
490 /* *INDENT-OFF* */
491 VLIB_CLI_COMMAND (set_l2_xcrw_command, static) = {
492  .path = "set interface l2 xcrw",
493  .short_help =
494  "set interface l2 xcrw <interface> next <node-name>\n"
495  " [del] [tx-fib-id <id>] [ipv6] rw <hex-bytes>",
496  .function = set_l2_xcrw_command_fn,
497 };
498 /* *INDENT-ON* */
499 
500 static u8 *
501 format_l2xcrw (u8 * s, va_list * args)
502 {
503  vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
504  l2_xcrw_tunnel_t *t = va_arg (*args, l2_xcrw_tunnel_t *);
506  vlib_main_t *vm = vlib_get_main ();
508  u8 *rewrite_string;
509 
510  if (t == 0)
511  {
512  s = format (s, "%-25s%s", "L2 interface", "Tunnel Details");
513  return s;
514  }
515 
516  s = format (s, "%-25U %U ",
519 
521 
522  s = format (s, "next %U ",
524  a->rewrite_header.next_index);
525 
526  if (a->rewrite_header.sw_if_index != ~0)
527  s = format (s, "tx fib index %d ", a->rewrite_header.sw_if_index);
528 
529  if (a->rewrite_header.data_bytes)
530  {
531  rewrite_string = (u8 *) (a + 1);
532  rewrite_string -= a->rewrite_header.data_bytes;
533  s = format (s, "rewrite data: %U ",
534  format_hex_bytes, rewrite_string,
535  a->rewrite_header.data_bytes);
536  }
537 
538  s = format (s, "\n");
539 
540  return s;
541 }
542 
543 
544 static clib_error_t *
546  unformat_input_t * input, vlib_cli_command_t * cmd)
547 {
548  vnet_main_t *vnm = vnet_get_main ();
550  l2_xcrw_tunnel_t *t;
551 
552  if (pool_elts (xcm->tunnels) == 0)
553  {
554  vlib_cli_output (vm, "No L2 / L3 rewrite cross-connects configured");
555  return 0;
556  }
557 
558  vlib_cli_output (vm, "%U", format_l2xcrw, 0, 0);
559 
560  /* *INDENT-OFF* */
561  pool_foreach (t, xcm->tunnels,
562  ({
563  vlib_cli_output (vm, "%U", format_l2xcrw, vnm, t);
564  }));
565  /* *INDENT-ON* */
566 
567  return 0;
568 }
569 
570 /*?
571  * Display a Layer 2 to Layer 3 rewrite cross-connect. This is used to
572  * hook Layer 2 interface(s) up to the Layer 3 stack in arbitrary ways.
573  *
574  * @todo This is incomplete. This needs a detailed description and a
575  * practical example.
576 ?*/
577 /* *INDENT-OFF* */
578 VLIB_CLI_COMMAND (show_l2xcrw_command, static) = {
579  .path = "show l2xcrw",
580  .short_help = "show l2xcrw",
581  .function = show_l2xcrw_command_fn,
582 };
583 /* *INDENT-ON* */
584 
585 /*
586  * fd.io coding-style-patch-verification: ON
587  *
588  * Local Variables:
589  * eval: (c-set-style "gnu")
590  * End:
591  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
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:457
#define vnet_rewrite_one_header(rw0, p0, most_likely_size)
Definition: rewrite.h:253
vmrglw vmrglh hi
u32 error_heap_index
Definition: node.h:278
#define hash_set(h, key, value)
Definition: hash.h:254
static char * l2_xcrw_error_strings[]
Definition: l2_xcrw.c:64
#define CLIB_UNUSED(x)
Definition: clib.h:79
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: l2_xcrw.c:275
#define hash_unset(h, key)
Definition: hash.h:260
a
Definition: bitmap.h:516
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
u32 next_index
Definition: l2_xcrw.c:43
static uword l2_xcrw_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: l2_xcrw.c:71
#define PREDICT_TRUE(x)
Definition: clib.h:98
u32 tx_fib_index
Definition: l2_xcrw.c:44
vlib_main_t * vlib_main
Definition: l2_xcrw.h:61
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
#define vnet_rewrite_set_data(rw, data, data_bytes)
Definition: rewrite.h:114
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
struct _vlib_node_registration vlib_node_registration_t
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:200
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:1063
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:545
static u8 * format_l2xcrw(u8 *s, va_list *args)
Definition: l2_xcrw.c:501
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:190
unformat_function_t unformat_hex_string
Definition: format.h:287
#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:283
clib_error_t * l2_xcrw_init(vlib_main_t *vm)
Definition: l2_xcrw.c:261
#define clib_warning(format, args...)
Definition: error.h:59
format_function_t format_vlib_next_node_name
Definition: node_funcs.h:1105
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:977
u32 set_int_l2_mode(vlib_main_t *vm, vnet_main_t *vnet_main, u32 mode, u32 sw_if_index, u32 bd_index, u32 bvi, u32 shg, u32 xc_sw_if_index)
Set the subinterface to run in l2 or l3 mode.
Definition: l2_input.c:555
u32 l2_sw_if_index
Definition: l2_xcrw.h:40
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
l2_xcrw_tunnel_t * tunnels
Definition: l2_xcrw.h:55
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:111
vlib_error_main_t error_main
Definition: main.h:124
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
#define PREDICT_FALSE(x)
Definition: clib.h:97
vnet_main_t vnet_main
Definition: misc.c:43
vnet_main_t * vnet_main
Definition: l2_xcrw.h:62
#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:216
#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:350
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
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:329
uword * fib_index_by_table_id
Definition: ip6.h:148
u64 * counters
Definition: error.h:78
u16 n_vectors
Definition: node.h:344
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
#define foreach_l2_xcrw_error
Definition: l2_xcrw.h:71
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:203
#define ARRAY_LEN(x)
Definition: clib.h:59
l2_xcrw_next_t
Definition: l2_xcrw.h:65
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
#define hash_create(elts, value_bytes)
Definition: hash.h:658
u16 cached_next_index
Definition: node.h:463
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:490
unsigned int u32
Definition: types.h:88
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
#define vnet_buffer(b)
Definition: buffer.h:333
ip6_main_t ip6_main
Definition: ip6_forward.c:2655
static u8 * format_l2_xcrw_trace(u8 *s, va_list *args)
Definition: l2_xcrw.c:49
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:205
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:259
#define MODE_L2_XC
Definition: l2_input.h:220
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:95
VNET_DEVICE_CLASS(xcrw_device_class, static)
u64 uword
Definition: types.h:112
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
Definition: defs.h:47
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:253
static vlib_node_registration_t l2_xcrw_node
(constructor) VLIB_REGISTER_NODE (l2_xcrw_node)
Definition: l2_xcrw.c:62
static u32 create_xcrw_interface(vlib_main_t *vm)
Definition: l2_xcrw.c:299
unformat_function_t unformat_vlib_node
Definition: node_funcs.h:1110
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:166
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
u32 tunnel_sw_if_index
Definition: l2_xcrw.h:43
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1060
u8 data[0]
Packet data.
Definition: buffer.h:154
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:58
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:530
#define clib_error_return(e, args...)
Definition: error.h:111
struct _unformat_input_t unformat_input_t
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:85
l2_xcrw_adjacency_t * adj_by_sw_if_index
Definition: l2_xcrw.h:52
unformat_function_t unformat_line_input
Definition: format.h:281
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:69
Definition: defs.h:46
#define MODE_L3
Definition: l2_input.h:218
l2_xcrw_main_t l2_xcrw_main
Definition: l2_xcrw.c:60
uword * tunnel_index_by_l2_sw_if_index
Definition: l2_xcrw.h:58
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:399
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109