FD.io VPP  v19.04-6-g6f05f72
Vector Packet Processing
udp_encap.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 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  * Pool of encaps
28  */
30 
31 /**
32  * Stats for each UDP encap object
33  */
34 vlib_combined_counter_main_t udp_encap_counters = {
35  /**
36  * The counter collection's name.
37  */
38  .name = "udp-encap",
39  /**
40  * Name in stat segment directory
41  */
42  .stat_segment_name = "/net/udp-encap",
43 };
44 
45 static void
47 {
50  &ue->ue_dpo,
52 }
53 
54 index_t
56  index_t fib_index,
57  const ip46_address_t * src_ip,
58  const ip46_address_t * dst_ip,
59  u16 src_port,
61 {
62  udp_encap_t *ue;
63  u8 pfx_len = 0;
64  index_t uei;
65 
66  pool_get_aligned (udp_encap_pool, ue, CLIB_CACHE_LINE_BYTES);
67  uei = ue - udp_encap_pool;
68 
69  vlib_validate_combined_counter (&(udp_encap_counters), uei);
70  vlib_zero_combined_counter (&(udp_encap_counters), uei);
71 
74  ue->ue_fib_index = fib_index;
75  ue->ue_flags = flags;
76  ue->ue_ip_proto = proto;
77 
78  switch (proto)
79  {
80  case FIB_PROTOCOL_IP4:
81  pfx_len = 32;
82  ue->ue_hdrs.ip4.ue_ip4.ip_version_and_header_length = 0x45;
83  ue->ue_hdrs.ip4.ue_ip4.ttl = 254;
84  ue->ue_hdrs.ip4.ue_ip4.protocol = IP_PROTOCOL_UDP;
85  ue->ue_hdrs.ip4.ue_ip4.src_address.as_u32 = src_ip->ip4.as_u32;
86  ue->ue_hdrs.ip4.ue_ip4.dst_address.as_u32 = dst_ip->ip4.as_u32;
87  ue->ue_hdrs.ip4.ue_ip4.checksum =
88  ip4_header_checksum (&ue->ue_hdrs.ip4.ue_ip4);
89  ue->ue_hdrs.ip4.ue_udp.src_port = clib_host_to_net_u16 (src_port);
90  ue->ue_hdrs.ip4.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
91 
92  break;
93  case FIB_PROTOCOL_IP6:
94  pfx_len = 128;
95  ue->ue_hdrs.ip6.ue_ip6.ip_version_traffic_class_and_flow_label =
96  clib_host_to_net_u32 (6 << 28);
97  ue->ue_hdrs.ip6.ue_ip6.hop_limit = 255;
98  ue->ue_hdrs.ip6.ue_ip6.protocol = IP_PROTOCOL_UDP;
99  ue->ue_hdrs.ip6.ue_ip6.src_address.as_u64[0] = src_ip->ip6.as_u64[0];
100  ue->ue_hdrs.ip6.ue_ip6.src_address.as_u64[1] = src_ip->ip6.as_u64[1];
101  ue->ue_hdrs.ip6.ue_ip6.dst_address.as_u64[0] = dst_ip->ip6.as_u64[0];
102  ue->ue_hdrs.ip6.ue_ip6.dst_address.as_u64[1] = dst_ip->ip6.as_u64[1];
103  ue->ue_hdrs.ip6.ue_udp.src_port = clib_host_to_net_u16 (src_port);
104  ue->ue_hdrs.ip6.ue_udp.dst_port = clib_host_to_net_u16 (dst_port);
105 
106  break;
107  default:
108  ASSERT (0);
109  }
110 
111  /*
112  * track the destination address
113  */
114  fib_prefix_t dst_pfx = {
115  .fp_proto = proto,
116  .fp_len = pfx_len,
117  .fp_addr = *dst_ip,
118  };
119 
120  ue->ue_fib_entry_index =
121  fib_table_entry_special_add (fib_index,
122  &dst_pfx,
124  ue->ue_fib_sibling =
127 
128  udp_encap_restack (ue);
129 
130  return (uei);
131 }
132 
133 void
135  dpo_id_t * dpo)
136 {
137  if (INDEX_INVALID == uei)
138  {
139  dpo_copy (dpo, drop_dpo_get (proto));
140  }
141  else
142  {
143  udp_encap_t *ue;
144 
145  ue = udp_encap_get (uei);
146 
147  dpo_set (dpo, udp_encap_dpo_types[ue->ue_ip_proto], proto, uei);
148  }
149 }
150 
151 void
153 {
154  udp_encap_t *ue;
155 
156  ue = udp_encap_get (uei);
157 
158  if (NULL != ue)
159  {
160  fib_node_lock (&ue->ue_fib_node);
161  }
162 }
163 
164 void
166 {
167  udp_encap_t *ue;
168 
169  if (INDEX_INVALID == uei)
170  {
171  return;
172  }
173 
174  ue = udp_encap_get (uei);
175 
176  if (NULL != ue)
177  {
179  }
180 }
181 
182 static void
184 {
185  udp_encap_t *ue;
186 
187  ue = udp_encap_get (dpo->dpoi_index);
188 
189  fib_node_lock (&ue->ue_fib_node);
190 }
191 
192 static void
194 {
195  udp_encap_t *ue;
196 
197  ue = udp_encap_get (dpo->dpoi_index);
198 
200 }
201 
202 static u8 *
203 format_udp_encap_i (u8 * s, va_list * args)
204 {
205  index_t uei = va_arg (*args, index_t);
206  u32 indent = va_arg (*args, u32);
207  u32 details = va_arg (*args, u32);
208  vlib_counter_t to;
209  udp_encap_t *ue;
210 
211  ue = udp_encap_get (uei);
212 
213  // FIXME
214  s = format (s, "udp-ecap:[%d]: ip-fib-index:%d ", uei, ue->ue_fib_index);
215  if (FIB_PROTOCOL_IP4 == ue->ue_ip_proto)
216  {
217  s = format (s, "ip:[src:%U, dst:%U] udp:[src:%d, dst:%d]",
219  &ue->ue_hdrs.ip4.ue_ip4.src_address,
221  &ue->ue_hdrs.ip4.ue_ip4.dst_address,
222  clib_net_to_host_u16 (ue->ue_hdrs.ip4.ue_udp.src_port),
223  clib_net_to_host_u16 (ue->ue_hdrs.ip4.ue_udp.dst_port));
224  }
225  else
226  {
227  s = format (s, "ip:[src:%U, dst:%U] udp:[src:%d dst:%d]",
229  &ue->ue_hdrs.ip6.ue_ip6.src_address,
231  &ue->ue_hdrs.ip6.ue_ip6.dst_address,
232  clib_net_to_host_u16 (ue->ue_hdrs.ip6.ue_udp.src_port),
233  clib_net_to_host_u16 (ue->ue_hdrs.ip6.ue_udp.dst_port));
234  }
235  vlib_get_combined_counter (&(udp_encap_counters), uei, &to);
236  s = format (s, " to:[%Ld:%Ld]]", to.packets, to.bytes);
237 
238  if (details)
239  {
240  s = format (s, " locks:%d", ue->ue_fib_node.fn_locks);
241  s = format (s, "\n%UStacked on:", format_white_space, indent + 1);
242  s = format (s, "\n%U%U",
243  format_white_space, indent + 2,
244  format_dpo_id, &ue->ue_dpo, indent + 3);
245  }
246  return (s);
247 }
248 
249 void
250 udp_encap_get_stats (index_t uei, u64 * packets, u64 * bytes)
251 {
252  vlib_counter_t to;
253 
254  vlib_get_combined_counter (&(udp_encap_counters), uei, &to);
255 
256  *packets = to.packets;
257  *bytes = to.bytes;
258 }
259 
260 static u8 *
261 format_udp_encap_dpo (u8 * s, va_list * args)
262 {
263  index_t uei = va_arg (*args, index_t);
264  u32 indent = va_arg (*args, u32);
265 
266  return (format (s, "%U", format_udp_encap_i, uei, indent, 1));
267 }
268 
269 u8 *
270 format_udp_encap (u8 * s, va_list * args)
271 {
272  index_t uei = va_arg (*args, u32);
273  u32 details = va_arg (*args, u32);
274 
275  return (format (s, "%U", format_udp_encap_i, uei, 0, details));
276 }
277 
278 static udp_encap_t *
280 {
282  return ((udp_encap_t *) (((char *) node) -
283  STRUCT_OFFSET_OF (udp_encap_t, ue_fib_node)));
284 }
285 
286 /**
287  * Function definition to backwalk a FIB node
288  */
291 {
293 
295 }
296 
297 /**
298  * Function definition to get a FIB node from its index
299  */
300 static fib_node_t *
302 {
303  udp_encap_t *ue;
304 
305  ue = pool_elt_at_index (udp_encap_pool, index);
306 
307  return (&ue->ue_fib_node);
308 }
309 
310 /**
311  * Function definition to inform the FIB node that its last lock has gone.
312  */
313 static void
315 {
316  udp_encap_t *ue;
317 
318  ue = udp_encap_from_fib_node (node);
319 
320  /**
321  * reset the stacked DPO to unlock it
322  */
323  dpo_reset (&ue->ue_dpo);
324 
327 
328 
329  pool_put (udp_encap_pool, ue);
330 }
331 
332 const static char *const udp4_encap_ip4_nodes[] = {
333  "udp4-encap",
334  NULL,
335 };
336 
337 const static char *const udp4_encap_ip6_nodes[] = {
338  "udp4-encap",
339  NULL,
340 };
341 
342 const static char *const udp4_encap_mpls_nodes[] = {
343  "udp4-encap",
344  NULL,
345 };
346 
347 const static char *const udp4_encap_bier_nodes[] = {
348  "udp4-encap",
349  NULL,
350 };
351 
352 const static char *const udp6_encap_ip4_nodes[] = {
353  "udp6-encap",
354  NULL,
355 };
356 
357 const static char *const udp6_encap_ip6_nodes[] = {
358  "udp6-encap",
359  NULL,
360 };
361 
362 const static char *const udp6_encap_mpls_nodes[] = {
363  "udp6-encap",
364  NULL,
365 };
366 
367 const static char *const udp6_encap_bier_nodes[] = {
368  "udp6-encap",
369  NULL,
370 };
371 
372 const static char *const *const udp4_encap_nodes[DPO_PROTO_NUM] = {
377 };
378 
379 const static char *const *const udp6_encap_nodes[DPO_PROTO_NUM] = {
384 };
385 
386 /*
387  * Virtual function table registered by UDP encaps
388  * for participation in the FIB object graph.
389  */
390 const static fib_node_vft_t udp_encap_fib_vft = {
392  .fnv_last_lock = udp_encap_fib_last_lock_gone,
393  .fnv_back_walk = udp_encap_fib_back_walk,
394 };
395 
396 const static dpo_vft_t udp_encap_dpo_vft = {
398  .dv_unlock = udp_encap_dpo_unlock,
399  .dv_format = format_udp_encap_dpo,
400 };
401 
402 clib_error_t *
404 {
405  fib_node_register_type (FIB_NODE_TYPE_UDP_ENCAP, &udp_encap_fib_vft);
406 
408  dpo_register_new_type (&udp_encap_dpo_vft, udp4_encap_nodes);
410  dpo_register_new_type (&udp_encap_dpo_vft, udp6_encap_nodes);
411 
412  return (NULL);
413 }
414 
416 
417 clib_error_t *
419  unformat_input_t * main_input, vlib_cli_command_t * cmd)
420 {
421  unformat_input_t _line_input, *line_input = &_line_input;
422  clib_error_t *error = NULL;
423  ip46_address_t src_ip, dst_ip;
424  u32 table_id, src_port, dst_port;
426  fib_protocol_t fproto;
427  index_t uei;
428  u8 is_del;
429 
430  is_del = 0;
431  table_id = 0;
432  flags = UDP_ENCAP_FIXUP_NONE;
433  fproto = FIB_PROTOCOL_MAX;
434  dst_port = 0;
435  uei = ~0;
436 
437  /* Get a line of input. */
438  if (!unformat_user (main_input, unformat_line_input, line_input))
439  return 0;
440 
441  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
442  {
443  if (unformat (line_input, "index %d", &uei))
444  ;
445  else if (unformat (line_input, "add"))
446  is_del = 0;
447  else if (unformat (line_input, "del"))
448  is_del = 1;
449  else if (unformat (line_input, "%U %U",
451  &src_ip.ip4, unformat_ip4_address, &dst_ip.ip4))
452  fproto = FIB_PROTOCOL_IP4;
453  else if (unformat (line_input, "%U %U",
455  &src_ip.ip6, unformat_ip6_address, &dst_ip.ip6))
456  fproto = FIB_PROTOCOL_IP6;
457  else if (unformat (line_input, "%d %d", &src_port, &dst_port))
458  ;
459  else if (unformat (line_input, "%d", &dst_port))
460  ;
461  else if (unformat (line_input, "table-id %d", &table_id))
462  ;
463  else if (unformat (line_input, "src-port-is-entropy"))
465  else
466  {
467  error = unformat_parse_error (line_input);
468  goto done;
469  }
470  }
471 
472  if (!is_del && fproto != FIB_PROTOCOL_MAX)
473  {
474  u32 fib_index;
475  index_t uei;
476 
477  fib_index = fib_table_find (fproto, table_id);
478 
479  if (~0 == fib_index)
480  {
481  error = clib_error_return (0, "Nonexistent table id %d", table_id);
482  goto done;
483  }
484 
485  uei = udp_encap_add_and_lock (fproto, fib_index,
486  &src_ip, &dst_ip,
487  src_port, dst_port, flags);
488 
489  vlib_cli_output (vm, "udp-encap: %d\n", uei);
490  }
491  else if (is_del)
492  {
493  if (INDEX_INVALID == uei)
494  {
495  error = clib_error_return (0, "specify udp-encap object index");
496  goto done;
497  }
498  udp_encap_unlock (uei);
499  }
500  else
501  {
502  error = clib_error_return (0, "specify some IP addresses");
503  }
504 
505 done:
506  unformat_free (line_input);
507  return error;
508 }
509 
510 void
512 {
513  index_t uei;
514 
515  /* *INDENT-OFF* */
516  pool_foreach_index(uei, udp_encap_pool,
517  ({
518  if (WALK_STOP == cb(uei, ctx))
519  break;
520  }));
521  /* *INDENT-ON* */
522 }
523 
524 clib_error_t *
526  unformat_input_t * input, vlib_cli_command_t * cmd)
527 {
528  index_t uei;
529 
530  uei = INDEX_INVALID;
531 
532  /* Get a line of input. */
534  {
535  if (unformat (input, "%d", &uei))
536  ;
537  else
538  return clib_error_return (0, "unknown input `%U'",
539  format_unformat_error, input);
540  }
541 
542  if (INDEX_INVALID == uei)
543  {
544  /* *INDENT-OFF* */
545  pool_foreach_index(uei, udp_encap_pool,
546  ({
547  vlib_cli_output(vm, "%U", format_udp_encap, uei, 0);
548  }));
549  /* *INDENT-ON* */
550  }
551  else
552  {
553  vlib_cli_output (vm, "%U", format_udp_encap, uei, 1);
554  }
555 
556  return NULL;
557 }
558 
559 /* *INDENT-OFF* */
560 VLIB_CLI_COMMAND (udp_encap_add_command, static) = {
561  .path = "udp encap",
562  .short_help = "udp encap [add|del] <id ID> <src-ip> <dst-ip> [<src-port>] <dst-port> [src-port-is-entropy] [table-id <table>]",
563  .function = udp_encap_cli,
564  .is_mp_safe = 1,
565 };
566 VLIB_CLI_COMMAND (udp_encap_show_command, static) = {
567  .path = "show udp encap",
568  .short_help = "show udp encap [ID]",
569  .function = udp_encap_show,
570  .is_mp_safe = 1,
571 };
572 /* *INDENT-ON* */
573 
574 /*
575  * fd.io coding-style-patch-verification: ON
576  *
577  * Local Variables:
578  * eval: (c-set-style "gnu")
579  * End:
580  */
void udp_encap_walk(udp_encap_walk_cb_t cb, void *ctx)
Walk each of the encap objects.
Definition: udp_encap.c:511
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:212
u32 ue_fib_sibling
Definition: udp_encap.h:99
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:404
Recursive resolution source.
Definition: fib_entry.h:125
u32 flags
Definition: vhost_user.h:115
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 representation.
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:29
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
Definition: counter.c:106
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:555
static u8 * format_udp_encap_i(u8 *s, va_list *args)
Definition: udp_encap.c:203
index_t udp_encap_add_and_lock(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:55
unsigned long u64
Definition: types.h:89
static const char *const udp6_encap_mpls_nodes[]
Definition: udp_encap.c:362
#define NULL
Definition: clib.h:58
fib_node_index_t ue_fib_entry_index
Tracking information for the IP destination.
Definition: udp_encap.h:98
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:506
static void udp_encap_dpo_lock(dpo_id_t *dpo)
Definition: udp_encap.c:183
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
Definition: fib_entry.c:566
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_types.h:26
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:65
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
clib_error_t * udp_encap_init(vlib_main_t *vm)
Definition: udp_encap.c:403
fib_node_t ue_fib_node
linkage into the FIB graph
Definition: udp_encap.h:93
union udp_encap_t_::@357 ue_hdrs
The headers to paint, in packet painting order.
unsigned char u8
Definition: types.h:56
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
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
u16 src_port
Definition: udp.api:41
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:75
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
unformat_function_t unformat_ip4_address
Definition: format.h:70
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
Aggregrate type for a prefix.
Definition: fib_types.h:203
#define clib_error_return(e, args...)
Definition: error.h:99
struct udp_encap_t_::@357::@358 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:1064
static const char *const *const udp4_encap_nodes[DPO_PROTO_NUM]
Definition: udp_encap.c:372
enum udp_encap_fixup_flags_t_ udp_encap_fixup_flags_t
UDP encapsulation.
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:357
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
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:285
counter_t packets
packet counter
Definition: counter_types.h:28
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:525
void fib_node_lock(fib_node_t *node)
Definition: fib_node.c:203
long ctx[MAX_CONNS]
Definition: main.c:144
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:193
u8 * format_udp_encap(u8 *s, va_list *args)
Definition: udp_encap.c:270
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
static void udp_encap_restack(udp_encap_t *ue)
Definition: udp_encap.c:46
static const char *const udp4_encap_bier_nodes[]
Definition: udp_encap.c:347
fib_node_type_t fn_type
The node&#39;s type.
Definition: fib_node.h:295
An node in the FIB graph.
Definition: fib_node.h:291
void fib_node_unlock(fib_node_t *node)
Definition: fib_node.c:209
unformat_function_t unformat_ip6_address
Definition: format.h:91
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:230
static u8 * format_udp_encap_dpo(u8 *s, va_list *args)
Definition: udp_encap.c:261
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:104
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
format_function_t format_ip6_address
Definition: format.h:93
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:259
vlib_main_t * vm
Definition: buffer.c:312
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
void udp_encap_lock(index_t uei)
Definition: udp_encap.c:152
fib_node_get_t fnv_get
Definition: fib_node.h:279
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:290
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:204
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
#define ASSERT(truth)
struct udp_encap_t_::@357::@359 ip6
static const char *const udp6_encap_bier_nodes[]
Definition: udp_encap.c:367
static const char *const udp4_encap_ip4_nodes[]
Definition: udp_encap.c:332
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:250
vl_api_address_t src_ip
Definition: udp.api:43
#define unformat_parse_error(input)
Definition: format.h:268
counter_t bytes
byte counter
Definition: counter_types.h:29
static udp_encap_t * udp_encap_from_fib_node(fib_node_t *node)
Definition: udp_encap.c:279
#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:128
u32 fn_locks
Number of dependents on this node.
Definition: fib_node.h:311
#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:342
static void unformat_free(unformat_input_t *i)
Definition: format.h:162
char * name
The counter collection&#39;s name.
Definition: counter.h:193
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:301
A collection of combined counters.
Definition: counter.h:188
#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
vl_api_address_t dst_ip
Definition: udp.api:44
A FIB graph nodes virtual function table.
Definition: fib_node.h:278
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:352
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
clib_error_t * udp_encap_cli(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
Definition: udp_encap.c:418
void udp_encap_unlock(index_t uei)
Definition: udp_encap.c:165
u16 dst_port
Definition: udp.api:42
#define pool_foreach_index(i, v, body)
Iterate pool by index.
Definition: pool.h:538
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
static const char *const *const udp6_encap_nodes[DPO_PROTO_NUM]
Definition: udp_encap.c:379
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:314
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:725
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:247
static udp_encap_t * udp_encap_get(index_t uei)
Definition: udp_encap.h:141
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
void udp_encap_contribute_forwarding(index_t uei, dpo_proto_t proto, dpo_id_t *dpo)
Definition: udp_encap.c:134
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:337