FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
ip6_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 IPv6 Full Reassembly.
19  *
20  * This file contains the source code for IPv6 full reassembly.
21  */
22 
23 #include <vppinfra/vec.h>
24 #include <vnet/vnet.h>
25 #include <vnet/ip/ip.h>
26 #include <vppinfra/bihash_48_8.h>
28 
29 #define MSEC_PER_SEC 1000
30 #define IP6_FULL_REASS_TIMEOUT_DEFAULT_MS 100
31 #define IP6_FULL_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS 10000 // 10 seconds default
32 #define IP6_FULL_REASS_MAX_REASSEMBLIES_DEFAULT 1024
33 #define IP6_FULL_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT 3
34 #define IP6_FULL_REASS_HT_LOAD_FACTOR (0.75)
35 
36 typedef enum
37 {
44 
45 typedef struct
46 {
47  union
48  {
49  struct
50  {
55  u8 unused[7];
57  };
58  u64 as_u64[6];
59  };
61 
62 typedef union
63 {
64  struct
65  {
68  };
71 
72 typedef union
73 {
74  struct
75  {
78  };
81 
82 
85 {
87  return vnb->ip.reass.range_first - vnb->ip.reass.fragment_first;
88 }
89 
92 {
94  return clib_min (vnb->ip.reass.range_last, vnb->ip.reass.fragment_last) -
95  (vnb->ip.reass.fragment_first +
97 }
98 
99 typedef struct
100 {
101  // hash table key
103  // time when last packet was received
105  // internal id of this reassembly
107  // buffer index of first buffer in this reassembly context
109  // last octet of packet, ~0 until fragment without more_fragments arrives
111  // length of data collected so far
113  // trace operation counter
115  // next index - used by custom apps (~0 if not set)
117  // error next index - used by custom apps (~0 if not set)
119  // minimum fragment length for this reassembly - used to estimate MTU
121  // number of fragments for this reassembly
123  // thread owning memory for this context (whose pool contains this ctx)
125  // thread which received fragment with offset 0 and which sends out the
126  // completed reassembly
129 
130 typedef struct
131 {
137 
138 typedef struct
139 {
140  // IPv6 config
144  // maximum number of fragments in one reassembly
146  // maximum number of reassemblies
148 
149  // IPv6 runtime
150  clib_bihash_48_8_t hash;
151 
152  // per-thread data
154 
155  // convenience
157 
158  // node index of ip6-drop node
162 
163  /** Worker handoff */
166 
167  // reference count for enabling/disabling feature - per interface
170 
172 
173 #ifndef CLIB_MARCH_VARIANT
175 #endif /* CLIB_MARCH_VARIANT */
176 
177 typedef enum
178 {
185 
186 typedef enum
187 {
196 
197 typedef struct
198 {
206 
207 typedef struct
208 {
209  ip6_full_reass_trace_operation_e action;
220  ip6_frag_hdr_t ip6_frag_header;
222 
223 static void
226 {
227  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
229  trace->range_first = vnb->ip.reass.range_first;
230  trace->range_last = vnb->ip.reass.range_last;
233  trace->range_bi = bi;
234 }
235 
236 static u8 *
238 {
240  va_arg (*args, ip6_full_reass_range_trace_t *);
241  s =
242  format (s, "range: [%u, %u], off %d, len %u, bi %u", trace->range_first,
243  trace->range_last, trace->data_offset, trace->data_len,
244  trace->range_bi);
245  return s;
246 }
247 
248 static u8 *
249 format_ip6_full_reass_trace (u8 * s, va_list * args)
250 {
251  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
252  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
253  ip6_full_reass_trace_t *t = va_arg (*args, ip6_full_reass_trace_t *);
254  u32 indent = 0;
255  if (~0 != t->reass_id)
256  {
257  if (t->is_after_handoff)
258  {
259  s =
260  format (s, "%U\n", format_ip6_header, &t->ip6_header,
261  sizeof (t->ip6_header));
262  s =
263  format (s, " %U\n", format_ip6_frag_hdr, &t->ip6_frag_header,
264  sizeof (t->ip6_frag_header));
265  indent = 2;
266  }
267  s =
268  format (s, "%Ureass id: %u, op id: %u, ", format_white_space, indent,
269  t->reass_id, t->op_id);
270  indent = format_get_indent (s);
271  s = format (s, "first bi: %u, data len: %u, ip/fragment[%u, %u]",
274  }
275  switch (t->action)
276  {
277  case RANGE_NEW:
278  s = format (s, "\n%Unew %U", format_white_space, indent,
280  break;
281  case RANGE_OVERLAP:
282  s = format (s, "\n%Uoverlap %U", format_white_space, indent,
284  break;
286  s = format (s, "\n%Uicmp-error - frag_len > 65535 %U",
287  format_white_space, indent,
289  break;
291  s = format (s, "\n%Uicmp-error - frag_len mod 8 != 0 %U",
292  format_white_space, indent,
294  break;
296  s = format (s, "\n%Uicmp-error - reassembly time exceeded",
297  format_white_space, indent);
298  break;
299  case FINALIZE:
300  s = format (s, "\n%Ufinalize reassembly", format_white_space, indent);
301  break;
302  case HANDOFF:
303  s =
304  format (s, "handoff from thread #%u to thread #%u", t->thread_id,
305  t->thread_id_to);
306  break;
307  }
308  return s;
309 }
310 
311 static void
314  ip6_full_reass_t * reass, u32 bi,
315  ip6_frag_hdr_t * ip6_frag_header,
316  ip6_full_reass_trace_operation_e action,
317  u32 thread_id_to)
318 {
319  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
321  bool is_after_handoff = false;
323  {
324  is_after_handoff = true;
325  }
326  ip6_full_reass_trace_t *t = vlib_add_trace (vm, node, b, sizeof (t[0]));
327  t->is_after_handoff = is_after_handoff;
328  if (t->is_after_handoff)
329  {
331  clib_min (sizeof (t->ip6_header), b->current_length));
332  if (ip6_frag_header)
333  {
334  clib_memcpy (&t->ip6_frag_header, ip6_frag_header,
335  sizeof (t->ip6_frag_header));
336  }
337  else
338  {
339  clib_memset (&t->ip6_frag_header, 0, sizeof (t->ip6_frag_header));
340  }
341  }
342  if (reass)
343  {
344  t->reass_id = reass->id;
345  t->op_id = reass->trace_op_counter;
346  t->trace_range.first_bi = reass->first_bi;
347  t->total_data_len = reass->data_len;
348  ++reass->trace_op_counter;
349  }
350  else
351  {
352  t->reass_id = ~0;
353  }
354  t->action = action;
355  t->thread_id = vm->thread_index;
356  t->thread_id_to = thread_id_to;
358  t->fragment_first = vnb->ip.reass.fragment_first;
359  t->fragment_last = vnb->ip.reass.fragment_last;
360 #if 0
361  static u8 *s = NULL;
362  s = format (s, "%U", format_ip6_full_reass_trace, NULL, NULL, t);
363  printf ("%.*s\n", vec_len (s), s);
364  fflush (stdout);
365  vec_reset_length (s);
366 #endif
367 }
368 
369 always_inline void
371  ip6_full_reass_t * reass)
372 {
373  pool_put (rt->pool, reass);
374  --rt->reass_n;
375 }
376 
377 always_inline void
380  ip6_full_reass_t * reass)
381 {
383  kv.key[0] = reass->key.as_u64[0];
384  kv.key[1] = reass->key.as_u64[1];
385  kv.key[2] = reass->key.as_u64[2];
386  kv.key[3] = reass->key.as_u64[3];
387  kv.key[4] = reass->key.as_u64[4];
388  kv.key[5] = reass->key.as_u64[5];
389  clib_bihash_add_del_48_8 (&rm->hash, &kv, 0);
390  ip6_full_reass_free_ctx (rt, reass);
391 }
392 
393 always_inline void
396 {
397  u32 range_bi = reass->first_bi;
398  vlib_buffer_t *range_b;
399  vnet_buffer_opaque_t *range_vnb;
400  u32 *to_free = NULL;
401  while (~0 != range_bi)
402  {
403  range_b = vlib_get_buffer (vm, range_bi);
404  range_vnb = vnet_buffer (range_b);
405  u32 bi = range_bi;
406  while (~0 != bi)
407  {
408  vec_add1 (to_free, bi);
409  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
410  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
411  {
412  bi = b->next_buffer;
413  b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
414  }
415  else
416  {
417  bi = ~0;
418  }
419  }
420  range_bi = range_vnb->ip.reass.next_range_bi;
421  }
422  /* send to next_error_index */
423  if (~0 != reass->error_next_index)
424  {
425  u32 n_left_to_next, *to_next, next_index;
426 
427  next_index = reass->error_next_index;
428  u32 bi = ~0;
429 
430  while (vec_len (to_free) > 0)
431  {
432  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
433 
434  while (vec_len (to_free) > 0 && n_left_to_next > 0)
435  {
436  bi = vec_pop (to_free);
437 
438  if (~0 != bi)
439  {
440  to_next[0] = bi;
441  to_next += 1;
442  n_left_to_next -= 1;
443  }
444  }
445  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
446  }
447  }
448  else
449  {
450  vlib_buffer_free (vm, to_free, vec_len (to_free));
451  }
452  vec_free (to_free);
453 }
454 
455 always_inline void
458  ip6_full_reass_t * reass, u32 * icmp_bi)
459 {
460  if (~0 == reass->first_bi)
461  {
462  return;
463  }
464  if (~0 == reass->next_index) // custom apps don't want icmp
465  {
466  vlib_buffer_t *b = vlib_get_buffer (vm, reass->first_bi);
467  if (0 == vnet_buffer (b)->ip.reass.fragment_first)
468  {
469  *icmp_bi = reass->first_bi;
470  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
471  {
472  ip6_full_reass_add_trace (vm, node, rm, reass, reass->first_bi,
474  }
475  // fragment with offset zero received - send icmp message back
476  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
477  {
478  // separate first buffer from chain and steer it towards icmp node
479  b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
480  reass->first_bi = b->next_buffer;
481  }
482  else
483  {
484  reass->first_bi = vnet_buffer (b)->ip.reass.next_range_bi;
485  }
486  icmp6_error_set_vnet_buffer (b, ICMP6_time_exceeded,
487  ICMP6_time_exceeded_fragment_reassembly_time_exceeded,
488  0);
489  }
490  }
491  ip6_full_reass_drop_all (vm, node, rm, reass);
492 }
493 
498  ip6_full_reass_kv_t * kv, u32 * icmp_bi,
499  u8 * do_handoff)
500 {
501  ip6_full_reass_t *reass;
502  f64 now;
503 
504 again:
505 
506  reass = NULL;
507  now = vlib_time_now (vm);
508 
509  if (!clib_bihash_search_48_8
510  (&rm->hash, (clib_bihash_kv_48_8_t *) kv, (clib_bihash_kv_48_8_t *) kv))
511  {
512  reass =
514  [kv->v.memory_owner_thread_index].pool,
515  kv->v.reass_index);
516  if (vm->thread_index != kv->v.memory_owner_thread_index)
517  {
518  *do_handoff = 1;
519  return reass;
520  }
521 
522  if (now > reass->last_heard + rm->timeout)
523  {
524  ip6_full_reass_on_timeout (vm, node, rm, reass, icmp_bi);
525  ip6_full_reass_free (rm, rt, reass);
526  reass = NULL;
527  }
528  }
529 
530  if (reass)
531  {
532  reass->last_heard = now;
533  return reass;
534  }
535 
536  if (rt->reass_n >= rm->max_reass_n)
537  {
538  reass = NULL;
539  return reass;
540  }
541  else
542  {
543  pool_get (rt->pool, reass);
544  clib_memset (reass, 0, sizeof (*reass));
545  reass->id = ((u64) vm->thread_index * 1000000000) + rt->id_counter;
546  ++rt->id_counter;
547  reass->first_bi = ~0;
548  reass->last_packet_octet = ~0;
549  reass->data_len = 0;
550  reass->next_index = ~0;
551  reass->error_next_index = ~0;
552  ++rt->reass_n;
553  }
554 
555  reass->key.as_u64[0] = ((clib_bihash_kv_48_8_t *) kv)->key[0];
556  reass->key.as_u64[1] = ((clib_bihash_kv_48_8_t *) kv)->key[1];
557  reass->key.as_u64[2] = ((clib_bihash_kv_48_8_t *) kv)->key[2];
558  reass->key.as_u64[3] = ((clib_bihash_kv_48_8_t *) kv)->key[3];
559  reass->key.as_u64[4] = ((clib_bihash_kv_48_8_t *) kv)->key[4];
560  reass->key.as_u64[5] = ((clib_bihash_kv_48_8_t *) kv)->key[5];
561  kv->v.reass_index = (reass - rt->pool);
562  kv->v.memory_owner_thread_index = vm->thread_index;
563  reass->last_heard = now;
564 
565  int rv =
566  clib_bihash_add_del_48_8 (&rm->hash, (clib_bihash_kv_48_8_t *) kv, 2);
567  if (rv)
568  {
569  ip6_full_reass_free (rm, rt, reass);
570  reass = NULL;
571  // if other worker created a context already work with the other copy
572  if (-2 == rv)
573  goto again;
574  }
575 
576  return reass;
577 }
578 
579 always_inline ip6_full_reass_rc_t
583  ip6_full_reass_t * reass, u32 * bi0, u32 * next0,
584  u32 * error0, bool is_custom_app)
585 {
586  *bi0 = reass->first_bi;
587  *error0 = IP6_ERROR_NONE;
588  ip6_frag_hdr_t *frag_hdr;
589  vlib_buffer_t *last_b = NULL;
590  u32 sub_chain_bi = reass->first_bi;
591  u32 total_length = 0;
592  u32 buf_cnt = 0;
593  u32 dropped_cnt = 0;
594  u32 *vec_drop_compress = NULL;
595  ip6_full_reass_rc_t rv = IP6_FULL_REASS_RC_OK;
596  do
597  {
598  u32 tmp_bi = sub_chain_bi;
599  vlib_buffer_t *tmp = vlib_get_buffer (vm, tmp_bi);
600  vnet_buffer_opaque_t *vnb = vnet_buffer (tmp);
601  if (!(vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first) &&
602  !(vnb->ip.reass.range_last > vnb->ip.reass.fragment_first))
603  {
605  goto free_buffers_and_return;
606  }
607 
608  u32 data_len = ip6_full_reass_buffer_get_data_len (tmp);
609  u32 trim_front = vnet_buffer (tmp)->ip.reass.ip6_frag_hdr_offset +
610  sizeof (*frag_hdr) + ip6_full_reass_buffer_get_data_offset (tmp);
611  u32 trim_end =
612  vlib_buffer_length_in_chain (vm, tmp) - trim_front - data_len;
613  if (tmp_bi == reass->first_bi)
614  {
615  /* first buffer - keep ip6 header */
616  if (0 != ip6_full_reass_buffer_get_data_offset (tmp))
617  {
619  goto free_buffers_and_return;
620  }
621  trim_front = 0;
622  trim_end = vlib_buffer_length_in_chain (vm, tmp) - data_len -
623  (vnet_buffer (tmp)->ip.reass.ip6_frag_hdr_offset +
624  sizeof (*frag_hdr));
625  if (!(vlib_buffer_length_in_chain (vm, tmp) - trim_end > 0))
626  {
628  goto free_buffers_and_return;
629  }
630  }
631  u32 keep_data =
632  vlib_buffer_length_in_chain (vm, tmp) - trim_front - trim_end;
633  while (1)
634  {
635  ++buf_cnt;
636  if (trim_front)
637  {
638  if (trim_front > tmp->current_length)
639  {
640  /* drop whole buffer */
641  vec_add1 (vec_drop_compress, tmp_bi);
642  trim_front -= tmp->current_length;
643  if (!(tmp->flags & VLIB_BUFFER_NEXT_PRESENT))
644  {
646  goto free_buffers_and_return;
647  }
648  tmp->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
649  tmp_bi = tmp->next_buffer;
650  tmp = vlib_get_buffer (vm, tmp_bi);
651  continue;
652  }
653  else
654  {
655  vlib_buffer_advance (tmp, trim_front);
656  trim_front = 0;
657  }
658  }
659  if (keep_data)
660  {
661  if (last_b)
662  {
663  last_b->flags |= VLIB_BUFFER_NEXT_PRESENT;
664  last_b->next_buffer = tmp_bi;
665  }
666  last_b = tmp;
667  if (keep_data <= tmp->current_length)
668  {
669  tmp->current_length = keep_data;
670  keep_data = 0;
671  }
672  else
673  {
674  keep_data -= tmp->current_length;
675  if (!(tmp->flags & VLIB_BUFFER_NEXT_PRESENT))
676  {
678  goto free_buffers_and_return;
679  }
680  }
681  total_length += tmp->current_length;
682  }
683  else
684  {
685  vec_add1 (vec_drop_compress, tmp_bi);
686  if (reass->first_bi == tmp_bi)
687  {
689  goto free_buffers_and_return;
690  }
691  ++dropped_cnt;
692  }
693  if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
694  {
695  tmp_bi = tmp->next_buffer;
696  tmp = vlib_get_buffer (vm, tmp->next_buffer);
697  }
698  else
699  {
700  break;
701  }
702  }
703  sub_chain_bi =
704  vnet_buffer (vlib_get_buffer (vm, sub_chain_bi))->ip.
705  reass.next_range_bi;
706  }
707  while (~0 != sub_chain_bi);
708 
709  if (!last_b)
710  {
712  goto free_buffers_and_return;
713  }
714  last_b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
715  vlib_buffer_t *first_b = vlib_get_buffer (vm, reass->first_bi);
716  if (total_length < first_b->current_length)
717  {
719  goto free_buffers_and_return;
720  }
721  total_length -= first_b->current_length;
722  first_b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
723  first_b->total_length_not_including_first_buffer = total_length;
724  // drop fragment header
725  vnet_buffer_opaque_t *first_b_vnb = vnet_buffer (first_b);
727  u16 ip6_frag_hdr_offset = first_b_vnb->ip.reass.ip6_frag_hdr_offset;
728  ip6_ext_header_t *prev_hdr;
729  frag_hdr =
730  ip6_ext_header_find (vm, first_b, ip, IP_PROTOCOL_IPV6_FRAGMENTATION,
731  &prev_hdr);
732  if (prev_hdr)
733  {
734  prev_hdr->next_hdr = frag_hdr->next_hdr;
735  }
736  else
737  {
738  ip->protocol = frag_hdr->next_hdr;
739  }
740  if (!((u8 *) frag_hdr - (u8 *) ip == ip6_frag_hdr_offset))
741  {
743  goto free_buffers_and_return;
744  }
745  memmove (frag_hdr, (u8 *) frag_hdr + sizeof (*frag_hdr),
746  first_b->current_length - ip6_frag_hdr_offset -
747  sizeof (ip6_frag_hdr_t));
748  first_b->current_length -= sizeof (*frag_hdr);
749  ip->payload_length =
750  clib_host_to_net_u16 (total_length + first_b->current_length -
751  sizeof (*ip));
752  if (!vlib_buffer_chain_linearize (vm, first_b))
753  {
755  goto free_buffers_and_return;
756  }
757  first_b->flags &= ~VLIB_BUFFER_EXT_HDR_VALID;
758  if (PREDICT_FALSE (first_b->flags & VLIB_BUFFER_IS_TRACED))
759  {
760  ip6_full_reass_add_trace (vm, node, rm, reass, reass->first_bi, NULL,
761  FINALIZE, ~0);
762 #if 0
763  // following code does a hexdump of packet fragments to stdout ...
764  do
765  {
766  u32 bi = reass->first_bi;
767  u8 *s = NULL;
768  while (~0 != bi)
769  {
770  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
771  s = format (s, "%u: %U\n", bi, format_hexdump,
773  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
774  {
775  bi = b->next_buffer;
776  }
777  else
778  {
779  break;
780  }
781  }
782  printf ("%.*s\n", vec_len (s), s);
783  fflush (stdout);
784  vec_free (s);
785  }
786  while (0);
787 #endif
788  }
789  if (!is_custom_app)
790  {
792  }
793  else
794  {
795  *next0 = reass->next_index;
796  }
797  vnet_buffer (first_b)->ip.reass.estimated_mtu = reass->min_fragment_length;
798  ip6_full_reass_free (rm, rt, reass);
799  reass = NULL;
800 free_buffers_and_return:
801  vlib_buffer_free (vm, vec_drop_compress, vec_len (vec_drop_compress));
802  vec_free (vec_drop_compress);
803  return rv;
804 }
805 
806 always_inline void
810  ip6_full_reass_t * reass,
811  u32 prev_range_bi, u32 new_next_bi)
812 {
813 
814  vlib_buffer_t *new_next_b = vlib_get_buffer (vm, new_next_bi);
815  vnet_buffer_opaque_t *new_next_vnb = vnet_buffer (new_next_b);
816  if (~0 != prev_range_bi)
817  {
818  vlib_buffer_t *prev_b = vlib_get_buffer (vm, prev_range_bi);
819  vnet_buffer_opaque_t *prev_vnb = vnet_buffer (prev_b);
820  new_next_vnb->ip.reass.next_range_bi = prev_vnb->ip.reass.next_range_bi;
821  prev_vnb->ip.reass.next_range_bi = new_next_bi;
822  }
823  else
824  {
825  if (~0 != reass->first_bi)
826  {
827  new_next_vnb->ip.reass.next_range_bi = reass->first_bi;
828  }
829  reass->first_bi = new_next_bi;
830  }
831  reass->data_len += ip6_full_reass_buffer_get_data_len (new_next_b);
832 }
833 
834 always_inline ip6_full_reass_rc_t
838  ip6_full_reass_t * reass, u32 * bi0, u32 * next0,
839  u32 * error0, ip6_frag_hdr_t * frag_hdr,
840  bool is_custom_app, u32 * handoff_thread_idx)
841 {
842  int consumed = 0;
843  vlib_buffer_t *fb = vlib_get_buffer (vm, *bi0);
844  vnet_buffer_opaque_t *fvnb = vnet_buffer (fb);
845  if (is_custom_app)
846  {
847  reass->next_index = fvnb->ip.reass.next_index; // store next_index before it's overwritten
848  reass->error_next_index = fvnb->ip.reass.error_next_index; // store error_next_index before it is overwritten
849  }
850 
851  fvnb->ip.reass.ip6_frag_hdr_offset =
852  (u8 *) frag_hdr - (u8 *) vlib_buffer_get_current (fb);
854  if (fb->current_length < sizeof (*fip) ||
855  fvnb->ip.reass.ip6_frag_hdr_offset == 0 ||
856  fvnb->ip.reass.ip6_frag_hdr_offset >= fb->current_length)
857  {
859  }
860 
861  u32 fragment_first = fvnb->ip.reass.fragment_first =
862  ip6_frag_hdr_offset_bytes (frag_hdr);
863  u32 fragment_length =
864  vlib_buffer_length_in_chain (vm, fb) -
865  (fvnb->ip.reass.ip6_frag_hdr_offset + sizeof (*frag_hdr));
866  u32 fragment_last = fvnb->ip.reass.fragment_last =
867  fragment_first + fragment_length - 1;
868  int more_fragments = ip6_frag_hdr_more (frag_hdr);
869  u32 candidate_range_bi = reass->first_bi;
870  u32 prev_range_bi = ~0;
871  fvnb->ip.reass.range_first = fragment_first;
872  fvnb->ip.reass.range_last = fragment_last;
873  fvnb->ip.reass.next_range_bi = ~0;
874  if (!more_fragments)
875  {
876  reass->last_packet_octet = fragment_last;
877  }
878  if (~0 == reass->first_bi)
879  {
880  // starting a new reassembly
881  ip6_full_reass_insert_range_in_chain (vm, rm, rt, reass, prev_range_bi,
882  *bi0);
883  reass->min_fragment_length = clib_net_to_host_u16 (fip->payload_length);
884  consumed = 1;
885  reass->fragments_n = 1;
886  goto check_if_done_maybe;
887  }
888  reass->min_fragment_length =
889  clib_min (clib_net_to_host_u16 (fip->payload_length),
890  fvnb->ip.reass.estimated_mtu);
891  while (~0 != candidate_range_bi)
892  {
893  vlib_buffer_t *candidate_b = vlib_get_buffer (vm, candidate_range_bi);
894  vnet_buffer_opaque_t *candidate_vnb = vnet_buffer (candidate_b);
895  if (fragment_first > candidate_vnb->ip.reass.range_last)
896  {
897  // this fragments starts after candidate range
898  prev_range_bi = candidate_range_bi;
899  candidate_range_bi = candidate_vnb->ip.reass.next_range_bi;
900  if (candidate_vnb->ip.reass.range_last < fragment_last &&
901  ~0 == candidate_range_bi)
902  {
903  // special case - this fragment falls beyond all known ranges
904  ip6_full_reass_insert_range_in_chain (vm, rm, rt, reass,
905  prev_range_bi, *bi0);
906  consumed = 1;
907  break;
908  }
909  continue;
910  }
911  if (fragment_last < candidate_vnb->ip.reass.range_first)
912  {
913  // this fragment ends before candidate range without any overlap
914  ip6_full_reass_insert_range_in_chain (vm, rm, rt, reass,
915  prev_range_bi, *bi0);
916  consumed = 1;
917  }
918  else if (fragment_first == candidate_vnb->ip.reass.range_first &&
919  fragment_last == candidate_vnb->ip.reass.range_last)
920  {
921  // duplicate fragment - ignore
922  }
923  else
924  {
925  // overlapping fragment - not allowed by RFC 8200
926  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
927  {
928  ip6_full_reass_add_trace (vm, node, rm, reass, *bi0, frag_hdr,
929  RANGE_OVERLAP, ~0);
930  }
931  ip6_full_reass_drop_all (vm, node, rm, reass);
932  ip6_full_reass_free (rm, rt, reass);
934  *error0 = IP6_ERROR_REASS_OVERLAPPING_FRAGMENT;
935  return IP6_FULL_REASS_RC_OK;
936  }
937  break;
938  }
939  ++reass->fragments_n;
940 check_if_done_maybe:
941  if (consumed)
942  {
943  if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
944  {
945  ip6_full_reass_add_trace (vm, node, rm, reass, *bi0, frag_hdr,
946  RANGE_NEW, ~0);
947  }
948  }
949  if (~0 != reass->last_packet_octet &&
950  reass->data_len == reass->last_packet_octet + 1)
951  {
952  *handoff_thread_idx = reass->sendout_thread_index;
953  int handoff =
955  ip6_full_reass_rc_t rc =
956  ip6_full_reass_finalize (vm, node, rm, rt, reass, bi0, next0, error0,
957  is_custom_app);
958  if (IP6_FULL_REASS_RC_OK == rc && handoff)
959  {
961  }
962  return rc;
963  }
964  else
965  {
966  if (consumed)
967  {
968  *bi0 = ~0;
969  if (reass->fragments_n > rm->max_reass_len)
970  {
972  }
973  }
974  else
975  {
977  *error0 = IP6_ERROR_REASS_DUPLICATE_FRAGMENT;
978  }
979  }
980  return IP6_FULL_REASS_RC_OK;
981 }
982 
983 always_inline bool
985  vlib_buffer_t * b,
986  ip6_frag_hdr_t * frag_hdr)
987 {
988  ip6_ext_header_t *tmp = (ip6_ext_header_t *) frag_hdr;
989  while (ip6_ext_hdr (tmp->next_hdr))
990  {
991  tmp = ip6_ext_next_header (tmp);
992  }
993  if (IP_PROTOCOL_IP6_NONXT == tmp->next_hdr)
994  {
995  icmp6_error_set_vnet_buffer (b, ICMP6_parameter_problem,
996  ICMP6_parameter_problem_first_fragment_has_incomplete_header_chain,
997  0);
998  b->error = node->errors[IP6_ERROR_REASS_MISSING_UPPER];
999 
1000  return false;
1001  }
1002  return true;
1003 }
1004 
1005 always_inline bool
1007  vlib_node_runtime_t * node,
1008  vlib_buffer_t * b,
1009  ip6_frag_hdr_t * frag_hdr)
1010 {
1011  vnet_buffer_opaque_t *vnb = vnet_buffer (b);
1013  int more_fragments = ip6_frag_hdr_more (frag_hdr);
1014  u32 fragment_length =
1015  vlib_buffer_length_in_chain (vm, b) -
1016  (vnb->ip.reass.ip6_frag_hdr_offset + sizeof (*frag_hdr));
1017  if (more_fragments && 0 != fragment_length % 8)
1018  {
1019  icmp6_error_set_vnet_buffer (b, ICMP6_parameter_problem,
1020  ICMP6_parameter_problem_erroneous_header_field,
1021  (u8 *) & ip->payload_length - (u8 *) ip);
1022  return false;
1023  }
1024  return true;
1025 }
1026 
1027 always_inline bool
1029  vlib_node_runtime_t * node,
1030  vlib_buffer_t * b,
1031  ip6_frag_hdr_t * frag_hdr)
1032 {
1033  vnet_buffer_opaque_t *vnb = vnet_buffer (b);
1034  u32 fragment_first = ip6_frag_hdr_offset_bytes (frag_hdr);
1035  u32 fragment_length =
1036  vlib_buffer_length_in_chain (vm, b) -
1037  (vnb->ip.reass.ip6_frag_hdr_offset + sizeof (*frag_hdr));
1038  if (fragment_first + fragment_length > 65535)
1039  {
1041  icmp6_error_set_vnet_buffer (b, ICMP6_parameter_problem,
1042  ICMP6_parameter_problem_erroneous_header_field,
1043  (u8 *) & frag_hdr->fragment_offset_and_more
1044  - (u8 *) ip0);
1045  return false;
1046  }
1047  return true;
1048 }
1049 
1052  vlib_node_runtime_t * node,
1053  vlib_frame_t * frame, bool is_feature,
1054  bool is_custom_app)
1055 {
1056  u32 *from = vlib_frame_vector_args (frame);
1057  u32 n_left_from, n_left_to_next, *to_next, next_index;
1060  clib_spinlock_lock (&rt->lock);
1061 
1062  n_left_from = frame->n_vectors;
1063  next_index = node->cached_next_index;
1064  while (n_left_from > 0)
1065  {
1066  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1067 
1068  while (n_left_from > 0 && n_left_to_next > 0)
1069  {
1070  u32 bi0;
1071  vlib_buffer_t *b0;
1073  u32 error0 = IP6_ERROR_NONE;
1074  u32 icmp_bi = ~0;
1075 
1076  bi0 = from[0];
1077  b0 = vlib_get_buffer (vm, bi0);
1078 
1080  ip6_frag_hdr_t *frag_hdr = NULL;
1081  ip6_ext_header_t *prev_hdr;
1082  if (ip6_ext_hdr (ip0->protocol))
1083  {
1084  frag_hdr =
1085  ip6_ext_header_find (vm, b0, ip0,
1086  IP_PROTOCOL_IPV6_FRAGMENTATION,
1087  &prev_hdr);
1088  }
1089  if (!frag_hdr)
1090  {
1091  // this is a regular packet - no fragmentation
1093  goto skip_reass;
1094  }
1095  vnet_buffer (b0)->ip.reass.ip6_frag_hdr_offset =
1096  (u8 *) frag_hdr - (u8 *) ip0;
1097 
1098  if (0 == ip6_frag_hdr_offset (frag_hdr))
1099  {
1100  // first fragment - verify upper-layer is present
1102  (node, b0, frag_hdr))
1103  {
1105  goto skip_reass;
1106  }
1107  }
1109  (vm, node, b0, frag_hdr)
1110  || !ip6_full_reass_verify_packet_size_lt_64k (vm, node, b0,
1111  frag_hdr))
1112  {
1114  goto skip_reass;
1115  }
1117  u8 do_handoff = 0;
1118 
1119  kv.k.as_u64[0] = ip0->src_address.as_u64[0];
1120  kv.k.as_u64[1] = ip0->src_address.as_u64[1];
1121  kv.k.as_u64[2] = ip0->dst_address.as_u64[0];
1122  kv.k.as_u64[3] = ip0->dst_address.as_u64[1];
1123  kv.k.as_u64[4] =
1125  vnet_buffer (b0)->sw_if_index[VLIB_RX])) << 32 |
1126  (u64) frag_hdr->identification;
1127  kv.k.as_u64[5] = ip0->protocol;
1128 
1129  ip6_full_reass_t *reass =
1130  ip6_full_reass_find_or_create (vm, node, rm, rt, &kv, &icmp_bi,
1131  &do_handoff);
1132 
1133  if (reass)
1134  {
1135  const u32 fragment_first = ip6_frag_hdr_offset (frag_hdr);
1136  if (0 == fragment_first)
1137  {
1138  reass->sendout_thread_index = vm->thread_index;
1139  }
1140  }
1141  if (PREDICT_FALSE (do_handoff))
1142  {
1144  vnet_buffer (b0)->ip.reass.owner_thread_index =
1146  }
1147  else if (reass)
1148  {
1149  u32 handoff_thread_idx;
1150  switch (ip6_full_reass_update
1151  (vm, node, rm, rt, reass, &bi0, &next0, &error0,
1152  frag_hdr, is_custom_app, &handoff_thread_idx))
1153  {
1154  case IP6_FULL_REASS_RC_OK:
1155  /* nothing to do here */
1156  break;
1159  b0 = vlib_get_buffer (vm, bi0);
1160  vnet_buffer (b0)->ip.reass.owner_thread_index =
1161  handoff_thread_idx;
1162  break;
1165  IP6_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
1166  1);
1167  ip6_full_reass_drop_all (vm, node, rm, reass);
1168  ip6_full_reass_free (rm, rt, reass);
1169  goto next_packet;
1170  break;
1173  IP6_ERROR_REASS_NO_BUF, 1);
1174  ip6_full_reass_drop_all (vm, node, rm, reass);
1175  ip6_full_reass_free (rm, rt, reass);
1176  goto next_packet;
1177  break;
1180  IP6_ERROR_REASS_INTERNAL_ERROR,
1181  1);
1182  ip6_full_reass_drop_all (vm, node, rm, reass);
1183  ip6_full_reass_free (rm, rt, reass);
1184  goto next_packet;
1185  break;
1186  }
1187  }
1188  else
1189  {
1190  if (is_feature)
1191  {
1193  }
1194  else
1195  {
1196  vnet_buffer_opaque_t *fvnb = vnet_buffer (b0);
1197  next0 = fvnb->ip.reass.error_next_index;
1198  }
1199  error0 = IP6_ERROR_REASS_LIMIT_REACHED;
1200  }
1201 
1202  if (~0 != bi0)
1203  {
1204  skip_reass:
1205  to_next[0] = bi0;
1206  to_next += 1;
1207  n_left_to_next -= 1;
1208 
1209  /* bi0 might have been updated by reass_finalize, reload */
1210  b0 = vlib_get_buffer (vm, bi0);
1211  b0->error = node->errors[error0];
1212 
1213  if (next0 == IP6_FULL_REASSEMBLY_NEXT_HANDOFF)
1214  {
1215  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1216  {
1217  ip6_full_reass_add_trace (vm, node, rm, NULL, bi0,
1218  frag_hdr, HANDOFF,
1219  vnet_buffer (b0)->ip.
1220  reass.owner_thread_index);
1221  }
1222  }
1223  else if (is_feature && IP6_ERROR_NONE == error0)
1224  {
1225  vnet_feature_next (&next0, b0);
1226  }
1227  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1228  n_left_to_next, bi0, next0);
1229  }
1230 
1231  if (~0 != icmp_bi)
1232  {
1234  to_next[0] = icmp_bi;
1235  to_next += 1;
1236  n_left_to_next -= 1;
1237  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1238  n_left_to_next, icmp_bi,
1239  next0);
1240  }
1241  next_packet:
1242  from += 1;
1243  n_left_from -= 1;
1244  }
1245 
1246  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1247  }
1248 
1249  clib_spinlock_unlock (&rt->lock);
1250  return frame->n_vectors;
1251 }
1252 
1254 #define _(sym, string) string,
1256 #undef _
1257 };
1258 
1261  vlib_frame_t * frame)
1262 {
1263  return ip6_full_reassembly_inline (vm, node, frame, false /* is_feature */ ,
1264  false /* is_custom_app */ );
1265 }
1266 
1267 /* *INDENT-OFF* */
1269  .name = "ip6-full-reassembly",
1270  .vector_size = sizeof (u32),
1271  .format_trace = format_ip6_full_reass_trace,
1272  .n_errors = ARRAY_LEN (ip6_full_reassembly_error_strings),
1273  .error_strings = ip6_full_reassembly_error_strings,
1274  .n_next_nodes = IP6_FULL_REASSEMBLY_N_NEXT,
1275  .next_nodes =
1276  {
1277  [IP6_FULL_REASSEMBLY_NEXT_INPUT] = "ip6-input",
1278  [IP6_FULL_REASSEMBLY_NEXT_DROP] = "ip6-drop",
1279  [IP6_FULL_REASSEMBLY_NEXT_ICMP_ERROR] = "ip6-icmp-error",
1280  [IP6_FULL_REASSEMBLY_NEXT_HANDOFF] = "ip6-full-reassembly-handoff",
1281  },
1282 };
1283 /* *INDENT-ON* */
1284 
1287  vlib_frame_t * frame)
1288 {
1289  return ip6_full_reassembly_inline (vm, node, frame, true /* is_feature */ ,
1290  false /* is_custom_app */ );
1291 }
1292 
1293 /* *INDENT-OFF* */
1295  .name = "ip6-full-reassembly-feature",
1296  .vector_size = sizeof (u32),
1297  .format_trace = format_ip6_full_reass_trace,
1298  .n_errors = ARRAY_LEN (ip6_full_reassembly_error_strings),
1299  .error_strings = ip6_full_reassembly_error_strings,
1300  .n_next_nodes = IP6_FULL_REASSEMBLY_N_NEXT,
1301  .next_nodes =
1302  {
1303  [IP6_FULL_REASSEMBLY_NEXT_INPUT] = "ip6-input",
1304  [IP6_FULL_REASSEMBLY_NEXT_DROP] = "ip6-drop",
1305  [IP6_FULL_REASSEMBLY_NEXT_ICMP_ERROR] = "ip6-icmp-error",
1306  [IP6_FULL_REASSEMBLY_NEXT_HANDOFF] = "ip6-full-reass-feature-hoff",
1307  },
1308 };
1309 /* *INDENT-ON* */
1310 
1311 /* *INDENT-OFF* */
1312 VNET_FEATURE_INIT (ip6_full_reassembly_feature, static) = {
1313  .arc_name = "ip6-unicast",
1314  .node_name = "ip6-full-reassembly-feature",
1315  .runs_before = VNET_FEATURES ("ip6-lookup",
1316  "ipsec6-input-feature"),
1317  .runs_after = 0,
1318 };
1319 /* *INDENT-ON* */
1320 
1321 #ifndef CLIB_MARCH_VARIANT
1322 static u32
1324 {
1326  u32 nbuckets;
1327  u8 i;
1328 
1329  nbuckets = (u32) (rm->max_reass_n / IP6_FULL_REASS_HT_LOAD_FACTOR);
1330 
1331  for (i = 0; i < 31; i++)
1332  if ((1 << i) >= nbuckets)
1333  break;
1334  nbuckets = 1 << i;
1335 
1336  return nbuckets;
1337 }
1338 #endif /* CLIB_MARCH_VARIANT */
1339 
1340 typedef enum
1341 {
1344 
1345 #ifndef CLIB_MARCH_VARIANT
1346 typedef struct
1347 {
1348  int failure;
1349  clib_bihash_48_8_t *new_hash;
1351 
1352 static int
1354 {
1355  ip6_rehash_cb_ctx *ctx = _ctx;
1356  if (clib_bihash_add_del_48_8 (ctx->new_hash, kv, 1))
1357  {
1358  ctx->failure = 1;
1359  }
1360  return (BIHASH_WALK_CONTINUE);
1361 }
1362 
1363 static void
1364 ip6_full_reass_set_params (u32 timeout_ms, u32 max_reassemblies,
1365  u32 max_reassembly_length,
1366  u32 expire_walk_interval_ms)
1367 {
1368  ip6_full_reass_main.timeout_ms = timeout_ms;
1369  ip6_full_reass_main.timeout = (f64) timeout_ms / (f64) MSEC_PER_SEC;
1370  ip6_full_reass_main.max_reass_n = max_reassemblies;
1371  ip6_full_reass_main.max_reass_len = max_reassembly_length;
1372  ip6_full_reass_main.expire_walk_interval_ms = expire_walk_interval_ms;
1373 }
1374 
1376 ip6_full_reass_set (u32 timeout_ms, u32 max_reassemblies,
1377  u32 max_reassembly_length, u32 expire_walk_interval_ms)
1378 {
1379  u32 old_nbuckets = ip6_full_reass_get_nbuckets ();
1380  ip6_full_reass_set_params (timeout_ms, max_reassemblies,
1381  max_reassembly_length, expire_walk_interval_ms);
1382  vlib_process_signal_event (ip6_full_reass_main.vlib_main,
1383  ip6_full_reass_main.ip6_full_reass_expire_node_idx,
1385  u32 new_nbuckets = ip6_full_reass_get_nbuckets ();
1386  if (ip6_full_reass_main.max_reass_n > 0 && new_nbuckets > old_nbuckets)
1387  {
1388  clib_bihash_48_8_t new_hash;
1389  clib_memset (&new_hash, 0, sizeof (new_hash));
1391  ctx.failure = 0;
1392  ctx.new_hash = &new_hash;
1393  clib_bihash_init_48_8 (&new_hash, "ip6-full-reass", new_nbuckets,
1394  new_nbuckets * 1024);
1395  clib_bihash_foreach_key_value_pair_48_8 (&ip6_full_reass_main.hash,
1396  ip6_rehash_cb, &ctx);
1397  if (ctx.failure)
1398  {
1399  clib_bihash_free_48_8 (&new_hash);
1400  return -1;
1401  }
1402  else
1403  {
1404  clib_bihash_free_48_8 (&ip6_full_reass_main.hash);
1405  clib_memcpy_fast (&ip6_full_reass_main.hash, &new_hash,
1406  sizeof (ip6_full_reass_main.hash));
1407  clib_bihash_copied (&ip6_full_reass_main.hash, &new_hash);
1408  }
1409  }
1410  return 0;
1411 }
1412 
1414 ip6_full_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
1415  u32 * max_reassembly_length,
1416  u32 * expire_walk_interval_ms)
1417 {
1418  *timeout_ms = ip6_full_reass_main.timeout_ms;
1419  *max_reassemblies = ip6_full_reass_main.max_reass_n;
1420  *max_reassembly_length = ip6_full_reass_main.max_reass_len;
1421  *expire_walk_interval_ms = ip6_full_reass_main.expire_walk_interval_ms;
1422  return 0;
1423 }
1424 
1425 static clib_error_t *
1427 {
1429  clib_error_t *error = 0;
1430  u32 nbuckets;
1431  vlib_node_t *node;
1432 
1433  rm->vlib_main = vm;
1434 
1437  vec_foreach (rt, rm->per_thread_data)
1438  {
1439  clib_spinlock_init (&rt->lock);
1440  pool_alloc (rt->pool, rm->max_reass_n);
1441  }
1442 
1443  node = vlib_get_node_by_name (vm, (u8 *) "ip6-full-reassembly-expire-walk");
1444  ASSERT (node);
1446 
1451 
1452  nbuckets = ip6_full_reass_get_nbuckets ();
1453  clib_bihash_init_48_8 (&rm->hash, "ip6-full-reass", nbuckets,
1454  nbuckets * 1024);
1455 
1456  node = vlib_get_node_by_name (vm, (u8 *) "ip6-drop");
1457  ASSERT (node);
1458  rm->ip6_drop_idx = node->index;
1459  node = vlib_get_node_by_name (vm, (u8 *) "ip6-icmp-error");
1460  ASSERT (node);
1461  rm->ip6_icmp_error_idx = node->index;
1462 
1463  if ((error = vlib_call_init_function (vm, ip_main_init)))
1464  return error;
1465  ip6_register_protocol (IP_PROTOCOL_IPV6_FRAGMENTATION,
1466  ip6_full_reass_node.index);
1467 
1469  rm->fq_feature_index =
1471 
1473  return error;
1474 }
1475 
1477 #endif /* CLIB_MARCH_VARIANT */
1478 
1479 static uword
1481  vlib_node_runtime_t * node, vlib_frame_t * f)
1482 {
1484  uword event_type, *event_data = 0;
1485 
1486  while (true)
1487  {
1490  / (f64) MSEC_PER_SEC);
1491  event_type = vlib_process_get_events (vm, &event_data);
1492 
1493  switch (event_type)
1494  {
1495  case ~0: /* no events => timeout */
1496  /* nothing to do here */
1497  break;
1499  break;
1500  default:
1501  clib_warning ("BUG: event type 0x%wx", event_type);
1502  break;
1503  }
1504  f64 now = vlib_time_now (vm);
1505 
1506  ip6_full_reass_t *reass;
1507  int *pool_indexes_to_free = NULL;
1508 
1509  uword thread_index = 0;
1510  int index;
1511  const uword nthreads = vlib_num_workers () + 1;
1512  u32 *vec_icmp_bi = NULL;
1513  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1514  {
1516  &rm->per_thread_data[thread_index];
1517  clib_spinlock_lock (&rt->lock);
1518 
1519  vec_reset_length (pool_indexes_to_free);
1520  /* *INDENT-OFF* */
1521  pool_foreach_index (index, rt->pool, ({
1522  reass = pool_elt_at_index (rt->pool, index);
1523  if (now > reass->last_heard + rm->timeout)
1524  {
1525  vec_add1 (pool_indexes_to_free, index);
1526  }
1527  }));
1528  /* *INDENT-ON* */
1529  int *i;
1530  /* *INDENT-OFF* */
1531  vec_foreach (i, pool_indexes_to_free)
1532  {
1533  ip6_full_reass_t *reass = pool_elt_at_index (rt->pool, i[0]);
1534  u32 icmp_bi = ~0;
1535  ip6_full_reass_on_timeout (vm, node, rm, reass, &icmp_bi);
1536  if (~0 != icmp_bi)
1537  vec_add1 (vec_icmp_bi, icmp_bi);
1538 
1539  ip6_full_reass_free (rm, rt, reass);
1540  }
1541  /* *INDENT-ON* */
1542 
1543  clib_spinlock_unlock (&rt->lock);
1544  }
1545 
1546  while (vec_len (vec_icmp_bi) > 0)
1547  {
1548  vlib_frame_t *f =
1550  u32 *to_next = vlib_frame_vector_args (f);
1551  u32 n_left_to_next = VLIB_FRAME_SIZE - f->n_vectors;
1552  int trace_frame = 0;
1553  while (vec_len (vec_icmp_bi) > 0 && n_left_to_next > 0)
1554  {
1555  u32 bi = vec_pop (vec_icmp_bi);
1556  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
1557  if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
1558  trace_frame = 1;
1559  b->error = node->errors[IP6_ERROR_REASS_TIMEOUT];
1560  to_next[0] = bi;
1561  ++f->n_vectors;
1562  to_next += 1;
1563  n_left_to_next -= 1;
1564  }
1565  f->frame_flags |= (trace_frame * VLIB_FRAME_TRACE);
1567  }
1568 
1569  vec_free (pool_indexes_to_free);
1570  vec_free (vec_icmp_bi);
1571  if (event_data)
1572  {
1573  _vec_len (event_data) = 0;
1574  }
1575  }
1576 
1577  return 0;
1578 }
1579 
1580 /* *INDENT-OFF* */
1582  .function = ip6_full_reass_walk_expired,
1583  .format_trace = format_ip6_full_reass_trace,
1584  .type = VLIB_NODE_TYPE_PROCESS,
1585  .name = "ip6-full-reassembly-expire-walk",
1586 
1588  .error_strings = ip6_full_reassembly_error_strings,
1589 
1590 };
1591 /* *INDENT-ON* */
1592 
1593 static u8 *
1594 format_ip6_full_reass_key (u8 * s, va_list * args)
1595 {
1596  ip6_full_reass_key_t *key = va_arg (*args, ip6_full_reass_key_t *);
1597  s = format (s, "xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1599  &key->dst, clib_net_to_host_u16 (key->frag_id), key->proto);
1600  return s;
1601 }
1602 
1603 static u8 *
1604 format_ip6_full_reass (u8 * s, va_list * args)
1605 {
1606  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
1607  ip6_full_reass_t *reass = va_arg (*args, ip6_full_reass_t *);
1608 
1609  s = format (s, "ID: %lu, key: %U\n first_bi: %u, data_len: %u, "
1610  "last_packet_octet: %u, trace_op_counter: %u\n",
1611  reass->id, format_ip6_full_reass_key, &reass->key,
1612  reass->first_bi, reass->data_len, reass->last_packet_octet,
1613  reass->trace_op_counter);
1614  u32 bi = reass->first_bi;
1615  u32 counter = 0;
1616  while (~0 != bi)
1617  {
1618  vlib_buffer_t *b = vlib_get_buffer (vm, bi);
1619  vnet_buffer_opaque_t *vnb = vnet_buffer (b);
1620  s = format (s, " #%03u: range: [%u, %u], bi: %u, off: %d, len: %u, "
1621  "fragment[%u, %u]\n",
1622  counter, vnb->ip.reass.range_first,
1623  vnb->ip.reass.range_last, bi,
1626  vnb->ip.reass.fragment_first, vnb->ip.reass.fragment_last);
1627  if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
1628  {
1629  bi = b->next_buffer;
1630  }
1631  else
1632  {
1633  bi = ~0;
1634  }
1635  }
1636  return s;
1637 }
1638 
1639 static clib_error_t *
1642 {
1644 
1645  vlib_cli_output (vm, "---------------------");
1646  vlib_cli_output (vm, "IP6 reassembly status");
1647  vlib_cli_output (vm, "---------------------");
1648  bool details = false;
1649  if (unformat (input, "details"))
1650  {
1651  details = true;
1652  }
1653 
1654  u32 sum_reass_n = 0;
1655  u64 sum_buffers_n = 0;
1656  ip6_full_reass_t *reass;
1657  uword thread_index;
1658  const uword nthreads = vlib_num_workers () + 1;
1659  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1660  {
1661  ip6_full_reass_per_thread_t *rt = &rm->per_thread_data[thread_index];
1662  clib_spinlock_lock (&rt->lock);
1663  if (details)
1664  {
1665  /* *INDENT-OFF* */
1666  pool_foreach (reass, rt->pool, {
1667  vlib_cli_output (vm, "%U", format_ip6_full_reass, vm, reass);
1668  });
1669  /* *INDENT-ON* */
1670  }
1671  sum_reass_n += rt->reass_n;
1672  clib_spinlock_unlock (&rt->lock);
1673  }
1674  vlib_cli_output (vm, "---------------------");
1675  vlib_cli_output (vm, "Current IP6 reassemblies count: %lu\n",
1676  (long unsigned) sum_reass_n);
1677  vlib_cli_output (vm, "Maximum configured concurrent IP6 reassemblies per "
1678  "worker-thread: %lu\n", (long unsigned) rm->max_reass_n);
1679  vlib_cli_output (vm, "Buffers in use: %lu\n",
1680  (long unsigned) sum_buffers_n);
1681  return 0;
1682 }
1683 
1684 /* *INDENT-OFF* */
1686  .path = "show ip6-full-reassembly",
1687  .short_help = "show ip6-full-reassembly [details]",
1688  .function = show_ip6_full_reass,
1689 };
1690 /* *INDENT-ON* */
1691 
1692 #ifndef CLIB_MARCH_VARIANT
1695 {
1696  return vnet_feature_enable_disable ("ip6-unicast",
1697  "ip6-full-reassembly-feature",
1698  sw_if_index, enable_disable, 0, 0);
1699 }
1700 #endif /* CLIB_MARCH_VARIANT */
1701 
1702 #define foreach_ip6_full_reassembly_handoff_error \
1703 _(CONGESTION_DROP, "congestion drop")
1704 
1705 
1706 typedef enum
1707 {
1708 #define _(sym,str) IP6_FULL_REASSEMBLY_HANDOFF_ERROR_##sym,
1710 #undef _
1713 
1715 #define _(sym,string) string,
1717 #undef _
1718 };
1719 
1720 typedef struct
1721 {
1724 
1725 static u8 *
1727 {
1728  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1729  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1731  va_arg (*args, ip6_full_reassembly_handoff_trace_t *);
1732 
1733  s =
1734  format (s, "ip6-full-reassembly-handoff: next-worker %d",
1735  t->next_worker_index);
1736 
1737  return s;
1738 }
1739 
1743  vlib_frame_t * frame, bool is_feature)
1744 {
1746 
1747  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
1748  u32 n_enq, n_left_from, *from;
1749  u16 thread_indices[VLIB_FRAME_SIZE], *ti;
1750  u32 fq_index;
1751 
1752  from = vlib_frame_vector_args (frame);
1753  n_left_from = frame->n_vectors;
1754  vlib_get_buffers (vm, from, bufs, n_left_from);
1755 
1756  b = bufs;
1757  ti = thread_indices;
1758 
1759  fq_index = (is_feature) ? rm->fq_feature_index : rm->fq_index;
1760 
1761  while (n_left_from > 0)
1762  {
1763  ti[0] = vnet_buffer (b[0])->ip.reass.owner_thread_index;
1764 
1765  if (PREDICT_FALSE
1766  ((node->flags & VLIB_NODE_FLAG_TRACE)
1767  && (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
1768  {
1770  vlib_add_trace (vm, node, b[0], sizeof (*t));
1771  t->next_worker_index = ti[0];
1772  }
1773 
1774  n_left_from -= 1;
1775  ti += 1;
1776  b += 1;
1777  }
1778  n_enq =
1779  vlib_buffer_enqueue_to_thread (vm, fq_index, from, thread_indices,
1780  frame->n_vectors, 1);
1781 
1782  if (n_enq < frame->n_vectors)
1784  IP6_FULL_REASSEMBLY_HANDOFF_ERROR_CONGESTION_DROP,
1785  frame->n_vectors - n_enq);
1786  return frame->n_vectors;
1787 }
1788 
1791  vlib_frame_t * frame)
1792 {
1793  return ip6_full_reassembly_handoff_inline (vm, node, frame,
1794  false /* is_feature */ );
1795 }
1796 
1797 /* *INDENT-OFF* */
1799  .name = "ip6-full-reassembly-handoff",
1800  .vector_size = sizeof (u32),
1801  .n_errors = ARRAY_LEN(ip6_full_reassembly_handoff_error_strings),
1804 
1805  .n_next_nodes = 1,
1806 
1807  .next_nodes = {
1808  [0] = "error-drop",
1809  },
1810 };
1811 
1812 
1815 {
1816  return ip6_full_reassembly_handoff_inline (vm, node, frame, true /* is_feature */ );
1817 }
1818 
1819 
1820 /* *INDENT-OFF* */
1822  .name = "ip6-full-reass-feature-hoff",
1823  .vector_size = sizeof (u32),
1824  .n_errors = ARRAY_LEN(ip6_full_reassembly_handoff_error_strings),
1827 
1828  .n_next_nodes = 1,
1829 
1830  .next_nodes = {
1831  [0] = "error-drop",
1832  },
1833 };
1834 /* *INDENT-ON* */
1835 
1836 #ifndef CLIB_MARCH_VARIANT
1837 int
1839 {
1841  vec_validate (rm->feature_use_refcount_per_intf, sw_if_index);
1842  if (is_enable)
1843  {
1844  if (!rm->feature_use_refcount_per_intf[sw_if_index])
1845  {
1847  return vnet_feature_enable_disable ("ip6-unicast",
1848  "ip6-full-reassembly-feature",
1849  sw_if_index, 1, 0, 0);
1850  }
1852  }
1853  else
1854  {
1856  if (!rm->feature_use_refcount_per_intf[sw_if_index])
1857  return vnet_feature_enable_disable ("ip6-unicast",
1858  "ip6-full-reassembly-feature",
1859  sw_if_index, 0, 0, 0);
1860  }
1861  return -1;
1862 }
1863 #endif
1864 
1865 /*
1866  * fd.io coding-style-patch-verification: ON
1867  *
1868  * Local Variables:
1869  * eval: (c-set-style "gnu")
1870  * End:
1871  */
#define IP6_FULL_REASS_MAX_REASSEMBLIES_DEFAULT
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:440
vnet_api_error_t ip6_full_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip6 reassembly configuration
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
clib_bihash_48_8_t hash
static bool ip6_full_reass_verify_fragment_multiple_8(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
vnet_api_error_t
Definition: api_errno.h:158
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:898
#define clib_min(x, y)
Definition: clib.h:295
vlib_node_registration_t ip6_full_reassembly_handoff_node
(constructor) VLIB_REGISTER_NODE (ip6_full_reassembly_handoff_node)
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
#define CLIB_UNUSED(x)
Definition: clib.h:82
static u32 ip6_full_reass_buffer_get_data_offset(vlib_buffer_t *b)
ip6_full_reass_trace_operation_e action
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
void ip6_register_protocol(u32 protocol, u32 node_index)
Definition: ip6_forward.c:1590
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
ip6_full_reass_main_t ip6_full_reass_main
static void ip6_full_reass_insert_range_in_chain(vlib_main_t *vm, ip6_full_reass_main_t *rm, ip6_full_reass_per_thread_t *rt, ip6_full_reass_t *reass, u32 prev_range_bi, u32 new_next_bi)
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
Definition: pool.h:346
u64 as_u64
Definition: bihash_doc.h:63
static ip6_full_reass_rc_t ip6_full_reass_update(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_full_reass_main_t *rm, ip6_full_reass_per_thread_t *rt, ip6_full_reass_t *reass, u32 *bi0, u32 *next0, u32 *error0, ip6_frag_hdr_t *frag_hdr, bool is_custom_app, u32 *handoff_thread_idx)
u64 as_u64[2]
Definition: ip6_packet.h:51
unsigned long u64
Definition: types.h:89
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
clib_bihash_48_8_t * new_hash
#define NULL
Definition: clib.h:58
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
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
Definition: threads.c:1810
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 ip6_full_reass_t * ip6_full_reass_find_or_create(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_full_reass_main_t *rm, ip6_full_reass_per_thread_t *rt, ip6_full_reass_kv_t *kv, u32 *icmp_bi, u8 *do_handoff)
static void * ip6_ext_next_header(ip6_ext_header_t *ext_hdr)
Definition: ip6_packet.h:510
ip6_full_reass_rc_t
int i
static uword ip6_full_reassembly_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature, bool is_custom_app)
#define MSEC_PER_SEC
static u32 format_get_indent(u8 *s)
Definition: format.h:72
format_function_t format_ip6_frag_hdr
Definition: format.h:96
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
static void ip6_full_reass_free_ctx(ip6_full_reass_per_thread_t *rt, ip6_full_reass_t *reass)
#define VLIB_NODE_FN(node)
Definition: node.h:202
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
ip6_address_t src_address
Definition: ip6_packet.h:307
ip6_full_reass_next_t
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
vlib_node_registration_t ip6_full_reass_expire_node
(constructor) VLIB_REGISTER_NODE (ip6_full_reass_expire_node)
static bool ip6_full_reass_verify_upper_layer_present(vlib_node_runtime_t *node, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
#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
static u8 * format_ip6_full_reass_trace(u8 *s, va_list *args)
#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
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
static char * ip6_full_reassembly_error_strings[]
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
Definition: main.c:185
vlib_node_registration_t ip6_full_reass_node
(constructor) VLIB_REGISTER_NODE (ip6_full_reass_node)
unsigned int u32
Definition: types.h:88
static void ip6_full_reass_free(ip6_full_reass_main_t *rm, ip6_full_reass_per_thread_t *rt, ip6_full_reass_t *reass)
#define vlib_call_init_function(vm, x)
Definition: init.h:270
#define VLIB_FRAME_SIZE
Definition: node.h:378
static void * ip6_ext_header_find(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6_header, u8 header_type, ip6_ext_header_t **prev_ext_header)
Definition: ip6_packet.h:536
static u32 ip6_full_reass_get_nbuckets()
void icmp6_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
Definition: icmp6.c:446
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:63
#define ip6_frag_hdr_more(hdr)
Definition: ip6_packet.h:667
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:136
static vlib_cli_command_t show_ip6_full_reassembly_cmd
(constructor) VLIB_CLI_COMMAND (show_ip6_full_reassembly_cmd)
#define IP6_FULL_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT
static u32 vlib_buffer_chain_linearize(vlib_main_t *vm, vlib_buffer_t *b)
static ip6_full_reass_rc_t ip6_full_reass_finalize(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_full_reass_main_t *rm, ip6_full_reass_per_thread_t *rt, ip6_full_reass_t *reass, u32 *bi0, u32 *next0, u32 *error0, bool is_custom_app)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:519
static clib_error_t * show_ip6_full_reass(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
ip6_full_reassembly_handoff_error_t
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:934
static u8 * format_ip6_full_reassembly_handoff_trace(u8 *s, va_list *args)
u16 frame_flags
Definition: node.h:385
long ctx[MAX_CONNS]
Definition: main.c:144
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
Definition: main.c:194
ip6_full_reass_trace_operation_e
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 int ip6_rehash_cb(clib_bihash_kv_48_8_t *kv, void *_ctx)
#define PREDICT_FALSE(x)
Definition: clib.h:111
#define always_inline
Definition: ipsec.h:28
ip6_main_t ip6_main
Definition: ip6_forward.c:2703
static void ip6_full_reass_on_timeout(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_full_reass_main_t *rm, ip6_full_reass_t *reass, u32 *icmp_bi)
static char * ip6_full_reassembly_handoff_error_strings[]
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
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1150
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
clib_error_t * ip_main_init(vlib_main_t *vm)
Definition: ip_init.c:45
VNET_FEATURE_INIT(ip6_full_reassembly_feature, static)
u16 n_vectors
Definition: node.h:397
format_function_t format_ip6_address
Definition: format.h:91
#define IP6_FULL_REASS_HT_LOAD_FACTOR
ip6_full_reass_range_trace_t trace_range
#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
ip6_full_reass_per_thread_t * per_thread_data
ip6_frag_hdr_t ip6_frag_header
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
#define ip6_frag_hdr_offset_bytes(hdr)
Definition: ip6_packet.h:664
vlib_main_t * vlib_main
#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
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1810
static u8 ip6_ext_hdr(u8 nexthdr)
Definition: ip6_packet.h:485
vlib_node_registration_t ip6_full_reass_node_feature
(constructor) VLIB_REGISTER_NODE (ip6_full_reass_node_feature)
clib_bihash_kv_48_8_t kv
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:152
u32 fq_index
Worker handoff.
signed int i32
Definition: types.h:77
#define ip6_frag_hdr_offset(hdr)
Definition: ip6_packet.h:661
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:515
#define IP6_FULL_REASS_TIMEOUT_DEFAULT_MS
#define ASSERT(truth)
ip6_full_reass_key_t k
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:248
static u16 ip6_full_reass_buffer_get_data_len(vlib_buffer_t *b)
format_function_t format_ip6_header
Definition: format.h:95
static uword ip6_full_reassembly_handoff_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature)
#define VNET_FEATURES(...)
Definition: feature.h:442
static void ip6_full_reass_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_full_reass_main_t *rm, ip6_full_reass_t *reass, u32 bi, ip6_frag_hdr_t *ip6_frag_header, ip6_full_reass_trace_operation_e action, u32 thread_id_to)
static u8 * format_ip6_full_reass(u8 *s, va_list *args)
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
static void ip6_full_reass_drop_all(vlib_main_t *vm, vlib_node_runtime_t *node, ip6_full_reass_main_t *rm, ip6_full_reass_t *reass)
static void ip6_full_reass_trace_details(vlib_main_t *vm, u32 bi, ip6_full_reass_range_trace_t *trace)
u16 payload_length
Definition: ip6_packet.h:298
u8 action
Definition: l2.api:173
vl_api_address_t ip
Definition: l2.api:490
#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
#define foreach_ip6_full_reassembly_handoff_error
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
#define VLIB_FRAME_TRACE
Definition: node.h:435
vnet_api_error_t ip6_full_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip6 reassembly configuration
#define IP6_FULL_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS
#define foreach_ip6_error
Definition: ip6_error.h:43
vlib_node_registration_t ip6_full_reassembly_feature_handoff_node
(constructor) VLIB_REGISTER_NODE (ip6_full_reassembly_feature_handoff_node)
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
static void ip6_full_reass_set_params(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
#define vnet_buffer(b)
Definition: buffer.h:408
static bool ip6_full_reass_verify_packet_size_lt_64k(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b, ip6_frag_hdr_t *frag_hdr)
static u32 vlib_num_workers()
Definition: threads.h:372
ip6_full_reass_key_t key
#define vec_foreach(var, vec)
Vector iterator.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: in2out_ed.c:1811
vnet_api_error_t ip6_full_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
ip6_full_reass_event_t
u16 flags
Copy of main node flags.
Definition: node.h:509
static u8 * format_ip6_full_reass_key(u8 *s, va_list *args)
int ip6_full_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
#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
static clib_error_t * ip6_full_reass_init_function(vlib_main_t *vm)
static uword ip6_full_reass_walk_expired(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
ip6_full_reass_val_t v
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:689
u32 * fib_index_by_sw_if_index
Definition: ip6.h:195
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
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
Definition: defs.h:46
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".
ip6_address_t dst_address
Definition: ip6_packet.h:307
static u8 * format_ip6_full_reass_range_trace(u8 *s, va_list *args)
IPv6 Reassembly.