FD.io VPP  v21.01.1
Vector Packet Processing
punt_node.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 
16 /**
17  * @file
18  * @brief Local TCP/IP stack punt infrastructure.
19  *
20  * Provides a set of VPP nodes together with the relevant APIs and CLI
21  * commands in order to adjust and dispatch packets from the VPP data plane
22  * to the local TCP/IP stack
23  */
24 
25 #include <vnet/ip/ip.h>
26 #include <vlib/vlib.h>
27 #include <vnet/ip/punt.h>
28 #include <vlib/unix/unix.h>
29 
30 #include <stdio.h>
31 #include <unistd.h>
32 #include <sys/socket.h>
33 #include <sys/uio.h>
34 #include <stdlib.h>
35 
36 typedef enum
37 {
38 #define punt_error(n,s) PUNT_ERROR_##n,
39 #include <vnet/ip/punt_error.def>
40 #undef punt_error
42 } punt_error_t;
43 
44 #define foreach_punt_next \
45  _ (PUNT4, "ip4-punt") \
46  _ (PUNT6, "ip6-punt")
47 
48 typedef enum
49 {
50 #define _(s,n) PUNT_NEXT_##s,
52 #undef _
54 } punt_next_t;
55 
57 {
62 };
63 
64 #define punt_next_punt(is_ip4) (is_ip4 ? PUNT_NEXT_PUNT4 : PUNT_NEXT_PUNT6)
65 
66 /** @brief IPv4/IPv6 UDP punt node main loop.
67 
68  This is the main loop inline function for IPv4/IPv6 UDP punt
69  transition node.
70 
71  @param vm vlib_main_t corresponding to the current thread
72  @param node vlib_node_runtime_t
73  @param frame vlib_frame_t whose contents should be dispatched
74  @param is_ipv4 indicates if called for IPv4 or IPv6 node
75 */
79  vlib_frame_t * from_frame, int is_ip4)
80 {
81  u32 n_left_from, *from, *to_next;
82  word advance;
83 
84  from = vlib_frame_vector_args (from_frame);
85  n_left_from = from_frame->n_vectors;
86 
87  /* udp[46]_lookup hands us the data payload, not the IP header */
88  if (is_ip4)
89  advance = -(sizeof (ip4_header_t) + sizeof (udp_header_t));
90  else
91  advance = -(sizeof (ip6_header_t) + sizeof (udp_header_t));
92 
93  while (n_left_from > 0)
94  {
95  u32 n_left_to_next;
96 
97  vlib_get_next_frame (vm, node, punt_next_punt (is_ip4), to_next,
98  n_left_to_next);
99 
100  while (n_left_from > 0 && n_left_to_next > 0)
101  {
102  u32 bi0;
103  vlib_buffer_t *b0;
104 
105  bi0 = from[0];
106  to_next[0] = bi0;
107  from += 1;
108  to_next += 1;
109  n_left_from -= 1;
110  n_left_to_next -= 1;
111 
112  b0 = vlib_get_buffer (vm, bi0);
113  vlib_buffer_advance (b0, advance);
114  b0->error = node->errors[PUNT_ERROR_UDP_PORT];
115  }
116 
117  vlib_put_next_frame (vm, node, punt_next_punt (is_ip4), n_left_to_next);
118  }
119 
120  return from_frame->n_vectors;
121 }
122 
123 static char *punt_error_strings[] = {
124 #define punt_error(n,s) s,
125 #include "punt_error.def"
126 #undef punt_error
127 };
128 
129 /** @brief IPv4 UDP punt node.
130  @node ip4-udp-punt
131 
132  This is the IPv4 UDP punt transition node. It is registered as a next
133  node for the "ip4-udp-lookup" handling UDP port(s) requested for punt.
134  The buffer's current data pointer is adjusted to the original packet
135  IPv4 header. All buffers are dispatched to "error-punt".
136 
137  @param vm vlib_main_t corresponding to the current thread
138  @param node vlib_node_runtime_t
139  @param frame vlib_frame_t whose contents should be dispatched
140 
141  @par Graph mechanics: next index usage
142 
143  @em Sets:
144  - <code>vnet_buffer(b)->current_data</code>
145  - <code>vnet_buffer(b)->current_len</code>
146 
147  <em>Next Index:</em>
148  - Dispatches the packet to the "error-punt" node
149 */
152  vlib_frame_t * from_frame)
153 {
154  return udp46_punt_inline (vm, node, from_frame, 1 /* is_ip4 */ );
155 }
156 
157 /** @brief IPv6 UDP punt node.
158  @node ip6-udp-punt
159 
160  This is the IPv6 UDP punt transition node. It is registered as a next
161  node for the "ip6-udp-lookup" handling UDP port(s) requested for punt.
162  The buffer's current data pointer is adjusted to the original packet
163  IPv6 header. All buffers are dispatched to "error-punt".
164 
165  @param vm vlib_main_t corresponding to the current thread
166  @param node vlib_node_runtime_t
167  @param frame vlib_frame_t whose contents should be dispatched
168 
169  @par Graph mechanics: next index usage
170 
171  @em Sets:
172  - <code>vnet_buffer(b)->current_data</code>
173  - <code>vnet_buffer(b)->current_len</code>
174 
175  <em>Next Index:</em>
176  - Dispatches the packet to the "error-punt" node
177 */
180  vlib_frame_t * from_frame)
181 {
182  return udp46_punt_inline (vm, node, from_frame, 0 /* is_ip4 */ );
183 }
184 
185 /* *INDENT-OFF* */
187  .name = "ip4-udp-punt",
188  /* Takes a vector of packets. */
189  .vector_size = sizeof (u32),
190 
191  .n_errors = PUNT_N_ERROR,
192  .error_strings = punt_error_strings,
193 
194  .n_next_nodes = PUNT_N_NEXT,
195  .next_nodes = {
196 #define _(s,n) [PUNT_NEXT_##s] = n,
198 #undef _
199  },
200 };
201 
203  .name = "ip6-udp-punt",
204  /* Takes a vector of packets. */
205  .vector_size = sizeof (u32),
206 
207  .n_errors = PUNT_N_ERROR,
208  .error_strings = punt_error_strings,
209 
210  .n_next_nodes = PUNT_N_NEXT,
211  .next_nodes = {
212 #define _(s,n) [PUNT_NEXT_##s] = n,
214 #undef _
215  },
216 };
217 /* *INDENT-ON* */
218 
219 typedef struct
220 {
223  u8 packet_data[64];
225 
226 static u8 *
227 format_udp_punt_trace (u8 * s, va_list * args)
228 {
229  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
230  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
231  udp_punt_trace_t *t = va_arg (*args, udp_punt_trace_t *);
232  u32 indent = format_get_indent (s);
233  s = format (s, "to: %s", t->client.caddr.sun_path);
234  if (t->is_midchain)
235  {
236  s = format (s, "\n%U(buffer is part of chain)", format_white_space,
237  indent);
238  }
239  s = format (s, "\n%U%U", format_white_space, indent,
240  format_hex_bytes, t->packet_data, sizeof (t->packet_data));
241 
242  return s;
243 }
244 
250 {
251  u32 *buffers = vlib_frame_vector_args (frame);
252  u32 thread_index = vm->thread_index;
253  uword n_packets = frame->n_vectors;
254  punt_main_t *pm = &punt_main;
255  int i;
256 
257  punt_thread_data_t *ptd = &pm->thread_data[thread_index];
258  u32 node_index = (AF_IP4 == af ?
259  udp4_punt_socket_node.index :
260  udp6_punt_socket_node.index);
261 
262  for (i = 0; i < n_packets; i++)
263  {
264  struct iovec *iov;
265  vlib_buffer_t *b;
266  uword l;
267  punt_packetdesc_t packetdesc;
268  punt_client_t *c;
269 
270  b = vlib_get_buffer (vm, buffers[i]);
271 
272  if (PUNT_TYPE_L4 == pt)
273  {
274  /* Reverse UDP Punt advance */
275  udp_header_t *udp;
276  if (AF_IP4 == af)
277  {
278  vlib_buffer_advance (b, -(sizeof (ip4_header_t) +
279  sizeof (udp_header_t)));
281  udp = (udp_header_t *) (ip + 1);
282  }
283  else
284  {
285  vlib_buffer_advance (b, -(sizeof (ip6_header_t) +
286  sizeof (udp_header_t)));
288  udp = (udp_header_t *) (ip + 1);
289  }
290 
291  /*
292  * Find registerered client
293  * If no registered client, drop packet and count
294  */
295  c = punt_client_l4_get (af, clib_net_to_host_u16 (udp->dst_port));
296  }
297  else if (PUNT_TYPE_IP_PROTO == pt)
298  {
299  /* Reverse UDP Punt advance */
301 
302  if (AF_IP4 == af)
303  {
305  proto = ip->protocol;
306  }
307  else
308  {
310  proto = ip->protocol;
311  }
312 
313  c = punt_client_ip_proto_get (af, proto);
314  }
315  else if (PUNT_TYPE_EXCEPTION == pt)
316  {
318  }
319  else
320  c = NULL;
321 
322  if (PREDICT_FALSE (NULL == c))
323  {
324  vlib_node_increment_counter (vm, node_index,
325  PUNT_ERROR_SOCKET_TX_ERROR, 1);
326  goto error;
327  }
328 
329  struct sockaddr_un *caddr = &c->caddr;
330 
331  /* Re-set iovecs */
332  vec_reset_length (ptd->iovecs);
333 
334  /* Add packet descriptor */
335  packetdesc.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
336  packetdesc.action = 0;
337  vec_add2 (ptd->iovecs, iov, 1);
338  iov->iov_base = &packetdesc;
339  iov->iov_len = sizeof (packetdesc);
340 
341  /** VLIB buffer chain -> Unix iovec(s). */
342  vlib_buffer_advance (b, -(sizeof (ethernet_header_t)));
343  vec_add2 (ptd->iovecs, iov, 1);
344  iov->iov_base = b->data + b->current_data;
345  iov->iov_len = l = b->current_length;
346 
347  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
348  {
349  udp_punt_trace_t *t;
350  t = vlib_add_trace (vm, node, b, sizeof (t[0]));
351  clib_memcpy_fast (&t->client, c, sizeof (t->client));
354  sizeof (t->packet_data));
355  }
356 
357  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NEXT_PRESENT))
358  {
359  do
360  {
361  b = vlib_get_buffer (vm, b->next_buffer);
362  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
363  {
364  udp_punt_trace_t *t;
365  t = vlib_add_trace (vm, node, b, sizeof (t[0]));
366  clib_memcpy_fast (&t->client, c, sizeof (t->client));
367  t->is_midchain = 1;
368  }
369 
370  vec_add2 (ptd->iovecs, iov, 1);
371 
372  iov->iov_base = b->data + b->current_data;
373  iov->iov_len = b->current_length;
374  l += b->current_length;
375  }
376  while (b->flags & VLIB_BUFFER_NEXT_PRESENT);
377  }
378 
379  struct msghdr msg = {
380  .msg_name = caddr,
381  .msg_namelen = sizeof (*caddr),
382  .msg_iov = ptd->iovecs,
383  .msg_iovlen = vec_len (ptd->iovecs),
384  };
385 
386  if (sendmsg (pm->socket_fd, &msg, 0) < (ssize_t) l)
387  vlib_node_increment_counter (vm, node_index,
388  PUNT_ERROR_SOCKET_TX_ERROR, 1);
389  else
390  vlib_node_increment_counter (vm, node_index, PUNT_ERROR_SOCKET_TX, 1);
391  }
392 
393 error:
394  vlib_buffer_free (vm, buffers, n_packets);
395 
396  return n_packets;
397 }
398 
399 static uword
401  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
402 {
403  return punt_socket_inline (vm, node, from_frame, PUNT_TYPE_L4, AF_IP4);
404 }
405 
406 static uword
408  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
409 {
410  return punt_socket_inline (vm, node, from_frame, PUNT_TYPE_L4, AF_IP6);
411 }
412 
413 static uword
415  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
416 {
417  return punt_socket_inline (vm, node, from_frame,
418  PUNT_TYPE_IP_PROTO, AF_IP4);
419 }
420 
421 static uword
423  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
424 {
425  return punt_socket_inline (vm, node, from_frame,
426  PUNT_TYPE_IP_PROTO, AF_IP6);
427 }
428 
429 static uword
431  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
432 {
433  return punt_socket_inline (vm, node, from_frame,
434  PUNT_TYPE_EXCEPTION, AF_IP4);
435 }
436 
437 
438 /* *INDENT-OFF* */
440  .function = udp4_punt_socket,
441  .name = "ip4-udp-punt-socket",
442  .format_trace = format_udp_punt_trace,
443  .flags = VLIB_NODE_FLAG_IS_DROP,
444  /* Takes a vector of packets. */
445  .vector_size = sizeof (u32),
446  .n_errors = PUNT_N_ERROR,
447  .error_strings = punt_error_strings,
448 };
450  .function = udp6_punt_socket,
451  .name = "ip6-udp-punt-socket",
452  .format_trace = format_udp_punt_trace,
453  .flags = VLIB_NODE_FLAG_IS_DROP,
454  .vector_size = sizeof (u32),
455  .n_errors = PUNT_N_ERROR,
456  .error_strings = punt_error_strings,
457 };
459  .function = ip4_proto_punt_socket,
460  .name = "ip4-proto-punt-socket",
461  .format_trace = format_udp_punt_trace,
462  .flags = VLIB_NODE_FLAG_IS_DROP,
463  /* Takes a vector of packets. */
464  .vector_size = sizeof (u32),
465  .n_errors = PUNT_N_ERROR,
466  .error_strings = punt_error_strings,
467 };
469  .function = ip6_proto_punt_socket,
470  .name = "ip6-proto-punt-socket",
471  .format_trace = format_udp_punt_trace,
472  .flags = VLIB_NODE_FLAG_IS_DROP,
473  .vector_size = sizeof (u32),
474  .n_errors = PUNT_N_ERROR,
475  .error_strings = punt_error_strings,
476 };
478  .function = exception_punt_socket,
479  .name = "exception-punt-socket",
480  .format_trace = format_udp_punt_trace,
481  .flags = VLIB_NODE_FLAG_IS_DROP,
482  .vector_size = sizeof (u32),
483  .n_errors = PUNT_N_ERROR,
484  .error_strings = punt_error_strings,
485 };
486 /* *INDENT-ON* */
487 
488 typedef struct
489 {
492 } punt_trace_t;
493 
494 static u8 *
495 format_punt_trace (u8 * s, va_list * va)
496 {
497  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
498  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
499  vnet_main_t *vnm = vnet_get_main ();
500  punt_trace_t *t = va_arg (*va, punt_trace_t *);
501  s = format (s, "%U Action: %d", format_vnet_sw_if_index_name,
502  vnm, t->sw_if_index, t->action);
503  return s;
504 }
505 
506 static uword
508 {
509  const uword buffer_size = vlib_buffer_get_default_data_size (vm);
510  u32 n_trace = vlib_get_trace_count (vm, node);
511  u32 next = node->cached_next_index;
512  u32 n_left_to_next, next_index;
513  u32 *to_next;
514  u32 error = PUNT_ERROR_NONE;
515  vlib_get_next_frame (vm, node, next, to_next, n_left_to_next);
516 
517  /* $$$$ Only dealing with one buffer at the time for now */
518 
519  u32 bi;
520  vlib_buffer_t *b;
521  punt_packetdesc_t packetdesc;
522  ssize_t size;
523  struct iovec io[2];
524 
525  if (vlib_buffer_alloc (vm, &bi, 1) != 1)
526  {
527  error = PUNT_ERROR_NOBUFFER;
528  goto error;
529  }
530 
531  b = vlib_get_buffer (vm, bi);
532  io[0].iov_base = &packetdesc;
533  io[0].iov_len = sizeof (packetdesc);
534  io[1].iov_base = b->data;
535  io[1].iov_len = buffer_size;
536 
537  size = readv (fd, io, 2);
538  /* We need at least the packet descriptor plus a header */
539  if (size <= (int) (sizeof (packetdesc) + sizeof (ip4_header_t)))
540  {
541  vlib_buffer_free (vm, &bi, 1);
542  error = PUNT_ERROR_READV;
543  goto error;
544  }
545 
546  b->flags = VNET_BUFFER_F_LOCALLY_ORIGINATED;
547  b->current_length = size - sizeof (packetdesc);
548 
550 
551  switch (packetdesc.action)
552  {
553  case PUNT_L2:
554  vnet_buffer (b)->sw_if_index[VLIB_TX] = packetdesc.sw_if_index;
556  break;
557 
558  case PUNT_IP4_ROUTED:
559  vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index;
560  vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
561  next_index = PUNT_SOCKET_RX_NEXT_IP4_LOOKUP;
562  break;
563 
564  case PUNT_IP6_ROUTED:
565  vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index;
566  vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
567  next_index = PUNT_SOCKET_RX_NEXT_IP6_LOOKUP;
568  break;
569 
570  default:
571  error = PUNT_ERROR_ACTION;
572  vlib_buffer_free (vm, &bi, 1);
573  goto error;
574  }
575 
576  if (PREDICT_FALSE
577  (n_trace > 0
578  && vlib_trace_buffer (vm, node, next_index, b, 1 /* follow_chain */ )))
579  {
580  punt_trace_t *t;
581  vlib_set_trace_count (vm, node, --n_trace);
582  t = vlib_add_trace (vm, node, b, sizeof (*t));
583  t->sw_if_index = packetdesc.sw_if_index;
584  t->action = packetdesc.action;
585  }
586 
587  to_next[0] = bi;
588  to_next++;
589  n_left_to_next--;
590 
591  vlib_validate_buffer_enqueue_x1 (vm, node, next, to_next, n_left_to_next,
592  bi, next_index);
593  vlib_put_next_frame (vm, node, next, n_left_to_next);
594 
595  return 1;
596 
597 error:
598  vlib_put_next_frame (vm, node, next, n_left_to_next);
599  vlib_node_increment_counter (vm, punt_socket_rx_node.index, error, 1);
600  return 0;
601 }
602 
603 static uword
606 {
607  punt_main_t *pm = &punt_main;
608  u32 total_count = 0;
609  int i;
610 
611  for (i = 0; i < vec_len (pm->ready_fds); i++)
612  {
613  total_count += punt_socket_rx_fd (vm, node, pm->ready_fds[i]);
614  vec_del1 (pm->ready_fds, i);
615  }
616  return total_count;
617 }
618 
619 /* *INDENT-OFF* */
621 {
622  .function = punt_socket_rx,
623  .name = "punt-socket-rx",
625  .type = VLIB_NODE_TYPE_INPUT,
626  .state = VLIB_NODE_STATE_INTERRUPT,
627  .vector_size = 1,
628  .n_errors = PUNT_N_ERROR,
629  .error_strings = punt_error_strings,
630  .n_next_nodes = PUNT_SOCKET_RX_N_NEXT,
631  .next_nodes = {
632  [PUNT_SOCKET_RX_NEXT_INTERFACE_OUTPUT] = "interface-output",
633  [PUNT_SOCKET_RX_NEXT_IP4_LOOKUP] = "ip4-lookup",
634  [PUNT_SOCKET_RX_NEXT_IP6_LOOKUP] = "ip6-lookup",
635  },
636  .format_trace = format_punt_trace,
637 };
638 /* *INDENT-ON* */
639 
640 /*
641  * fd.io coding-style-patch-verification: ON
642  *
643  * Local Variables:
644  * eval: (c-set-style "gnu")
645  * End:
646  */
vlib_node_registration_t udp6_punt_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_node)
Definition: punt_node.c:202
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
enum punt_type_t_ punt_type_t
#define CLIB_UNUSED(x)
Definition: clib.h:87
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
Definition: trace_funcs.h:201
static uword punt_socket_rx_fd(vlib_main_t *vm, vlib_node_runtime_t *node, u32 fd)
Definition: punt_node.c:507
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:937
Definition: punt.h:82
#define punt_next_punt(is_ip4)
Definition: punt_node.c:64
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
vlib_node_registration_t udp4_punt_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_node)
Definition: punt_node.c:186
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 VLIB_NODE_FLAG_TRACE_SUPPORTED
Definition: node.h:306
static uword udp46_punt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip4)
IPv4/IPv6 UDP punt node main loop.
Definition: punt_node.c:77
u32 * ready_fds
Definition: punt.h:128
u32 thread_index
Definition: main.h:250
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
vlib_node_registration_t ip4_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip4_proto_punt_socket_node)
Definition: punt_node.c:458
static_always_inline punt_client_t * punt_client_l4_get(ip_address_family_t af, u16 port)
Definition: punt.h:151
u8 packet_data[64]
Definition: punt_node.c:223
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:630
int socket_fd
Definition: punt.h:121
static u32 format_get_indent(u8 *s)
Definition: format.h:72
vlib_main_t * vm
Definition: in2out_ed.c:1580
static_always_inline punt_client_t * punt_client_ip_proto_get(ip_address_family_t af, ip_protocol_t proto)
Definition: punt.h:171
#define VLIB_NODE_FN(node)
Definition: node.h:203
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:470
static uword punt_socket_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, punt_type_t pt, ip_address_family_t af)
Definition: punt_node.c:246
format_function_t format_vnet_sw_if_index_name
unsigned char u8
Definition: types.h:56
enum punt_action_e action
Definition: punt.h:95
punt_thread_data_t * thread_data
Definition: punt.h:130
punt_socket_rx_next_e
Definition: punt_node.c:56
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static uword ip4_proto_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:414
static char * punt_error_strings[]
Definition: punt_node.c:123
i64 word
Definition: types.h:111
struct punt_trace_t_ punt_trace_t
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
description fragment has unexpected format
Definition: map.api:433
u8 * format_hex_bytes(u8 *s, va_list *va)
Definition: std-formats.c:84
const cJSON *const b
Definition: cJSON.h:255
static_always_inline punt_client_t * punt_client_exception_get(vlib_punt_reason_t reason)
Definition: punt.h:187
unsigned int u32
Definition: types.h:88
struct iovec * iovecs
Definition: punt.h:116
static u8 * format_punt_trace(u8 *s, va_list *va)
Definition: punt_node.c:495
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:136
enum ip_protocol ip_protocol_t
Definition: cJSON.c:84
vl_api_ip_proto_t proto
Definition: acl_types.api:51
vlib_node_registration_t punt_socket_rx_node
(constructor) VLIB_REGISTER_NODE (punt_socket_rx_node)
Definition: punt_node.c:620
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:677
static __clib_warn_unused_result int vlib_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, vlib_buffer_t *b, int follow_chain)
Definition: trace_funcs.h:142
vlib_node_registration_t ip6_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip6_proto_punt_socket_node)
Definition: punt_node.c:468
u32 size
Definition: vhost_user.h:106
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:233
#define PREDICT_FALSE(x)
Definition: clib.h:121
#define always_inline
Definition: ipsec.h:28
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:875
static u8 * format_udp_punt_trace(u8 *s, va_list *args)
Definition: punt_node.c:227
#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
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1231
u32 punt_reason
Definition: buffer.h:149
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:96
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:170
#define foreach_punt_next
Definition: punt_node.c:44
svmdb_client_t * c
u16 n_vectors
Definition: node.h:397
u32 sw_if_index
Definition: punt.h:94
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
u8 data[]
Packet data.
Definition: buffer.h:181
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_node_registration_t udp6_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_socket_node)
Definition: punt_node.c:449
enum punt_action_e action
Definition: punt_node.c:490
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1580
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:511
punt_main_t punt_main
Definition: punt.c:38
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:252
static uword udp4_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:400
static uword ip6_proto_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:422
punt_action_e
Definition: punt.h:80
punt_next_t
Definition: punt_node.c:48
enum ip_address_family_t_ ip_address_family_t
Definition: defs.h:47
punt_client_t client
Definition: punt_node.c:221
vl_api_address_t ip
Definition: l2.api:501
vlib_node_registration_t exception_punt_socket_node
(constructor) VLIB_REGISTER_NODE (exception_punt_socket_node)
Definition: punt_node.c:477
punt_error_t
Definition: punt_node.c:36
vl_api_mac_event_action_t action
Definition: l2.api:181
static uword exception_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:430
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:140
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: in2out_ed.c:1581
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
Definition: buffer.h:497
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:297
#define VLIB_NODE_FLAG_IS_DROP
Definition: node.h:297
static uword punt_socket_rx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: punt_node.c:604
#define vnet_buffer(b)
Definition: buffer.h:417
u32 sw_if_index
Definition: punt_node.c:491
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
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
Definition: trace_funcs.h:215
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
vlib_node_registration_t udp4_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_socket_node)
Definition: punt_node.c:439
struct sockaddr_un caddr
Definition: punt.h:104
Definition: defs.h:46
Definitions for punt infrastructure.
static uword udp6_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:407