FD.io VPP  v21.06-3-gbb25fbf28
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 
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 */
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 */
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);
253  uword n_packets = frame->n_vectors;
254  punt_main_t *pm = &punt_main;
255  int i;
256 
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 
314  }
315  else if (PUNT_TYPE_EXCEPTION == pt)
316  {
318  }
319  else
320  c = NULL;
321 
322  if (PREDICT_FALSE (NULL == c))
323  {
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  {
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)
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
402 {
403  return punt_socket_inline (vm, node, from_frame, PUNT_TYPE_L4, AF_IP4);
404 }
405 
406 static uword
409 {
410  return punt_socket_inline (vm, node, from_frame, PUNT_TYPE_L4, AF_IP6);
411 }
412 
413 static uword
416 {
418  PUNT_TYPE_IP_PROTO, AF_IP4);
419 }
420 
421 static uword
424 {
426  PUNT_TYPE_IP_PROTO, AF_IP6);
427 }
428 
429 static uword
432 {
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 
549  switch (packetdesc.action)
550  {
551  case PUNT_L2:
552  vnet_buffer (b)->sw_if_index[VLIB_TX] = packetdesc.sw_if_index;
554  break;
555 
556  case PUNT_IP4_ROUTED:
557  vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index;
558  vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
560  break;
561 
562  case PUNT_IP6_ROUTED:
563  vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index;
564  vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
566  break;
567 
568  default:
569  error = PUNT_ERROR_ACTION;
570  vlib_buffer_free (vm, &bi, 1);
571  goto error;
572  }
573 
574  if (PREDICT_FALSE
575  (n_trace > 0
576  && vlib_trace_buffer (vm, node, next_index, b, 1 /* follow_chain */ )))
577  {
578  punt_trace_t *t;
579  vlib_set_trace_count (vm, node, --n_trace);
580  t = vlib_add_trace (vm, node, b, sizeof (*t));
581  t->sw_if_index = packetdesc.sw_if_index;
582  t->action = packetdesc.action;
583  }
584 
585  to_next[0] = bi;
586  to_next++;
587  n_left_to_next--;
588 
589  vlib_validate_buffer_enqueue_x1 (vm, node, next, to_next, n_left_to_next,
590  bi, next_index);
591  vlib_put_next_frame (vm, node, next, n_left_to_next);
592 
593  return 1;
594 
595 error:
596  vlib_put_next_frame (vm, node, next, n_left_to_next);
598  return 0;
599 }
600 
601 static uword
604 {
605  punt_main_t *pm = &punt_main;
606  u32 total_count = 0;
607  int i;
608 
609  for (i = 0; i < vec_len (pm->ready_fds); i++)
610  {
611  total_count += punt_socket_rx_fd (vm, node, pm->ready_fds[i]);
612  vec_del1 (pm->ready_fds, i);
613  }
614  return total_count;
615 }
616 
617 /* *INDENT-OFF* */
619 {
620  .function = punt_socket_rx,
621  .name = "punt-socket-rx",
623  .type = VLIB_NODE_TYPE_INPUT,
624  .state = VLIB_NODE_STATE_INTERRUPT,
625  .vector_size = 1,
626  .n_errors = PUNT_N_ERROR,
627  .error_strings = punt_error_strings,
628  .n_next_nodes = PUNT_SOCKET_RX_N_NEXT,
629  .next_nodes = {
630  [PUNT_SOCKET_RX_NEXT_INTERFACE_OUTPUT] = "interface-output",
631  [PUNT_SOCKET_RX_NEXT_IP4_LOOKUP] = "ip4-lookup",
632  [PUNT_SOCKET_RX_NEXT_IP6_LOOKUP] = "ip6-lookup",
633  },
634  .format_trace = format_punt_trace,
635 };
636 /* *INDENT-ON* */
637 
638 /*
639  * fd.io coding-style-patch-verification: ON
640  *
641  * Local Variables:
642  * eval: (c-set-style "gnu")
643  * End:
644  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
vlib.h
vlib_buffer_t::next_buffer
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:149
punt_socket_rx
static uword punt_socket_rx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: punt_node.c:602
udp_punt_trace_t
Definition: punt_node.c:219
vlib_buffer_free
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:982
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:492
punt_client_t
Definition: punt.h:133
format_udp_punt_trace
static u8 * format_udp_punt_trace(u8 *s, va_list *args)
Definition: punt_node.c:227
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
PUNT_SOCKET_RX_N_NEXT
@ PUNT_SOCKET_RX_N_NEXT
Definition: punt_node.c:61
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
punt_socket_rx_node
vlib_node_registration_t punt_socket_rx_node
(constructor) VLIB_REGISTER_NODE (punt_socket_rx_node)
Definition: punt_node.c:618
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
PUNT_SOCKET_RX_NEXT_IP4_LOOKUP
@ PUNT_SOCKET_RX_NEXT_IP4_LOOKUP
Definition: punt_node.c:59
next
u16 * next
Definition: nat44_ei_out2in.c:718
format_hex_bytes
u8 * format_hex_bytes(u8 *s, va_list *va)
Definition: std-formats.c:84
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
punt_socket_rx_fd
static uword punt_socket_rx_fd(vlib_main_t *vm, vlib_node_runtime_t *node, u32 fd)
Definition: punt_node.c:507
VLIB_NODE_TYPE_INPUT
@ VLIB_NODE_TYPE_INPUT
Definition: node.h:76
udp_punt_trace_t::packet_data
u8 packet_data[64]
Definition: punt_node.c:223
punt_client_exception_get
static_always_inline punt_client_t * punt_client_exception_get(vlib_punt_reason_t reason)
Definition: punt.h:221
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
AF_IP4
@ AF_IP4
Definition: ip_types.h:23
udp6_punt_socket
static uword udp6_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:407
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
PUNT_N_ERROR
@ PUNT_N_ERROR
Definition: punt_node.c:41
node_index
node node_index
Definition: interface_output.c:420
vlib_get_trace_count
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
Definition: trace_funcs.h:212
foreach_punt_next
#define foreach_punt_next
Definition: punt_node.c:44
from_frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
Definition: esp_encrypt.c:1328
format_punt_trace
static u8 * format_punt_trace(u8 *s, va_list *va)
Definition: punt_node.c:495
punt_trace_t::sw_if_index
u32 sw_if_index
Definition: punt_node.c:491
vlib_frame_t
Definition: node.h:372
punt_next_punt
#define punt_next_punt(is_ip4)
Definition: punt_node.c:64
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
punt_packetdesc_t
Definition: punt.h:124
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
error
Definition: cJSON.c:88
punt_client_ip_proto_get
static_always_inline punt_client_t * punt_client_ip_proto_get(ip_address_family_t af, ip_protocol_t proto)
Definition: punt.h:205
ip4_proto_punt_socket_node
vlib_node_registration_t ip4_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip4_proto_punt_socket_node)
Definition: punt_node.c:458
punt_main_t
Definition: punt.h:151
vlib_buffer_t::punt_reason
u32 punt_reason
Definition: buffer.h:158
punt_client_l4_get
static_always_inline punt_client_t * punt_client_l4_get(ip_address_family_t af, u16 port)
Definition: punt.h:185
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
vlib_buffer_advance
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:276
udp_punt_trace_t::is_midchain
u8 is_midchain
Definition: punt_node.c:222
punt_trace_t::action
enum punt_action_e action
Definition: punt_node.c:490
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
exception_punt_socket_node
vlib_node_registration_t exception_punt_socket_node
(constructor) VLIB_REGISTER_NODE (exception_punt_socket_node)
Definition: punt_node.c:477
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
ip6_proto_punt_socket
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
vlib_buffer_alloc
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:708
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
punt_thread_data_t_
Definition: punt.h:146
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
exception_punt_socket
static uword exception_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:430
punt_error.def
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
uword
u64 uword
Definition: types.h:112
udp4_punt_socket
static uword udp4_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt_node.c:400
ethernet_header_t
Definition: packet.h:52
punt_error_t
punt_error_t
Definition: punt_node.c:36
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:213
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
VLIB_NODE_FLAG_TRACE_SUPPORTED
#define VLIB_NODE_FLAG_TRACE_SUPPORTED
Definition: node.h:295
udp6_punt_node
vlib_node_registration_t udp6_punt_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_node)
Definition: punt_node.c:202
VLIB_NODE_FLAG_IS_DROP
#define VLIB_NODE_FLAG_IS_DROP
Definition: node.h:286
punt_main_t::ready_fds
u32 * ready_fds
Definition: punt.h:160
PUNT_N_NEXT
@ PUNT_N_NEXT
Definition: punt_node.c:53
PUNT_L2
@ PUNT_L2
Definition: punt.h:114
ip4_proto_punt_socket
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
vlib_set_trace_count
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
Definition: trace_funcs.h:226
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
punt_action_e
punt_action_e
Definition: punt.h:112
PUNT_IP4_ROUTED
@ PUNT_IP4_ROUTED
Definition: punt.h:115
punt_error_strings
static char * punt_error_strings[]
Definition: punt_node.c:123
PUNT_IP6_ROUTED
@ PUNT_IP6_ROUTED
Definition: punt.h:116
punt_client_t::caddr
struct sockaddr_un caddr
Definition: punt.h:136
vnet_main_t
Definition: vnet.h:76
punt_thread_data_t_::iovecs
struct iovec * iovecs
Definition: punt.h:148
vlib_validate_buffer_enqueue_x1
#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
size
u32 size
Definition: vhost_user.h:125
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
punt.h
Definitions for punt infrastructure.
punt_next_t
punt_next_t
Definition: punt_node.c:48
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:455
format
description fragment has unexpected format
Definition: map.api:433
punt_packetdesc_t::action
enum punt_action_e action
Definition: punt.h:127
format_get_indent
static u32 format_get_indent(u8 *s)
Definition: format.h:72
PUNT_SOCKET_RX_NEXT_IP6_LOOKUP
@ PUNT_SOCKET_RX_NEXT_IP6_LOOKUP
Definition: punt_node.c:60
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
vlib_buffer_get_default_data_size
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:122
ip.h
u32
unsigned int u32
Definition: types.h:88
punt_socket_rx_next_e
punt_socket_rx_next_e
Definition: punt_node.c:56
udp_header_t::dst_port
u16 dst_port
Definition: udp_packet.h:48
AF_IP6
@ AF_IP6
Definition: ip_types.h:24
udp4_punt_socket_node
vlib_node_registration_t udp4_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_socket_node)
Definition: punt_node.c:439
punt_type_t
enum punt_type_t_ punt_type_t
ip6_header_t
Definition: ip6_packet.h:294
ip_protocol_t
enum ip_protocol ip_protocol_t
vlib_main_t
Definition: main.h:102
punt_main_t::socket_fd
int socket_fd
Definition: punt.h:153
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
udp_punt_trace_t::client
punt_client_t client
Definition: punt_node.c:221
unix.h
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
ip
vl_api_address_t ip
Definition: l2.api:558
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
udp46_punt_inline
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
punt_packetdesc_t::sw_if_index
u32 sw_if_index
Definition: punt.h:126
punt_socket_inline
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
word
i64 word
Definition: types.h:111
PUNT_SOCKET_RX_NEXT_INTERFACE_OUTPUT
@ PUNT_SOCKET_RX_NEXT_INTERFACE_OUTPUT
Definition: punt_node.c:58
punt_main_t::thread_data
punt_thread_data_t * thread_data
Definition: punt.h:162
udp4_punt_node
vlib_node_registration_t udp4_punt_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_node)
Definition: punt_node.c:186
vlib_node_runtime_t
Definition: node.h:454
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
vlib_trace_buffer
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:153
punt_trace_t
Definition: punt_node.c:488
punt_trace_t
struct punt_trace_t_ punt_trace_t
from
from
Definition: nat44_ei_hairpinning.c:415
udp6_punt_socket_node
vlib_node_registration_t udp6_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_socket_node)
Definition: punt_node.c:449
action
vl_api_mac_event_action_t action
Definition: l2.api:211
vlib_get_next_frame
#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:395
ip6_proto_punt_socket_node
vlib_node_registration_t ip6_proto_punt_socket_node
(constructor) VLIB_REGISTER_NODE (ip6_proto_punt_socket_node)
Definition: punt_node.c:468
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
punt_main
punt_main_t punt_main
Definition: punt.c:38
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
vec_del1
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:896
format_white_space
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
ip_address_family_t
enum ip_address_family_t_ ip_address_family_t
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169