FD.io VPP  v18.07.1-19-g511ce25
Vector Packet Processing
udp_encap.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 #include <vnet/udp/udp_encap.h>
17 #include <vnet/fib/fib_entry.h>
18 #include <vnet/fib/fib_table.h>
19 #include <vnet/dpo/drop_dpo.h>
20 
21 /**
22  * Registered DPO types for the IP header encapsulated, v4 or v6.
23  */
25 
26 /**
27  * Hash DB to map from client ID to VPP index.
28  */
30 
31 /**
32  * Pool of encaps
33  */
35 
36 /**
37  * Stats for each UDP encap object
38  */
40 
41 static udp_encap_t *
43 {
44  udp_encap_t *ue = NULL;
45  index_t uei;
46 
47  uei = udp_encap_find (id);
48 
49  if (INDEX_INVALID != uei)
50  {
51  ue = udp_encap_get (uei);
52  }
53 
54  return (ue);
55 }
56 
57 static void
59 {
62  &ue->ue_dpo,
64 }
65 
66 index_t
68  fib_protocol_t proto,
69  index_t fib_index,
70  const ip46_address_t * src_ip,
71  const ip46_address_t * dst_ip,
72  u16 src_port,
74 {
75  udp_encap_t *ue;
76  index_t uei;
77 
78  uei = udp_encap_find (id);
79 
80  if (INDEX_INVALID == uei)
81  {
82  u8 pfx_len = 0;
83 
84  pool_get_aligned (udp_encap_pool, ue, CLIB_CACHE_LINE_BYTES);
85  uei = ue - udp_encap_pool;
86 
87  vlib_validate_combined_counter (&(udp_encap_counters), uei);
88  vlib_zero_combined_counter (&(udp_encap_counters), uei);
89 
90  hash_set (udp_encap_db, id, uei);
91 
94  ue->ue_fib_index = fib_index;
95  ue->ue_flags = flags;
96  ue->ue_id = id;
97  ue->ue_ip_proto = proto;
98 
99  switch (proto)
100  {
101  case FIB_PROTOCOL_IP4:
102  pfx_len = 32;
103  ue->ue_hdrs.ip4.ue_ip4.ip_version_and_header_length = 0x45;
104  ue->ue_hdrs.ip4.ue_ip4.ttl = 254;
105  ue->ue_hdrs.ip4.ue_ip4.protocol = IP_PROTOCOL_UDP;
106  ue->ue_hdrs.ip4.ue_ip4.src_address.as_u32 = src_ip->ip4.as_u32;
107  ue->ue_hdrs.ip4.ue_ip4.dst_address.as_u32 = dst_ip->ip4.as_u32;
108  ue->ue_hdrs.ip4.ue_ip4.checksum =
109  ip4_header_checksum (&ue->ue_hdrs.ip4.ue_ip4);
110  ue->ue_hdrs.ip4.ue_udp.src_port = clib_host_to_net_u16 (src_port);
111  ue->ue_hdrs.ip4.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
112 
113  break;
114  case FIB_PROTOCOL_IP6:
115  pfx_len = 128;
116  ue->ue_hdrs.ip6.ue_ip6.ip_version_traffic_class_and_flow_label =
117  clib_host_to_net_u32 (6 << 28);
118  ue->ue_hdrs.ip6.ue_ip6.hop_limit = 255;
119  ue->ue_hdrs.ip6.ue_ip6.protocol = IP_PROTOCOL_UDP;
120  ue->ue_hdrs.ip6.ue_ip6.src_address.as_u64[0] =
121  src_ip->ip6.as_u64[0];
122  ue->ue_hdrs.ip6.ue_ip6.src_address.as_u64[1] =
123  src_ip->ip6.as_u64[1];
124  ue->ue_hdrs.ip6.ue_ip6.dst_address.as_u64[0] =
125  dst_ip->ip6.as_u64[0];
126  ue->ue_hdrs.ip6.ue_ip6.dst_address.as_u64[1] =
127  dst_ip->ip6.as_u64[1];
128  ue->ue_hdrs.ip6.ue_udp.src_port = clib_host_to_net_u16 (src_port);
129  ue->ue_hdrs.ip6.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
130 
131  break;
132  default:
133  ASSERT (0);
134  }
135 
136  /*
137  * track the destination address
138  */
139  fib_prefix_t dst_pfx = {
140  .fp_proto = proto,
141  .fp_len = pfx_len,
142  .fp_addr = *dst_ip,
143  };
144 
145  ue->ue_fib_entry_index =
146  fib_table_entry_special_add (fib_index,
147  &dst_pfx,
149  ue->ue_fib_sibling =
152 
153  udp_encap_restack (ue);
154  }
155  else
156  {
157  /*
158  * existing entry. updates not supported yet
159  */
160  uei = INDEX_INVALID;
161  }
162  return (uei);
163 }
164 
165 void
167 {
168  index_t uei;
169 
170  uei = udp_encap_find (id);
171 
172  if (INDEX_INVALID == uei)
173  {
174  dpo_copy (dpo, drop_dpo_get (proto));
175  }
176  else
177  {
178  udp_encap_t *ue;
179 
180  ue = udp_encap_get (uei);
181 
182  dpo_set (dpo, udp_encap_dpo_types[ue->ue_ip_proto], proto, uei);
183  }
184 }
185 
186 index_t
188 {
189  uword *p;
190 
191  p = hash_get (udp_encap_db, id);
192 
193  if (NULL != p)
194  return p[0];
195 
196  return INDEX_INVALID;
197 }
198 
199 void
201 {
202  udp_encap_t *ue;
203 
204  ue = udp_encap_get_w_id (id);
205 
206  if (NULL != ue)
207  {
208  fib_node_lock (&ue->ue_fib_node);
209  }
210 }
211 
212 void
214 {
215  udp_encap_t *ue;
216 
217  if (INDEX_INVALID == uei)
218  {
219  return;
220  }
221 
222  ue = udp_encap_get (uei);
223 
224  if (NULL != ue)
225  {
227  }
228 }
229 
230 void
232 {
233  udp_encap_t *ue;
234 
235  ue = udp_encap_get_w_id (id);
236 
237  if (NULL != ue)
238  {
240  }
241 }
242 
243 static void
245 {
246  udp_encap_t *ue;
247 
248  ue = udp_encap_get (dpo->dpoi_index);
249 
250  fib_node_lock (&ue->ue_fib_node);
251 }
252 
253 static void
255 {
256  udp_encap_t *ue;
257 
258  ue = udp_encap_get (dpo->dpoi_index);
259 
261 }
262 
263 static u8 *
264 format_udp_encap_i (u8 * s, va_list * args)
265 {
266  index_t uei = va_arg (*args, index_t);
267  u32 indent = va_arg (*args, u32);
268  u32 details = va_arg (*args, u32);
269  vlib_counter_t to;
270  udp_encap_t *ue;
271 
272  ue = udp_encap_get (uei);
273 
274  // FIXME
275  s = format (s, "udp-ecap:[%d]: id:%d ip-fib-index:%d ",
276  uei, ue->ue_id, ue->ue_fib_index);
277  if (FIB_PROTOCOL_IP4 == ue->ue_ip_proto)
278  {
279  s = format (s, "ip:[src:%U, dst:%U] udp:[src:%d, dst:%d]",
281  &ue->ue_hdrs.ip4.ue_ip4.src_address,
283  &ue->ue_hdrs.ip4.ue_ip4.dst_address,
284  clib_net_to_host_u16 (ue->ue_hdrs.ip4.ue_udp.src_port),
285  clib_net_to_host_u16 (ue->ue_hdrs.ip4.ue_udp.dst_port));
286  }
287  else
288  {
289  s = format (s, "ip:[src:%U, dst:%U] udp:[src:%d dst:%d]",
291  &ue->ue_hdrs.ip6.ue_ip6.src_address,
293  &ue->ue_hdrs.ip6.ue_ip6.dst_address,
294  clib_net_to_host_u16 (ue->ue_hdrs.ip6.ue_udp.src_port),
295  clib_net_to_host_u16 (ue->ue_hdrs.ip6.ue_udp.dst_port));
296  }
297  vlib_get_combined_counter (&(udp_encap_counters), uei, &to);
298  s = format (s, " to:[%Ld:%Ld]]", to.packets, to.bytes);
299 
300  if (details)
301  {
302  s = format (s, " locks:%d", ue->ue_fib_node.fn_locks);
303  s = format (s, "\n%UStacked on:", format_white_space, indent + 1);
304  s = format (s, "\n%U%U",
305  format_white_space, indent + 2,
306  format_dpo_id, &ue->ue_dpo, indent + 3);
307  }
308  return (s);
309 }
310 
311 void
312 udp_encap_get_stats (index_t uei, u64 * packets, u64 * bytes)
313 {
314  vlib_counter_t to;
315 
316  vlib_get_combined_counter (&(udp_encap_counters), uei, &to);
317 
318  *packets = to.packets;
319  *bytes = to.bytes;
320 }
321 
322 static u8 *
323 format_udp_encap_dpo (u8 * s, va_list * args)
324 {
325  index_t uei = va_arg (*args, index_t);
326  u32 indent = va_arg (*args, u32);
327 
328  return (format (s, "%U", format_udp_encap_i, uei, indent, 1));
329 }
330 
331 u8 *
332 format_udp_encap (u8 * s, va_list * args)
333 {
334  u32 id = va_arg (*args, u32);
335  u32 details = va_arg (*args, u32);
336  index_t uei;
337 
338  uei = udp_encap_find (id);
339 
340  if (INDEX_INVALID == uei)
341  {
342  return (format (s, "Invalid udp-encap ID: %d", id));
343  }
344 
345  return (format (s, "%U", format_udp_encap_i, uei, 0, details));
346 }
347 
348 static udp_encap_t *
350 {
352  return ((udp_encap_t *) (((char *) node) -
353  STRUCT_OFFSET_OF (udp_encap_t, ue_fib_node)));
354 }
355 
356 /**
357  * Function definition to backwalk a FIB node
358  */
361 {
363 
365 }
366 
367 /**
368  * Function definition to get a FIB node from its index
369  */
370 static fib_node_t *
372 {
373  udp_encap_t *ue;
374 
375  ue = pool_elt_at_index (udp_encap_pool, index);
376 
377  return (&ue->ue_fib_node);
378 }
379 
380 /**
381  * Function definition to inform the FIB node that its last lock has gone.
382  */
383 static void
385 {
386  udp_encap_t *ue;
387 
388  ue = udp_encap_from_fib_node (node);
389 
390  /**
391  * reset the stacked DPO to unlock it
392  */
393  dpo_reset (&ue->ue_dpo);
395 
398 
399 
400  pool_put (udp_encap_pool, ue);
401 }
402 
403 const static char *const udp4_encap_ip4_nodes[] = {
404  "udp4-encap",
405  NULL,
406 };
407 
408 const static char *const udp4_encap_ip6_nodes[] = {
409  "udp4-encap",
410  NULL,
411 };
412 
413 const static char *const udp4_encap_mpls_nodes[] = {
414  "udp4-encap",
415  NULL,
416 };
417 
418 const static char *const udp4_encap_bier_nodes[] = {
419  "udp4-encap",
420  NULL,
421 };
422 
423 const static char *const udp6_encap_ip4_nodes[] = {
424  "udp6-encap",
425  NULL,
426 };
427 
428 const static char *const udp6_encap_ip6_nodes[] = {
429  "udp6-encap",
430  NULL,
431 };
432 
433 const static char *const udp6_encap_mpls_nodes[] = {
434  "udp6-encap",
435  NULL,
436 };
437 
438 const static char *const udp6_encap_bier_nodes[] = {
439  "udp6-encap",
440  NULL,
441 };
442 
443 const static char *const *const udp4_encap_nodes[DPO_PROTO_NUM] = {
448 };
449 
450 const static char *const *const udp6_encap_nodes[DPO_PROTO_NUM] = {
455 };
456 
457 /*
458  * Virtual function table registered by UDP encaps
459  * for participation in the FIB object graph.
460  */
461 const static fib_node_vft_t udp_encap_fib_vft = {
463  .fnv_last_lock = udp_encap_fib_last_lock_gone,
464  .fnv_back_walk = udp_encap_fib_back_walk,
465 };
466 
467 const static dpo_vft_t udp_encap_dpo_vft = {
469  .dv_unlock = udp_encap_dpo_unlock,
470  .dv_format = format_udp_encap_dpo,
471 };
472 
473 clib_error_t *
475 {
476  udp_encap_db = hash_create (0, sizeof (index_t));
477 
478  fib_node_register_type (FIB_NODE_TYPE_UDP_ENCAP, &udp_encap_fib_vft);
479 
481  dpo_register_new_type (&udp_encap_dpo_vft, udp4_encap_nodes);
483  dpo_register_new_type (&udp_encap_dpo_vft, udp6_encap_nodes);
484 
485  return (NULL);
486 }
487 
489 
490 clib_error_t *
492  unformat_input_t * main_input, vlib_cli_command_t * cmd)
493 {
494  unformat_input_t _line_input, *line_input = &_line_input;
495  clib_error_t *error = NULL;
496  ip46_address_t src_ip, dst_ip;
497  u32 table_id, ue_id;
498  u32 src_port, dst_port;
500  fib_protocol_t fproto;
501  u8 is_del;
502 
503  is_del = 0;
504  table_id = 0;
505  flags = UDP_ENCAP_FIXUP_NONE;
506  fproto = FIB_PROTOCOL_MAX;
507  dst_port = 0;
508  ue_id = ~0;
509 
510  /* Get a line of input. */
511  if (!unformat_user (main_input, unformat_line_input, line_input))
512  return 0;
513 
514  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
515  {
516  if (unformat (line_input, "id %d", &ue_id))
517  ;
518  else if (unformat (line_input, "add"))
519  is_del = 0;
520  else if (unformat (line_input, "del"))
521  is_del = 1;
522  else if (unformat (line_input, "%U %U",
524  &src_ip.ip4, unformat_ip4_address, &dst_ip.ip4))
525  fproto = FIB_PROTOCOL_IP4;
526  else if (unformat (line_input, "%U %U",
528  &src_ip.ip6, unformat_ip6_address, &dst_ip.ip6))
529  fproto = FIB_PROTOCOL_IP6;
530  else if (unformat (line_input, "%d %d", &src_port, &dst_port))
531  ;
532  else if (unformat (line_input, "%d", &dst_port))
533  ;
534  else if (unformat (line_input, "table-id %d", &table_id))
535  ;
536  else if (unformat (line_input, "src-port-is-entropy"))
538  else
539  {
540  error = unformat_parse_error (line_input);
541  goto done;
542  }
543  }
544 
545  if (~0 == ue_id)
546  {
547  error =
548  clib_error_return (0, "An ID for the UDP encap instance is required");
549  goto done;
550  }
551 
552  if (!is_del && fproto != FIB_PROTOCOL_MAX)
553  {
554  u32 fib_index;
555  index_t uei;
556 
557  fib_index = fib_table_find (fproto, table_id);
558 
559  if (~0 == fib_index)
560  {
561  error = clib_error_return (0, "Nonexistent table id %d", table_id);
562  goto done;
563  }
564 
565  uei = udp_encap_add_and_lock (ue_id, fproto, fib_index,
566  &src_ip, &dst_ip,
567  src_port, dst_port, flags);
568 
569  if (INDEX_INVALID == uei)
570  {
571  error =
572  clib_error_return (0, "update to existing encap not supported %d",
573  ue_id);
574  goto done;
575  }
576  }
577  else if (is_del)
578  {
579  udp_encap_unlock (ue_id);
580  }
581  else
582  {
583  error =
585  "Some IP addresses would be usefull, don't you think?",
586  ue_id);
587  }
588 
589 done:
590  unformat_free (line_input);
591  return error;
592 }
593 
594 void
596 {
597  index_t uei;
598 
599  /* *INDENT-OFF* */
600  pool_foreach_index(uei, udp_encap_pool,
601  ({
602  if (WALK_STOP == cb(uei, ctx))
603  break;
604  }));
605  /* *INDENT-ON* */
606 }
607 
608 clib_error_t *
610  unformat_input_t * input, vlib_cli_command_t * cmd)
611 {
612  u32 ue_id;
613 
614  ue_id = ~0;
615 
616  /* Get a line of input. */
618  {
619  if (unformat (input, "%d", &ue_id))
620  ;
621  else
622  return clib_error_return (0, "unknown input `%U'",
623  format_unformat_error, input);
624  }
625 
626  if (~0 == ue_id)
627  {
628  udp_encap_t *ue;
629 
630  /* *INDENT-OFF* */
631  pool_foreach(ue, udp_encap_pool,
632  ({
633  vlib_cli_output(vm, "%U", format_udp_encap, ue->ue_id, 0);
634  }));
635  /* *INDENT-ON* */
636  }
637  else
638  {
639  vlib_cli_output (vm, "%U", format_udp_encap, ue_id, 1);
640  }
641 
642  return NULL;
643 }
644 
645 /* *INDENT-OFF* */
646 VLIB_CLI_COMMAND (udp_encap_add_command, static) = {
647  .path = "udp encap",
648  .short_help = "udp encap [add|del] <id ID> <src-ip> <dst-ip> [<src-port>] <dst-port> [src-port-is-entropy] [table-id <table>]",
649  .function = udp_encap_cli,
650  .is_mp_safe = 1,
651 };
652 VLIB_CLI_COMMAND (udp_encap_show_command, static) = {
653  .path = "show udp encap",
654  .short_help = "show udp encap [ID]",
655  .function = udp_encap_show,
656  .is_mp_safe = 1,
657 };
658 /* *INDENT-ON* */
659 
660 /*
661  * fd.io coding-style-patch-verification: ON
662  *
663  * Local Variables:
664  * eval: (c-set-style "gnu")
665  * End:
666  */
void udp_encap_walk(udp_encap_walk_cb_t cb, void *ctx)
Walk each of the encap objects.
Definition: udp_encap.c:595
fib_protocol_t ue_ip_proto
the protocol of the IP header imposed
Definition: udp_encap.h:83
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:202
u32 ue_fib_sibling
Definition: udp_encap.h:102
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:404
Recursive resolution source.
Definition: fib_entry.h:125
#define hash_set(h, key, value)
Definition: hash.h:255
dpo_type_t udp_encap_dpo_types[FIB_PROTOCOL_MAX]
Registered DPO types for the IP header encapsulated, v4 or v6.
Definition: udp_encap.c:24
The UDP encap represenation.
Definition: udp_encap.h:46
A virtual function table regisitered for a DPO type.
Definition: dpo.h:399
udp_encap_t * udp_encap_pool
Pool of encaps.
Definition: udp_encap.c:34
vlib_combined_counter_main_t udp_encap_counters
Stats for each UDP encap object.
Definition: udp_encap.c:39
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
Definition: counter.c:106
#define hash_unset(h, key)
Definition: hash.h:261
index_t udp_encap_find(u32 id)
Definition: udp_encap.c:187
void fib_node_init(fib_node_t *node, fib_node_type_t type)
Definition: fib_node.c:185
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
Definition: fib_entry.c:527
static u8 * format_udp_encap_i(u8 *s, va_list *args)
Definition: udp_encap.c:264
unsigned long u64
Definition: types.h:89
static const char *const udp6_encap_mpls_nodes[]
Definition: udp_encap.c:433
#define NULL
Definition: clib.h:55
fib_node_index_t ue_fib_entry_index
Tracking information for the IP destination.
Definition: udp_encap.h:101
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
static udp_encap_t * udp_encap_get_w_id(u32 id)
Definition: udp_encap.c:42
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:478
void udp_encap_lock(u32 id)
Definition: udp_encap.c:200
static void udp_encap_dpo_lock(dpo_id_t *dpo)
Definition: udp_encap.c:244
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
Definition: fib_entry.c:538
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
Definition: dpo.c:261
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
Combined counter to hold both packets and byte differences.
Definition: counter.h:140
dpo_id_t ue_dpo
The DPO used to forward to the next node in the VLIB graph.
Definition: udp_encap.h:78
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:62
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
clib_error_t * udp_encap_init(vlib_main_t *vm)
Definition: udp_encap.c:474
fib_node_t ue_fib_node
linkage into the FIB graph
Definition: udp_encap.h:90
unsigned char u8
Definition: types.h:56
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
uword * udp_encap_db
Hash DB to map from client ID to VPP index.
Definition: udp_encap.c:29
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
Definition: fib_node.c:60
u32 ue_id
The ID given by the user/client.
Definition: udp_encap.h:96
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
format_function_t format_ip4_address
Definition: format.h:81
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:443
unformat_function_t unformat_ip4_address
Definition: format.h:76
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:156
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
Aggregrate type for a prefix.
Definition: fib_types.h:193
#define clib_error_return(e, args...)
Definition: error.h:99
struct udp_encap_t_::@335::@336 ip4
unsigned int u32
Definition: types.h:88
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1056
void udp_encap_unlock(u32 id)
Definition: udp_encap.c:231
static const char *const *const udp4_encap_nodes[DPO_PROTO_NUM]
Definition: udp_encap.c:443
enum udp_encap_fixup_flags_t_ udp_encap_fixup_flags_t
UDP encapsualtion.
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
Definition: dpo.c:341
Definition: fib_entry.h:275
unformat_function_t unformat_line_input
Definition: format.h:282
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:168
static const char *const udp6_encap_ip6_nodes[]
Definition: udp_encap.c:428
#define hash_get(h, key)
Definition: hash.h:249
index_t udp_encap_add_and_lock(u32 id, fib_protocol_t proto, index_t fib_index, const ip46_address_t *src_ip, const ip46_address_t *dst_ip, u16 src_port, u16 dst_port, udp_encap_fixup_flags_t flags)
Definition: udp_encap.c:67
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:464
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
Definition: counter.h:278
counter_t packets
packet counter
Definition: counter.h:142
UDP source port contains an entropy/hash value for load-balancing by downstream peers.
Definition: udp_encap.h:40
clib_error_t * udp_encap_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: udp_encap.c:609
void fib_node_lock(fib_node_t *node)
Definition: fib_node.c:203
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
static void udp_encap_dpo_unlock(dpo_id_t *dpo)
Definition: udp_encap.c:254
u8 * format_udp_encap(u8 *s, va_list *args)
Definition: udp_encap.c:332
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:274
static void udp_encap_restack(udp_encap_t *ue)
Definition: udp_encap.c:58
static const char *const udp4_encap_bier_nodes[]
Definition: udp_encap.c:418
fib_node_type_t fn_type
The node&#39;s type.
Definition: fib_node.h:291
An node in the FIB graph.
Definition: fib_node.h:287
void fib_node_unlock(fib_node_t *node)
Definition: fib_node.c:209
u32 flags
Definition: vhost_user.h:110
unformat_function_t unformat_ip6_address
Definition: format.h:97
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Definition: pool.h:188
static u8 * format_udp_encap_dpo(u8 *s, va_list *args)
Definition: udp_encap.c:323
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a &#39;special&#39; entry to the FIB.
Definition: fib_table.c:388
index_t ue_fib_index
The FIB index in which the encap destination resides.
Definition: udp_encap.h:107
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
format_function_t format_ip6_address
Definition: format.h:99
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
Definition: counter.h:252
vlib_main_t * vm
Definition: buffer.c:294
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:877
fib_node_get_t fnv_get
Definition: fib_node.h:275
struct udp_encap_t_::@335::@337 ip6
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
static fib_node_back_walk_rc_t udp_encap_fib_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node.
Definition: udp_encap.c:360
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:185
Context passed between object during a back walk.
Definition: fib_node.h:200
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
#define hash_create(elts, value_bytes)
Definition: hash.h:696
#define ASSERT(truth)
long ctx[MAX_CONNS]
Definition: main.c:126
static const char *const udp6_encap_bier_nodes[]
Definition: udp_encap.c:438
static const char *const udp4_encap_ip4_nodes[]
Definition: udp_encap.c:403
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:237
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject
Definition: dpo.c:147
void udp_encap_get_stats(index_t uei, u64 *packets, u64 *bytes)
Definition: udp_encap.c:312
#define unformat_parse_error(input)
Definition: format.h:268
counter_t bytes
byte counter
Definition: counter.h:143
static udp_encap_t * udp_encap_from_fib_node(fib_node_t *node)
Definition: udp_encap.c:349
#define DPO_PROTO_NUM
Definition: dpo.h:70
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:184
walk_rc_t(* udp_encap_walk_cb_t)(index_t uei, void *ctx)
Callback function invoked when walking all encap objects.
Definition: udp_encap.h:134
u32 fn_locks
Number of dependents on this node.
Definition: fib_node.h:307
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
static const char *const udp4_encap_mpls_nodes[]
Definition: udp_encap.c:413
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:162
static fib_node_t * udp_encap_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
Definition: udp_encap.c:371
A collection of combined counters.
Definition: counter.h:181
#define FIB_PROTOCOL_MAX
Definition outside of enum so it does not need to be included in non-defaulted switch statements...
Definition: fib_types.h:52
A FIB graph nodes virtual function table.
Definition: fib_node.h:274
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static const char *const udp6_encap_ip4_nodes[]
Definition: udp_encap.c:423
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:231
udp_encap_fixup_flags_t ue_flags
Flags controlling fixup behaviour.
Definition: udp_encap.h:73
void udp_encap_unlock_w_index(index_t uei)
Definition: udp_encap.c:213
clib_error_t * udp_encap_cli(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
Definition: udp_encap.c:491
#define pool_foreach_index(i, v, body)
Iterate pool by index.
Definition: pool.h:488
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:62
static const char *const *const udp6_encap_nodes[DPO_PROTO_NUM]
Definition: udp_encap.c:450
static void udp_encap_fib_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
Definition: udp_encap.c:384
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:681
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:246
void udp_encap_contribute_forwarding(u32 id, dpo_proto_t proto, dpo_id_t *dpo)
Definition: udp_encap.c:166
static udp_encap_t * udp_encap_get(index_t uei)
Definition: udp_encap.h:147
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
union udp_encap_t_::@335 ue_hdrs
The headers to paint, in packet painting order.
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
Definition: dpo.c:515
static const char *const udp4_encap_ip6_nodes[]
Definition: udp_encap.c:408