FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
punt.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/pg/pg.h>
28 #include <vnet/udp/udp.h>
29 #include <vnet/tcp/tcp.h>
30 #include <vnet/sctp/sctp.h>
31 #include <vnet/ip/punt.h>
32 #include <vppinfra/sparse_vec.h>
33 #include <vlib/unix/unix.h>
34 
35 #include <stdio.h>
36 #include <unistd.h>
37 #include <sys/socket.h>
38 #include <sys/uio.h>
39 #include <stdlib.h>
40 
41 #define foreach_punt_next \
42  _ (PUNT4, "ip4-punt") \
43  _ (PUNT6, "ip6-punt")
44 
45 typedef enum
46 {
47 #define _(s,n) PUNT_NEXT_##s,
49 #undef _
51 } punt_next_t;
52 
54 {
59 };
60 
61 #define punt_next_punt(is_ip4) (is_ip4 ? PUNT_NEXT_PUNT4 : PUNT_NEXT_PUNT6)
62 
68 
69 extern punt_main_t punt_main;
70 
71 #ifndef CLIB_MARCH_VARIANT
73 
74 char *
76 {
77  punt_main_t *pm = &punt_main;
78  return pm->sun_path;
79 }
80 #endif /* CLIB_MARCH_VARIANT */
81 
82 /** @brief IPv4/IPv6 UDP punt node main loop.
83 
84  This is the main loop inline function for IPv4/IPv6 UDP punt
85  transition node.
86 
87  @param vm vlib_main_t corresponding to the current thread
88  @param node vlib_node_runtime_t
89  @param frame vlib_frame_t whose contents should be dispatched
90  @param is_ipv4 indicates if called for IPv4 or IPv6 node
91 */
94  vlib_node_runtime_t * node,
95  vlib_frame_t * from_frame, int is_ip4)
96 {
97  u32 n_left_from, *from, *to_next;
98  word advance;
99 
100  from = vlib_frame_vector_args (from_frame);
101  n_left_from = from_frame->n_vectors;
102 
103  /* udp[46]_lookup hands us the data payload, not the IP header */
104  if (is_ip4)
105  advance = -(sizeof (ip4_header_t) + sizeof (udp_header_t));
106  else
107  advance = -(sizeof (ip6_header_t) + sizeof (udp_header_t));
108 
109  while (n_left_from > 0)
110  {
111  u32 n_left_to_next;
112 
113  vlib_get_next_frame (vm, node, punt_next_punt (is_ip4), to_next,
114  n_left_to_next);
115 
116  while (n_left_from > 0 && n_left_to_next > 0)
117  {
118  u32 bi0;
119  vlib_buffer_t *b0;
120 
121  bi0 = from[0];
122  to_next[0] = bi0;
123  from += 1;
124  to_next += 1;
125  n_left_from -= 1;
126  n_left_to_next -= 1;
127 
128  b0 = vlib_get_buffer (vm, bi0);
129  vlib_buffer_advance (b0, advance);
130  b0->error = node->errors[PUNT_ERROR_UDP_PORT];
131  }
132 
133  vlib_put_next_frame (vm, node, punt_next_punt (is_ip4), n_left_to_next);
134  }
135 
136  return from_frame->n_vectors;
137 }
138 
139 static char *punt_error_strings[] = {
140 #define punt_error(n,s) s,
141 #include "punt_error.def"
142 #undef punt_error
143 };
144 
145 /** @brief IPv4 UDP punt node.
146  @node ip4-udp-punt
147 
148  This is the IPv4 UDP punt transition node. It is registered as a next
149  node for the "ip4-udp-lookup" handling UDP port(s) requested for punt.
150  The buffer's current data pointer is adjusted to the original packet
151  IPv4 header. All buffers are dispatched to "error-punt".
152 
153  @param vm vlib_main_t corresponding to the current thread
154  @param node vlib_node_runtime_t
155  @param frame vlib_frame_t whose contents should be dispatched
156 
157  @par Graph mechanics: next index usage
158 
159  @em Sets:
160  - <code>vnet_buffer(b)->current_data</code>
161  - <code>vnet_buffer(b)->current_len</code>
162 
163  <em>Next Index:</em>
164  - Dispatches the packet to the "error-punt" node
165 */
167  vlib_node_runtime_t * node,
168  vlib_frame_t * from_frame)
169 {
170  return udp46_punt_inline (vm, node, from_frame, 1 /* is_ip4 */ );
171 }
172 
173 /** @brief IPv6 UDP punt node.
174  @node ip6-udp-punt
175 
176  This is the IPv6 UDP punt transition node. It is registered as a next
177  node for the "ip6-udp-lookup" handling UDP port(s) requested for punt.
178  The buffer's current data pointer is adjusted to the original packet
179  IPv6 header. All buffers are dispatched to "error-punt".
180 
181  @param vm vlib_main_t corresponding to the current thread
182  @param node vlib_node_runtime_t
183  @param frame vlib_frame_t whose contents should be dispatched
184 
185  @par Graph mechanics: next index usage
186 
187  @em Sets:
188  - <code>vnet_buffer(b)->current_data</code>
189  - <code>vnet_buffer(b)->current_len</code>
190 
191  <em>Next Index:</em>
192  - Dispatches the packet to the "error-punt" node
193 */
195  vlib_node_runtime_t * node,
196  vlib_frame_t * from_frame)
197 {
198  return udp46_punt_inline (vm, node, from_frame, 0 /* is_ip4 */ );
199 }
200 
201 /* *INDENT-OFF* */
203  .name = "ip4-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 
219  .name = "ip6-udp-punt",
220  /* Takes a vector of packets. */
221  .vector_size = sizeof (u32),
222 
223  .n_errors = PUNT_N_ERROR,
224  .error_strings = punt_error_strings,
225 
226  .n_next_nodes = PUNT_N_NEXT,
227  .next_nodes = {
228 #define _(s,n) [PUNT_NEXT_##s] = n,
230 #undef _
231  },
232 };
233 
234 /* *INDENT-ON* */
235 
236 static punt_client_t *
237 punt_client_get (bool is_ip4, u16 port)
238 {
239  punt_main_t *pm = &punt_main;
240  punt_client_t *v =
241  is_ip4 ? pm->clients_by_dst_port4 : pm->clients_by_dst_port6;
242 
243  u16 i = sparse_vec_index (v, port);
244  if (i == SPARSE_VEC_INVALID_INDEX)
245  return 0;
246 
247  return &vec_elt (v, i);
248 }
249 
250 static struct sockaddr_un *
251 punt_socket_get (bool is_ip4, u16 port)
252 {
253  punt_client_t *v = punt_client_get (is_ip4, port);
254  if (v)
255  return &v->caddr;
256 
257  return NULL;
258 }
259 
260 #ifndef CLIB_MARCH_VARIANT
261 static int
262 punt_socket_register (bool is_ip4, u8 protocol, u16 port,
263  char *client_pathname)
264 {
265  punt_main_t *pm = &punt_main;
266  punt_client_t c, *n;
267  punt_client_t *v = is_ip4 ? pm->clients_by_dst_port4 :
269 
270  if (strncmp (client_pathname, vnet_punt_get_server_pathname (),
271  UNIX_PATH_MAX) == 0)
272  return -1;
273 
274  clib_memset (&c, 0, sizeof (c));
275  memcpy (c.caddr.sun_path, client_pathname, sizeof (c.caddr.sun_path));
276  c.caddr.sun_family = AF_UNIX;
277  c.port = port;
278  c.protocol = protocol;
279  n = sparse_vec_validate (v, port);
280  n[0] = c;
281  return 0;
282 }
283 
284 /* $$$$ Just leaves the mapping in place for now */
285 static void
286 punt_socket_unregister (bool is_ip4, u8 protocol, u16 port)
287 {
288  return;
289 }
290 #endif /* CLIB_MARCH_VARIANT */
291 
292 typedef struct
293 {
297 
298 static u8 *
299 format_udp_punt_trace (u8 * s, va_list * args)
300 {
301  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
302  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
303  udp_punt_trace_t *t = va_arg (*args, udp_punt_trace_t *);
304  u32 indent = format_get_indent (s);
305  s = format (s, "to: %s", t->client.caddr.sun_path);
306  if (t->is_midchain)
307  {
308  s = format (s, "\n%U(buffer is part of chain)", format_white_space,
309  indent);
310  }
311  return s;
312 }
313 
316  vlib_node_runtime_t * node,
317  vlib_frame_t * frame, bool is_ip4)
318 {
319  u32 *buffers = vlib_frame_vector_args (frame);
320  u32 thread_index = vm->thread_index;
321  uword n_packets = frame->n_vectors;
322  punt_main_t *pm = &punt_main;
323  int i;
324 
325  punt_thread_data_t *ptd = &pm->thread_data[thread_index];
326  u32 node_index = is_ip4 ? udp4_punt_socket_node.index :
327  udp6_punt_socket_node.index;
328 
329  for (i = 0; i < n_packets; i++)
330  {
331  struct iovec *iov;
332  vlib_buffer_t *b;
333  uword l;
334  punt_packetdesc_t packetdesc;
335 
336  b = vlib_get_buffer (vm, buffers[i]);
337 
338  /* Reverse UDP Punt advance */
339  udp_header_t *udp;
340  if (is_ip4)
341  {
342  vlib_buffer_advance (b, -(sizeof (ip4_header_t) +
343  sizeof (udp_header_t)));
345  udp = (udp_header_t *) (ip + 1);
346  }
347  else
348  {
349  vlib_buffer_advance (b, -(sizeof (ip6_header_t) +
350  sizeof (udp_header_t)));
352  udp = (udp_header_t *) (ip + 1);
353  }
354 
355  u16 port = clib_net_to_host_u16 (udp->dst_port);
356 
357  /*
358  * Find registerered client
359  * If no registered client, drop packet and count
360  */
361  struct sockaddr_un *caddr;
362  caddr = punt_socket_get (is_ip4, port);
363  if (!caddr)
364  {
365  vlib_node_increment_counter (vm, node_index,
366  PUNT_ERROR_SOCKET_TX_ERROR, 1);
367  goto error;
368  }
369 
370  punt_client_t *c = NULL;
371  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
372  {
373  c = punt_client_get (is_ip4, port);
374  udp_punt_trace_t *t;
375  t = vlib_add_trace (vm, node, b, sizeof (t[0]));
376  clib_memcpy_fast (&t->client, c, sizeof (t->client));
377  }
378 
379  /* Re-set iovecs */
380  vec_reset_length (ptd->iovecs);
381 
382  /* Add packet descriptor */
383  packetdesc.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
384  packetdesc.action = 0;
385  vec_add2 (ptd->iovecs, iov, 1);
386  iov->iov_base = &packetdesc;
387  iov->iov_len = sizeof (packetdesc);
388 
389  /** VLIB buffer chain -> Unix iovec(s). */
390  vlib_buffer_advance (b, -(sizeof (ethernet_header_t)));
391  vec_add2 (ptd->iovecs, iov, 1);
392  iov->iov_base = b->data + b->current_data;
393  iov->iov_len = l = b->current_length;
394 
395  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NEXT_PRESENT))
396  {
397  do
398  {
399  b = vlib_get_buffer (vm, b->next_buffer);
400  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
401  {
402  if (PREDICT_FALSE (!c))
403  {
404  c = punt_client_get (is_ip4, port);
405  }
406  udp_punt_trace_t *t;
407  t = vlib_add_trace (vm, node, b, sizeof (t[0]));
408  clib_memcpy_fast (&t->client, c, sizeof (t->client));
409  t->is_midchain = 1;
410  }
411 
412  vec_add2 (ptd->iovecs, iov, 1);
413 
414  iov->iov_base = b->data + b->current_data;
415  iov->iov_len = b->current_length;
416  l += b->current_length;
417  }
418  while (b->flags & VLIB_BUFFER_NEXT_PRESENT);
419  }
420 
421  struct msghdr msg = {
422  .msg_name = caddr,
423  .msg_namelen = sizeof (*caddr),
424  .msg_iov = ptd->iovecs,
425  .msg_iovlen = vec_len (ptd->iovecs),
426  };
427 
428  if (sendmsg (pm->socket_fd, &msg, 0) < (ssize_t) l)
429  vlib_node_increment_counter (vm, node_index,
430  PUNT_ERROR_SOCKET_TX_ERROR, 1);
431  else
432  vlib_node_increment_counter (vm, node_index, PUNT_ERROR_SOCKET_TX, 1);
433 
434  }
435 
436 error:
437  vlib_buffer_free (vm, buffers, n_packets);
438 
439  return n_packets;
440 }
441 
442 static uword
444  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
445 {
446  return udp46_punt_socket_inline (vm, node, from_frame, true /* is_ip4 */ );
447 }
448 
449 static uword
451  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
452 {
453  return udp46_punt_socket_inline (vm, node, from_frame, false /* is_ip4 */ );
454 }
455 
456 
457 /* *INDENT-OFF* */
459  .function = udp4_punt_socket,
460  .name = "ip4-udp-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 = udp6_punt_socket,
470  .name = "ip6-udp-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 };
477 /* *INDENT-ON* */
478 
479 typedef struct
480 {
481  enum punt_action_e action;
483 } punt_trace_t;
484 
485 static u8 *
486 format_punt_trace (u8 * s, va_list * va)
487 {
488  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
489  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
490  vnet_main_t *vnm = vnet_get_main ();
491  punt_trace_t *t = va_arg (*va, punt_trace_t *);
492  s = format (s, "%U Action: %d", format_vnet_sw_if_index_name,
493  vnm, t->sw_if_index, t->action);
494  return s;
495 }
496 
497 static uword
499 {
500  const uword buffer_size = vlib_buffer_get_default_data_size (vm);
501  u32 n_trace = vlib_get_trace_count (vm, node);
502  u32 next = node->cached_next_index;
503  u32 n_left_to_next, next_index;
504  u32 *to_next;
505  u32 error = PUNT_ERROR_NONE;
506  vlib_get_next_frame (vm, node, next, to_next, n_left_to_next);
507 
508  /* $$$$ Only dealing with one buffer at the time for now */
509 
510  u32 bi;
511  vlib_buffer_t *b;
512  punt_packetdesc_t packetdesc;
513  ssize_t size;
514  struct iovec io[2];
515 
516  if (vlib_buffer_alloc (vm, &bi, 1) != 1)
517  {
518  error = PUNT_ERROR_NOBUFFER;
519  goto error;
520  }
521 
522  b = vlib_get_buffer (vm, bi);
523  io[0].iov_base = &packetdesc;
524  io[0].iov_len = sizeof (packetdesc);
525  io[1].iov_base = b->data;
526  io[1].iov_len = buffer_size;
527 
528  size = readv (fd, io, 2);
529  /* We need at least the packet descriptor plus a header */
530  if (size <= (int) (sizeof (packetdesc) + sizeof (ip4_header_t)))
531  {
532  vlib_buffer_free (vm, &bi, 1);
533  error = PUNT_ERROR_READV;
534  goto error;
535  }
536 
537  b->flags = VNET_BUFFER_F_LOCALLY_ORIGINATED;
538  b->current_length = size - sizeof (packetdesc);
539 
541 
542  switch (packetdesc.action)
543  {
544  case PUNT_L2:
545  vnet_buffer (b)->sw_if_index[VLIB_TX] = packetdesc.sw_if_index;
547  break;
548 
549  case PUNT_IP4_ROUTED:
550  vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index;
551  vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
552  next_index = PUNT_SOCKET_RX_NEXT_IP4_LOOKUP;
553  break;
554 
555  case PUNT_IP6_ROUTED:
556  vnet_buffer (b)->sw_if_index[VLIB_RX] = packetdesc.sw_if_index;
557  vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
558  next_index = PUNT_SOCKET_RX_NEXT_IP6_LOOKUP;
559  break;
560 
561  default:
562  error = PUNT_ERROR_ACTION;
563  vlib_buffer_free (vm, &bi, 1);
564  goto error;
565  }
566 
567  if (PREDICT_FALSE (n_trace > 0))
568  {
569  punt_trace_t *t;
570  vlib_trace_buffer (vm, node, next_index, b, 1 /* follow_chain */ );
571  vlib_set_trace_count (vm, node, --n_trace);
572  t = vlib_add_trace (vm, node, b, sizeof (*t));
573  t->sw_if_index = packetdesc.sw_if_index;
574  t->action = packetdesc.action;
575  }
576 
577  to_next[0] = bi;
578  to_next++;
579  n_left_to_next--;
580 
581  vlib_validate_buffer_enqueue_x1 (vm, node, next, to_next, n_left_to_next,
582  bi, next_index);
583  vlib_put_next_frame (vm, node, next, n_left_to_next);
584  return 1;
585 
586 error:
587  vlib_node_increment_counter (vm, punt_socket_rx_node.index, error, 1);
588  return 0;
589 }
590 
591 static uword
593  vlib_node_runtime_t * node, vlib_frame_t * frame)
594 {
595  punt_main_t *pm = &punt_main;
596  u32 total_count = 0;
597  int i;
598 
599  for (i = 0; i < vec_len (pm->ready_fds); i++)
600  {
601  total_count += punt_socket_rx_fd (vm, node, pm->ready_fds[i]);
602  vec_del1 (pm->ready_fds, i);
603  }
604  return total_count;
605 }
606 
607 /* *INDENT-OFF* */
609 {
610  .function = punt_socket_rx,
611  .name = "punt-socket-rx",
612  .type = VLIB_NODE_TYPE_INPUT,
613  .state = VLIB_NODE_STATE_INTERRUPT,
614  .vector_size = 1,
615  .n_errors = PUNT_N_ERROR,
616  .error_strings = punt_error_strings,
617  .n_next_nodes = PUNT_SOCKET_RX_N_NEXT,
618  .next_nodes = {
619  [PUNT_SOCKET_RX_NEXT_INTERFACE_OUTPUT] = "interface-output",
620  [PUNT_SOCKET_RX_NEXT_IP4_LOOKUP] = "ip4-lookup",
621  [PUNT_SOCKET_RX_NEXT_IP6_LOOKUP] = "ip6-lookup",
622  },
623  .format_trace = format_punt_trace,
624 };
625 /* *INDENT-ON* */
626 
627 static clib_error_t *
629 {
630  vlib_main_t *vm = vlib_get_main ();
631  punt_main_t *pm = &punt_main;
632 
633  /** Schedule the rx node */
636 
637  return 0;
638 }
639 
640 #ifndef CLIB_MARCH_VARIANT
641 clib_error_t *
642 vnet_punt_socket_add (vlib_main_t * vm, u32 header_version,
643  bool is_ip4, u8 protocol, u16 port,
644  char *client_pathname)
645 {
646  punt_main_t *pm = &punt_main;
647 
648  if (!pm->is_configured)
649  return clib_error_return (0, "socket is not configured");
650 
651  if (header_version != PUNT_PACKETDESC_VERSION)
652  return clib_error_return (0, "Invalid packet descriptor version");
653 
654  /* For now we only support UDP punt */
655  if (protocol != IP_PROTOCOL_UDP)
656  return clib_error_return (0,
657  "only UDP protocol (%d) is supported, got %d",
658  IP_PROTOCOL_UDP, protocol);
659 
660  if (port == (u16) ~ 0)
661  return clib_error_return (0, "UDP port number required");
662 
663  /* Register client */
664  if (punt_socket_register (is_ip4, protocol, port, client_pathname) < 0)
665  return clib_error_return (0,
666  "Punt socket: Invalid client path: %s",
667  client_pathname);
668 
669  u32 node_index = is_ip4 ? udp4_punt_socket_node.index :
670  udp6_punt_socket_node.index;
671 
672  udp_register_dst_port (vm, port, node_index, is_ip4);
673 
674  return 0;
675 }
676 
677 clib_error_t *
678 vnet_punt_socket_del (vlib_main_t * vm, bool is_ip4, u8 l4_protocol, u16 port)
679 {
680  punt_main_t *pm = &punt_main;
681 
682  if (!pm->is_configured)
683  return clib_error_return (0, "socket is not configured");
684 
685  punt_socket_unregister (is_ip4, l4_protocol, port);
686  udp_unregister_dst_port (vm, port, is_ip4);
687 
688  return 0;
689 }
690 
691 /**
692  * @brief Request IP traffic punt to the local TCP/IP stack.
693  *
694  * @em Note
695  * - UDP and TCP are the only protocols supported in the current implementation
696  *
697  * @param vm vlib_main_t corresponding to the current thread
698  * @param ipv IP protcol version.
699  * 4 - IPv4, 6 - IPv6, ~0 for both IPv6 and IPv4
700  * @param protocol 8-bits L4 protocol value
701  * UDP is 17
702  * TCP is 1
703  * @param port 16-bits L4 (TCP/IP) port number when applicable (UDP only)
704  *
705  * @returns 0 on success, non-zero value otherwise
706  */
707 clib_error_t *
709  bool is_add)
710 {
711 
712  /* For now we only support TCP, UDP and SCTP punt */
713  if (protocol != IP_PROTOCOL_UDP &&
714  protocol != IP_PROTOCOL_TCP && protocol != IP_PROTOCOL_SCTP)
715  return clib_error_return (0,
716  "only UDP (%d), TCP (%d) and SCTP (%d) protocols are supported, got %d",
717  IP_PROTOCOL_UDP, IP_PROTOCOL_TCP,
718  IP_PROTOCOL_SCTP, protocol);
719 
720  if (ipv != (u8) ~ 0 && ipv != 4 && ipv != 6)
721  return clib_error_return (0, "IP version must be 4 or 6, got %d", ipv);
722 
723  if (port == (u16) ~ 0)
724  {
725  if ((ipv == 4) || (ipv == (u8) ~ 0))
726  {
727  if (protocol == IP_PROTOCOL_UDP)
728  udp_punt_unknown (vm, 1, is_add);
729  else if (protocol == IP_PROTOCOL_TCP)
730  tcp_punt_unknown (vm, 1, is_add);
731  else if (protocol == IP_PROTOCOL_SCTP)
732  sctp_punt_unknown (vm, 1, is_add);
733  }
734 
735  if ((ipv == 6) || (ipv == (u8) ~ 0))
736  {
737  if (protocol == IP_PROTOCOL_UDP)
738  udp_punt_unknown (vm, 0, is_add);
739  else if (protocol == IP_PROTOCOL_TCP)
740  tcp_punt_unknown (vm, 0, is_add);
741  else if (protocol == IP_PROTOCOL_SCTP)
742  sctp_punt_unknown (vm, 0, is_add);
743  }
744 
745  return 0;
746  }
747 
748  else if (is_add)
749  {
750  if (protocol == IP_PROTOCOL_TCP || protocol == IP_PROTOCOL_SCTP)
751  return clib_error_return (0,
752  "punt TCP/SCTP ports is not supported yet");
753 
754  if (ipv == 4 || ipv == (u8) ~ 0)
755  udp_register_dst_port (vm, port, udp4_punt_node.index, 1);
756 
757  if (ipv == 6 || ipv == (u8) ~ 0)
758  udp_register_dst_port (vm, port, udp6_punt_node.index, 0);
759 
760  return 0;
761  }
762  else
763  {
764  if (protocol == IP_PROTOCOL_TCP || protocol == IP_PROTOCOL_SCTP)
765  return clib_error_return (0,
766  "punt TCP/SCTP ports is not supported yet");
767  if (ipv == 4 || ipv == (u8) ~ 0)
768  udp_unregister_dst_port (vm, port, 1);
769 
770  if (ipv == 6 || ipv == (u8) ~ 0)
771  udp_unregister_dst_port (vm, port, 0);
772 
773  return 0;
774  }
775 }
776 #endif /* CLIB_MARCH_VARIANT */
777 
778 static clib_error_t *
780  unformat_input_t * input, vlib_cli_command_t * cmd)
781 {
782  u32 port = ~0;
783  bool is_add = true;
784  u32 protocol = ~0;
785  clib_error_t *error = NULL;
786 
788  {
789  if (unformat (input, "del"))
790  is_add = false;
791  else if (unformat (input, "all"))
792  ;
793  else if (unformat (input, "%d", &port))
794  ;
795  else if (unformat (input, "udp"))
796  protocol = IP_PROTOCOL_UDP;
797  else if (unformat (input, "tcp"))
798  protocol = IP_PROTOCOL_TCP;
799  else
800  {
801  error = clib_error_return (0, "parse error: '%U'",
802  format_unformat_error, input);
803  goto done;
804  }
805  }
806 
807  /* punt both IPv6 and IPv4 when used in CLI */
808  error = vnet_punt_add_del (vm, ~0, protocol, port, is_add);
809  if (error)
810  {
811  clib_error_report (error);
812  }
813 
814 done:
815  return error;
816 }
817 
818 /*?
819  * The set of '<em>set punt</em>' commands allows specific IP traffic to
820  * be punted to the host TCP/IP stack
821  *
822  * @em Note
823  * - UDP is the only protocol supported in the current implementation
824  * - All TCP traffic is currently punted to the host by default
825  *
826  * @cliexpar
827  * @parblock
828  * Example of how to request NTP traffic to be punted
829  * @cliexcmd{set punt udp 125}
830  *
831  * Example of how to request all 'unknown' UDP traffic to be punted
832  * @cliexcmd{set punt udp all}
833  *
834  * Example of how to stop all 'unknown' UDP traffic to be punted
835  * @cliexcmd{set punt udp del all}
836  * @endparblock
837 ?*/
838 /* *INDENT-OFF* */
839 VLIB_CLI_COMMAND (punt_command, static) = {
840  .path = "set punt",
841  .short_help = "set punt [udp|tcp] [del] <all | port-num1 [port-num2 ...]>",
842  .function = punt_cli,
843 };
844 /* *INDENT-ON* */
845 
846 #ifndef CLIB_MARCH_VARIANT
847 static clib_error_t *
849  unformat_input_t * input, vlib_cli_command_t * cmd)
850 {
851  bool is_ipv4 = true;
852  u32 protocol = ~0;
853  u32 port = ~0;
854  u8 *socket_name = 0;
855  clib_error_t *error = NULL;
856 
858  {
859  if (unformat (input, "ipv4"))
860  ;
861  else if (unformat (input, "ipv6"))
862  is_ipv4 = false;
863  else if (unformat (input, "udp"))
864  protocol = IP_PROTOCOL_UDP;
865  else if (unformat (input, "tcp"))
866  protocol = IP_PROTOCOL_TCP;
867  else if (unformat (input, "%d", &port))
868  ;
869  else if (unformat (input, "socket %s", &socket_name))
870  ;
871  else
872  {
873  error = clib_error_return (0, "parse error: '%U'",
874  format_unformat_error, input);
875  goto done;
876  }
877  }
878 
879  error =
880  vnet_punt_socket_add (vm, 1, is_ipv4, protocol, port,
881  (char *) socket_name);
882 done:
883  return error;
884 }
885 
886 /*?
887  *
888  * @cliexpar
889  * @cliexcmd{punt socket register}
890  ?*/
891 /* *INDENT-OFF* */
892 VLIB_CLI_COMMAND (punt_socket_register_command, static) =
893 {
894  .path = "punt socket register",
895  .function = punt_socket_register_cmd,
896  .short_help = "punt socket register [ipv4|ipv6] [udp|tcp]> <all | port-num1 [port-num2 ...]> <socket>",
897  .is_mp_safe = 1,
898 };
899 /* *INDENT-ON* */
900 
901 static clib_error_t *
903  unformat_input_t * input,
904  vlib_cli_command_t * cmd)
905 {
906  bool is_ipv4 = true;
907  u32 protocol = ~0;
908  u32 port = ~0;
909  clib_error_t *error = NULL;
910 
912  {
913  if (unformat (input, "ipv4"))
914  ;
915  else if (unformat (input, "ipv6"))
916  is_ipv4 = false;
917  else if (unformat (input, "udp"))
918  protocol = IP_PROTOCOL_UDP;
919  else if (unformat (input, "tcp"))
920  protocol = IP_PROTOCOL_TCP;
921  else if (unformat (input, "%d", &port))
922  ;
923  else
924  {
925  error = clib_error_return (0, "parse error: '%U'",
926  format_unformat_error, input);
927  goto done;
928  }
929  }
930 
931  error = vnet_punt_socket_del (vm, is_ipv4, protocol, port);
932 done:
933  return error;
934 }
935 
936 /*?
937  *
938  * @cliexpar
939  * @cliexcmd{punt socket register}
940  ?*/
941 /* *INDENT-OFF* */
942 VLIB_CLI_COMMAND (punt_socket_deregister_command, static) =
943 {
944  .path = "punt socket deregister",
945  .function = punt_socket_deregister_cmd,
946  .short_help = "punt socket deregister [ipv4|ipv6] [udp|tcp]> <all | port-num1 [port-num2 ...]>",
947  .is_mp_safe = 1,
948 };
949 /* *INDENT-ON* */
950 
953 {
954  punt_main_t *pm = &punt_main;
955  punt_client_t *pc;
956  punt_socket_detail_t *ps = 0;
957  bool is_valid;
958 
959  punt_client_t *v = !ipv ? pm->clients_by_dst_port4 :
961 
962  vec_foreach (pc, v)
963  {
964  if (pc && pc->port != 0)
965  {
966  is_valid = false;
967  if (pc->protocol == IP_PROTOCOL_UDP)
968  {
969  is_valid = udp_is_valid_dst_port (pc->port, !ipv);
970  }
971  if (is_valid)
972  {
973  punt_socket_detail_t detail = {
974  .ipv = ipv,
975  .l4_protocol = pc->protocol,
976  .l4_port = pc->port
977  };
978  memcpy (detail.pathname, pc->caddr.sun_path,
979  sizeof (pc->caddr.sun_path));
980  vec_add1 (ps, detail);
981  }
982  }
983  }
984  return ps;
985 }
986 
987 u8 *
988 format_punt_socket (u8 * s, va_list * args)
989 {
990  punt_client_t *clients = va_arg (*args, punt_client_t *);
991  u8 *is_ipv6 = va_arg (*args, u8 *);
992  punt_client_t *pc;
993  bool is_valid;
994 
995  vec_foreach (pc, clients)
996  {
997  if (pc && pc->port != 0)
998  {
999  is_valid = false;
1000  if (pc->protocol == IP_PROTOCOL_UDP)
1001  {
1002  is_valid = udp_is_valid_dst_port (pc->port, !(*is_ipv6));
1003  }
1004  if (is_valid)
1005  {
1006  s = format (s, " punt %s port %d to socket %s \n",
1007  (pc->protocol == IP_PROTOCOL_UDP) ? "UDP" : "TCP",
1008  pc->port, pc->caddr.sun_path);
1009  }
1010  }
1011  }
1012 
1013  return (s);
1014 }
1015 
1016 static clib_error_t *
1018  unformat_input_t * input, vlib_cli_command_t * cmd)
1019 {
1020  u8 is_ipv6;
1021  punt_main_t *pm = &punt_main;
1022  clib_error_t *error = NULL;
1023 
1024  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1025  {
1026  if (unformat (input, "ipv4"))
1027  is_ipv6 = 0;
1028  else if (unformat (input, "ipv6"))
1029  is_ipv6 = 1;
1030  else
1031  {
1032  error = clib_error_return (0, "parse error: '%U'",
1033  format_unformat_error, input);
1034  goto done;
1035  }
1036  }
1037 
1038  punt_client_t *v =
1039  is_ipv6 ? pm->clients_by_dst_port6 : pm->clients_by_dst_port4;
1040  vlib_cli_output (vm, "%U", format_punt_socket, v, &is_ipv6);
1041 
1042 done:
1043  return (error);
1044 }
1045 
1046 /*?
1047  *
1048  * @cliexpar
1049  * @cliexcmd{show punt socket ipv4}
1050  ?*/
1051 /* *INDENT-OFF* */
1052 VLIB_CLI_COMMAND (show_punt_socket_registration_command, static) =
1053 {
1054  .path = "show punt socket registrations",
1055  .function = punt_socket_show_cmd,
1056  .short_help = "show punt socket registrations [ipv4|ipv6]",
1057  .is_mp_safe = 1,
1058 };
1059 /* *INDENT-ON* */
1060 
1061 clib_error_t *
1063 {
1064  punt_main_t *pm = &punt_main;
1066 
1068  (sizeof (pm->clients_by_dst_port6[0]),
1069  BITS (((udp_header_t *) 0)->dst_port));
1071  (sizeof (pm->clients_by_dst_port4[0]),
1072  BITS (((udp_header_t *) 0)->dst_port));
1073 
1074  pm->is_configured = false;
1076  (u8 *)
1077  "interface-output");
1078 
1081  return 0;
1082 }
1083 
1085 #endif /* CLIB_MARCH_VARIANT */
1086 
1087 static clib_error_t *
1089 {
1090  punt_main_t *pm = &punt_main;
1091  char *socket_path = 0;
1092 
1093  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1094  {
1095  if (unformat (input, "socket %s", &socket_path))
1096  strncpy (pm->sun_path, socket_path, UNIX_PATH_MAX - 1);
1097  else
1098  return clib_error_return (0, "unknown input `%U'",
1099  format_unformat_error, input);
1100  }
1101 
1102  if (socket_path == 0)
1103  return 0;
1104 
1105  /* UNIX domain socket */
1106  struct sockaddr_un addr;
1107  if ((pm->socket_fd = socket (AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0)) == -1)
1108  {
1109  return clib_error_return (0, "socket error");
1110  }
1111 
1112  clib_memset (&addr, 0, sizeof (addr));
1113  addr.sun_family = AF_UNIX;
1114  if (*socket_path == '\0')
1115  {
1116  *addr.sun_path = '\0';
1117  strncpy (addr.sun_path + 1, socket_path + 1,
1118  sizeof (addr.sun_path) - 2);
1119  }
1120  else
1121  {
1122  strncpy (addr.sun_path, socket_path, sizeof (addr.sun_path) - 1);
1123  unlink (socket_path);
1124  }
1125 
1126  if (bind (pm->socket_fd, (struct sockaddr *) &addr, sizeof (addr)) == -1)
1127  {
1128  return clib_error_return (0, "bind error");
1129  }
1130 
1131  /* Register socket */
1133  clib_file_t template = { 0 };
1135  template.file_descriptor = pm->socket_fd;
1136  template.description = format (0, "%s", socket_path);
1137  pm->clib_file_index = clib_file_add (fm, &template);
1138 
1139  pm->is_configured = true;
1140 
1141  return 0;
1142 }
1143 
1145 
1146 /*
1147  * fd.io coding-style-patch-verification: ON
1148  *
1149  * Local Variables:
1150  * eval: (c-set-style "gnu")
1151  * End:
1152  */
vlib_node_t * interface_output_node
Definition: punt.h:85
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
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.c:93
#define CLIB_UNUSED(x)
Definition: clib.h:82
u8 protocol
Definition: punt.h:67
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
Definition: trace_funcs.h:156
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:865
Definition: punt.h:46
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
static clib_error_t * punt_config(vlib_main_t *vm, unformat_input_t *input)
Definition: punt.c:1088
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:110
static clib_error_t * punt_socket_read_ready(clib_file_t *uf)
Definition: punt.c:628
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
Definition: node_funcs.h:197
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
#define NULL
Definition: clib.h:58
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static punt_client_t * punt_client_get(bool is_ip4, u16 port)
Definition: punt.c:237
u32 * ready_fds
Definition: punt.h:86
u32 clib_file_index
Definition: punt.h:83
u32 thread_index
Definition: main.h:197
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
u32 file_descriptor
Definition: file.h:54
u8 data[0]
Packet data.
Definition: buffer.h:181
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:560
int i
int socket_fd
Definition: punt.h:79
u8 * format_punt_socket(u8 *s, va_list *args)
Definition: punt.c:988
clib_error_t * vnet_punt_add_del(vlib_main_t *vm, u8 ipv, u8 protocol, u16 port, bool is_add)
Request IP traffic punt to the local TCP/IP stack.
Definition: punt.c:708
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define VLIB_NODE_FN(node)
Definition: node.h:201
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:450
punt_socket_detail_t * punt_socket_entries(u8 ipv)
Definition: punt.c:952
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:468
#define foreach_punt_next
Definition: punt.c:41
format_function_t format_vnet_sw_if_index_name
unsigned char u8
Definition: types.h:56
enum punt_action_e action
Definition: punt.h:59
punt_thread_data_t * thread_data
Definition: punt.h:88
#define punt_next_punt(is_ip4)
Definition: punt.c:61
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
clib_file_function_t * read_function
Definition: file.h:67
u16 port
Definition: punt.h:68
#define fm
static void 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:114
i64 word
Definition: types.h:111
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
#define always_inline
Definition: clib.h:98
static uword udp46_punt_socket_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_ip4)
Definition: punt.c:315
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
static clib_error_t * punt_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: punt.c:779
#define sparse_vec_validate(v, i)
Definition: sparse_vec.h:231
#define clib_error_return(e, args...)
Definition: error.h:99
clib_file_main_t file_main
Definition: main.c:63
unsigned int u32
Definition: types.h:88
static struct sockaddr_un * punt_socket_get(bool is_ip4, u16 port)
Definition: punt.c:251
punt_client_t * clients_by_dst_port6
Definition: punt.h:82
struct iovec * iovecs
Definition: punt.h:74
static uword udp4_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt.c:443
struct punt_trace_t_ punt_trace_t
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:136
void sctp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
Definition: sctp.c:97
clib_error_t * vnet_punt_socket_del(vlib_main_t *vm, bool is_ip4, u8 l4_protocol, u16 port)
Definition: punt.c:678
vlib_node_registration_t udp4_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_socket_node)
Definition: punt.c:458
uword size
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
punt_socket_rx_next_e
Definition: punt.c:53
static uword udp6_punt_socket(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: punt.c:450
#define PREDICT_FALSE(x)
Definition: clib.h:111
#define VLIB_CONFIG_FUNCTION(x, n,...)
Definition: init.h:172
u8 is_midchain
Definition: punt.c:295
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:804
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:218
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:338
static uword punt_socket_rx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: punt.c:592
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1150
punt_next_t
Definition: punt.c:45
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:96
void udp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
Definition: udp_local.c:561
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
svmdb_client_t * c
u16 n_vectors
Definition: node.h:395
static vlib_node_registration_t punt_socket_rx_node
(constructor) VLIB_REGISTER_NODE (punt_socket_rx_node)
Definition: punt.c:67
vlib_main_t * vm
Definition: buffer.c:312
u32 sw_if_index
Definition: punt.h:58
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
Definition: udp_local.c:522
#define IP_PROTOCOL_SCTP
Definition: sctp.h:343
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:458
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
static clib_error_t * punt_socket_show_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: punt.c:1017
enum punt_action_e action
Definition: punt.c:481
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
static uword sparse_vec_index(void *v, uword sparse_index)
Definition: sparse_vec.h:161
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:513
u8 is_add
Definition: ipsec_gre.api:36
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
Definition: file.h:96
char sun_path[sizeof(struct sockaddr_un)]
Definition: punt.h:80
punt_main_t punt_main
Definition: punt.c:72
#define clib_error_report(e)
Definition: error.h:113
punt_client_t * clients_by_dst_port4
Definition: punt.h:81
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:248
punt_action_e
Definition: punt.h:44
static clib_error_t * punt_socket_deregister_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: punt.c:902
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
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:57
#define vec_elt(v, i)
Get vector value at index i.
static u8 * format_punt_trace(u8 *s, va_list *va)
Definition: punt.c:486
struct _vlib_node_registration vlib_node_registration_t
void tcp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
Definition: tcp.c:1516
Definition: defs.h:47
vlib_node_registration_t udp6_punt_socket_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_socket_node)
Definition: punt.c:468
clib_error_t * vnet_punt_socket_add(vlib_main_t *vm, u32 header_version, bool is_ip4, u8 protocol, u16 port, char *client_pathname)
Definition: punt.c:642
punt_client_t client
Definition: punt.c:294
static u8 * format_udp_punt_trace(u8 *s, va_list *args)
Definition: punt.c:299
bool is_configured
Definition: punt.h:84
bool udp_is_valid_dst_port(udp_dst_port_t dst_port, u8 is_ip4)
Definition: udp_local.c:545
#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
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
Definition: buffer.h:451
vlib_node_registration_t udp4_punt_node
(constructor) VLIB_REGISTER_NODE (udp4_punt_node)
Definition: punt.c:202
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:244
u8 pathname[108]
Definition: punt.h:97
static int punt_socket_register(bool is_ip4, u8 protocol, u16 port, char *client_pathname)
Definition: punt.c:262
#define VLIB_NODE_FLAG_IS_DROP
Definition: node.h:296
#define PUNT_PACKETDESC_VERSION
Definition: punt.h:55
#define vnet_buffer(b)
Definition: buffer.h:369
u32 sw_if_index
Definition: punt.c:482
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
#define vec_foreach(var, vec)
Vector iterator.
static void punt_socket_unregister(bool is_ip4, u8 protocol, u16 port)
Definition: punt.c:286
static char * punt_error_strings[]
Definition: punt.c:139
clib_error_t * ip_punt_init(vlib_main_t *vm)
Definition: punt.c:1062
Definition: file.h:51
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
Definition: udp_local.c:484
u16 dst_port
Definition: udp.api:42
static clib_error_t * punt_socket_register_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: punt.c:848
vlib_node_registration_t udp6_punt_node
(constructor) VLIB_REGISTER_NODE (udp6_punt_node)
Definition: punt.c:218
static void vlib_set_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt, u32 count)
Definition: trace_funcs.h:172
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
Definition: sparse_vec.h:71
static uword punt_socket_rx_fd(vlib_main_t *vm, vlib_node_runtime_t *node, u32 fd)
Definition: punt.c:498
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:612
#define BITS(x)
Definition: clib.h:61
char * vnet_punt_get_server_pathname(void)
Definition: punt.c:75
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:762
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
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
struct sockaddr_un caddr
Definition: punt.h:69
Definition: defs.h:46
Definitions for punt infrastructure.
u8 protocol
Definition: ipsec.api:96
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
#define SPARSE_VEC_INVALID_INDEX
Definition: sparse_vec.h:68