FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
ip4_full_reass.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 /**
17  * @file
18  * @brief IPv4 Full Reassembly.
19  *
20  * This file contains the source code for IPv4 full reassembly.
21  */
22 
23 #include <vppinfra/vec.h>
24 #include <vnet/vnet.h>
25 #include <vnet/ip/ip.h>
26 #include <vppinfra/fifo.h>
27 #include <vppinfra/bihash_16_8.h>
29 #include <stddef.h>
30 
31 #define MSEC_PER_SEC 1000
32 #define IP4_REASS_TIMEOUT_DEFAULT_MS 100
33 #define IP4_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS 10000 // 10 seconds default
34 #define IP4_REASS_MAX_REASSEMBLIES_DEFAULT 1024
35 #define IP4_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT 3
36 #define IP4_REASS_HT_LOAD_FACTOR (0.75)
37 
38 #define IP4_REASS_DEBUG_BUFFERS 0
39 #if IP4_REASS_DEBUG_BUFFERS
40 #define IP4_REASS_DEBUG_BUFFER(bi, what) \
41  do \
42  { \
43  u32 _bi = bi; \
44  printf (#what "buffer %u", _bi); \
45  vlib_buffer_t *_b = vlib_get_buffer (vm, _bi); \
46  while (_b->flags & VLIB_BUFFER_NEXT_PRESENT) \
47  { \
48  _bi = _b->next_buffer; \
49  printf ("[%u]", _bi); \
50  _b = vlib_get_buffer (vm, _bi); \
51  } \
52  printf ("\n"); \
53  fflush (stdout); \
54  } \
55  while (0)
56 #else
57 #define IP4_REASS_DEBUG_BUFFER(...)
58 #endif
59 
60 typedef enum
61 {
68 
69 typedef struct
70 {
71  union
72  {
73  struct
74  {
81  };
82  u64 as_u64[2];
83  };
85 
86 typedef union
87 {
88  struct
89  {
92  };
95 
96 typedef union
97 {
98  struct
99  {
102  };
105 
108 {
110  return vnb->ip.reass.range_first - vnb->ip.reass.fragment_first;
111 }
112 
115 {
117  return clib_min (vnb->ip.reass.range_last, vnb->ip.reass.fragment_last) -
118  (vnb->ip.reass.fragment_first +
120 }
121 
122 typedef struct
123 {
124  // hash table key
126  // time when last packet was received
128  // internal id of this reassembly
130  // buffer index of first buffer in this reassembly context
132  // last octet of packet, ~0 until fragment without more_fragments arrives
134  // length of data collected so far
136  // trace operation counter
138  // next index - used by non-feature node
140  // error next index - used by custom apps (~0 if not used)
142  // minimum fragment length for this reassembly - used to estimate MTU
144  // number of fragments in this reassembly
146  // thread owning memory for this context (whose pool contains this ctx)
148  // thread which received fragment with offset 0 and which sends out the
149  // completed reassembly
152 
153 typedef struct
154 {
160 
161 typedef struct
162 {
163  // IPv4 config
167  // maximum number of fragments in one reassembly
169  // maximum number of reassemblies
171 
172  // IPv4 runtime
173  clib_bihash_16_8_t hash;
174  // per-thread data
176 
177  // convenience
179 
180  // node index of ip4-drop node
183 
184  /** Worker handoff */
187 
189 
191 
192 #ifndef CLIB_MARCH_VARIANT
194 #endif /* CLIB_MARCH_VARIANT */
195 
196 typedef enum
197 {
203 
204 typedef enum
205 {
213 
214 typedef struct
215 {
223 
224 typedef struct
225 {
226  ip4_full_reass_trace_operation_e action;
237 
240 
241 static void
244 {
245  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
247  trace->range_first = vnb->ip.reass.range_first;
248  trace->range_last = vnb->ip.reass.range_last;
251  trace->range_bi = bi;
252 }
253 
254 static u8 *
256 {
258  va_arg (*args, ip4_full_reass_range_trace_t *);
259  s =
260  format (s, "range: [%u, %u], off %d, len %u, bi %u", trace->range_first,
261  trace->range_last, trace->data_offset, trace->data_len,
262  trace->range_bi);
263  return s;
264 }
265 
266 static u8 *
267 format_ip4_full_reass_trace (u8 * s, va_list * args)
268 {
269  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
270  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
271  ip4_full_reass_trace_t *t = va_arg (*args, ip4_full_reass_trace_t *);
272  u32 indent = 0;
273  if (~0 != t->reass_id)
274  {
275  s = format (s, "reass id: %u, op id: %u, ", t->reass_id, t->op_id);
276  indent = format_get_indent (s);
277  s =
278  format (s,
279  "first bi: %u, data len: %u, ip/fragment[%u, %u]",
281  t->fragment_last);
282  }
283  switch (t->action)
284  {
285  case RANGE_SHRINK:
286  s = format (s, "\n%Ushrink %U by %u", format_white_space, indent,
288  t->size_diff);
289  break;
290  case RANGE_DISCARD:
291  s = format (s, "\n%Udiscard %U", format_white_space, indent,
293  break;
294  case RANGE_NEW:
295  s = format (s, "\n%Unew %U", format_white_space, indent,
297  break;
298  case RANGE_OVERLAP:
299  s = format (s, "\n%Uoverlapping/ignored %U", format_white_space, indent,
301  break;
302  case FINALIZE:
303  s = format (s, "\n%Ufinalize reassembly", format_white_space, indent);
304  break;
305  case HANDOFF:
306  s =
307  format (s, "handoff from thread #%u to thread #%u", t->thread_id,
308  t->thread_id_to);
309  break;
310  }
311  return s;
312 }
313 
314 static void
317  ip4_full_reass_t * reass, u32 bi,
318  ip4_full_reass_trace_operation_e action,
319  u32 size_diff, u32 thread_id_to)
320 {
321  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
323  ip4_full_reass_trace_t *t = vlib_add_trace (vm, node, b, sizeof (t[0]));
324  if (reass)
325  {
326  t->reass_id = reass->id;
327  t->op_id = reass->trace_op_counter;
328  t->trace_range.first_bi = reass->first_bi;
329  t->total_data_len = reass->data_len;
330  ++reass->trace_op_counter;
331  }
332  else
333  {
334  t->reass_id = ~0;
335  t->op_id = 0;
336  t->trace_range.first_bi = 0;
337  t->total_data_len = 0;
338  }
339  t->action = action;
341  t->size_diff = size_diff;
342  t->thread_id = vm->thread_index;
343  t->thread_id_to = thread_id_to;
344  t->fragment_first = vnb->ip.reass.fragment_first;
345  t->fragment_last = vnb->ip.reass.fragment_last;
346 #if 0
347  static u8 *s = NULL;
348  s = format (s, "%U", format_ip4_full_reass_trace, NULL, NULL, t);
349  printf ("%.*s\n", vec_len (s), s);
350  fflush (stdout);
351  vec_reset_length (s);
352 #endif
353 }
354 
355 always_inline void
357  ip4_full_reass_t * reass)
358 {
359  pool_put (rt->pool, reass);
360  --rt->reass_n;
361 }
362 
363 always_inline void
366  ip4_full_reass_t * reass)
367 {
369  kv.key[0] = reass->key.as_u64[0];
370  kv.key[1] = reass->key.as_u64[1];
371  clib_bihash_add_del_16_8 (&rm->hash, &kv, 0);
372  return ip4_full_reass_free_ctx (rt, reass);
373 }
374 
375 always_inline void
378 {
379  u32 range_bi = reass->first_bi;
380  vlib_buffer_t *range_b;
381  vnet_buffer_opaque_t *range_vnb;
382  u32 *to_free = NULL;
383  while (~0 != range_bi)
384  {
385  range_b = vlib_get_buffer (vm, range_bi);
386  range_vnb = vnet_buffer (range_b);
387  u32 bi = range_bi;
388  while (~0 != bi)
389  {
390  vec_add1 (to_free, bi);
391  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
392  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
393  {
394  bi = b->next_buffer;
395  b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
396  }
397  else
398  {
399  bi = ~0;
400  }
401  }
402  range_bi = range_vnb->ip.reass.next_range_bi;
403  }
404  /* send to next_error_index */
405  if (~0 != reass->error_next_index)
406  {
407  u32 n_left_to_next, *to_next, next_index;
408 
409  next_index = reass->error_next_index;
410  u32 bi = ~0;
411 
412  while (vec_len (to_free) > 0)
413  {
414  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
415 
416  while (vec_len (to_free) > 0 && n_left_to_next > 0)
417  {
418  bi = vec_pop (to_free);
419 
420  if (~0 != bi)
421  {
422  to_next[0] = bi;
423  to_next += 1;
424  n_left_to_next -= 1;
425  }
426  }
427  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
428  }
429  }
430  else
431  {
432  vlib_buffer_free (vm, to_free, vec_len (to_free));
433  }
434 }
435 
436 always_inline void
438 {
439  reass->first_bi = ~0;
440  reass->last_packet_octet = ~0;
441  reass->data_len = 0;
442  reass->next_index = ~0;
443  reass->error_next_index = ~0;
444 }
445 
450  ip4_full_reass_kv_t * kv, u8 * do_handoff)
451 {
452  ip4_full_reass_t *reass;
453  f64 now;
454 
455 again:
456 
457  reass = NULL;
458  now = vlib_time_now (vm);
459  if (!clib_bihash_search_16_8
460  (&rm->hash, (clib_bihash_kv_16_8_t *) kv, (clib_bihash_kv_16_8_t *) kv))
461  {
462  if (vm->thread_index != kv->v.memory_owner_thread_index)
463  {
464  *do_handoff = 1;
465  return NULL;
466  }
467  reass =
469  [kv->v.memory_owner_thread_index].pool,
470  kv->v.reass_index);
471 
472  if (now > reass->last_heard + rm->timeout)
473  {
474  ip4_full_reass_drop_all (vm, node, rm, reass);
475  ip4_full_reass_free (rm, rt, reass);
476  reass = NULL;
477  }
478  }
479 
480  if (reass)
481  {
482  reass->last_heard = now;
483  return reass;
484  }
485 
486  if (rt->reass_n >= rm->max_reass_n)
487  {
488  reass = NULL;
489  return reass;
490  }
491  else
492  {
493  pool_get (rt->pool, reass);
494  clib_memset (reass, 0, sizeof (*reass));
495  reass->id = ((u64) vm->thread_index * 1000000000) + rt->id_counter;
497  ++rt->id_counter;
498  ip4_full_reass_init (reass);
499  ++rt->reass_n;
500  }
501 
502  reass->key.as_u64[0] = ((clib_bihash_kv_16_8_t *) kv)->key[0];
503  reass->key.as_u64[1] = ((clib_bihash_kv_16_8_t *) kv)->key[1];
504  kv->v.reass_index = (reass - rt->pool);
505  kv->v.memory_owner_thread_index = vm->thread_index;
506  reass->last_heard = now;
507 
508  int rv =
509  clib_bihash_add_del_16_8 (&rm->hash, (clib_bihash_kv_16_8_t *) kv, 2);
510  if (rv)
511  {
512  ip4_full_reass_free_ctx (rt, reass);
513  reass = NULL;
514  // if other worker created a context already work with the other copy
515  if (-2 == rv)
516  goto again;
517  }
518 
519  return reass;
520 }
521 
522 always_inline ip4_full_reass_rc_t
526  ip4_full_reass_t * reass, u32 * bi0,
527  u32 * next0, u32 * error0, bool is_custom_app)
528 {
529  vlib_buffer_t *first_b = vlib_get_buffer (vm, reass->first_bi);
530  vlib_buffer_t *last_b = NULL;
531  u32 sub_chain_bi = reass->first_bi;
532  u32 total_length = 0;
533  u32 buf_cnt = 0;
534  do
535  {
536  u32 tmp_bi = sub_chain_bi;
537  vlib_buffer_t *tmp = vlib_get_buffer (vm, tmp_bi);
539  vnet_buffer_opaque_t *vnb = vnet_buffer (tmp);
540  if (!(vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first) &&
541  !(vnb->ip.reass.range_last > vnb->ip.reass.fragment_first))
542  {
544  }
545 
546  u32 data_len = ip4_full_reass_buffer_get_data_len (tmp);
547  u32 trim_front =
549  u32 trim_end =
550  vlib_buffer_length_in_chain (vm, tmp) - trim_front - data_len;
551  if (tmp_bi == reass->first_bi)
552  {
553  /* first buffer - keep ip4 header */
555  {
557  }
558  trim_front = 0;
559  trim_end = vlib_buffer_length_in_chain (vm, tmp) - data_len -
560  ip4_header_bytes (ip);
561  if (!(vlib_buffer_length_in_chain (vm, tmp) - trim_end > 0))
562  {
564  }
565  }
566  u32 keep_data =
567  vlib_buffer_length_in_chain (vm, tmp) - trim_front - trim_end;
568  while (1)
569  {
570  ++buf_cnt;
571  if (trim_front)
572  {
573  if (trim_front > tmp->current_length)
574  {
575  /* drop whole buffer */
576  u32 to_be_freed_bi = tmp_bi;
577  trim_front -= tmp->current_length;
578  if (!(tmp->flags & VLIB_BUFFER_NEXT_PRESENT))
579  {
581  }
582  tmp->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
583  tmp_bi = tmp->next_buffer;
584  tmp->next_buffer = 0;
585  tmp = vlib_get_buffer (vm, tmp_bi);
586  vlib_buffer_free_one (vm, to_be_freed_bi);
587  continue;
588  }
589  else
590  {
591  vlib_buffer_advance (tmp, trim_front);
592  trim_front = 0;
593  }
594  }
595  if (keep_data)
596  {
597  if (last_b)
598  {
599  last_b->flags |= VLIB_BUFFER_NEXT_PRESENT;
600  last_b->next_buffer = tmp_bi;
601  }
602  last_b = tmp;
603  if (keep_data <= tmp->current_length)
604  {
605  tmp->current_length = keep_data;
606  keep_data = 0;
607  }
608  else
609  {
610  keep_data -= tmp->current_length;
611  if (!(tmp->flags & VLIB_BUFFER_NEXT_PRESENT))
612  {
614  }
615  }
616  total_length += tmp->current_length;
617  if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
618  {
619  tmp_bi = tmp->next_buffer;
620  tmp = vlib_get_buffer (vm, tmp->next_buffer);
621  }
622  else
623  {
624  break;
625  }
626  }
627  else
628  {
629  u32 to_be_freed_bi = tmp_bi;
630  if (reass->first_bi == tmp_bi)
631  {
633  }
634  if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
635  {
636  tmp->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
637  tmp_bi = tmp->next_buffer;
638  tmp->next_buffer = 0;
639  tmp = vlib_get_buffer (vm, tmp_bi);
640  vlib_buffer_free_one (vm, to_be_freed_bi);
641  }
642  else
643  {
644  tmp->next_buffer = 0;
645  vlib_buffer_free_one (vm, to_be_freed_bi);
646  break;
647  }
648  }
649  }
650  sub_chain_bi =
651  vnet_buffer (vlib_get_buffer (vm, sub_chain_bi))->ip.
652  reass.next_range_bi;
653  }
654  while (~0 != sub_chain_bi);
655 
656  if (!last_b)
657  {
659  }
660  last_b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
661 
662  if (total_length < first_b->current_length)
663  {
665  }
666  total_length -= first_b->current_length;
667  first_b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
668  first_b->total_length_not_including_first_buffer = total_length;
671  ip->length = clib_host_to_net_u16 (first_b->current_length + total_length);
672  ip->checksum = ip4_header_checksum (ip);
673  if (!vlib_buffer_chain_linearize (vm, first_b))
674  {
675  return IP4_REASS_RC_NO_BUF;
676  }
677  // reset to reconstruct the mbuf linking
678  first_b->flags &= ~VLIB_BUFFER_EXT_HDR_VALID;
679  if (PREDICT_FALSE (first_b->flags & VLIB_BUFFER_IS_TRACED))
680  {
681  ip4_full_reass_add_trace (vm, node, rm, reass, reass->first_bi,
682  FINALIZE, 0, ~0);
683 #if 0
684  // following code does a hexdump of packet fragments to stdout ...
685  do
686  {
687  u32 bi = reass->first_bi;
688  u8 *s = NULL;
689  while (~0 != bi)
690  {
691  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
692  s = format (s, "%u: %U\n", bi, format_hexdump,
694  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
695  {
696  bi = b->next_buffer;
697  }
698  else
699  {
700  break;
701  }
702  }
703  printf ("%.*s\n", vec_len (s), s);
704  fflush (stdout);
705  vec_free (s);
706  }
707  while (0);
708 #endif
709  }
710  *bi0 = reass->first_bi;
711  if (!is_custom_app)
712  {
713  *next0 = IP4_FULL_REASS_NEXT_INPUT;
714  }
715  else
716  {
717  *next0 = reass->next_index;
718  }
719  vnet_buffer (first_b)->ip.reass.estimated_mtu = reass->min_fragment_length;
720  *error0 = IP4_ERROR_NONE;
721  ip4_full_reass_free (rm, rt, reass);
722  reass = NULL;
723  return IP4_REASS_RC_OK;
724 }
725 
726 always_inline ip4_full_reass_rc_t
730  ip4_full_reass_t * reass,
731  u32 prev_range_bi, u32 new_next_bi)
732 {
733  vlib_buffer_t *new_next_b = vlib_get_buffer (vm, new_next_bi);
734  vnet_buffer_opaque_t *new_next_vnb = vnet_buffer (new_next_b);
735  if (~0 != prev_range_bi)
736  {
737  vlib_buffer_t *prev_b = vlib_get_buffer (vm, prev_range_bi);
738  vnet_buffer_opaque_t *prev_vnb = vnet_buffer (prev_b);
739  new_next_vnb->ip.reass.next_range_bi = prev_vnb->ip.reass.next_range_bi;
740  prev_vnb->ip.reass.next_range_bi = new_next_bi;
741  }
742  else
743  {
744  if (~0 != reass->first_bi)
745  {
746  new_next_vnb->ip.reass.next_range_bi = reass->first_bi;
747  }
748  reass->first_bi = new_next_bi;
749  }
750  vnet_buffer_opaque_t *vnb = vnet_buffer (new_next_b);
751  if (!(vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first) &&
752  !(vnb->ip.reass.range_last > vnb->ip.reass.fragment_first))
753  {
755  }
756  reass->data_len += ip4_full_reass_buffer_get_data_len (new_next_b);
757  return IP4_REASS_RC_OK;
758 }
759 
760 always_inline ip4_full_reass_rc_t
762  vlib_node_runtime_t * node,
764  ip4_full_reass_t * reass,
765  u32 prev_range_bi, u32 discard_bi)
766 {
767  vlib_buffer_t *discard_b = vlib_get_buffer (vm, discard_bi);
768  vnet_buffer_opaque_t *discard_vnb = vnet_buffer (discard_b);
769  if (~0 != prev_range_bi)
770  {
771  vlib_buffer_t *prev_b = vlib_get_buffer (vm, prev_range_bi);
772  vnet_buffer_opaque_t *prev_vnb = vnet_buffer (prev_b);
773  if (!(prev_vnb->ip.reass.next_range_bi == discard_bi))
774  {
776  }
777  prev_vnb->ip.reass.next_range_bi = discard_vnb->ip.reass.next_range_bi;
778  }
779  else
780  {
781  reass->first_bi = discard_vnb->ip.reass.next_range_bi;
782  }
783  vnet_buffer_opaque_t *vnb = vnet_buffer (discard_b);
784  if (!(vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first) &&
785  !(vnb->ip.reass.range_last > vnb->ip.reass.fragment_first))
786  {
788  }
789  reass->data_len -= ip4_full_reass_buffer_get_data_len (discard_b);
790  while (1)
791  {
792  u32 to_be_freed_bi = discard_bi;
793  if (PREDICT_FALSE (discard_b->flags & VLIB_BUFFER_IS_TRACED))
794  {
795  ip4_full_reass_add_trace (vm, node, rm, reass, discard_bi,
796  RANGE_DISCARD, 0, ~0);
797  }
798  if (discard_b->flags & VLIB_BUFFER_NEXT_PRESENT)
799  {
800  discard_b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
801  discard_bi = discard_b->next_buffer;
802  discard_b->next_buffer = 0;
803  discard_b = vlib_get_buffer (vm, discard_bi);
804  vlib_buffer_free_one (vm, to_be_freed_bi);
805  }
806  else
807  {
808  discard_b->next_buffer = 0;
809  vlib_buffer_free_one (vm, to_be_freed_bi);
810  break;
811  }
812  }
813  return IP4_REASS_RC_OK;
814 }
815 
816 always_inline ip4_full_reass_rc_t
820  ip4_full_reass_t * reass, u32 * bi0, u32 * next0,
821  u32 * error0, bool is_custom_app,
822  u32 * handoff_thread_idx)
823 {
824  vlib_buffer_t *fb = vlib_get_buffer (vm, *bi0);
825  vnet_buffer_opaque_t *fvnb = vnet_buffer (fb);
826  if (is_custom_app)
827  {
828  // store (error_)next_index before it's overwritten
829  reass->next_index = fvnb->ip.reass.next_index;
830  reass->error_next_index = fvnb->ip.reass.error_next_index;
831  }
832  ip4_full_reass_rc_t rc = IP4_REASS_RC_OK;
833  int consumed = 0;
835  const u32 fragment_first = ip4_get_fragment_offset_bytes (fip);
836  const u32 fragment_length =
837  clib_net_to_host_u16 (fip->length) - ip4_header_bytes (fip);
838  const u32 fragment_last = fragment_first + fragment_length - 1;
839  fvnb->ip.reass.fragment_first = fragment_first;
840  fvnb->ip.reass.fragment_last = fragment_last;
841  int more_fragments = ip4_get_fragment_more (fip);
842  u32 candidate_range_bi = reass->first_bi;
843  u32 prev_range_bi = ~0;
844  fvnb->ip.reass.range_first = fragment_first;
845  fvnb->ip.reass.range_last = fragment_last;
846  fvnb->ip.reass.next_range_bi = ~0;
847  if (!more_fragments)
848  {
849  reass->last_packet_octet = fragment_last;
850  }
851  if (~0 == reass->first_bi)
852  {
853  // starting a new reassembly
854  rc =
855  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
856  prev_range_bi, *bi0);
857  if (IP4_REASS_RC_OK != rc)
858  {
859  return rc;
860  }
861  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
862  {
863  ip4_full_reass_add_trace (vm, node, rm, reass, *bi0, RANGE_NEW, 0,
864  ~0);
865  }
866  *bi0 = ~0;
867  reass->min_fragment_length = clib_net_to_host_u16 (fip->length);
868  reass->fragments_n = 1;
869  return IP4_REASS_RC_OK;
870  }
871  reass->min_fragment_length =
872  clib_min (clib_net_to_host_u16 (fip->length),
873  fvnb->ip.reass.estimated_mtu);
874  while (~0 != candidate_range_bi)
875  {
876  vlib_buffer_t *candidate_b = vlib_get_buffer (vm, candidate_range_bi);
877  vnet_buffer_opaque_t *candidate_vnb = vnet_buffer (candidate_b);
878  if (fragment_first > candidate_vnb->ip.reass.range_last)
879  {
880  // this fragments starts after candidate range
881  prev_range_bi = candidate_range_bi;
882  candidate_range_bi = candidate_vnb->ip.reass.next_range_bi;
883  if (candidate_vnb->ip.reass.range_last < fragment_last &&
884  ~0 == candidate_range_bi)
885  {
886  // special case - this fragment falls beyond all known ranges
887  rc =
888  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
889  prev_range_bi, *bi0);
890  if (IP4_REASS_RC_OK != rc)
891  {
892  return rc;
893  }
894  consumed = 1;
895  break;
896  }
897  continue;
898  }
899  if (fragment_last < candidate_vnb->ip.reass.range_first)
900  {
901  // this fragment ends before candidate range without any overlap
902  rc =
903  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
904  prev_range_bi, *bi0);
905  if (IP4_REASS_RC_OK != rc)
906  {
907  return rc;
908  }
909  consumed = 1;
910  }
911  else
912  {
913  if (fragment_first >= candidate_vnb->ip.reass.range_first &&
914  fragment_last <= candidate_vnb->ip.reass.range_last)
915  {
916  // this fragment is a (sub)part of existing range, ignore it
917  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
918  {
919  ip4_full_reass_add_trace (vm, node, rm, reass, *bi0,
920  RANGE_OVERLAP, 0, ~0);
921  }
922  break;
923  }
924  int discard_candidate = 0;
925  if (fragment_first < candidate_vnb->ip.reass.range_first)
926  {
927  u32 overlap =
928  fragment_last - candidate_vnb->ip.reass.range_first + 1;
929  if (overlap < ip4_full_reass_buffer_get_data_len (candidate_b))
930  {
931  candidate_vnb->ip.reass.range_first += overlap;
932  if (reass->data_len < overlap)
933  {
935  }
936  reass->data_len -= overlap;
937  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
938  {
939  ip4_full_reass_add_trace (vm, node, rm, reass,
940  candidate_range_bi,
941  RANGE_SHRINK, 0, ~0);
942  }
943  rc =
944  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
945  prev_range_bi,
946  *bi0);
947  if (IP4_REASS_RC_OK != rc)
948  {
949  return rc;
950  }
951  consumed = 1;
952  }
953  else
954  {
955  discard_candidate = 1;
956  }
957  }
958  else if (fragment_last > candidate_vnb->ip.reass.range_last)
959  {
960  u32 overlap =
961  candidate_vnb->ip.reass.range_last - fragment_first + 1;
962  if (overlap < ip4_full_reass_buffer_get_data_len (candidate_b))
963  {
964  fvnb->ip.reass.range_first += overlap;
965  if (~0 != candidate_vnb->ip.reass.next_range_bi)
966  {
967  prev_range_bi = candidate_range_bi;
968  candidate_range_bi =
969  candidate_vnb->ip.reass.next_range_bi;
970  continue;
971  }
972  else
973  {
974  // special case - last range discarded
975  rc =
977  reass,
978  candidate_range_bi,
979  *bi0);
980  if (IP4_REASS_RC_OK != rc)
981  {
982  return rc;
983  }
984  consumed = 1;
985  }
986  }
987  else
988  {
989  discard_candidate = 1;
990  }
991  }
992  else
993  {
994  discard_candidate = 1;
995  }
996  if (discard_candidate)
997  {
998  u32 next_range_bi = candidate_vnb->ip.reass.next_range_bi;
999  // discard candidate range, probe next range
1000  rc =
1001  ip4_full_reass_remove_range_from_chain (vm, node, rm, reass,
1002  prev_range_bi,
1003  candidate_range_bi);
1004  if (IP4_REASS_RC_OK != rc)
1005  {
1006  return rc;
1007  }
1008  if (~0 != next_range_bi)
1009  {
1010  candidate_range_bi = next_range_bi;
1011  continue;
1012  }
1013  else
1014  {
1015  // special case - last range discarded
1016  rc =
1017  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
1018  prev_range_bi,
1019  *bi0);
1020  if (IP4_REASS_RC_OK != rc)
1021  {
1022  return rc;
1023  }
1024  consumed = 1;
1025  }
1026  }
1027  }
1028  break;
1029  }
1030  ++reass->fragments_n;
1031  if (consumed)
1032  {
1033  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
1034  {
1035  ip4_full_reass_add_trace (vm, node, rm, reass, *bi0, RANGE_NEW, 0,
1036  ~0);
1037  }
1038  }
1039  if (~0 != reass->last_packet_octet &&
1040  reass->data_len == reass->last_packet_octet + 1)
1041  {
1042  *handoff_thread_idx = reass->sendout_thread_index;
1043  int handoff =
1045  rc =
1046  ip4_full_reass_finalize (vm, node, rm, rt, reass, bi0, next0, error0,
1047  is_custom_app);
1048  if (IP4_REASS_RC_OK == rc && handoff)
1049  {
1050  rc = IP4_REASS_RC_HANDOFF;
1051  }
1052  }
1053  else
1054  {
1055  if (consumed)
1056  {
1057  *bi0 = ~0;
1058  if (reass->fragments_n > rm->max_reass_len)
1059  {
1061  }
1062  }
1063  else
1064  {
1065  *next0 = IP4_FULL_REASS_NEXT_DROP;
1066  *error0 = IP4_ERROR_REASS_DUPLICATE_FRAGMENT;
1067  }
1068  }
1069  return rc;
1070 }
1071 
1074  vlib_frame_t * frame, bool is_feature,
1075  bool is_custom_app)
1076 {
1077  u32 *from = vlib_frame_vector_args (frame);
1078  u32 n_left_from, n_left_to_next, *to_next, next_index;
1081  clib_spinlock_lock (&rt->lock);
1082 
1083  n_left_from = frame->n_vectors;
1084  next_index = node->cached_next_index;
1085  while (n_left_from > 0)
1086  {
1087  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1088 
1089  while (n_left_from > 0 && n_left_to_next > 0)
1090  {
1091  u32 bi0;
1092  vlib_buffer_t *b0;
1093  u32 next0;
1094  u32 error0 = IP4_ERROR_NONE;
1095 
1096  bi0 = from[0];
1097  b0 = vlib_get_buffer (vm, bi0);
1098 
1100  if (!ip4_get_fragment_more (ip0) && !ip4_get_fragment_offset (ip0))
1101  {
1102  // this is a whole packet - no fragmentation
1103  if (!is_custom_app)
1104  {
1105  next0 = IP4_FULL_REASS_NEXT_INPUT;
1106  }
1107  else
1108  {
1109  next0 = vnet_buffer (b0)->ip.reass.next_index;
1110  }
1111  goto packet_enqueue;
1112  }
1113  const u32 fragment_first = ip4_get_fragment_offset_bytes (ip0);
1114  const u32 fragment_length =
1115  clib_net_to_host_u16 (ip0->length) - ip4_header_bytes (ip0);
1116  const u32 fragment_last = fragment_first + fragment_length - 1;
1117  if (fragment_first > fragment_last || fragment_first + fragment_length > UINT16_MAX - 20 || (fragment_length < 8 && ip4_get_fragment_more (ip0))) // 8 is minimum frag length per RFC 791
1118  {
1119  next0 = IP4_FULL_REASS_NEXT_DROP;
1120  error0 = IP4_ERROR_REASS_MALFORMED_PACKET;
1121  goto packet_enqueue;
1122  }
1124  u8 do_handoff = 0;
1125 
1126  kv.k.as_u64[0] =
1128  vnet_buffer (b0)->sw_if_index[VLIB_RX]) |
1129  (u64) ip0->src_address.as_u32 << 32;
1130  kv.k.as_u64[1] =
1131  (u64) ip0->dst_address.
1132  as_u32 | (u64) ip0->fragment_id << 32 | (u64) ip0->protocol << 48;
1133 
1134  ip4_full_reass_t *reass =
1135  ip4_full_reass_find_or_create (vm, node, rm, rt, &kv,
1136  &do_handoff);
1137 
1138  if (reass)
1139  {
1140  const u32 fragment_first = ip4_get_fragment_offset_bytes (ip0);
1141  if (0 == fragment_first)
1142  {
1143  reass->sendout_thread_index = vm->thread_index;
1144  }
1145  }
1146 
1147  if (PREDICT_FALSE (do_handoff))
1148  {
1150  if (is_feature)
1151  vnet_buffer (b0)->ip.reass.owner_feature_thread_index =
1153  else
1154  vnet_buffer (b0)->ip.reass.owner_thread_index =
1156  }
1157  else if (reass)
1158  {
1159  u32 handoff_thread_idx;
1160  switch (ip4_full_reass_update
1161  (vm, node, rm, rt, reass, &bi0, &next0,
1162  &error0, is_custom_app, &handoff_thread_idx))
1163  {
1164  case IP4_REASS_RC_OK:
1165  /* nothing to do here */
1166  break;
1167  case IP4_REASS_RC_HANDOFF:
1169  b0 = vlib_get_buffer (vm, bi0);
1170  if (is_feature)
1171  vnet_buffer (b0)->ip.reass.owner_feature_thread_index =
1172  handoff_thread_idx;
1173  else
1174  vnet_buffer (b0)->ip.reass.owner_thread_index =
1175  handoff_thread_idx;
1176  break;
1179  IP4_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
1180  1);
1181  ip4_full_reass_drop_all (vm, node, rm, reass);
1182  ip4_full_reass_free (rm, rt, reass);
1183  goto next_packet;
1184  break;
1185  case IP4_REASS_RC_NO_BUF:
1187  IP4_ERROR_REASS_NO_BUF, 1);
1188  ip4_full_reass_drop_all (vm, node, rm, reass);
1189  ip4_full_reass_free (rm, rt, reass);
1190  goto next_packet;
1191  break;
1193  /* drop everything and start with a clean slate */
1195  IP4_ERROR_REASS_INTERNAL_ERROR,
1196  1);
1197  ip4_full_reass_drop_all (vm, node, rm, reass);
1198  ip4_full_reass_free (rm, rt, reass);
1199  goto next_packet;
1200  break;
1201  }
1202  }
1203  else
1204  {
1205  next0 = IP4_FULL_REASS_NEXT_DROP;
1206  error0 = IP4_ERROR_REASS_LIMIT_REACHED;
1207  }
1208 
1209 
1210  packet_enqueue:
1211 
1212  if (bi0 != ~0)
1213  {
1214  to_next[0] = bi0;
1215  to_next += 1;
1216  n_left_to_next -= 1;
1217 
1218  /* bi0 might have been updated by reass_finalize, reload */
1219  b0 = vlib_get_buffer (vm, bi0);
1220  b0->error = node->errors[error0];
1221 
1222  if (next0 == IP4_FULL_REASS_NEXT_HANDOFF)
1223  {
1224  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1225  {
1226  if (is_feature)
1227  ip4_full_reass_add_trace (vm, node, rm, NULL,
1228  bi0, HANDOFF, 0,
1229  vnet_buffer (b0)->ip.
1230  reass.owner_feature_thread_index);
1231  else
1232  ip4_full_reass_add_trace (vm, node, rm, NULL,
1233  bi0, HANDOFF, 0,
1234  vnet_buffer (b0)->ip.
1235  reass.owner_thread_index);
1236  }
1237  }
1238  else if (is_feature && IP4_ERROR_NONE == error0)
1239  {
1240  vnet_feature_next (&next0, b0);
1241  }
1242  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
1243  to_next, n_left_to_next,
1244  bi0, next0);
1245  IP4_REASS_DEBUG_BUFFER (bi0, enqueue_next);
1246  }
1247 
1248  next_packet:
1249  from += 1;
1250  n_left_from -= 1;
1251  }
1252 
1253  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1254  }
1255 
1256  clib_spinlock_unlock (&rt->lock);
1257  return frame->n_vectors;
1258 }
1259 
1261 #define _(sym, string) string,
1263 #undef _
1264 };
1265 
1266 VLIB_NODE_FN (ip4_full_reass_node) (vlib_main_t * vm,
1267  vlib_node_runtime_t * node,
1268  vlib_frame_t * frame)
1269 {
1270  return ip4_full_reass_inline (vm, node, frame, false /* is_feature */ ,
1271  false /* is_custom_app */ );
1272 }
1273 
1274 /* *INDENT-OFF* */
1275 VLIB_REGISTER_NODE (ip4_full_reass_node) = {
1276  .name = "ip4-full-reassembly",
1277  .vector_size = sizeof (u32),
1278  .format_trace = format_ip4_full_reass_trace,
1279  .n_errors = ARRAY_LEN (ip4_full_reass_error_strings),
1280  .error_strings = ip4_full_reass_error_strings,
1281  .n_next_nodes = IP4_FULL_REASS_N_NEXT,
1282  .next_nodes =
1283  {
1284  [IP4_FULL_REASS_NEXT_INPUT] = "ip4-input",
1285  [IP4_FULL_REASS_NEXT_DROP] = "ip4-drop",
1286  [IP4_FULL_REASS_NEXT_HANDOFF] = "ip4-full-reassembly-handoff",
1287 
1288  },
1289 };
1290 /* *INDENT-ON* */
1291 
1292 VLIB_NODE_FN (ip4_full_reass_node_feature) (vlib_main_t * vm,
1293  vlib_node_runtime_t * node,
1294  vlib_frame_t * frame)
1295 {
1296  return ip4_full_reass_inline (vm, node, frame, true /* is_feature */ ,
1297  false /* is_custom_app */ );
1298 }
1299 
1300 /* *INDENT-OFF* */
1301 VLIB_REGISTER_NODE (ip4_full_reass_node_feature) = {
1302  .name = "ip4-full-reassembly-feature",
1303  .vector_size = sizeof (u32),
1304  .format_trace = format_ip4_full_reass_trace,
1305  .n_errors = ARRAY_LEN (ip4_full_reass_error_strings),
1306  .error_strings = ip4_full_reass_error_strings,
1307  .n_next_nodes = IP4_FULL_REASS_N_NEXT,
1308  .next_nodes =
1309  {
1310  [IP4_FULL_REASS_NEXT_INPUT] = "ip4-input",
1311  [IP4_FULL_REASS_NEXT_DROP] = "ip4-drop",
1312  [IP4_FULL_REASS_NEXT_HANDOFF] = "ip4-full-reass-feature-hoff",
1313  },
1314 };
1315 /* *INDENT-ON* */
1316 
1317 /* *INDENT-OFF* */
1318 VNET_FEATURE_INIT (ip4_full_reass_feature, static) = {
1319  .arc_name = "ip4-unicast",
1320  .node_name = "ip4-full-reassembly-feature",
1321  .runs_before = VNET_FEATURES ("ip4-lookup",
1322  "ipsec4-input-feature"),
1323  .runs_after = 0,
1324 };
1325 /* *INDENT-ON* */
1326 
1327 #ifndef CLIB_MARCH_VARIANT
1330 {
1332  u32 nbuckets;
1333  u8 i;
1334 
1335  nbuckets = (u32) (rm->max_reass_n / IP4_REASS_HT_LOAD_FACTOR);
1336 
1337  for (i = 0; i < 31; i++)
1338  if ((1 << i) >= nbuckets)
1339  break;
1340  nbuckets = 1 << i;
1341 
1342  return nbuckets;
1343 }
1344 #endif /* CLIB_MARCH_VARIANT */
1345 
1346 typedef enum
1347 {
1350 
1351 typedef struct
1352 {
1353  int failure;
1354  clib_bihash_16_8_t *new_hash;
1356 
1357 #ifndef CLIB_MARCH_VARIANT
1358 static void
1360 {
1361  ip4_rehash_cb_ctx *ctx = _ctx;
1362  if (clib_bihash_add_del_16_8 (ctx->new_hash, kv, 1))
1363  {
1364  ctx->failure = 1;
1365  }
1366 }
1367 
1368 static void
1369 ip4_full_reass_set_params (u32 timeout_ms, u32 max_reassemblies,
1370  u32 max_reassembly_length,
1371  u32 expire_walk_interval_ms)
1372 {
1373  ip4_full_reass_main.timeout_ms = timeout_ms;
1374  ip4_full_reass_main.timeout = (f64) timeout_ms / (f64) MSEC_PER_SEC;
1375  ip4_full_reass_main.max_reass_n = max_reassemblies;
1376  ip4_full_reass_main.max_reass_len = max_reassembly_length;
1377  ip4_full_reass_main.expire_walk_interval_ms = expire_walk_interval_ms;
1378 }
1379 
1381 ip4_full_reass_set (u32 timeout_ms, u32 max_reassemblies,
1382  u32 max_reassembly_length, u32 expire_walk_interval_ms)
1383 {
1384  u32 old_nbuckets = ip4_full_reass_get_nbuckets ();
1385  ip4_full_reass_set_params (timeout_ms, max_reassemblies,
1386  max_reassembly_length, expire_walk_interval_ms);
1387  vlib_process_signal_event (ip4_full_reass_main.vlib_main,
1388  ip4_full_reass_main.ip4_full_reass_expire_node_idx,
1390  u32 new_nbuckets = ip4_full_reass_get_nbuckets ();
1391  if (ip4_full_reass_main.max_reass_n > 0 && new_nbuckets > old_nbuckets)
1392  {
1393  clib_bihash_16_8_t new_hash;
1394  clib_memset (&new_hash, 0, sizeof (new_hash));
1396  ctx.failure = 0;
1397  ctx.new_hash = &new_hash;
1398  clib_bihash_init_16_8 (&new_hash, "ip4-dr", new_nbuckets,
1399  new_nbuckets * 1024);
1400  clib_bihash_foreach_key_value_pair_16_8 (&ip4_full_reass_main.hash,
1401  ip4_rehash_cb, &ctx);
1402  if (ctx.failure)
1403  {
1404  clib_bihash_free_16_8 (&new_hash);
1405  return -1;
1406  }
1407  else
1408  {
1409  clib_bihash_free_16_8 (&ip4_full_reass_main.hash);
1410  clib_memcpy_fast (&ip4_full_reass_main.hash, &new_hash,
1411  sizeof (ip4_full_reass_main.hash));
1412  clib_bihash_copied (&ip4_full_reass_main.hash, &new_hash);
1413  }
1414  }
1415  return 0;
1416 }
1417 
1419 ip4_full_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
1420  u32 * max_reassembly_length,
1421  u32 * expire_walk_interval_ms)
1422 {
1423  *timeout_ms = ip4_full_reass_main.timeout_ms;
1424  *max_reassemblies = ip4_full_reass_main.max_reass_n;
1425  *max_reassembly_length = ip4_full_reass_main.max_reass_len;
1426  *expire_walk_interval_ms = ip4_full_reass_main.expire_walk_interval_ms;
1427  return 0;
1428 }
1429 
1430 static clib_error_t *
1432 {
1434  clib_error_t *error = 0;
1435  u32 nbuckets;
1436  vlib_node_t *node;
1437 
1438  rm->vlib_main = vm;
1439 
1442  vec_foreach (rt, rm->per_thread_data)
1443  {
1444  clib_spinlock_init (&rt->lock);
1445  pool_alloc (rt->pool, rm->max_reass_n);
1446  }
1447 
1448  node = vlib_get_node_by_name (vm, (u8 *) "ip4-full-reassembly-expire-walk");
1449  ASSERT (node);
1451 
1456 
1457  nbuckets = ip4_full_reass_get_nbuckets ();
1458  clib_bihash_init_16_8 (&rm->hash, "ip4-dr", nbuckets, nbuckets * 1024);
1459 
1460  node = vlib_get_node_by_name (vm, (u8 *) "ip4-drop");
1461  ASSERT (node);
1462  rm->ip4_drop_idx = node->index;
1463 
1464  rm->fq_index = vlib_frame_queue_main_init (ip4_full_reass_node.index, 0);
1465  rm->fq_feature_index =
1466  vlib_frame_queue_main_init (ip4_full_reass_node_feature.index, 0);
1467 
1468  return error;
1469 }
1470 
1472 #endif /* CLIB_MARCH_VARIANT */
1473 
1474 static uword
1476  vlib_node_runtime_t * node, vlib_frame_t * f)
1477 {
1479  uword event_type, *event_data = 0;
1480 
1481  while (true)
1482  {
1484  (f64)
1486  (f64) MSEC_PER_SEC);
1487  event_type = vlib_process_get_events (vm, &event_data);
1488 
1489  switch (event_type)
1490  {
1491  case ~0: /* no events => timeout */
1492  /* nothing to do here */
1493  break;
1495  break;
1496  default:
1497  clib_warning ("BUG: event type 0x%wx", event_type);
1498  break;
1499  }
1500  f64 now = vlib_time_now (vm);
1501 
1502  ip4_full_reass_t *reass;
1503  int *pool_indexes_to_free = NULL;
1504 
1505  uword thread_index = 0;
1506  int index;
1507  const uword nthreads = vlib_num_workers () + 1;
1508  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1509  {
1511  &rm->per_thread_data[thread_index];
1512  clib_spinlock_lock (&rt->lock);
1513 
1514  vec_reset_length (pool_indexes_to_free);
1515  /* *INDENT-OFF* */
1516  pool_foreach_index (index, rt->pool, ({
1517  reass = pool_elt_at_index (rt->pool, index);
1518  if (now > reass->last_heard + rm->timeout)
1519  {
1520  vec_add1 (pool_indexes_to_free, index);
1521  }
1522  }));
1523  /* *INDENT-ON* */
1524  int *i;
1525  /* *INDENT-OFF* */
1526  vec_foreach (i, pool_indexes_to_free)
1527  {
1528  ip4_full_reass_t *reass = pool_elt_at_index (rt->pool, i[0]);
1529  ip4_full_reass_drop_all (vm, node, rm, reass);
1530  ip4_full_reass_free (rm, rt, reass);
1531  }
1532  /* *INDENT-ON* */
1533 
1534  clib_spinlock_unlock (&rt->lock);
1535  }
1536 
1537  vec_free (pool_indexes_to_free);
1538  if (event_data)
1539  {
1540  _vec_len (event_data) = 0;
1541  }
1542  }
1543 
1544  return 0;
1545 }
1546 
1547 /* *INDENT-OFF* */
1549  .function = ip4_full_reass_walk_expired,
1550  .type = VLIB_NODE_TYPE_PROCESS,
1551  .name = "ip4-full-reassembly-expire-walk",
1552  .format_trace = format_ip4_full_reass_trace,
1554  .error_strings = ip4_full_reass_error_strings,
1555 
1556 };
1557 /* *INDENT-ON* */
1558 
1559 static u8 *
1560 format_ip4_full_reass_key (u8 * s, va_list * args)
1561 {
1562  ip4_full_reass_key_t *key = va_arg (*args, ip4_full_reass_key_t *);
1563  s =
1564  format (s,
1565  "xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1567  &key->dst, clib_net_to_host_u16 (key->frag_id), key->proto);
1568  return s;
1569 }
1570 
1571 static u8 *
1572 format_ip4_reass (u8 * s, va_list * args)
1573 {
1574  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
1575  ip4_full_reass_t *reass = va_arg (*args, ip4_full_reass_t *);
1576 
1577  s = format (s, "ID: %lu, key: %U\n first_bi: %u, data_len: %u, "
1578  "last_packet_octet: %u, trace_op_counter: %u\n",
1579  reass->id, format_ip4_full_reass_key, &reass->key,
1580  reass->first_bi, reass->data_len,
1581  reass->last_packet_octet, reass->trace_op_counter);
1582 
1583  u32 bi = reass->first_bi;
1584  u32 counter = 0;
1585  while (~0 != bi)
1586  {
1587  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
1588  vnet_buffer_opaque_t *vnb = vnet_buffer (b);
1589  s =
1590  format (s,
1591  " #%03u: range: [%u, %u], bi: %u, off: %d, len: %u, "
1592  "fragment[%u, %u]\n", counter, vnb->ip.reass.range_first,
1593  vnb->ip.reass.range_last, bi,
1596  vnb->ip.reass.fragment_first, vnb->ip.reass.fragment_last);
1597  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
1598  {
1599  bi = b->next_buffer;
1600  }
1601  else
1602  {
1603  bi = ~0;
1604  }
1605  }
1606  return s;
1607 }
1608 
1609 static clib_error_t *
1611  unformat_input_t * input,
1613 {
1615 
1616  vlib_cli_output (vm, "---------------------");
1617  vlib_cli_output (vm, "IP4 reassembly status");
1618  vlib_cli_output (vm, "---------------------");
1619  bool details = false;
1620  if (unformat (input, "details"))
1621  {
1622  details = true;
1623  }
1624 
1625  u32 sum_reass_n = 0;
1626  ip4_full_reass_t *reass;
1627  uword thread_index;
1628  const uword nthreads = vlib_num_workers () + 1;
1629  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1630  {
1631  ip4_full_reass_per_thread_t *rt = &rm->per_thread_data[thread_index];
1632  clib_spinlock_lock (&rt->lock);
1633  if (details)
1634  {
1635  /* *INDENT-OFF* */
1636  pool_foreach (reass, rt->pool, {
1637  vlib_cli_output (vm, "%U", format_ip4_reass, vm, reass);
1638  });
1639  /* *INDENT-ON* */
1640  }
1641  sum_reass_n += rt->reass_n;
1642  clib_spinlock_unlock (&rt->lock);
1643  }
1644  vlib_cli_output (vm, "---------------------");
1645  vlib_cli_output (vm, "Current IP4 reassemblies count: %lu\n",
1646  (long unsigned) sum_reass_n);
1647  vlib_cli_output (vm,
1648  "Maximum configured concurrent IP4 reassemblies per worker-thread: %lu\n",
1649  (long unsigned) rm->max_reass_n);
1650  return 0;
1651 }
1652 
1653 /* *INDENT-OFF* */
1655  .path = "show ip4-full-reassembly",
1656  .short_help = "show ip4-full-reassembly [details]",
1657  .function = show_ip4_reass,
1658 };
1659 /* *INDENT-ON* */
1660 
1661 #ifndef CLIB_MARCH_VARIANT
1664 {
1665  return vnet_feature_enable_disable ("ip4-unicast",
1666  "ip4-full-reassembly-feature",
1667  sw_if_index, enable_disable, 0, 0);
1668 }
1669 #endif /* CLIB_MARCH_VARIANT */
1670 
1671 
1672 #define foreach_ip4_full_reass_handoff_error \
1673 _(CONGESTION_DROP, "congestion drop")
1674 
1675 
1676 typedef enum
1677 {
1678 #define _(sym,str) IP4_FULL_REASS_HANDOFF_ERROR_##sym,
1680 #undef _
1683 
1685 #define _(sym,string) string,
1687 #undef _
1688 };
1689 
1690 typedef struct
1691 {
1694 
1695 static u8 *
1697 {
1698  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1699  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1701  va_arg (*args, ip4_full_reass_handoff_trace_t *);
1702 
1703  s =
1704  format (s, "ip4-full-reassembly-handoff: next-worker %d",
1705  t->next_worker_index);
1706 
1707  return s;
1708 }
1709 
1712  vlib_node_runtime_t * node,
1713  vlib_frame_t * frame, bool is_feature)
1714 {
1716 
1717  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
1718  u32 n_enq, n_left_from, *from;
1719  u16 thread_indices[VLIB_FRAME_SIZE], *ti;
1720  u32 fq_index;
1721 
1722  from = vlib_frame_vector_args (frame);
1723  n_left_from = frame->n_vectors;
1724  vlib_get_buffers (vm, from, bufs, n_left_from);
1725 
1726  b = bufs;
1727  ti = thread_indices;
1728 
1729  fq_index = (is_feature) ? rm->fq_feature_index : rm->fq_index;
1730 
1731  while (n_left_from > 0)
1732  {
1733  ti[0] =
1734  (is_feature) ? vnet_buffer (b[0])->ip.
1735  reass.owner_feature_thread_index : vnet_buffer (b[0])->ip.
1736  reass.owner_thread_index;
1737 
1738  if (PREDICT_FALSE
1739  ((node->flags & VLIB_NODE_FLAG_TRACE)
1740  && (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
1741  {
1743  vlib_add_trace (vm, node, b[0], sizeof (*t));
1744  t->next_worker_index = ti[0];
1745  }
1746 
1747  n_left_from -= 1;
1748  ti += 1;
1749  b += 1;
1750  }
1751  n_enq =
1752  vlib_buffer_enqueue_to_thread (vm, fq_index, from, thread_indices,
1753  frame->n_vectors, 1);
1754 
1755  if (n_enq < frame->n_vectors)
1757  IP4_FULL_REASS_HANDOFF_ERROR_CONGESTION_DROP,
1758  frame->n_vectors - n_enq);
1759  return frame->n_vectors;
1760 }
1761 
1763  vlib_node_runtime_t * node,
1764  vlib_frame_t * frame)
1765 {
1766  return ip4_full_reass_handoff_node_inline (vm, node, frame,
1767  false /* is_feature */ );
1768 }
1769 
1770 
1771 /* *INDENT-OFF* */
1773  .name = "ip4-full-reassembly-handoff",
1774  .vector_size = sizeof (u32),
1775  .n_errors = ARRAY_LEN(ip4_full_reass_handoff_error_strings),
1776  .error_strings = ip4_full_reass_handoff_error_strings,
1777  .format_trace = format_ip4_full_reass_handoff_trace,
1778 
1779  .n_next_nodes = 1,
1780 
1781  .next_nodes = {
1782  [0] = "error-drop",
1783  },
1784 };
1785 /* *INDENT-ON* */
1786 
1787 
1788 /* *INDENT-OFF* */
1791  node,
1792  vlib_frame_t * frame)
1793 {
1794  return ip4_full_reass_handoff_node_inline (vm, node, frame,
1795  true /* is_feature */ );
1796 }
1797 /* *INDENT-ON* */
1798 
1799 
1800 /* *INDENT-OFF* */
1802  .name = "ip4-full-reass-feature-hoff",
1803  .vector_size = sizeof (u32),
1804  .n_errors = ARRAY_LEN(ip4_full_reass_handoff_error_strings),
1805  .error_strings = ip4_full_reass_handoff_error_strings,
1806  .format_trace = format_ip4_full_reass_handoff_trace,
1807 
1808  .n_next_nodes = 1,
1809 
1810  .next_nodes = {
1811  [0] = "error-drop",
1812  },
1813 };
1814 /* *INDENT-ON* */
1815 
1816 /*
1817  * fd.io coding-style-patch-verification: ON
1818  *
1819  * Local Variables:
1820  * eval: (c-set-style "gnu")
1821  * End:
1822  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
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
vnet_api_error_t
Definition: api_errno.h:154
clib_bihash_16_8_t hash
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:889
static u16 ip4_full_reass_buffer_get_data_len(vlib_buffer_t *b)
#define clib_min(x, y)
Definition: clib.h:302
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:102
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:80
ip4_full_reass_key_t key
#define CLIB_UNUSED(x)
Definition: clib.h:83
vnet_api_error_t ip4_full_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
ip4_full_reass_next_t
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:673
ip4_full_reass_rc_t
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
ip4_address_t src_address
Definition: ip4_packet.h:170
ip4_full_reass_trace_operation_e
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
Definition: pool.h:341
u64 as_u64
Definition: bihash_doc.h:63
static void ip4_full_reass_set_params(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
unsigned long u64
Definition: types.h:89
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
static char * ip4_full_reass_error_strings[]
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 index
Definition: node.h:280
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:279
ip4_full_reass_handoff_error_t
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
Definition: threads.c:1834
static u8 * format_ip4_full_reass_key(u8 *s, va_list *args)
u32 thread_index
Definition: main.h:218
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
static clib_error_t * show_ip4_reass(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
ip4_full_reass_val_t v
IPv4 Reassembly.
int i
#define MSEC_PER_SEC
static void ip4_full_reass_init(ip4_full_reass_t *reass)
static u32 format_get_indent(u8 *s)
Definition: format.h:72
static ip4_full_reass_rc_t ip4_full_reass_update(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_full_reass_main_t *rm, ip4_full_reass_per_thread_t *rt, ip4_full_reass_t *reass, u32 *bi0, u32 *next0, u32 *error0, bool is_custom_app, u32 *handoff_thread_idx)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:121
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
u16 flags_and_fragment_offset
Definition: ip4_packet.h:151
#define VLIB_NODE_FN(node)
Definition: node.h:202
#define IP4_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:470
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:366
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
unsigned char u8
Definition: types.h:56
#define vec_pop(V)
Returns last element of a vector and decrements its length.
Definition: vec.h:615
static int ip4_get_fragment_offset_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:229
vlib_node_registration_t ip4_full_reass_handoff_node
(constructor) VLIB_REGISTER_NODE (ip4_full_reass_handoff_node)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
vlib_main_t * vlib_main
format_function_t format_ip4_address
Definition: format.h:75
#define IP4_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
Definition: node_funcs.h:516
#define always_inline
Definition: clib.h:99
ip4_address_t dst_address
Definition: ip4_packet.h:170
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
#define foreach_ip4_full_reass_handoff_error
static ip4_full_reass_rc_t ip4_full_reass_insert_range_in_chain(vlib_main_t *vm, ip4_full_reass_main_t *rm, ip4_full_reass_per_thread_t *rt, ip4_full_reass_t *reass, u32 prev_range_bi, u32 new_next_bi)
struct vnet_buffer_opaque_t::@60::@62 ip
static uword ip4_full_reass_walk_expired(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
static void ip4_full_reass_free(ip4_full_reass_main_t *rm, ip4_full_reass_per_thread_t *rt, ip4_full_reass_t *reass)
unsigned int u32
Definition: types.h:88
vlib_node_registration_t ip4_full_reass_node_feature
(constructor) VLIB_REGISTER_NODE (ip4_full_reass_node_feature)
#define VLIB_FRAME_SIZE
Definition: node.h:378
static uword ip4_full_reass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature, bool is_custom_app)
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:63
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:136
vlib_node_registration_t ip4_full_reass_node
(constructor) VLIB_REGISTER_NODE (ip4_full_reass_node)
static u32 vlib_buffer_chain_linearize(vlib_main_t *vm, vlib_buffer_t *b)
u32 fq_index
Worker handoff.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
static u32 ip4_full_reass_get_nbuckets()
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:934
long ctx[MAX_CONNS]
Definition: main.c:144
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
static int ip4_get_fragment_offset(const ip4_header_t *i)
Definition: ip4_packet.h:200
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
static void ip4_full_reass_free_ctx(ip4_full_reass_per_thread_t *rt, ip4_full_reass_t *reass)
#define PREDICT_FALSE(x)
Definition: clib.h:112
ip4_full_reass_per_thread_t * per_thread_data
static void ip4_full_reass_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_full_reass_main_t *rm, ip4_full_reass_t *reass, u32 bi, ip4_full_reass_trace_operation_e action, u32 size_diff, u32 thread_id_to)
clib_bihash_kv_16_8_t kv
u32 node_index
Node index.
Definition: node.h:496
#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
ip4_full_reass_event_t
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1150
ip4_full_reass_main_t ip4_full_reass_main
static ip4_full_reass_t * ip4_full_reass_find_or_create(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_full_reass_main_t *rm, ip4_full_reass_per_thread_t *rt, ip4_full_reass_kv_t *kv, u8 *do_handoff)
#define foreach_ip4_error
Definition: ip4_error.h:43
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
static u8 * format_ip4_reass(u8 *s, va_list *args)
u16 n_vectors
Definition: node.h:397
vlib_main_t * vm
Definition: buffer.c:323
clib_bihash_16_8_t * new_hash
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:302
#define clib_warning(format, args...)
Definition: error.h:59
vnet_api_error_t ip4_full_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip4 reassembly configuration
vlib_node_registration_t ip4_full_reass_expire_node
(constructor) VLIB_REGISTER_NODE (ip4_full_reass_expire_node)
u8 * format_hexdump(u8 *s, va_list *va)
Definition: std-formats.c:297
static u8 * format_ip4_full_reass_trace(u8 *s, va_list *args)
#define ARRAY_LEN(x)
Definition: clib.h:63
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:456
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
static void ip4_full_reass_drop_all(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_full_reass_main_t *rm, ip4_full_reass_t *reass)
static vlib_cli_command_t show_ip4_full_reass_cmd
(constructor) VLIB_CLI_COMMAND (show_ip4_full_reass_cmd)
static int ip4_get_fragment_more(const ip4_header_t *i)
Definition: ip4_packet.h:206
static ip4_full_reass_rc_t ip4_full_reass_remove_range_from_chain(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_full_reass_main_t *rm, ip4_full_reass_t *reass, u32 prev_range_bi, u32 discard_bi)
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:161
signed int i32
Definition: types.h:77
static ip4_full_reass_rc_t ip4_full_reass_finalize(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_full_reass_main_t *rm, ip4_full_reass_per_thread_t *rt, ip4_full_reass_t *reass, u32 *bi0, u32 *next0, u32 *error0, bool is_custom_app)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:515
static char * ip4_full_reass_handoff_error_strings[]
ip4_full_reass_key_t k
#define ASSERT(truth)
vnet_api_error_t ip4_full_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip4 reassembly configuration
static uword ip4_full_reass_handoff_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:248
VNET_FEATURE_INIT(ip4_full_reass_feature, static)
ip4_full_reass_trace_operation_e action
#define VNET_FEATURES(...)
Definition: feature.h:442
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.
void clib_bihash_copied(void *dst, void *src)
struct _vlib_node_registration vlib_node_registration_t
static void ip4_full_reass_trace_details(vlib_main_t *vm, u32 bi, ip4_full_reass_range_trace_t *trace)
vl_api_address_t ip
Definition: l2.api:489
static u8 * format_ip4_full_reass_range_trace(u8 *s, va_list *args)
#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
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
typedef key
Definition: ipsec.api:247
ip4_full_reass_range_trace_t trace_range
static_always_inline u32 vlib_buffer_enqueue_to_thread(vlib_main_t *vm, u32 frame_queue_index, u32 *buffer_indices, u16 *thread_indices, u32 n_packets, int drop_on_congestion)
Definition: buffer_node.h:487
#define vnet_buffer(b)
Definition: buffer.h:365
static u32 ip4_full_reass_buffer_get_data_offset(vlib_buffer_t *b)
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1076
static u32 vlib_num_workers()
Definition: threads.h:372
static u8 * format_ip4_full_reass_handoff_trace(u8 *s, va_list *args)
static clib_error_t * ip4_full_reass_init_function(vlib_main_t *vm)
#define vec_foreach(var, vec)
Vector iterator.
u16 flags
Copy of main node flags.
Definition: node.h:509
#define IP4_REASS_MAX_REASSEMBLIES_DEFAULT
static void vlib_buffer_free_one(vlib_main_t *vm, u32 buffer_index)
Free one buffer Shorthand to free a single buffer chain.
Definition: buffer_funcs.h:898
static int ip4_header_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:235
#define pool_foreach_index(i, v, body)
Iterate pool by index.
Definition: pool.h:538
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
Definition: buffer_funcs.h:244
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:302
static void ip4_rehash_cb(clib_bihash_kv_16_8_t *kv, void *_ctx)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
Definition: buffer.h:167
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:772
#define IP4_REASS_HT_LOAD_FACTOR
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
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:247
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
Definition: defs.h:46
vlib_node_registration_t ip4_full_reass_feature_handoff_node
(constructor) VLIB_REGISTER_NODE (ip4_full_reass_feature_handoff_node)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:275
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
#define IP4_REASS_TIMEOUT_DEFAULT_MS
#define IP4_REASS_DEBUG_BUFFER(...)