FD.io VPP  v20.01-48-g3e0dafb74
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 
188  // reference count for enabling/disabling feature - per interface
191 
193 
194 #ifndef CLIB_MARCH_VARIANT
196 #endif /* CLIB_MARCH_VARIANT */
197 
198 typedef enum
199 {
205 
206 typedef enum
207 {
215 
216 typedef struct
217 {
225 
226 typedef struct
227 {
228  ip4_full_reass_trace_operation_e action;
241 
244 
245 static void
248 {
249  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
251  trace->range_first = vnb->ip.reass.range_first;
252  trace->range_last = vnb->ip.reass.range_last;
255  trace->range_bi = bi;
256 }
257 
258 static u8 *
260 {
262  va_arg (*args, ip4_full_reass_range_trace_t *);
263  s =
264  format (s, "range: [%u, %u], off %d, len %u, bi %u", trace->range_first,
265  trace->range_last, trace->data_offset, trace->data_len,
266  trace->range_bi);
267  return s;
268 }
269 
270 static u8 *
271 format_ip4_full_reass_trace (u8 * s, va_list * args)
272 {
273  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
274  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
275  ip4_full_reass_trace_t *t = va_arg (*args, ip4_full_reass_trace_t *);
276  u32 indent = 0;
277  if (~0 != t->reass_id)
278  {
279  if (t->is_after_handoff)
280  {
281  s =
282  format (s, "%U\n", format_ip4_header, &t->ip4_header,
283  sizeof (t->ip4_header));
284  indent = 2;
285  }
286  s =
287  format (s, "%Ureass id: %u, op id: %u, ", format_white_space, indent,
288  t->reass_id, t->op_id);
289  indent = format_get_indent (s);
290  s =
291  format (s,
292  "first bi: %u, data len: %u, ip/fragment[%u, %u]",
294  t->fragment_last);
295  }
296  switch (t->action)
297  {
298  case RANGE_SHRINK:
299  s = format (s, "\n%Ushrink %U by %u", format_white_space, indent,
301  t->size_diff);
302  break;
303  case RANGE_DISCARD:
304  s = format (s, "\n%Udiscard %U", format_white_space, indent,
306  break;
307  case RANGE_NEW:
308  s = format (s, "\n%Unew %U", format_white_space, indent,
310  break;
311  case RANGE_OVERLAP:
312  s = format (s, "\n%Uoverlapping/ignored %U", format_white_space, indent,
314  break;
315  case FINALIZE:
316  s = format (s, "\n%Ufinalize reassembly", format_white_space, indent);
317  break;
318  case HANDOFF:
319  s =
320  format (s, "handoff from thread #%u to thread #%u", t->thread_id,
321  t->thread_id_to);
322  break;
323  }
324  return s;
325 }
326 
327 static void
330  ip4_full_reass_t * reass, u32 bi,
331  ip4_full_reass_trace_operation_e action,
332  u32 size_diff, u32 thread_id_to)
333 {
334  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
336  bool is_after_handoff = false;
338  {
339  is_after_handoff = true;
340  }
341  ip4_full_reass_trace_t *t = vlib_add_trace (vm, node, b, sizeof (t[0]));
342  t->is_after_handoff = is_after_handoff;
343  if (t->is_after_handoff)
344  {
346  clib_min (sizeof (t->ip4_header), b->current_length));
347  }
348  if (reass)
349  {
350  t->reass_id = reass->id;
351  t->op_id = reass->trace_op_counter;
352  t->trace_range.first_bi = reass->first_bi;
353  t->total_data_len = reass->data_len;
354  ++reass->trace_op_counter;
355  }
356  else
357  {
358  t->reass_id = ~0;
359  t->op_id = 0;
360  t->trace_range.first_bi = 0;
361  t->total_data_len = 0;
362  }
363  t->action = action;
365  t->size_diff = size_diff;
366  t->thread_id = vm->thread_index;
367  t->thread_id_to = thread_id_to;
368  t->fragment_first = vnb->ip.reass.fragment_first;
369  t->fragment_last = vnb->ip.reass.fragment_last;
370 #if 0
371  static u8 *s = NULL;
372  s = format (s, "%U", format_ip4_full_reass_trace, NULL, NULL, t);
373  printf ("%.*s\n", vec_len (s), s);
374  fflush (stdout);
375  vec_reset_length (s);
376 #endif
377 }
378 
379 always_inline void
381  ip4_full_reass_t * reass)
382 {
383  pool_put (rt->pool, reass);
384  --rt->reass_n;
385 }
386 
387 always_inline void
390  ip4_full_reass_t * reass)
391 {
393  kv.key[0] = reass->key.as_u64[0];
394  kv.key[1] = reass->key.as_u64[1];
395  clib_bihash_add_del_16_8 (&rm->hash, &kv, 0);
396  return ip4_full_reass_free_ctx (rt, reass);
397 }
398 
399 always_inline void
402 {
403  u32 range_bi = reass->first_bi;
404  vlib_buffer_t *range_b;
405  vnet_buffer_opaque_t *range_vnb;
406  u32 *to_free = NULL;
407  while (~0 != range_bi)
408  {
409  range_b = vlib_get_buffer (vm, range_bi);
410  range_vnb = vnet_buffer (range_b);
411  u32 bi = range_bi;
412  while (~0 != bi)
413  {
414  vec_add1 (to_free, bi);
415  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
416  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
417  {
418  bi = b->next_buffer;
419  b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
420  }
421  else
422  {
423  bi = ~0;
424  }
425  }
426  range_bi = range_vnb->ip.reass.next_range_bi;
427  }
428  /* send to next_error_index */
429  if (~0 != reass->error_next_index)
430  {
431  u32 n_left_to_next, *to_next, next_index;
432 
433  next_index = reass->error_next_index;
434  u32 bi = ~0;
435 
436  while (vec_len (to_free) > 0)
437  {
438  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
439 
440  while (vec_len (to_free) > 0 && n_left_to_next > 0)
441  {
442  bi = vec_pop (to_free);
443 
444  if (~0 != bi)
445  {
446  to_next[0] = bi;
447  to_next += 1;
448  n_left_to_next -= 1;
449  }
450  }
451  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
452  }
453  }
454  else
455  {
456  vlib_buffer_free (vm, to_free, vec_len (to_free));
457  }
458 }
459 
460 always_inline void
462 {
463  reass->first_bi = ~0;
464  reass->last_packet_octet = ~0;
465  reass->data_len = 0;
466  reass->next_index = ~0;
467  reass->error_next_index = ~0;
468 }
469 
474  ip4_full_reass_kv_t * kv, u8 * do_handoff)
475 {
476  ip4_full_reass_t *reass;
477  f64 now;
478 
479 again:
480 
481  reass = NULL;
482  now = vlib_time_now (vm);
483  if (!clib_bihash_search_16_8
484  (&rm->hash, (clib_bihash_kv_16_8_t *) kv, (clib_bihash_kv_16_8_t *) kv))
485  {
486  reass =
488  [kv->v.memory_owner_thread_index].pool,
489  kv->v.reass_index);
490  if (vm->thread_index != reass->memory_owner_thread_index)
491  {
492  *do_handoff = 1;
493  return reass;
494  }
495 
496  if (now > reass->last_heard + rm->timeout)
497  {
498  ip4_full_reass_drop_all (vm, node, rm, reass);
499  ip4_full_reass_free (rm, rt, reass);
500  reass = NULL;
501  }
502  }
503 
504  if (reass)
505  {
506  reass->last_heard = now;
507  return reass;
508  }
509 
510  if (rt->reass_n >= rm->max_reass_n)
511  {
512  reass = NULL;
513  return reass;
514  }
515  else
516  {
517  pool_get (rt->pool, reass);
518  clib_memset (reass, 0, sizeof (*reass));
519  reass->id = ((u64) vm->thread_index * 1000000000) + rt->id_counter;
521  ++rt->id_counter;
522  ip4_full_reass_init (reass);
523  ++rt->reass_n;
524  }
525 
526  reass->key.as_u64[0] = ((clib_bihash_kv_16_8_t *) kv)->key[0];
527  reass->key.as_u64[1] = ((clib_bihash_kv_16_8_t *) kv)->key[1];
528  kv->v.reass_index = (reass - rt->pool);
529  kv->v.memory_owner_thread_index = vm->thread_index;
530  reass->last_heard = now;
531 
532  int rv =
533  clib_bihash_add_del_16_8 (&rm->hash, (clib_bihash_kv_16_8_t *) kv, 2);
534  if (rv)
535  {
536  ip4_full_reass_free_ctx (rt, reass);
537  reass = NULL;
538  // if other worker created a context already work with the other copy
539  if (-2 == rv)
540  goto again;
541  }
542 
543  return reass;
544 }
545 
546 always_inline ip4_full_reass_rc_t
550  ip4_full_reass_t * reass, u32 * bi0,
551  u32 * next0, u32 * error0, bool is_custom_app)
552 {
553  vlib_buffer_t *first_b = vlib_get_buffer (vm, reass->first_bi);
554  vlib_buffer_t *last_b = NULL;
555  u32 sub_chain_bi = reass->first_bi;
556  u32 total_length = 0;
557  u32 buf_cnt = 0;
558  do
559  {
560  u32 tmp_bi = sub_chain_bi;
561  vlib_buffer_t *tmp = vlib_get_buffer (vm, tmp_bi);
563  vnet_buffer_opaque_t *vnb = vnet_buffer (tmp);
564  if (!(vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first) &&
565  !(vnb->ip.reass.range_last > vnb->ip.reass.fragment_first))
566  {
568  }
569 
570  u32 data_len = ip4_full_reass_buffer_get_data_len (tmp);
571  u32 trim_front =
573  u32 trim_end =
574  vlib_buffer_length_in_chain (vm, tmp) - trim_front - data_len;
575  if (tmp_bi == reass->first_bi)
576  {
577  /* first buffer - keep ip4 header */
579  {
581  }
582  trim_front = 0;
583  trim_end = vlib_buffer_length_in_chain (vm, tmp) - data_len -
584  ip4_header_bytes (ip);
585  if (!(vlib_buffer_length_in_chain (vm, tmp) - trim_end > 0))
586  {
588  }
589  }
590  u32 keep_data =
591  vlib_buffer_length_in_chain (vm, tmp) - trim_front - trim_end;
592  while (1)
593  {
594  ++buf_cnt;
595  if (trim_front)
596  {
597  if (trim_front > tmp->current_length)
598  {
599  /* drop whole buffer */
600  u32 to_be_freed_bi = tmp_bi;
601  trim_front -= tmp->current_length;
602  if (!(tmp->flags & VLIB_BUFFER_NEXT_PRESENT))
603  {
605  }
606  tmp->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
607  tmp_bi = tmp->next_buffer;
608  tmp->next_buffer = 0;
609  tmp = vlib_get_buffer (vm, tmp_bi);
610  vlib_buffer_free_one (vm, to_be_freed_bi);
611  continue;
612  }
613  else
614  {
615  vlib_buffer_advance (tmp, trim_front);
616  trim_front = 0;
617  }
618  }
619  if (keep_data)
620  {
621  if (last_b)
622  {
623  last_b->flags |= VLIB_BUFFER_NEXT_PRESENT;
624  last_b->next_buffer = tmp_bi;
625  }
626  last_b = tmp;
627  if (keep_data <= tmp->current_length)
628  {
629  tmp->current_length = keep_data;
630  keep_data = 0;
631  }
632  else
633  {
634  keep_data -= tmp->current_length;
635  if (!(tmp->flags & VLIB_BUFFER_NEXT_PRESENT))
636  {
638  }
639  }
640  total_length += tmp->current_length;
641  if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
642  {
643  tmp_bi = tmp->next_buffer;
644  tmp = vlib_get_buffer (vm, tmp->next_buffer);
645  }
646  else
647  {
648  break;
649  }
650  }
651  else
652  {
653  u32 to_be_freed_bi = tmp_bi;
654  if (reass->first_bi == tmp_bi)
655  {
657  }
658  if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
659  {
660  tmp->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
661  tmp_bi = tmp->next_buffer;
662  tmp->next_buffer = 0;
663  tmp = vlib_get_buffer (vm, tmp_bi);
664  vlib_buffer_free_one (vm, to_be_freed_bi);
665  }
666  else
667  {
668  tmp->next_buffer = 0;
669  vlib_buffer_free_one (vm, to_be_freed_bi);
670  break;
671  }
672  }
673  }
674  sub_chain_bi =
675  vnet_buffer (vlib_get_buffer (vm, sub_chain_bi))->ip.
676  reass.next_range_bi;
677  }
678  while (~0 != sub_chain_bi);
679 
680  if (!last_b)
681  {
683  }
684  last_b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
685 
686  if (total_length < first_b->current_length)
687  {
689  }
690  total_length -= first_b->current_length;
691  first_b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
692  first_b->total_length_not_including_first_buffer = total_length;
695  ip->length = clib_host_to_net_u16 (first_b->current_length + total_length);
696  ip->checksum = ip4_header_checksum (ip);
697  if (!vlib_buffer_chain_linearize (vm, first_b))
698  {
699  return IP4_REASS_RC_NO_BUF;
700  }
701  // reset to reconstruct the mbuf linking
702  first_b->flags &= ~VLIB_BUFFER_EXT_HDR_VALID;
703  if (PREDICT_FALSE (first_b->flags & VLIB_BUFFER_IS_TRACED))
704  {
705  ip4_full_reass_add_trace (vm, node, rm, reass, reass->first_bi,
706  FINALIZE, 0, ~0);
707 #if 0
708  // following code does a hexdump of packet fragments to stdout ...
709  do
710  {
711  u32 bi = reass->first_bi;
712  u8 *s = NULL;
713  while (~0 != bi)
714  {
715  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
716  s = format (s, "%u: %U\n", bi, format_hexdump,
718  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
719  {
720  bi = b->next_buffer;
721  }
722  else
723  {
724  break;
725  }
726  }
727  printf ("%.*s\n", vec_len (s), s);
728  fflush (stdout);
729  vec_free (s);
730  }
731  while (0);
732 #endif
733  }
734  *bi0 = reass->first_bi;
735  if (!is_custom_app)
736  {
737  *next0 = IP4_FULL_REASS_NEXT_INPUT;
738  }
739  else
740  {
741  *next0 = reass->next_index;
742  }
743  vnet_buffer (first_b)->ip.reass.estimated_mtu = reass->min_fragment_length;
744  *error0 = IP4_ERROR_NONE;
745  ip4_full_reass_free (rm, rt, reass);
746  reass = NULL;
747  return IP4_REASS_RC_OK;
748 }
749 
750 always_inline ip4_full_reass_rc_t
754  ip4_full_reass_t * reass,
755  u32 prev_range_bi, u32 new_next_bi)
756 {
757  vlib_buffer_t *new_next_b = vlib_get_buffer (vm, new_next_bi);
758  vnet_buffer_opaque_t *new_next_vnb = vnet_buffer (new_next_b);
759  if (~0 != prev_range_bi)
760  {
761  vlib_buffer_t *prev_b = vlib_get_buffer (vm, prev_range_bi);
762  vnet_buffer_opaque_t *prev_vnb = vnet_buffer (prev_b);
763  new_next_vnb->ip.reass.next_range_bi = prev_vnb->ip.reass.next_range_bi;
764  prev_vnb->ip.reass.next_range_bi = new_next_bi;
765  }
766  else
767  {
768  if (~0 != reass->first_bi)
769  {
770  new_next_vnb->ip.reass.next_range_bi = reass->first_bi;
771  }
772  reass->first_bi = new_next_bi;
773  }
774  vnet_buffer_opaque_t *vnb = vnet_buffer (new_next_b);
775  if (!(vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first) &&
776  !(vnb->ip.reass.range_last > vnb->ip.reass.fragment_first))
777  {
779  }
780  reass->data_len += ip4_full_reass_buffer_get_data_len (new_next_b);
781  return IP4_REASS_RC_OK;
782 }
783 
784 always_inline ip4_full_reass_rc_t
786  vlib_node_runtime_t * node,
788  ip4_full_reass_t * reass,
789  u32 prev_range_bi, u32 discard_bi)
790 {
791  vlib_buffer_t *discard_b = vlib_get_buffer (vm, discard_bi);
792  vnet_buffer_opaque_t *discard_vnb = vnet_buffer (discard_b);
793  if (~0 != prev_range_bi)
794  {
795  vlib_buffer_t *prev_b = vlib_get_buffer (vm, prev_range_bi);
796  vnet_buffer_opaque_t *prev_vnb = vnet_buffer (prev_b);
797  if (!(prev_vnb->ip.reass.next_range_bi == discard_bi))
798  {
800  }
801  prev_vnb->ip.reass.next_range_bi = discard_vnb->ip.reass.next_range_bi;
802  }
803  else
804  {
805  reass->first_bi = discard_vnb->ip.reass.next_range_bi;
806  }
807  vnet_buffer_opaque_t *vnb = vnet_buffer (discard_b);
808  if (!(vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first) &&
809  !(vnb->ip.reass.range_last > vnb->ip.reass.fragment_first))
810  {
812  }
813  reass->data_len -= ip4_full_reass_buffer_get_data_len (discard_b);
814  while (1)
815  {
816  u32 to_be_freed_bi = discard_bi;
817  if (PREDICT_FALSE (discard_b->flags & VLIB_BUFFER_IS_TRACED))
818  {
819  ip4_full_reass_add_trace (vm, node, rm, reass, discard_bi,
820  RANGE_DISCARD, 0, ~0);
821  }
822  if (discard_b->flags & VLIB_BUFFER_NEXT_PRESENT)
823  {
824  discard_b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
825  discard_bi = discard_b->next_buffer;
826  discard_b->next_buffer = 0;
827  discard_b = vlib_get_buffer (vm, discard_bi);
828  vlib_buffer_free_one (vm, to_be_freed_bi);
829  }
830  else
831  {
832  discard_b->next_buffer = 0;
833  vlib_buffer_free_one (vm, to_be_freed_bi);
834  break;
835  }
836  }
837  return IP4_REASS_RC_OK;
838 }
839 
840 always_inline ip4_full_reass_rc_t
844  ip4_full_reass_t * reass, u32 * bi0, u32 * next0,
845  u32 * error0, bool is_custom_app,
846  u32 * handoff_thread_idx)
847 {
848  vlib_buffer_t *fb = vlib_get_buffer (vm, *bi0);
849  vnet_buffer_opaque_t *fvnb = vnet_buffer (fb);
850  if (is_custom_app)
851  {
852  // store (error_)next_index before it's overwritten
853  reass->next_index = fvnb->ip.reass.next_index;
854  reass->error_next_index = fvnb->ip.reass.error_next_index;
855  }
856  ip4_full_reass_rc_t rc = IP4_REASS_RC_OK;
857  int consumed = 0;
859  const u32 fragment_first = ip4_get_fragment_offset_bytes (fip);
860  const u32 fragment_length =
861  clib_net_to_host_u16 (fip->length) - ip4_header_bytes (fip);
862  const u32 fragment_last = fragment_first + fragment_length - 1;
863  fvnb->ip.reass.fragment_first = fragment_first;
864  fvnb->ip.reass.fragment_last = fragment_last;
865  int more_fragments = ip4_get_fragment_more (fip);
866  u32 candidate_range_bi = reass->first_bi;
867  u32 prev_range_bi = ~0;
868  fvnb->ip.reass.range_first = fragment_first;
869  fvnb->ip.reass.range_last = fragment_last;
870  fvnb->ip.reass.next_range_bi = ~0;
871  if (!more_fragments)
872  {
873  reass->last_packet_octet = fragment_last;
874  }
875  if (~0 == reass->first_bi)
876  {
877  // starting a new reassembly
878  rc =
879  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
880  prev_range_bi, *bi0);
881  if (IP4_REASS_RC_OK != rc)
882  {
883  return rc;
884  }
885  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
886  {
887  ip4_full_reass_add_trace (vm, node, rm, reass, *bi0, RANGE_NEW, 0,
888  ~0);
889  }
890  *bi0 = ~0;
891  reass->min_fragment_length = clib_net_to_host_u16 (fip->length);
892  reass->fragments_n = 1;
893  return IP4_REASS_RC_OK;
894  }
895  reass->min_fragment_length =
896  clib_min (clib_net_to_host_u16 (fip->length),
897  fvnb->ip.reass.estimated_mtu);
898  while (~0 != candidate_range_bi)
899  {
900  vlib_buffer_t *candidate_b = vlib_get_buffer (vm, candidate_range_bi);
901  vnet_buffer_opaque_t *candidate_vnb = vnet_buffer (candidate_b);
902  if (fragment_first > candidate_vnb->ip.reass.range_last)
903  {
904  // this fragments starts after candidate range
905  prev_range_bi = candidate_range_bi;
906  candidate_range_bi = candidate_vnb->ip.reass.next_range_bi;
907  if (candidate_vnb->ip.reass.range_last < fragment_last &&
908  ~0 == candidate_range_bi)
909  {
910  // special case - this fragment falls beyond all known ranges
911  rc =
912  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
913  prev_range_bi, *bi0);
914  if (IP4_REASS_RC_OK != rc)
915  {
916  return rc;
917  }
918  consumed = 1;
919  break;
920  }
921  continue;
922  }
923  if (fragment_last < candidate_vnb->ip.reass.range_first)
924  {
925  // this fragment ends before candidate range without any overlap
926  rc =
927  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
928  prev_range_bi, *bi0);
929  if (IP4_REASS_RC_OK != rc)
930  {
931  return rc;
932  }
933  consumed = 1;
934  }
935  else
936  {
937  if (fragment_first >= candidate_vnb->ip.reass.range_first &&
938  fragment_last <= candidate_vnb->ip.reass.range_last)
939  {
940  // this fragment is a (sub)part of existing range, ignore it
941  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
942  {
943  ip4_full_reass_add_trace (vm, node, rm, reass, *bi0,
944  RANGE_OVERLAP, 0, ~0);
945  }
946  break;
947  }
948  int discard_candidate = 0;
949  if (fragment_first < candidate_vnb->ip.reass.range_first)
950  {
951  u32 overlap =
952  fragment_last - candidate_vnb->ip.reass.range_first + 1;
953  if (overlap < ip4_full_reass_buffer_get_data_len (candidate_b))
954  {
955  candidate_vnb->ip.reass.range_first += overlap;
956  if (reass->data_len < overlap)
957  {
959  }
960  reass->data_len -= overlap;
961  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
962  {
963  ip4_full_reass_add_trace (vm, node, rm, reass,
964  candidate_range_bi,
965  RANGE_SHRINK, 0, ~0);
966  }
967  rc =
968  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
969  prev_range_bi,
970  *bi0);
971  if (IP4_REASS_RC_OK != rc)
972  {
973  return rc;
974  }
975  consumed = 1;
976  }
977  else
978  {
979  discard_candidate = 1;
980  }
981  }
982  else if (fragment_last > candidate_vnb->ip.reass.range_last)
983  {
984  u32 overlap =
985  candidate_vnb->ip.reass.range_last - fragment_first + 1;
986  if (overlap < ip4_full_reass_buffer_get_data_len (candidate_b))
987  {
988  fvnb->ip.reass.range_first += overlap;
989  if (~0 != candidate_vnb->ip.reass.next_range_bi)
990  {
991  prev_range_bi = candidate_range_bi;
992  candidate_range_bi =
993  candidate_vnb->ip.reass.next_range_bi;
994  continue;
995  }
996  else
997  {
998  // special case - last range discarded
999  rc =
1001  reass,
1002  candidate_range_bi,
1003  *bi0);
1004  if (IP4_REASS_RC_OK != rc)
1005  {
1006  return rc;
1007  }
1008  consumed = 1;
1009  }
1010  }
1011  else
1012  {
1013  discard_candidate = 1;
1014  }
1015  }
1016  else
1017  {
1018  discard_candidate = 1;
1019  }
1020  if (discard_candidate)
1021  {
1022  u32 next_range_bi = candidate_vnb->ip.reass.next_range_bi;
1023  // discard candidate range, probe next range
1024  rc =
1025  ip4_full_reass_remove_range_from_chain (vm, node, rm, reass,
1026  prev_range_bi,
1027  candidate_range_bi);
1028  if (IP4_REASS_RC_OK != rc)
1029  {
1030  return rc;
1031  }
1032  if (~0 != next_range_bi)
1033  {
1034  candidate_range_bi = next_range_bi;
1035  continue;
1036  }
1037  else
1038  {
1039  // special case - last range discarded
1040  rc =
1041  ip4_full_reass_insert_range_in_chain (vm, rm, rt, reass,
1042  prev_range_bi,
1043  *bi0);
1044  if (IP4_REASS_RC_OK != rc)
1045  {
1046  return rc;
1047  }
1048  consumed = 1;
1049  }
1050  }
1051  }
1052  break;
1053  }
1054  ++reass->fragments_n;
1055  if (consumed)
1056  {
1057  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
1058  {
1059  ip4_full_reass_add_trace (vm, node, rm, reass, *bi0, RANGE_NEW, 0,
1060  ~0);
1061  }
1062  }
1063  if (~0 != reass->last_packet_octet &&
1064  reass->data_len == reass->last_packet_octet + 1)
1065  {
1066  *handoff_thread_idx = reass->sendout_thread_index;
1067  int handoff =
1069  rc =
1070  ip4_full_reass_finalize (vm, node, rm, rt, reass, bi0, next0, error0,
1071  is_custom_app);
1072  if (IP4_REASS_RC_OK == rc && handoff)
1073  {
1074  rc = IP4_REASS_RC_HANDOFF;
1075  }
1076  }
1077  else
1078  {
1079  if (consumed)
1080  {
1081  *bi0 = ~0;
1082  if (reass->fragments_n > rm->max_reass_len)
1083  {
1085  }
1086  }
1087  else
1088  {
1089  *next0 = IP4_FULL_REASS_NEXT_DROP;
1090  *error0 = IP4_ERROR_REASS_DUPLICATE_FRAGMENT;
1091  }
1092  }
1093  return rc;
1094 }
1095 
1098  vlib_frame_t * frame, bool is_feature,
1099  bool is_custom_app)
1100 {
1101  u32 *from = vlib_frame_vector_args (frame);
1102  u32 n_left_from, n_left_to_next, *to_next, next_index;
1105  clib_spinlock_lock (&rt->lock);
1106 
1107  n_left_from = frame->n_vectors;
1108  next_index = node->cached_next_index;
1109  while (n_left_from > 0)
1110  {
1111  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1112 
1113  while (n_left_from > 0 && n_left_to_next > 0)
1114  {
1115  u32 bi0;
1116  vlib_buffer_t *b0;
1117  u32 next0;
1118  u32 error0 = IP4_ERROR_NONE;
1119 
1120  bi0 = from[0];
1121  b0 = vlib_get_buffer (vm, bi0);
1122 
1124  if (!ip4_get_fragment_more (ip0) && !ip4_get_fragment_offset (ip0))
1125  {
1126  // this is a whole packet - no fragmentation
1127  if (!is_custom_app)
1128  {
1129  next0 = IP4_FULL_REASS_NEXT_INPUT;
1130  }
1131  else
1132  {
1133  next0 = vnet_buffer (b0)->ip.reass.next_index;
1134  }
1135  goto packet_enqueue;
1136  }
1137  const u32 fragment_first = ip4_get_fragment_offset_bytes (ip0);
1138  const u32 fragment_length =
1139  clib_net_to_host_u16 (ip0->length) - ip4_header_bytes (ip0);
1140  const u32 fragment_last = fragment_first + fragment_length - 1;
1141  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
1142  {
1143  next0 = IP4_FULL_REASS_NEXT_DROP;
1144  error0 = IP4_ERROR_REASS_MALFORMED_PACKET;
1145  goto packet_enqueue;
1146  }
1148  u8 do_handoff = 0;
1149 
1150  kv.k.as_u64[0] =
1152  vnet_buffer (b0)->sw_if_index[VLIB_RX]) |
1153  (u64) ip0->src_address.as_u32 << 32;
1154  kv.k.as_u64[1] =
1155  (u64) ip0->dst_address.
1156  as_u32 | (u64) ip0->fragment_id << 32 | (u64) ip0->protocol << 48;
1157 
1158  ip4_full_reass_t *reass =
1159  ip4_full_reass_find_or_create (vm, node, rm, rt, &kv,
1160  &do_handoff);
1161 
1162  if (reass)
1163  {
1164  const u32 fragment_first = ip4_get_fragment_offset_bytes (ip0);
1165  if (0 == fragment_first)
1166  {
1167  reass->sendout_thread_index = vm->thread_index;
1168  }
1169  }
1170 
1171  if (PREDICT_FALSE (do_handoff))
1172  {
1174  vnet_buffer (b0)->ip.reass.owner_thread_index =
1176  }
1177  else if (reass)
1178  {
1179  u32 handoff_thread_idx;
1180  switch (ip4_full_reass_update
1181  (vm, node, rm, rt, reass, &bi0, &next0,
1182  &error0, is_custom_app, &handoff_thread_idx))
1183  {
1184  case IP4_REASS_RC_OK:
1185  /* nothing to do here */
1186  break;
1187  case IP4_REASS_RC_HANDOFF:
1189  b0 = vlib_get_buffer (vm, bi0);
1190  vnet_buffer (b0)->ip.reass.owner_thread_index =
1191  handoff_thread_idx;
1192  break;
1195  IP4_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
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  case IP4_REASS_RC_NO_BUF:
1203  IP4_ERROR_REASS_NO_BUF, 1);
1204  ip4_full_reass_drop_all (vm, node, rm, reass);
1205  ip4_full_reass_free (rm, rt, reass);
1206  goto next_packet;
1207  break;
1209  /* drop everything and start with a clean slate */
1211  IP4_ERROR_REASS_INTERNAL_ERROR,
1212  1);
1213  ip4_full_reass_drop_all (vm, node, rm, reass);
1214  ip4_full_reass_free (rm, rt, reass);
1215  goto next_packet;
1216  break;
1217  }
1218  }
1219  else
1220  {
1221  next0 = IP4_FULL_REASS_NEXT_DROP;
1222  error0 = IP4_ERROR_REASS_LIMIT_REACHED;
1223  }
1224 
1225 
1226  packet_enqueue:
1227 
1228  if (bi0 != ~0)
1229  {
1230  to_next[0] = bi0;
1231  to_next += 1;
1232  n_left_to_next -= 1;
1233 
1234  /* bi0 might have been updated by reass_finalize, reload */
1235  b0 = vlib_get_buffer (vm, bi0);
1236  b0->error = node->errors[error0];
1237 
1238  if (next0 == IP4_FULL_REASS_NEXT_HANDOFF)
1239  {
1240  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1241  {
1242  ip4_full_reass_add_trace (vm, node, rm, NULL, bi0,
1243  HANDOFF, 0,
1244  vnet_buffer (b0)->ip.
1245  reass.owner_thread_index);
1246  }
1247  }
1248  else if (is_feature && IP4_ERROR_NONE == error0)
1249  {
1250  vnet_feature_next (&next0, b0);
1251  }
1252  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
1253  to_next, n_left_to_next,
1254  bi0, next0);
1255  IP4_REASS_DEBUG_BUFFER (bi0, enqueue_next);
1256  }
1257 
1258  next_packet:
1259  from += 1;
1260  n_left_from -= 1;
1261  }
1262 
1263  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1264  }
1265 
1266  clib_spinlock_unlock (&rt->lock);
1267  return frame->n_vectors;
1268 }
1269 
1271 #define _(sym, string) string,
1273 #undef _
1274 };
1275 
1276 VLIB_NODE_FN (ip4_full_reass_node) (vlib_main_t * vm,
1278  vlib_frame_t * frame)
1279 {
1280  return ip4_full_reass_inline (vm, node, frame, false /* is_feature */ ,
1281  false /* is_custom_app */ );
1282 }
1283 
1284 /* *INDENT-OFF* */
1285 VLIB_REGISTER_NODE (ip4_full_reass_node) = {
1286  .name = "ip4-full-reassembly",
1287  .vector_size = sizeof (u32),
1288  .format_trace = format_ip4_full_reass_trace,
1289  .n_errors = ARRAY_LEN (ip4_full_reass_error_strings),
1290  .error_strings = ip4_full_reass_error_strings,
1291  .n_next_nodes = IP4_FULL_REASS_N_NEXT,
1292  .next_nodes =
1293  {
1294  [IP4_FULL_REASS_NEXT_INPUT] = "ip4-input",
1295  [IP4_FULL_REASS_NEXT_DROP] = "ip4-drop",
1296  [IP4_FULL_REASS_NEXT_HANDOFF] = "ip4-full-reassembly-handoff",
1297 
1298  },
1299 };
1300 /* *INDENT-ON* */
1301 
1302 VLIB_NODE_FN (ip4_full_reass_node_feature) (vlib_main_t * vm,
1304  vlib_frame_t * frame)
1305 {
1306  return ip4_full_reass_inline (vm, node, frame, true /* is_feature */ ,
1307  false /* is_custom_app */ );
1308 }
1309 
1310 /* *INDENT-OFF* */
1311 VLIB_REGISTER_NODE (ip4_full_reass_node_feature) = {
1312  .name = "ip4-full-reassembly-feature",
1313  .vector_size = sizeof (u32),
1314  .format_trace = format_ip4_full_reass_trace,
1315  .n_errors = ARRAY_LEN (ip4_full_reass_error_strings),
1316  .error_strings = ip4_full_reass_error_strings,
1317  .n_next_nodes = IP4_FULL_REASS_N_NEXT,
1318  .next_nodes =
1319  {
1320  [IP4_FULL_REASS_NEXT_INPUT] = "ip4-input",
1321  [IP4_FULL_REASS_NEXT_DROP] = "ip4-drop",
1322  [IP4_FULL_REASS_NEXT_HANDOFF] = "ip4-full-reass-feature-hoff",
1323  },
1324 };
1325 /* *INDENT-ON* */
1326 
1327 /* *INDENT-OFF* */
1328 VNET_FEATURE_INIT (ip4_full_reass_feature, static) = {
1329  .arc_name = "ip4-unicast",
1330  .node_name = "ip4-full-reassembly-feature",
1331  .runs_before = VNET_FEATURES ("ip4-lookup",
1332  "ipsec4-input-feature"),
1333  .runs_after = 0,
1334 };
1335 /* *INDENT-ON* */
1336 
1337 #ifndef CLIB_MARCH_VARIANT
1340 {
1342  u32 nbuckets;
1343  u8 i;
1344 
1345  nbuckets = (u32) (rm->max_reass_n / IP4_REASS_HT_LOAD_FACTOR);
1346 
1347  for (i = 0; i < 31; i++)
1348  if ((1 << i) >= nbuckets)
1349  break;
1350  nbuckets = 1 << i;
1351 
1352  return nbuckets;
1353 }
1354 #endif /* CLIB_MARCH_VARIANT */
1355 
1356 typedef enum
1357 {
1360 
1361 typedef struct
1362 {
1363  int failure;
1364  clib_bihash_16_8_t *new_hash;
1366 
1367 #ifndef CLIB_MARCH_VARIANT
1368 static int
1370 {
1371  ip4_rehash_cb_ctx *ctx = _ctx;
1372  if (clib_bihash_add_del_16_8 (ctx->new_hash, kv, 1))
1373  {
1374  ctx->failure = 1;
1375  }
1376  return (BIHASH_WALK_CONTINUE);
1377 }
1378 
1379 static void
1380 ip4_full_reass_set_params (u32 timeout_ms, u32 max_reassemblies,
1381  u32 max_reassembly_length,
1382  u32 expire_walk_interval_ms)
1383 {
1384  ip4_full_reass_main.timeout_ms = timeout_ms;
1385  ip4_full_reass_main.timeout = (f64) timeout_ms / (f64) MSEC_PER_SEC;
1386  ip4_full_reass_main.max_reass_n = max_reassemblies;
1387  ip4_full_reass_main.max_reass_len = max_reassembly_length;
1388  ip4_full_reass_main.expire_walk_interval_ms = expire_walk_interval_ms;
1389 }
1390 
1392 ip4_full_reass_set (u32 timeout_ms, u32 max_reassemblies,
1393  u32 max_reassembly_length, u32 expire_walk_interval_ms)
1394 {
1395  u32 old_nbuckets = ip4_full_reass_get_nbuckets ();
1396  ip4_full_reass_set_params (timeout_ms, max_reassemblies,
1397  max_reassembly_length, expire_walk_interval_ms);
1398  vlib_process_signal_event (ip4_full_reass_main.vlib_main,
1399  ip4_full_reass_main.ip4_full_reass_expire_node_idx,
1401  u32 new_nbuckets = ip4_full_reass_get_nbuckets ();
1402  if (ip4_full_reass_main.max_reass_n > 0 && new_nbuckets > old_nbuckets)
1403  {
1404  clib_bihash_16_8_t new_hash;
1405  clib_memset (&new_hash, 0, sizeof (new_hash));
1407  ctx.failure = 0;
1408  ctx.new_hash = &new_hash;
1409  clib_bihash_init_16_8 (&new_hash, "ip4-dr", new_nbuckets,
1410  new_nbuckets * 1024);
1411  clib_bihash_foreach_key_value_pair_16_8 (&ip4_full_reass_main.hash,
1412  ip4_rehash_cb, &ctx);
1413  if (ctx.failure)
1414  {
1415  clib_bihash_free_16_8 (&new_hash);
1416  return -1;
1417  }
1418  else
1419  {
1420  clib_bihash_free_16_8 (&ip4_full_reass_main.hash);
1421  clib_memcpy_fast (&ip4_full_reass_main.hash, &new_hash,
1422  sizeof (ip4_full_reass_main.hash));
1423  clib_bihash_copied (&ip4_full_reass_main.hash, &new_hash);
1424  }
1425  }
1426  return 0;
1427 }
1428 
1430 ip4_full_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
1431  u32 * max_reassembly_length,
1432  u32 * expire_walk_interval_ms)
1433 {
1434  *timeout_ms = ip4_full_reass_main.timeout_ms;
1435  *max_reassemblies = ip4_full_reass_main.max_reass_n;
1436  *max_reassembly_length = ip4_full_reass_main.max_reass_len;
1437  *expire_walk_interval_ms = ip4_full_reass_main.expire_walk_interval_ms;
1438  return 0;
1439 }
1440 
1441 static clib_error_t *
1443 {
1445  clib_error_t *error = 0;
1446  u32 nbuckets;
1447  vlib_node_t *node;
1448 
1449  rm->vlib_main = vm;
1450 
1453  vec_foreach (rt, rm->per_thread_data)
1454  {
1455  clib_spinlock_init (&rt->lock);
1456  pool_alloc (rt->pool, rm->max_reass_n);
1457  }
1458 
1459  node = vlib_get_node_by_name (vm, (u8 *) "ip4-full-reassembly-expire-walk");
1460  ASSERT (node);
1462 
1467 
1468  nbuckets = ip4_full_reass_get_nbuckets ();
1469  clib_bihash_init_16_8 (&rm->hash, "ip4-dr", nbuckets, nbuckets * 1024);
1470 
1471  node = vlib_get_node_by_name (vm, (u8 *) "ip4-drop");
1472  ASSERT (node);
1473  rm->ip4_drop_idx = node->index;
1474 
1475  rm->fq_index = vlib_frame_queue_main_init (ip4_full_reass_node.index, 0);
1476  rm->fq_feature_index =
1477  vlib_frame_queue_main_init (ip4_full_reass_node_feature.index, 0);
1478 
1480  return error;
1481 }
1482 
1484 #endif /* CLIB_MARCH_VARIANT */
1485 
1486 static uword
1488  vlib_node_runtime_t * node, vlib_frame_t * f)
1489 {
1491  uword event_type, *event_data = 0;
1492 
1493  while (true)
1494  {
1496  (f64)
1498  (f64) MSEC_PER_SEC);
1499  event_type = vlib_process_get_events (vm, &event_data);
1500 
1501  switch (event_type)
1502  {
1503  case ~0: /* no events => timeout */
1504  /* nothing to do here */
1505  break;
1507  break;
1508  default:
1509  clib_warning ("BUG: event type 0x%wx", event_type);
1510  break;
1511  }
1512  f64 now = vlib_time_now (vm);
1513 
1514  ip4_full_reass_t *reass;
1515  int *pool_indexes_to_free = NULL;
1516 
1517  uword thread_index = 0;
1518  int index;
1519  const uword nthreads = vlib_num_workers () + 1;
1520  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1521  {
1523  &rm->per_thread_data[thread_index];
1524  clib_spinlock_lock (&rt->lock);
1525 
1526  vec_reset_length (pool_indexes_to_free);
1527  /* *INDENT-OFF* */
1528  pool_foreach_index (index, rt->pool, ({
1529  reass = pool_elt_at_index (rt->pool, index);
1530  if (now > reass->last_heard + rm->timeout)
1531  {
1532  vec_add1 (pool_indexes_to_free, index);
1533  }
1534  }));
1535  /* *INDENT-ON* */
1536  int *i;
1537  /* *INDENT-OFF* */
1538  vec_foreach (i, pool_indexes_to_free)
1539  {
1540  ip4_full_reass_t *reass = pool_elt_at_index (rt->pool, i[0]);
1541  ip4_full_reass_drop_all (vm, node, rm, reass);
1542  ip4_full_reass_free (rm, rt, reass);
1543  }
1544  /* *INDENT-ON* */
1545 
1546  clib_spinlock_unlock (&rt->lock);
1547  }
1548 
1549  vec_free (pool_indexes_to_free);
1550  if (event_data)
1551  {
1552  _vec_len (event_data) = 0;
1553  }
1554  }
1555 
1556  return 0;
1557 }
1558 
1559 /* *INDENT-OFF* */
1561  .function = ip4_full_reass_walk_expired,
1562  .type = VLIB_NODE_TYPE_PROCESS,
1563  .name = "ip4-full-reassembly-expire-walk",
1564  .format_trace = format_ip4_full_reass_trace,
1566  .error_strings = ip4_full_reass_error_strings,
1567 
1568 };
1569 /* *INDENT-ON* */
1570 
1571 static u8 *
1572 format_ip4_full_reass_key (u8 * s, va_list * args)
1573 {
1574  ip4_full_reass_key_t *key = va_arg (*args, ip4_full_reass_key_t *);
1575  s =
1576  format (s,
1577  "xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1579  &key->dst, clib_net_to_host_u16 (key->frag_id), key->proto);
1580  return s;
1581 }
1582 
1583 static u8 *
1584 format_ip4_reass (u8 * s, va_list * args)
1585 {
1586  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
1587  ip4_full_reass_t *reass = va_arg (*args, ip4_full_reass_t *);
1588 
1589  s = format (s, "ID: %lu, key: %U\n first_bi: %u, data_len: %u, "
1590  "last_packet_octet: %u, trace_op_counter: %u\n",
1591  reass->id, format_ip4_full_reass_key, &reass->key,
1592  reass->first_bi, reass->data_len,
1593  reass->last_packet_octet, reass->trace_op_counter);
1594 
1595  u32 bi = reass->first_bi;
1596  u32 counter = 0;
1597  while (~0 != bi)
1598  {
1599  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
1600  vnet_buffer_opaque_t *vnb = vnet_buffer (b);
1601  s =
1602  format (s,
1603  " #%03u: range: [%u, %u], bi: %u, off: %d, len: %u, "
1604  "fragment[%u, %u]\n", counter, vnb->ip.reass.range_first,
1605  vnb->ip.reass.range_last, bi,
1608  vnb->ip.reass.fragment_first, vnb->ip.reass.fragment_last);
1609  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
1610  {
1611  bi = b->next_buffer;
1612  }
1613  else
1614  {
1615  bi = ~0;
1616  }
1617  }
1618  return s;
1619 }
1620 
1621 static clib_error_t *
1623  unformat_input_t * input,
1625 {
1627 
1628  vlib_cli_output (vm, "---------------------");
1629  vlib_cli_output (vm, "IP4 reassembly status");
1630  vlib_cli_output (vm, "---------------------");
1631  bool details = false;
1632  if (unformat (input, "details"))
1633  {
1634  details = true;
1635  }
1636 
1637  u32 sum_reass_n = 0;
1638  ip4_full_reass_t *reass;
1639  uword thread_index;
1640  const uword nthreads = vlib_num_workers () + 1;
1641  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1642  {
1643  ip4_full_reass_per_thread_t *rt = &rm->per_thread_data[thread_index];
1644  clib_spinlock_lock (&rt->lock);
1645  if (details)
1646  {
1647  /* *INDENT-OFF* */
1648  pool_foreach (reass, rt->pool, {
1649  vlib_cli_output (vm, "%U", format_ip4_reass, vm, reass);
1650  });
1651  /* *INDENT-ON* */
1652  }
1653  sum_reass_n += rt->reass_n;
1654  clib_spinlock_unlock (&rt->lock);
1655  }
1656  vlib_cli_output (vm, "---------------------");
1657  vlib_cli_output (vm, "Current IP4 reassemblies count: %lu\n",
1658  (long unsigned) sum_reass_n);
1659  vlib_cli_output (vm,
1660  "Maximum configured concurrent IP4 reassemblies per worker-thread: %lu\n",
1661  (long unsigned) rm->max_reass_n);
1662  return 0;
1663 }
1664 
1665 /* *INDENT-OFF* */
1667  .path = "show ip4-full-reassembly",
1668  .short_help = "show ip4-full-reassembly [details]",
1669  .function = show_ip4_reass,
1670 };
1671 /* *INDENT-ON* */
1672 
1673 #ifndef CLIB_MARCH_VARIANT
1676 {
1677  return vnet_feature_enable_disable ("ip4-unicast",
1678  "ip4-full-reassembly-feature",
1679  sw_if_index, enable_disable, 0, 0);
1680 }
1681 #endif /* CLIB_MARCH_VARIANT */
1682 
1683 
1684 #define foreach_ip4_full_reass_handoff_error \
1685 _(CONGESTION_DROP, "congestion drop")
1686 
1687 
1688 typedef enum
1689 {
1690 #define _(sym,str) IP4_FULL_REASS_HANDOFF_ERROR_##sym,
1692 #undef _
1695 
1697 #define _(sym,string) string,
1699 #undef _
1700 };
1701 
1702 typedef struct
1703 {
1706 
1707 static u8 *
1709 {
1710  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1711  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1713  va_arg (*args, ip4_full_reass_handoff_trace_t *);
1714 
1715  s =
1716  format (s, "ip4-full-reassembly-handoff: next-worker %d",
1717  t->next_worker_index);
1718 
1719  return s;
1720 }
1721 
1725  vlib_frame_t * frame, bool is_feature)
1726 {
1728 
1729  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
1730  u32 n_enq, n_left_from, *from;
1731  u16 thread_indices[VLIB_FRAME_SIZE], *ti;
1732  u32 fq_index;
1733 
1734  from = vlib_frame_vector_args (frame);
1735  n_left_from = frame->n_vectors;
1736  vlib_get_buffers (vm, from, bufs, n_left_from);
1737 
1738  b = bufs;
1739  ti = thread_indices;
1740 
1741  fq_index = (is_feature) ? rm->fq_feature_index : rm->fq_index;
1742 
1743  while (n_left_from > 0)
1744  {
1745  ti[0] = vnet_buffer (b[0])->ip.reass.owner_thread_index;
1746 
1747  if (PREDICT_FALSE
1748  ((node->flags & VLIB_NODE_FLAG_TRACE)
1749  && (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
1750  {
1752  vlib_add_trace (vm, node, b[0], sizeof (*t));
1753  t->next_worker_index = ti[0];
1754  }
1755 
1756  n_left_from -= 1;
1757  ti += 1;
1758  b += 1;
1759  }
1760  n_enq =
1761  vlib_buffer_enqueue_to_thread (vm, fq_index, from, thread_indices,
1762  frame->n_vectors, 1);
1763 
1764  if (n_enq < frame->n_vectors)
1766  IP4_FULL_REASS_HANDOFF_ERROR_CONGESTION_DROP,
1767  frame->n_vectors - n_enq);
1768  return frame->n_vectors;
1769 }
1770 
1773  vlib_frame_t * frame)
1774 {
1775  return ip4_full_reass_handoff_node_inline (vm, node, frame,
1776  false /* is_feature */ );
1777 }
1778 
1779 
1780 /* *INDENT-OFF* */
1782  .name = "ip4-full-reassembly-handoff",
1783  .vector_size = sizeof (u32),
1784  .n_errors = ARRAY_LEN(ip4_full_reass_handoff_error_strings),
1785  .error_strings = ip4_full_reass_handoff_error_strings,
1786  .format_trace = format_ip4_full_reass_handoff_trace,
1787 
1788  .n_next_nodes = 1,
1789 
1790  .next_nodes = {
1791  [0] = "error-drop",
1792  },
1793 };
1794 /* *INDENT-ON* */
1795 
1796 
1797 /* *INDENT-OFF* */
1800  node,
1801  vlib_frame_t * frame)
1802 {
1803  return ip4_full_reass_handoff_node_inline (vm, node, frame,
1804  true /* is_feature */ );
1805 }
1806 /* *INDENT-ON* */
1807 
1808 
1809 /* *INDENT-OFF* */
1811  .name = "ip4-full-reass-feature-hoff",
1812  .vector_size = sizeof (u32),
1813  .n_errors = ARRAY_LEN(ip4_full_reass_handoff_error_strings),
1814  .error_strings = ip4_full_reass_handoff_error_strings,
1815  .format_trace = format_ip4_full_reass_handoff_trace,
1816 
1817  .n_next_nodes = 1,
1818 
1819  .next_nodes = {
1820  [0] = "error-drop",
1821  },
1822 };
1823 /* *INDENT-ON* */
1824 
1825 #ifndef CLIB_MARCH_VARIANT
1826 int
1828 {
1830  vec_validate (rm->feature_use_refcount_per_intf, sw_if_index);
1831  if (is_enable)
1832  {
1833  if (!rm->feature_use_refcount_per_intf[sw_if_index])
1834  {
1836  return vnet_feature_enable_disable ("ip4-unicast",
1837  "ip4-full-reassembly-feature",
1838  sw_if_index, 1, 0, 0);
1839  }
1841  }
1842  else
1843  {
1845  if (!rm->feature_use_refcount_per_intf[sw_if_index])
1846  return vnet_feature_enable_disable ("ip4-unicast",
1847  "ip4-full-reassembly-feature",
1848  sw_if_index, 0, 0, 0);
1849  }
1850  return -1;
1851 }
1852 #endif
1853 
1854 /*
1855  * fd.io coding-style-patch-verification: ON
1856  *
1857  * Local Variables:
1858  * eval: (c-set-style "gnu")
1859  * End:
1860  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:440
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:158
clib_bihash_16_8_t hash
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:898
static u16 ip4_full_reass_buffer_get_data_len(vlib_buffer_t *b)
#define clib_min(x, y)
Definition: clib.h:295
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:82
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:890
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:346
format_function_t format_ip4_header
Definition: format.h:81
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
#define NULL
Definition: clib.h:58
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:1810
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:523
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:237
unsigned char u8
Definition: types.h:56
#define vec_pop(V)
Returns last element of a vector and decrements its length.
Definition: vec.h:616
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
#define clib_memcpy(d, s, n)
Definition: string.h:180
vlib_main_t * vlib_main
format_function_t format_ip4_address
Definition: format.h:73
#define IP4_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:498
vl_api_interface_index_t sw_if_index
Definition: gre.api:59
#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
static u16 ip4_get_fragment_more(const ip4_header_t *i)
Definition: ip4_packet.h:206
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)
static uword ip4_full_reass_walk_expired(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
clib_bihash_16_8_t * new_hash
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:519
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 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:287
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:111
ip4_full_reass_per_thread_t * per_thread_data
#define always_inline
Definition: ipsec.h:28
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
vlib_main_t * vm
Definition: in2out_ed.c:1810
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
static int ip4_rehash_cb(clib_bihash_kv_16_8_t *kv, void *_ctx)
#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
static u16 ip4_get_fragment_offset(const ip4_header_t *i)
Definition: ip4_packet.h:200
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:342
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)
static u32 vlib_buffer_get_trace_thread(vlib_buffer_t *b)
Extract the thread id from a trace handle.
Definition: buffer.h:376
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:62
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)
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1810
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:152
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
struct vnet_buffer_opaque_t::@132::@134 ip
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)
typedef key
Definition: ipsec_types.api:83
struct _vlib_node_registration vlib_node_registration_t
u8 action
Definition: l2.api:173
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:490
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
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
int ip4_full_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
#define vnet_buffer(b)
Definition: buffer.h:408
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:1079
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.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: in2out_ed.c:1811
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:923
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:543
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
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:689
#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:304
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
#define IP4_REASS_TIMEOUT_DEFAULT_MS
#define IP4_REASS_DEBUG_BUFFER(...)