FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
udp_local.c
Go to the documentation of this file.
1 /*
2  * node.c: udp packet processing
3  *
4  * Copyright (c) 2013 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vlib/vlib.h>
19 #include <vnet/pg/pg.h>
20 #include <vnet/ip/udp.h>
21 #include <vnet/ip/udp_packet.h>
22 #include <vppinfra/sparse_vec.h>
23 
25 
26 #define foreach_udp_input_next \
27  _ (PUNT, "error-punt") \
28  _ (DROP, "error-drop") \
29  _ (ICMP4_ERROR, "ip4-icmp-error") \
30  _ (ICMP6_ERROR, "ip6-icmp-error")
31 
32 typedef enum {
33 #define _(s,n) UDP_INPUT_NEXT_##s,
35 #undef _
38 
39 typedef struct {
44 
45 u8 * format_udp_rx_trace (u8 * s, va_list * args)
46 {
47  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
48  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
49  udp_rx_trace_t * t = va_arg (*args, udp_rx_trace_t *);
50 
51  s = format (s, "UDP: src-port %d dst-port %d%s",
52  clib_net_to_host_u16(t->src_port),
53  clib_net_to_host_u16(t->dst_port),
54  t->bound ? "" : " (no listener)");
55  return s;
56 }
57 
58 typedef struct {
59  /* Sparse vector mapping udp dst_port in network byte order
60  to next index. */
63 
66 
69  vlib_node_runtime_t * node,
70  vlib_frame_t * from_frame,
71  int is_ip4)
72 {
73  udp_input_runtime_t * rt = is_ip4 ?
74  (void *) vlib_node_get_runtime_data (vm, udp4_input_node.index)
75  : (void *) vlib_node_get_runtime_data (vm, udp6_input_node.index);
76  __attribute__((unused)) u32 n_left_from, next_index, * from, * to_next;
77  word n_no_listener = 0;
78 
79  from = vlib_frame_vector_args (from_frame);
80  n_left_from = from_frame->n_vectors;
81 
82  next_index = node->cached_next_index;
83 
84  while (n_left_from > 0)
85  {
86  u32 n_left_to_next;
87 
88  vlib_get_next_frame (vm, node, next_index,
89  to_next, n_left_to_next);
90 
91  while (n_left_from >= 4 && n_left_to_next >= 2)
92  {
93  u32 bi0, bi1;
94  vlib_buffer_t * b0, * b1;
95  udp_header_t * h0 = 0, * h1 = 0;
96  u32 i0, i1, dst_port0, dst_port1;
97  u32 advance0, advance1;
98  u32 error0, next0, error1, next1;
99 
100  /* Prefetch next iteration. */
101  {
102  vlib_buffer_t * p2, * p3;
103 
104  p2 = vlib_get_buffer (vm, from[2]);
105  p3 = vlib_get_buffer (vm, from[3]);
106 
107  vlib_prefetch_buffer_header (p2, LOAD);
108  vlib_prefetch_buffer_header (p3, LOAD);
109 
110  CLIB_PREFETCH (p2->data, sizeof (h0[0]), LOAD);
111  CLIB_PREFETCH (p3->data, sizeof (h1[0]), LOAD);
112  }
113 
114  bi0 = from[0];
115  bi1 = from[1];
116  to_next[0] = bi0;
117  to_next[1] = bi1;
118  from += 2;
119  to_next += 2;
120  n_left_to_next -= 2;
121  n_left_from -= 2;
122 
123  b0 = vlib_get_buffer (vm, bi0);
124  b1 = vlib_get_buffer (vm, bi1);
125 
126  /* ip4/6_local hands us the ip header, not the udp header */
127  if (is_ip4)
128  {
129  advance0 = sizeof(ip4_header_t);
130  advance1 = sizeof(ip4_header_t);
131  }
132  else
133  {
134  advance0 = sizeof(ip6_header_t);
135  advance1 = sizeof(ip6_header_t);
136  }
137 
138  if (PREDICT_FALSE(b0->current_length < advance0 + sizeof (*h0)))
139  {
140  error0 = UDP_ERROR_LENGTH_ERROR;
141  next0 = UDP_INPUT_NEXT_DROP;
142  }
143  else
144  {
145  vlib_buffer_advance (b0, advance0);
146  h0 = vlib_buffer_get_current (b0);
147  error0 = next0 = 0;
148  if (PREDICT_FALSE(clib_net_to_host_u16(h0->length) >
150  {
151  error0 = UDP_ERROR_LENGTH_ERROR;
152  next0 = UDP_INPUT_NEXT_DROP;
153  }
154  }
155 
156  if (PREDICT_FALSE(b1->current_length < advance1 + sizeof (*h1)))
157  {
158  error1 = UDP_ERROR_LENGTH_ERROR;
159  next1 = UDP_INPUT_NEXT_DROP;
160  }
161  else
162  {
163  vlib_buffer_advance (b1, advance1);
164  h1 = vlib_buffer_get_current (b1);
165  error1 = next1 = 0;
166  if (PREDICT_FALSE(clib_net_to_host_u16(h1->length) >
168  {
169  error1 = UDP_ERROR_LENGTH_ERROR;
170  next1 = UDP_INPUT_NEXT_DROP;
171  }
172  }
173 
174  /* Index sparse array with network byte order. */
175  dst_port0 = (error0 == 0) ? h0->dst_port : 0;
176  dst_port1 = (error1 == 0) ? h1->dst_port : 0;
177  sparse_vec_index2 (rt->next_by_dst_port, dst_port0, dst_port1,
178  &i0, &i1);
179  next0 = (error0 == 0) ? vec_elt(rt->next_by_dst_port, i0) : next0;
180  next1 = (error1 == 0) ? vec_elt(rt->next_by_dst_port, i1) : next1;
181 
183  {
184  // move the pointer back so icmp-error can find the
185  // ip packet header
186  vlib_buffer_advance (b0, - (word)advance0);
187 
188  if (is_ip4)
189  {
190  icmp4_error_set_vnet_buffer(b0, ICMP4_destination_unreachable,
191  ICMP4_destination_unreachable_port_unreachable, 0);
192  next0 = UDP_INPUT_NEXT_ICMP4_ERROR;
193  }
194  else
195  {
196  icmp6_error_set_vnet_buffer(b0, ICMP6_destination_unreachable,
197  ICMP6_destination_unreachable_port_unreachable, 0);
198  next0 = UDP_INPUT_NEXT_ICMP6_ERROR;
199  }
200  n_no_listener ++;
201  }
202  else
203  {
204  b0->error = node->errors[UDP_ERROR_NONE];
205  // advance to the payload
206  vlib_buffer_advance (b0, sizeof (*h0));
207  }
208 
210  {
211  // move the pointer back so icmp-error can find the
212  // ip packet header
213  vlib_buffer_advance (b1, - (word)advance1);
214 
215  if (is_ip4)
216  {
217  icmp4_error_set_vnet_buffer(b1, ICMP4_destination_unreachable,
218  ICMP4_destination_unreachable_port_unreachable, 0);
219  next1 = UDP_INPUT_NEXT_ICMP4_ERROR;
220  }
221  else
222  {
223  icmp6_error_set_vnet_buffer(b1, ICMP6_destination_unreachable,
224  ICMP6_destination_unreachable_port_unreachable, 0);
225  next1 = UDP_INPUT_NEXT_ICMP6_ERROR;
226  }
227  n_no_listener ++;
228  }
229  else
230  {
231  b1->error = node->errors[UDP_ERROR_NONE];
232  // advance to the payload
233  vlib_buffer_advance (b1, sizeof (*h1));
234  }
235 
237  {
238  udp_rx_trace_t *tr = vlib_add_trace (vm, node,
239  b0, sizeof (*tr));
240  if (b0->error != node->errors[UDP_ERROR_LENGTH_ERROR])
241  {
242  tr->src_port = h0 ? h0->src_port : 0;
243  tr->dst_port = h0 ? h0->dst_port : 0;
244  tr->bound = (next0 != UDP_INPUT_NEXT_ICMP4_ERROR &&
245  next0 != UDP_INPUT_NEXT_ICMP6_ERROR);
246  }
247  }
249  {
250  udp_rx_trace_t *tr = vlib_add_trace (vm, node,
251  b1, sizeof (*tr));
252  if (b1->error != node->errors[UDP_ERROR_LENGTH_ERROR])
253  {
254  tr->src_port = h1 ? h1->src_port : 0;
255  tr->dst_port = h1 ? h1->dst_port : 0;
256  tr->bound = (next1 != UDP_INPUT_NEXT_ICMP4_ERROR &&
257  next1 != UDP_INPUT_NEXT_ICMP6_ERROR);
258  }
259  }
260 
261  vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
262  to_next, n_left_to_next,
263  bi0, bi1, next0, next1);
264  }
265 
266  while (n_left_from > 0 && n_left_to_next > 0)
267  {
268  u32 bi0;
269  vlib_buffer_t * b0;
270  udp_header_t * h0 = 0;
271  u32 i0, next0;
272  u32 advance0;
273 
274  bi0 = from[0];
275  to_next[0] = bi0;
276  from += 1;
277  to_next += 1;
278  n_left_from -= 1;
279  n_left_to_next -= 1;
280 
281  b0 = vlib_get_buffer (vm, bi0);
282 
283  /* ip4/6_local hands us the ip header, not the udp header */
284  if (is_ip4)
285  advance0 = sizeof(ip4_header_t);
286  else
287  advance0 = sizeof(ip6_header_t);
288 
289  if (PREDICT_FALSE(b0->current_length < advance0 + sizeof (*h0)))
290  {
291  b0->error = node->errors[UDP_ERROR_LENGTH_ERROR];
292  next0 = UDP_INPUT_NEXT_DROP;
293  goto trace_x1;
294  }
295 
296  vlib_buffer_advance (b0, advance0);
297 
298  h0 = vlib_buffer_get_current (b0);
299 
300  if (PREDICT_TRUE(clib_net_to_host_u16(h0->length) <=
302  {
304  next0 = vec_elt(rt->next_by_dst_port, i0);
305 
307  {
308  // move the pointer back so icmp-error can find the
309  // ip packet header
310  vlib_buffer_advance (b0, - (word)advance0);
311 
312  if (is_ip4)
313  {
314  icmp4_error_set_vnet_buffer(b0, ICMP4_destination_unreachable,
315  ICMP4_destination_unreachable_port_unreachable, 0);
316  next0 = UDP_INPUT_NEXT_ICMP4_ERROR;
317  }
318  else
319  {
320  icmp6_error_set_vnet_buffer(b0, ICMP6_destination_unreachable,
321  ICMP6_destination_unreachable_port_unreachable, 0);
322  next0 = UDP_INPUT_NEXT_ICMP6_ERROR;
323  }
324  n_no_listener ++;
325  }
326  else
327  {
328  b0->error = node->errors[UDP_ERROR_NONE];
329  // advance to the payload
330  vlib_buffer_advance (b0, sizeof (*h0));
331  }
332  }
333  else
334  {
335  b0->error = node->errors[UDP_ERROR_LENGTH_ERROR];
336  next0 = UDP_INPUT_NEXT_DROP;
337  }
338 
339  trace_x1:
341  {
342  udp_rx_trace_t *tr = vlib_add_trace (vm, node,
343  b0, sizeof (*tr));
344  if (b0->error != node->errors[UDP_ERROR_LENGTH_ERROR])
345  {
346  tr->src_port = h0->src_port;
347  tr->dst_port = h0->dst_port;
348  tr->bound = (next0 != UDP_INPUT_NEXT_ICMP4_ERROR &&
349  next0 != UDP_INPUT_NEXT_ICMP6_ERROR);
350  }
351  }
352 
353  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
354  to_next, n_left_to_next,
355  bi0, next0);
356  }
357 
358  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
359  }
360  vlib_error_count(vm, node->node_index, UDP_ERROR_NO_LISTENER, n_no_listener);
361  return from_frame->n_vectors;
362 }
363 
364 static char * udp_error_strings[] = {
365 #define udp_error(n,s) s,
366 #include "udp_error.def"
367 #undef udp_error
368 };
369 
370 static uword
372  vlib_node_runtime_t * node,
373  vlib_frame_t * from_frame)
374 {
375  return udp46_input_inline (vm, node, from_frame, 1 /* is_ip4 */);
376 }
377 
378 static uword
380  vlib_node_runtime_t * node,
381  vlib_frame_t * from_frame)
382 {
383  return udp46_input_inline (vm, node, from_frame, 0 /* is_ip4 */);
384 }
385 
386 
388  .function = udp4_input,
389  .name = "ip4-udp-lookup",
390  /* Takes a vector of packets. */
391  .vector_size = sizeof (u32),
392 
393  .runtime_data_bytes = sizeof (udp_input_runtime_t),
394 
395  .n_errors = UDP_N_ERROR,
396  .error_strings = udp_error_strings,
397 
398  .n_next_nodes = UDP_INPUT_N_NEXT,
399  .next_nodes = {
400 #define _(s,n) [UDP_INPUT_NEXT_##s] = n,
402 #undef _
403  },
404 
405  .format_buffer = format_udp_header,
406  .format_trace = format_udp_rx_trace,
407  .unformat_buffer = unformat_udp_header,
408 };
409 
411 
413  .function = udp6_input,
414  .name = "ip6-udp-lookup",
415  /* Takes a vector of packets. */
416  .vector_size = sizeof (u32),
417 
418  .runtime_data_bytes = sizeof (udp_input_runtime_t),
419 
420  .n_errors = UDP_N_ERROR,
421  .error_strings = udp_error_strings,
422 
423  .n_next_nodes = UDP_INPUT_N_NEXT,
424  .next_nodes = {
425 #define _(s,n) [UDP_INPUT_NEXT_##s] = n,
427 #undef _
428  },
429 
430  .format_buffer = format_udp_header,
431  .format_trace = format_udp_rx_trace,
432  .unformat_buffer = unformat_udp_header,
433 };
434 
436 
437 static void add_dst_port (udp_main_t * um,
438  udp_dst_port_t dst_port,
439  char * dst_port_name, u8 is_ip4)
440 {
441  udp_dst_port_info_t * pi;
442  u32 i;
443 
444  vec_add2 (um->dst_port_infos[is_ip4], pi, 1);
445  i = pi - um->dst_port_infos[is_ip4];
446 
447  pi->name = dst_port_name;
448  pi->dst_port = dst_port;
449  pi->next_index = pi->node_index = ~0;
450 
451  hash_set (um->dst_port_info_by_dst_port[is_ip4], dst_port, i);
452 
453  if (pi->name)
454  hash_set_mem (um->dst_port_info_by_name[is_ip4], pi->name, i);
455 }
456 
457 void
459  udp_dst_port_t dst_port,
460  u32 node_index, u8 is_ip4)
461 {
462  udp_main_t * um = &udp_main;
463  udp_dst_port_info_t * pi;
464  udp_input_runtime_t * rt;
465  u16 * n;
466 
467  {
469  if (error)
470  clib_error_report (error);
471  }
472 
473  pi = udp_get_dst_port_info (um, dst_port, is_ip4);
474  if (! pi)
475  {
476  add_dst_port (um, dst_port, 0, is_ip4);
477  pi = udp_get_dst_port_info (um, dst_port, is_ip4);
478  ASSERT (pi);
479  }
480 
481  pi->node_index = node_index;
482  pi->next_index = vlib_node_add_next (vm,
483  is_ip4 ? udp4_input_node.index
484  : udp6_input_node.index,
485  node_index);
486 
487  /* Setup udp protocol -> next index sparse vector mapping. */
489  (vm, is_ip4 ? udp4_input_node.index: udp6_input_node.index);
491  clib_host_to_net_u16 (dst_port));
492  n[0] = pi->next_index;
493 }
494 
495 /* Parse a UDP header. */
496 uword unformat_udp_header (unformat_input_t * input, va_list * args)
497 {
498  u8 ** result = va_arg (*args, u8 **);
499  udp_header_t * udp;
500  __attribute__((unused)) int old_length;
501  u16 src_port, dst_port;
502 
503  /* Allocate space for IP header. */
504  {
505  void * p;
506 
507  old_length = vec_len (*result);
508  vec_add2 (*result, p, sizeof (ip4_header_t));
509  udp = p;
510  }
511 
512  memset (udp, 0, sizeof (udp[0]));
513  if (unformat (input, "src-port %d dst-port %d",
514  &src_port, &dst_port))
515  {
516  udp->src_port = clib_host_to_net_u16 (src_port);
517  udp->dst_port = clib_host_to_net_u16 (dst_port);
518  return 1;
519  }
520  return 0;
521 }
522 
523 static void
524 udp_setup_node (vlib_main_t * vm, u32 node_index)
525 {
526  vlib_node_t * n = vlib_get_node (vm, node_index);
527  pg_node_t * pn = pg_get_node (node_index);
528 
532 }
533 
535 {
536  udp_input_runtime_t * rt;
537  udp_main_t * um = &udp_main;
538  int i;
539 
540  {
541  clib_error_t * error;
542  error = vlib_call_init_function (vm, udp_init);
543  if (error)
544  clib_error_report (error);
545  }
546 
547 
548  for (i = 0; i < 2; i++)
549  {
550  um->dst_port_info_by_name[i] = hash_create_string (0, sizeof(uword));
551  um->dst_port_info_by_dst_port[i] = hash_create (0, sizeof(uword));
552  }
553 
554  udp_setup_node (vm, udp4_input_node.index);
555  udp_setup_node (vm, udp6_input_node.index);
556 
558 
560  (/* elt bytes */ sizeof (rt->next_by_dst_port[0]),
561  /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
562 
563 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 1 /* is_ip4 */);
565 #undef _
566 
568 
569  rt->next_by_dst_port = sparse_vec_new
570  (/* elt bytes */ sizeof (rt->next_by_dst_port[0]),
571  /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
572 
573 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 0 /* is_ip4 */);
575 #undef _
576 
577  ip4_register_protocol (IP_PROTOCOL_UDP, udp4_input_node.index);
578  /* Note: ip6 differs from ip4, UDP is hotwired to ip6-udp-lookup */
579  return 0;
580 }
581 
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:457
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define CLIB_UNUSED(x)
Definition: clib.h:79
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
clib_error_t * udp_local_init(vlib_main_t *vm)
Definition: udp_local.c:534
static char * udp_error_strings[]
Definition: udp_local.c:364
udp_main_t udp_main
Definition: udp_local.c:24
#define PREDICT_TRUE(x)
Definition: clib.h:98
uword * dst_port_info_by_dst_port[N_UDP_AF]
Definition: udp.h:95
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
Definition: error_funcs.h:55
clib_error_t * udp_init(vlib_main_t *vm)
Definition: udp_init.c:43
Definition: udp.h:90
u32 node_index
Definition: udp.h:78
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:521
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:458
#define hash_set_mem(h, key, value)
Definition: hash.h:274
static udp_dst_port_info_t * udp_get_dst_port_info(udp_main_t *um, udp_dst_port_t dst_port, u8 is_ip4)
Definition: udp.h:102
#define clib_error_report(e)
Definition: error.h:125
void ip4_register_protocol(u32 protocol, u32 node_index)
Definition: ip4_forward.c:1790
vlib_error_t * errors
Definition: node.h:419
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:112
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1063
static void add_dst_port(udp_main_t *um, udp_dst_port_t dst_port, char *dst_port_name, u8 is_ip4)
Definition: udp_local.c:437
static pg_node_t * pg_get_node(uword node_index)
Definition: pg.h:347
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
#define always_inline
Definition: clib.h:84
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:190
#define sparse_vec_validate(v, i)
Definition: sparse_vec.h:214
static void sparse_vec_index2(void *v, u32 si0, u32 si1, u32 *i0_return, u32 *i1_return)
Definition: sparse_vec.h:160
#define vlib_call_init_function(vm, x)
Definition: init.h:161
#define hash_create_string(elts, value_bytes)
Definition: hash.h:652
void icmp6_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
Definition: icmp6.c:492
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:82
uword * dst_port_info_by_name[N_UDP_AF]
Definition: udp.h:94
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
Definition: node_funcs.h:109
#define PREDICT_FALSE(x)
Definition: clib.h:97
format_function_t * format_buffer
Definition: node.h:311
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
Definition: buffer_node.h:70
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:216
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:350
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:121
static void udp_setup_node(vlib_main_t *vm, u32 node_index)
Definition: udp_local.c:524
u16 n_vectors
Definition: node.h:344
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
vlib_node_registration_t udp4_input_node
(constructor) VLIB_REGISTER_NODE (udp4_input_node)
Definition: udp_local.c:64
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
Definition: icmp4.c:416
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:203
unformat_function_t * unformat_buffer
Definition: node.h:312
unformat_function_t * unformat_edit
Definition: pg.h:301
static uword udp46_input_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip4)
Definition: udp_local.c:68
u16 * next_by_dst_port
Definition: udp_local.c:61
vlib_node_registration_t udp6_input_node
(constructor) VLIB_REGISTER_NODE (udp6_input_node)
Definition: udp_local.c:65
udp_dst_port_t
Definition: udp.h:57
#define hash_create(elts, value_bytes)
Definition: hash.h:658
static uword sparse_vec_index(void *v, uword sparse_index)
Definition: sparse_vec.h:152
u16 cached_next_index
Definition: node.h:463
#define foreach_udp4_dst_port
Definition: udp.h:36
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
udp_input_next_t
Definition: udp_local.c:32
#define foreach_udp_input_next
Definition: udp_local.c:26
udp_dst_port_t dst_port
Definition: udp.h:75
char * name
Definition: udp.h:72
static uword udp6_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: udp_local.c:379
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:95
u64 uword
Definition: types.h:112
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:55
#define vec_elt(v, i)
Get vector value at index i.
static uword udp4_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: udp_local.c:371
unsigned short u16
Definition: types.h:57
i64 word
Definition: types.h:111
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:253
uword unformat_udp_header(unformat_input_t *input, va_list *args)
Definition: udp_local.c:496
u8 * format_udp_rx_trace(u8 *s, va_list *args)
Definition: udp_local.c:45
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:166
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
u32 next_index
Definition: udp.h:81
u8 data[0]
Packet data.
Definition: buffer.h:154
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:58
format_function_t format_udp_header
Definition: format.h:101
struct _unformat_input_t unformat_input_t
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
Definition: sparse_vec.h:71
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:85
#define BITS(x)
Definition: clib.h:58
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:69
unformat_function_t unformat_pg_udp_header
Definition: format.h:103
Definition: pg.h:298
#define SPARSE_VEC_INVALID_INDEX
Definition: sparse_vec.h:68