FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip4_sv_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 Shallow Virtual Reassembly.
19  *
20  * This file contains the source code for IPv4 Shallow Virtual reassembly.
21  */
22 
23 #include <vppinfra/vec.h>
24 #include <vnet/vnet.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/ip/ip4_to_ip6.h>
27 #include <vppinfra/fifo.h>
28 #include <vppinfra/bihash_16_8.h>
30 
31 #define MSEC_PER_SEC 1000
32 #define IP4_SV_REASS_TIMEOUT_DEFAULT_MS 100
33 #define IP4_SV_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS 10000 // 10 seconds default
34 #define IP4_SV_REASS_MAX_REASSEMBLIES_DEFAULT 1024
35 #define IP4_SV_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT 3
36 #define IP4_SV_REASS_HT_LOAD_FACTOR (0.75)
37 
38 typedef enum
39 {
44 
45 typedef struct
46 {
47  union
48  {
49  struct
50  {
57  };
58  u64 as_u64[2];
59  };
61 
62 typedef union
63 {
64  struct
65  {
68  };
71 
72 typedef union
73 {
74  struct
75  {
78  };
81 
82 typedef struct
83 {
84  // hash table key
86  // time when last packet was received
88  // internal id of this reassembly
90  // trace operation counter
92  // minimum fragment length for this reassembly - used to estimate MTU
94  // buffer indexes of buffers in this reassembly in chronological order -
95  // including overlaps and duplicate fragments
97  // set to true when this reassembly is completed
99  // ip protocol
104  // l4 src port
106  // l4 dst port
109  // lru indexes
113 
114 typedef struct
115 {
120  // lru indexes
123 
125 
126 typedef struct
127 {
128  // IPv4 config
132  // maximum number of fragments in one reassembly
134  // maximum number of reassemblies
136 
137  // IPv4 runtime
138  clib_bihash_16_8_t hash;
139  // per-thread data
141 
142  // convenience
145 
146  // node index of ip4-drop node
149 
150  /** Worker handoff */
153 
154  // reference count for enabling/disabling feature - per interface
156 
157  // reference count for enabling/disabling feature - per interface
159 
161 
163 
164 #ifndef CLIB_MARCH_VARIANT
166 #endif /* CLIB_MARCH_VARIANT */
167 
168 typedef enum
169 {
175 
176 typedef enum
177 {
183 
184 typedef struct
185 {
193 
196 
197 static u8 *
198 format_ip4_sv_reass_trace (u8 * s, va_list * args)
199 {
200  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
201  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
202  ip4_sv_reass_trace_t *t = va_arg (*args, ip4_sv_reass_trace_t *);
203  if (REASS_PASSTHROUGH != t->action)
204  {
205  s = format (s, "reass id: %u, op id: %u ", t->reass_id, t->op_id);
206  }
207  switch (t->action)
208  {
210  s = format (s, "[cached]");
211  break;
212  case REASS_FINISH:
213  s =
214  format (s, "[finish, ip proto=%u, src_port=%u, dst_port=%u]",
215  t->ip_proto, clib_net_to_host_u16 (t->l4_src_port),
216  clib_net_to_host_u16 (t->l4_dst_port));
217  break;
219  s =
220  format (s, "[forward, ip proto=%u, src_port=%u, dst_port=%u]",
221  t->ip_proto, clib_net_to_host_u16 (t->l4_src_port),
222  clib_net_to_host_u16 (t->l4_dst_port));
223  break;
224  case REASS_PASSTHROUGH:
225  s = format (s, "[not-fragmented]");
226  break;
227  }
228  return s;
229 }
230 
231 static void
233  ip4_sv_reass_t *reass, u32 bi,
235  u16 l4_src_port, u16 l4_dst_port)
236 {
240  {
241  // this buffer's trace is gone
242  b->flags &= ~VLIB_BUFFER_IS_TRACED;
243  return;
244  }
245  ip4_sv_reass_trace_t *t = vlib_add_trace (vm, node, b, sizeof (t[0]));
246  if (reass)
247  {
248  t->reass_id = reass->id;
249  t->op_id = reass->trace_op_counter;
250  ++reass->trace_op_counter;
251  }
252  t->action = action;
253  t->ip_proto = ip_proto;
254  t->l4_src_port = l4_src_port;
255  t->l4_dst_port = l4_dst_port;
256 #if 0
257  static u8 *s = NULL;
258  s = format (s, "%U", format_ip4_sv_reass_trace, NULL, NULL, t);
259  printf ("%.*s\n", vec_len (s), s);
260  fflush (stdout);
261  vec_reset_length (s);
262 #endif
263 }
264 
265 
266 always_inline void
269 {
271  kv.key[0] = reass->key.as_u64[0];
272  kv.key[1] = reass->key.as_u64[1];
273  clib_bihash_add_del_16_8 (&rm->hash, &kv, 0);
275  vec_len (reass->cached_buffers));
276  vec_free (reass->cached_buffers);
277  reass->cached_buffers = NULL;
278  if (~0 != reass->lru_prev)
279  {
280  ip4_sv_reass_t *lru_prev =
281  pool_elt_at_index (rt->pool, reass->lru_prev);
282  lru_prev->lru_next = reass->lru_next;
283  }
284  if (~0 != reass->lru_next)
285  {
286  ip4_sv_reass_t *lru_next =
287  pool_elt_at_index (rt->pool, reass->lru_next);
288  lru_next->lru_prev = reass->lru_prev;
289  }
290  if (rt->lru_first == reass - rt->pool)
291  {
292  rt->lru_first = reass->lru_next;
293  }
294  if (rt->lru_last == reass - rt->pool)
295  {
296  rt->lru_last = reass->lru_prev;
297  }
298  pool_put (rt->pool, reass);
299  --rt->reass_n;
300 }
301 
302 always_inline void
304 {
305  reass->cached_buffers = NULL;
306  reass->is_complete = false;
307 }
308 
312  ip4_sv_reass_kv_t * kv, u8 * do_handoff)
313 {
314  ip4_sv_reass_t *reass = NULL;
315  f64 now = vlib_time_now (vm);
316 
317  if (!clib_bihash_search_16_8 (&rm->hash, &kv->kv, &kv->kv))
318  {
319  if (vm->thread_index != kv->v.thread_index)
320  {
321  *do_handoff = 1;
322  return NULL;
323  }
324  reass = pool_elt_at_index (rt->pool, kv->v.reass_index);
325 
326  if (now > reass->last_heard + rm->timeout)
327  {
328  ip4_sv_reass_free (vm, rm, rt, reass);
329  reass = NULL;
330  }
331  }
332 
333  if (reass)
334  {
335  reass->last_heard = now;
336  return reass;
337  }
338 
339  if (rt->reass_n >= rm->max_reass_n && rm->max_reass_n)
340  {
341  reass = pool_elt_at_index (rt->pool, rt->lru_first);
342  ip4_sv_reass_free (vm, rm, rt, reass);
343  }
344 
345  pool_get (rt->pool, reass);
346  clib_memset (reass, 0, sizeof (*reass));
347  reass->id = ((u64) vm->thread_index * 1000000000) + rt->id_counter;
348  ++rt->id_counter;
349  ip4_sv_reass_init (reass);
350  ++rt->reass_n;
351  reass->lru_prev = reass->lru_next = ~0;
352 
353  if (~0 != rt->lru_last)
354  {
355  ip4_sv_reass_t *lru_last = pool_elt_at_index (rt->pool, rt->lru_last);
356  reass->lru_prev = rt->lru_last;
357  lru_last->lru_next = rt->lru_last = reass - rt->pool;
358  }
359 
360  if (~0 == rt->lru_first)
361  {
362  rt->lru_first = rt->lru_last = reass - rt->pool;
363  }
364 
365  reass->key.as_u64[0] = kv->kv.key[0];
366  reass->key.as_u64[1] = kv->kv.key[1];
367  kv->v.reass_index = (reass - rt->pool);
368  kv->v.thread_index = vm->thread_index;
369  reass->last_heard = now;
370 
371  if (clib_bihash_add_del_16_8 (&rm->hash, &kv->kv, 1))
372  {
373  ip4_sv_reass_free (vm, rm, rt, reass);
374  reass = NULL;
375  }
376 
377  return reass;
378 }
379 
383  ip4_sv_reass_t *reass, u32 bi0)
384 {
385  vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
387  const u32 fragment_first = ip4_get_fragment_offset_bytes (ip0);
388  if (0 == fragment_first)
389  {
390  reass->ip_proto = ip0->protocol;
391  reass->l4_src_port = ip4_get_port (ip0, 1);
392  reass->l4_dst_port = ip4_get_port (ip0, 0);
393  if (!reass->l4_src_port || !reass->l4_dst_port)
395  if (IP_PROTOCOL_TCP == reass->ip_proto)
396  {
397  reass->icmp_type_or_tcp_flags = ((tcp_header_t *) (ip0 + 1))->flags;
398  reass->tcp_ack_number = ((tcp_header_t *) (ip0 + 1))->ack_number;
399  reass->tcp_seq_number = ((tcp_header_t *) (ip0 + 1))->seq_number;
400  }
401  else if (IP_PROTOCOL_ICMP == reass->ip_proto)
402  {
403  reass->icmp_type_or_tcp_flags =
404  ((icmp46_header_t *) (ip0 + 1))->type;
405  }
406  reass->is_complete = true;
407  vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
408  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
409  {
411  reass->ip_proto, reass->l4_src_port,
412  reass->l4_dst_port);
413  }
414  }
415  vec_add1 (reass->cached_buffers, bi0);
416  if (!reass->is_complete)
417  {
418  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
419  {
421  ~0, ~0, ~0);
422  }
423  if (vec_len (reass->cached_buffers) > rm->max_reass_len)
424  {
426  }
427  }
428  return rc;
429 }
430 
433  vlib_frame_t * frame, bool is_feature,
434  bool is_output_feature, bool is_custom)
435 {
437  u32 n_left_from, n_left_to_next, *to_next, next_index;
440  clib_spinlock_lock (&rt->lock);
441 
442  n_left_from = frame->n_vectors;
443  next_index = node->cached_next_index;
444 
448  b = bufs;
449 
450  /* optimistic case first - no fragments */
451  while (n_left_from >= 2)
452  {
453  vlib_buffer_t *b0, *b1;
454  u32 next0, next1;
455  b0 = *b;
456  b++;
457  b1 = *b;
458  b++;
459 
460  /* Prefetch next iteration. */
461  if (PREDICT_TRUE (n_left_from >= 4))
462  {
463  vlib_buffer_t *p2, *p3;
464 
465  p2 = *b;
466  p3 = *(b + 1);
467 
468  vlib_prefetch_buffer_header (p2, LOAD);
469  vlib_prefetch_buffer_header (p3, LOAD);
470 
471  clib_prefetch_load (p2->data);
472  clib_prefetch_load (p3->data);
473  }
474 
475  ip4_header_t *ip0 =
477  (is_output_feature ? 1 : 0) *
478  vnet_buffer (b0)->
479  ip.save_rewrite_length);
480  ip4_header_t *ip1 =
482  (is_output_feature ? 1 : 0) *
483  vnet_buffer (b1)->
484  ip.save_rewrite_length);
485  if (PREDICT_FALSE
488  {
489  // fragment found, go slow path
490  b -= 2;
491  if (b - bufs > 0)
492  {
494  b - bufs);
495  }
496  goto slow_path;
497  }
498  if (is_feature)
499  {
500  vnet_feature_next (&next0, b0);
501  }
502  else
503  {
504  next0 = is_custom ? vnet_buffer (b0)->ip.reass.next_index :
506  }
507  vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
508  vnet_buffer (b0)->ip.reass.ip_proto = ip0->protocol;
509  if (IP_PROTOCOL_TCP == ip0->protocol)
510  {
511  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
512  ((tcp_header_t *) (ip0 + 1))->flags;
513  vnet_buffer (b0)->ip.reass.tcp_ack_number =
514  ((tcp_header_t *) (ip0 + 1))->ack_number;
515  vnet_buffer (b0)->ip.reass.tcp_seq_number =
516  ((tcp_header_t *) (ip0 + 1))->seq_number;
517  }
518  else if (IP_PROTOCOL_ICMP == ip0->protocol)
519  {
520  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
521  ((icmp46_header_t *) (ip0 + 1))->type;
522  }
523  vnet_buffer (b0)->ip.reass.l4_src_port = ip4_get_port (ip0, 1);
524  vnet_buffer (b0)->ip.reass.l4_dst_port = ip4_get_port (ip0, 0);
525  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
526  {
527  ip4_sv_reass_add_trace (vm, node, NULL, from[(b - 2) - bufs],
529  vnet_buffer (b0)->ip.reass.ip_proto,
530  vnet_buffer (b0)->ip.reass.l4_src_port,
531  vnet_buffer (b0)->ip.reass.l4_dst_port);
532  }
533  if (is_feature)
534  {
535  vnet_feature_next (&next1, b1);
536  }
537  else
538  {
539  next1 = is_custom ? vnet_buffer (b1)->ip.reass.next_index :
541  }
542  vnet_buffer (b1)->ip.reass.is_non_first_fragment = 0;
543  vnet_buffer (b1)->ip.reass.ip_proto = ip1->protocol;
544  if (IP_PROTOCOL_TCP == ip1->protocol)
545  {
546  vnet_buffer (b1)->ip.reass.icmp_type_or_tcp_flags =
547  ((tcp_header_t *) (ip1 + 1))->flags;
548  vnet_buffer (b1)->ip.reass.tcp_ack_number =
549  ((tcp_header_t *) (ip1 + 1))->ack_number;
550  vnet_buffer (b1)->ip.reass.tcp_seq_number =
551  ((tcp_header_t *) (ip1 + 1))->seq_number;
552  }
553  else if (IP_PROTOCOL_ICMP == ip1->protocol)
554  {
555  vnet_buffer (b1)->ip.reass.icmp_type_or_tcp_flags =
556  ((icmp46_header_t *) (ip1 + 1))->type;
557  }
558  vnet_buffer (b1)->ip.reass.l4_src_port = ip4_get_port (ip1, 1);
559  vnet_buffer (b1)->ip.reass.l4_dst_port = ip4_get_port (ip1, 0);
560  if (PREDICT_FALSE (b1->flags & VLIB_BUFFER_IS_TRACED))
561  {
562  ip4_sv_reass_add_trace (vm, node, NULL, from[(b - 1) - bufs],
564  vnet_buffer (b1)->ip.reass.ip_proto,
565  vnet_buffer (b1)->ip.reass.l4_src_port,
566  vnet_buffer (b1)->ip.reass.l4_dst_port);
567  }
568 
569  n_left_from -= 2;
570  next[0] = next0;
571  next[1] = next1;
572  next += 2;
573  }
574 
575  while (n_left_from > 0)
576  {
577  vlib_buffer_t *b0;
578  u32 next0;
579  b0 = *b;
580  b++;
581 
582  ip4_header_t *ip0 =
584  (is_output_feature ? 1 : 0) *
585  vnet_buffer (b0)->
586  ip.save_rewrite_length);
587  if (PREDICT_FALSE
589  {
590  // fragment found, go slow path
591  b -= 1;
592  if (b - bufs > 0)
593  {
595  b - bufs);
596  }
597  goto slow_path;
598  }
599  if (is_feature)
600  {
601  vnet_feature_next (&next0, b0);
602  }
603  else
604  {
605  next0 =
606  is_custom ? vnet_buffer (b0)->ip.
607  reass.next_index : IP4_SV_REASSEMBLY_NEXT_INPUT;
608  }
609  vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
610  vnet_buffer (b0)->ip.reass.ip_proto = ip0->protocol;
611  if (IP_PROTOCOL_TCP == ip0->protocol)
612  {
613  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
614  ((tcp_header_t *) (ip0 + 1))->flags;
615  vnet_buffer (b0)->ip.reass.tcp_ack_number =
616  ((tcp_header_t *) (ip0 + 1))->ack_number;
617  vnet_buffer (b0)->ip.reass.tcp_seq_number =
618  ((tcp_header_t *) (ip0 + 1))->seq_number;
619  }
620  else if (IP_PROTOCOL_ICMP == ip0->protocol)
621  {
622  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
623  ((icmp46_header_t *) (ip0 + 1))->type;
624  }
625  vnet_buffer (b0)->ip.reass.l4_src_port = ip4_get_port (ip0, 1);
626  vnet_buffer (b0)->ip.reass.l4_dst_port = ip4_get_port (ip0, 0);
627  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
628  {
629  ip4_sv_reass_add_trace (vm, node, NULL, from[(b - 1) - bufs],
631  vnet_buffer (b0)->ip.reass.ip_proto,
632  vnet_buffer (b0)->ip.reass.l4_src_port,
633  vnet_buffer (b0)->ip.reass.l4_dst_port);
634  }
635 
636  n_left_from -= 1;
637  next[0] = next0;
638  next += 1;
639  }
640 
642  frame->n_vectors);
643 
644  goto done;
645 
646 slow_path:
647 
648  from += b - bufs;
649 
650  while (n_left_from > 0)
651  {
652  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
653 
654  while (n_left_from > 0 && n_left_to_next > 0)
655  {
656  u32 bi0;
657  vlib_buffer_t *b0;
658  u32 next0;
659  u32 error0 = IP4_ERROR_NONE;
660 
661  bi0 = from[0];
662  b0 = vlib_get_buffer (vm, bi0);
663 
664  ip4_header_t *ip0 =
666  (is_output_feature ? 1 : 0) *
667  vnet_buffer (b0)->
668  ip.save_rewrite_length);
669  if (!ip4_get_fragment_more (ip0) && !ip4_get_fragment_offset (ip0))
670  {
671  // this is a regular packet - no fragmentation
672  if (is_custom)
673  {
674  next0 = vnet_buffer (b0)->ip.reass.next_index;
675  }
676  else
677  {
679  }
680  vnet_buffer (b0)->ip.reass.is_non_first_fragment = 0;
681  vnet_buffer (b0)->ip.reass.ip_proto = ip0->protocol;
682  if (IP_PROTOCOL_TCP == ip0->protocol)
683  {
684  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
685  ((tcp_header_t *) (ip0 + 1))->flags;
686  vnet_buffer (b0)->ip.reass.tcp_ack_number =
687  ((tcp_header_t *) (ip0 + 1))->ack_number;
688  vnet_buffer (b0)->ip.reass.tcp_seq_number =
689  ((tcp_header_t *) (ip0 + 1))->seq_number;
690  }
691  else if (IP_PROTOCOL_ICMP == ip0->protocol)
692  {
693  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
694  ((icmp46_header_t *) (ip0 + 1))->type;
695  }
696  vnet_buffer (b0)->ip.reass.l4_src_port = ip4_get_port (ip0, 1);
697  vnet_buffer (b0)->ip.reass.l4_dst_port = ip4_get_port (ip0, 0);
698  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
699  {
701  vm, node, NULL, bi0, REASS_PASSTHROUGH,
702  vnet_buffer (b0)->ip.reass.ip_proto,
703  vnet_buffer (b0)->ip.reass.l4_src_port,
704  vnet_buffer (b0)->ip.reass.l4_dst_port);
705  }
706  goto packet_enqueue;
707  }
708  const u32 fragment_first = ip4_get_fragment_offset_bytes (ip0);
709  const u32 fragment_length =
710  clib_net_to_host_u16 (ip0->length) - ip4_header_bytes (ip0);
711  const u32 fragment_last = fragment_first + fragment_length - 1;
712  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
713  {
715  error0 = IP4_ERROR_REASS_MALFORMED_PACKET;
716  b0->error = node->errors[error0];
717  goto packet_enqueue;
718  }
720  u8 do_handoff = 0;
721 
722  kv.k.as_u64[0] =
724  vnet_buffer (b0)->sw_if_index[VLIB_RX]) |
725  (u64) ip0->src_address.as_u32 << 32;
726  kv.k.as_u64[1] =
727  (u64) ip0->dst_address.
728  as_u32 | (u64) ip0->fragment_id << 32 | (u64) ip0->protocol << 48;
729 
730  ip4_sv_reass_t *reass =
731  ip4_sv_reass_find_or_create (vm, rm, rt, &kv, &do_handoff);
732 
733  if (PREDICT_FALSE (do_handoff))
734  {
736  vnet_buffer (b0)->ip.reass.owner_thread_index =
737  kv.v.thread_index;
738  goto packet_enqueue;
739  }
740 
741  if (!reass)
742  {
744  error0 = IP4_ERROR_REASS_LIMIT_REACHED;
745  b0->error = node->errors[error0];
746  goto packet_enqueue;
747  }
748 
749  if (reass->is_complete)
750  {
751  if (is_custom)
752  {
753  next0 = vnet_buffer (b0)->ip.reass.next_index;
754  }
755  else
756  {
758  }
759  vnet_buffer (b0)->ip.reass.is_non_first_fragment =
760  ! !fragment_first;
761  vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
762  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
763  reass->icmp_type_or_tcp_flags;
764  vnet_buffer (b0)->ip.reass.tcp_ack_number =
765  reass->tcp_ack_number;
766  vnet_buffer (b0)->ip.reass.tcp_seq_number =
767  reass->tcp_seq_number;
768  vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
769  vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
770  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
771  {
773  vm, node, reass, bi0, REASS_FRAGMENT_FORWARD,
774  reass->ip_proto, reass->l4_src_port, reass->l4_dst_port);
775  }
776  goto packet_enqueue;
777  }
778 
779  ip4_sv_reass_rc_t rc =
780  ip4_sv_reass_update (vm, node, rm, ip0, reass, bi0);
781  switch (rc)
782  {
783  case IP4_SV_REASS_RC_OK:
784  /* nothing to do here */
785  break;
787  vlib_node_increment_counter (vm, node->node_index,
788  IP4_ERROR_REASS_FRAGMENT_CHAIN_TOO_LONG,
789  1);
790  ip4_sv_reass_free (vm, rm, rt, reass);
791  goto next_packet;
792  break;
794  vlib_node_increment_counter (vm, node->node_index,
795  IP4_ERROR_REASS_UNSUPP_IP_PROT, 1);
796  ip4_sv_reass_free (vm, rm, rt, reass);
797  goto next_packet;
798  break;
799  }
800  if (reass->is_complete)
801  {
802  u32 idx;
803  vec_foreach_index (idx, reass->cached_buffers)
804  {
805  u32 bi0 = vec_elt (reass->cached_buffers, idx);
806  vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
807  ip0 =
809  (is_output_feature ? 1 : 0) *
810  vnet_buffer (b0)->
811  ip.save_rewrite_length);
813  if (is_feature)
814  {
815  vnet_feature_next (&next0, b0);
816  }
817  if (is_custom)
818  {
819  next0 = vnet_buffer (b0)->ip.reass.next_index;
820  }
821  if (0 == n_left_to_next)
822  {
824  n_left_to_next);
826  n_left_to_next);
827  }
828  to_next[0] = bi0;
829  to_next += 1;
830  n_left_to_next -= 1;
831  vnet_buffer (b0)->ip.reass.is_non_first_fragment =
832  ! !ip4_get_fragment_offset (ip0);
833  vnet_buffer (b0)->ip.reass.ip_proto = reass->ip_proto;
834  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags =
835  reass->icmp_type_or_tcp_flags;
836  vnet_buffer (b0)->ip.reass.tcp_ack_number =
837  reass->tcp_ack_number;
838  vnet_buffer (b0)->ip.reass.tcp_seq_number =
839  reass->tcp_seq_number;
840  vnet_buffer (b0)->ip.reass.l4_src_port = reass->l4_src_port;
841  vnet_buffer (b0)->ip.reass.l4_dst_port = reass->l4_dst_port;
842  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
843  {
845  vm, node, reass, bi0, REASS_FRAGMENT_FORWARD,
846  reass->ip_proto, reass->l4_src_port, reass->l4_dst_port);
847  }
849  to_next, n_left_to_next, bi0,
850  next0);
851  }
852  _vec_len (reass->cached_buffers) = 0; // buffers are owned by frame now
853  }
854  goto next_packet;
855 
856  packet_enqueue:
857  to_next[0] = bi0;
858  to_next += 1;
859  n_left_to_next -= 1;
860  if (is_feature && IP4_ERROR_NONE == error0)
861  {
862  b0 = vlib_get_buffer (vm, bi0);
863  vnet_feature_next (&next0, b0);
864  }
866  to_next, n_left_to_next,
867  bi0, next0);
868 
869  next_packet:
870  from += 1;
871  n_left_from -= 1;
872  }
873 
874  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
875  }
876 
877 done:
878  clib_spinlock_unlock (&rt->lock);
879  return frame->n_vectors;
880 }
881 
882 static char *ip4_sv_reass_error_strings[] = {
883 #define _(sym, string) string,
885 #undef _
886 };
887 
891 {
892  return ip4_sv_reass_inline (vm, node, frame, false /* is_feature */ ,
893  false /* is_output_feature */ ,
894  false /* is_custom */ );
895 }
896 
897 /* *INDENT-OFF* */
899  .name = "ip4-sv-reassembly",
900  .vector_size = sizeof (u32),
901  .format_trace = format_ip4_sv_reass_trace,
903  .error_strings = ip4_sv_reass_error_strings,
904  .n_next_nodes = IP4_SV_REASSEMBLY_N_NEXT,
905  .next_nodes =
906  {
907  [IP4_SV_REASSEMBLY_NEXT_INPUT] = "ip4-input",
908  [IP4_SV_REASSEMBLY_NEXT_DROP] = "ip4-drop",
909  [IP4_SV_REASSEMBLY_NEXT_HANDOFF] = "ip4-sv-reassembly-handoff",
910 
911  },
912 };
913 /* *INDENT-ON* */
914 
918 {
919  return ip4_sv_reass_inline (vm, node, frame, true /* is_feature */ ,
920  false /* is_output_feature */ ,
921  false /* is_custom */ );
922 }
923 
924 /* *INDENT-OFF* */
926  .name = "ip4-sv-reassembly-feature",
927  .vector_size = sizeof (u32),
928  .format_trace = format_ip4_sv_reass_trace,
930  .error_strings = ip4_sv_reass_error_strings,
931  .n_next_nodes = IP4_SV_REASSEMBLY_N_NEXT,
932  .next_nodes =
933  {
934  [IP4_SV_REASSEMBLY_NEXT_INPUT] = "ip4-input",
935  [IP4_SV_REASSEMBLY_NEXT_DROP] = "ip4-drop",
936  [IP4_SV_REASSEMBLY_NEXT_HANDOFF] = "ip4-sv-reass-feature-hoff",
937  },
938 };
939 /* *INDENT-ON* */
940 
941 /* *INDENT-OFF* */
942 VNET_FEATURE_INIT (ip4_sv_reass_feature) = {
943  .arc_name = "ip4-unicast",
944  .node_name = "ip4-sv-reassembly-feature",
945  .runs_before = VNET_FEATURES ("ip4-lookup"),
946  .runs_after = 0,
947 };
948 /* *INDENT-ON* */
949 
953 {
954  return ip4_sv_reass_inline (vm, node, frame, true /* is_feature */ ,
955  true /* is_output_feature */ ,
956  false /* is_custom */ );
957 }
958 
959 
960 /* *INDENT-OFF* */
962  .name = "ip4-sv-reassembly-output-feature",
963  .vector_size = sizeof (u32),
964  .format_trace = format_ip4_sv_reass_trace,
966  .error_strings = ip4_sv_reass_error_strings,
967  .n_next_nodes = IP4_SV_REASSEMBLY_N_NEXT,
968  .next_nodes =
969  {
970  [IP4_SV_REASSEMBLY_NEXT_INPUT] = "ip4-input",
971  [IP4_SV_REASSEMBLY_NEXT_DROP] = "ip4-drop",
972  [IP4_SV_REASSEMBLY_NEXT_HANDOFF] = "ip4-sv-reass-feature-hoff",
973  },
974 };
975 /* *INDENT-ON* */
976 
977 /* *INDENT-OFF* */
978 VNET_FEATURE_INIT (ip4_sv_reass_output_feature) = {
979  .arc_name = "ip4-output",
980  .node_name = "ip4-sv-reassembly-output-feature",
981  .runs_before = 0,
982  .runs_after = 0,
983 };
984 /* *INDENT-ON* */
985 
986 /* *INDENT-OFF* */
988  .name = "ip4-sv-reassembly-custom-next",
989  .vector_size = sizeof (u32),
990  .format_trace = format_ip4_sv_reass_trace,
992  .error_strings = ip4_sv_reass_error_strings,
993  .n_next_nodes = IP4_SV_REASSEMBLY_N_NEXT,
994  .next_nodes =
995  {
996  [IP4_SV_REASSEMBLY_NEXT_INPUT] = "ip4-input",
997  [IP4_SV_REASSEMBLY_NEXT_DROP] = "ip4-drop",
998  [IP4_SV_REASSEMBLY_NEXT_HANDOFF] = "ip4-sv-reassembly-handoff",
999 
1000  },
1001 };
1002 /* *INDENT-ON* */
1003 
1006  vlib_frame_t * frame)
1007 {
1008  return ip4_sv_reass_inline (vm, node, frame, false /* is_feature */ ,
1009  false /* is_output_feature */ ,
1010  true /* is_custom */ );
1011 }
1012 
1013 #ifndef CLIB_MARCH_VARIANT
1016 {
1018  u32 nbuckets;
1019  u8 i;
1020 
1021  nbuckets = (u32) (rm->max_reass_n / IP4_SV_REASS_HT_LOAD_FACTOR);
1022 
1023  for (i = 0; i < 31; i++)
1024  if ((1 << i) >= nbuckets)
1025  break;
1026  nbuckets = 1 << i;
1027 
1028  return nbuckets;
1029 }
1030 #endif /* CLIB_MARCH_VARIANT */
1031 
1032 typedef enum
1033 {
1036 
1037 typedef struct
1038 {
1039  int failure;
1040  clib_bihash_16_8_t *new_hash;
1042 
1043 #ifndef CLIB_MARCH_VARIANT
1044 static int
1046 {
1047  ip4_rehash_cb_ctx *ctx = _ctx;
1048  if (clib_bihash_add_del_16_8 (ctx->new_hash, kv, 1))
1049  {
1050  ctx->failure = 1;
1051  }
1052  return (BIHASH_WALK_CONTINUE);
1053 }
1054 
1055 static void
1056 ip4_sv_reass_set_params (u32 timeout_ms, u32 max_reassemblies,
1057  u32 max_reassembly_length,
1058  u32 expire_walk_interval_ms)
1059 {
1060  ip4_sv_reass_main.timeout_ms = timeout_ms;
1061  ip4_sv_reass_main.timeout = (f64) timeout_ms / (f64) MSEC_PER_SEC;
1062  ip4_sv_reass_main.max_reass_n = max_reassemblies;
1063  ip4_sv_reass_main.max_reass_len = max_reassembly_length;
1064  ip4_sv_reass_main.expire_walk_interval_ms = expire_walk_interval_ms;
1065 }
1066 
1068 ip4_sv_reass_set (u32 timeout_ms, u32 max_reassemblies,
1069  u32 max_reassembly_length, u32 expire_walk_interval_ms)
1070 {
1071  u32 old_nbuckets = ip4_sv_reass_get_nbuckets ();
1072  ip4_sv_reass_set_params (timeout_ms, max_reassemblies,
1073  max_reassembly_length, expire_walk_interval_ms);
1077  u32 new_nbuckets = ip4_sv_reass_get_nbuckets ();
1078  if (ip4_sv_reass_main.max_reass_n > 0 && new_nbuckets > old_nbuckets)
1079  {
1080  clib_bihash_16_8_t new_hash;
1081  clib_memset (&new_hash, 0, sizeof (new_hash));
1083  ctx.failure = 0;
1084  ctx.new_hash = &new_hash;
1085  clib_bihash_init_16_8 (&new_hash, "ip4-dr", new_nbuckets,
1086  new_nbuckets * 1024);
1087  clib_bihash_foreach_key_value_pair_16_8 (&ip4_sv_reass_main.hash,
1088  ip4_rehash_cb, &ctx);
1089  if (ctx.failure)
1090  {
1091  clib_bihash_free_16_8 (&new_hash);
1092  return -1;
1093  }
1094  else
1095  {
1096  clib_bihash_free_16_8 (&ip4_sv_reass_main.hash);
1098  sizeof (ip4_sv_reass_main.hash));
1100  }
1101  }
1102  return 0;
1103 }
1104 
1106 ip4_sv_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
1107  u32 * max_reassembly_length, u32 * expire_walk_interval_ms)
1108 {
1109  *timeout_ms = ip4_sv_reass_main.timeout_ms;
1110  *max_reassemblies = ip4_sv_reass_main.max_reass_n;
1111  *max_reassembly_length = ip4_sv_reass_main.max_reass_len;
1112  *expire_walk_interval_ms = ip4_sv_reass_main.expire_walk_interval_ms;
1113  return 0;
1114 }
1115 
1116 static clib_error_t *
1118 {
1120  clib_error_t *error = 0;
1121  u32 nbuckets;
1122  vlib_node_t *node;
1123 
1124  rm->vlib_main = vm;
1125  rm->vnet_main = vnet_get_main ();
1126 
1130  {
1131  clib_spinlock_init (&rt->lock);
1132  pool_alloc (rt->pool, rm->max_reass_n);
1133  rt->lru_first = rt->lru_last = ~0;
1134  }
1135 
1136  node = vlib_get_node_by_name (vm, (u8 *) "ip4-sv-reassembly-expire-walk");
1137  ASSERT (node);
1138  rm->ip4_sv_reass_expire_node_idx = node->index;
1139 
1144 
1145  nbuckets = ip4_sv_reass_get_nbuckets ();
1146  clib_bihash_init_16_8 (&rm->hash, "ip4-dr", nbuckets, nbuckets * 1024);
1147 
1148  node = vlib_get_node_by_name (vm, (u8 *) "ip4-drop");
1149  ASSERT (node);
1150  rm->ip4_drop_idx = node->index;
1151 
1153  rm->fq_feature_index =
1155 
1156  rm->feature_use_refcount_per_intf = NULL;
1158 
1159  return error;
1160 }
1161 
1163 #endif /* CLIB_MARCH_VARIANT */
1164 
1165 static uword
1169 {
1171  uword event_type, *event_data = 0;
1172 
1173  while (true)
1174  {
1176  (f64)
1178  (f64) MSEC_PER_SEC);
1179  event_type = vlib_process_get_events (vm, &event_data);
1180 
1181  switch (event_type)
1182  {
1183  case ~0:
1184  /* no events => timeout */
1185  /* fallthrough */
1187  /* nothing to do here */
1188  break;
1189  default:
1190  clib_warning ("BUG: event type 0x%wx", event_type);
1191  break;
1192  }
1193  f64 now = vlib_time_now (vm);
1194 
1195  ip4_sv_reass_t *reass;
1196  int *pool_indexes_to_free = NULL;
1197 
1198  uword thread_index = 0;
1199  int index;
1200  const uword nthreads = vlib_num_workers () + 1;
1201  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1202  {
1204  clib_spinlock_lock (&rt->lock);
1205 
1206  vec_reset_length (pool_indexes_to_free);
1207  /* *INDENT-OFF* */
1208  pool_foreach_index (index, rt->pool) {
1209  reass = pool_elt_at_index (rt->pool, index);
1210  if (now > reass->last_heard + rm->timeout)
1211  {
1212  vec_add1 (pool_indexes_to_free, index);
1213  }
1214  }
1215  /* *INDENT-ON* */
1216  int *i;
1217  /* *INDENT-OFF* */
1218  vec_foreach (i, pool_indexes_to_free)
1219  {
1220  ip4_sv_reass_t *reass = pool_elt_at_index (rt->pool, i[0]);
1221  ip4_sv_reass_free (vm, rm, rt, reass);
1222  }
1223  /* *INDENT-ON* */
1224 
1225  clib_spinlock_unlock (&rt->lock);
1226  }
1227 
1228  vec_free (pool_indexes_to_free);
1229  if (event_data)
1230  {
1231  _vec_len (event_data) = 0;
1232  }
1233  }
1234 
1235  return 0;
1236 }
1237 
1238 /* *INDENT-OFF* */
1240  .function = ip4_sv_reass_walk_expired,
1241  .type = VLIB_NODE_TYPE_PROCESS,
1242  .name = "ip4-sv-reassembly-expire-walk",
1243  .format_trace = format_ip4_sv_reass_trace,
1244  .n_errors = ARRAY_LEN (ip4_sv_reass_error_strings),
1245  .error_strings = ip4_sv_reass_error_strings,
1246 
1247 };
1248 /* *INDENT-ON* */
1249 
1250 static u8 *
1251 format_ip4_sv_reass_key (u8 * s, va_list * args)
1252 {
1253  ip4_sv_reass_key_t *key = va_arg (*args, ip4_sv_reass_key_t *);
1254  s =
1255  format (s,
1256  "xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1257  key->xx_id, format_ip4_address, &key->src, format_ip4_address,
1258  &key->dst, clib_net_to_host_u16 (key->frag_id), key->proto);
1259  return s;
1260 }
1261 
1262 static u8 *
1263 format_ip4_sv_reass (u8 * s, va_list * args)
1264 {
1265  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
1266  ip4_sv_reass_t *reass = va_arg (*args, ip4_sv_reass_t *);
1267 
1268  s = format (s, "ID: %lu, key: %U trace_op_counter: %u\n",
1269  reass->id, format_ip4_sv_reass_key, &reass->key,
1270  reass->trace_op_counter);
1271 
1272  vlib_buffer_t *b;
1273  u32 *bip;
1274  u32 counter = 0;
1275  vec_foreach (bip, reass->cached_buffers)
1276  {
1277  u32 bi = *bip;
1278  do
1279  {
1280  b = vlib_get_buffer (vm, bi);
1281  s = format (s, " #%03u: bi: %u, ", counter, bi);
1282  ++counter;
1283  bi = b->next_buffer;
1284  }
1285  while (b->flags & VLIB_BUFFER_NEXT_PRESENT);
1286  }
1287  return s;
1288 }
1289 
1290 static clib_error_t *
1292  unformat_input_t * input,
1294 {
1296 
1297  vlib_cli_output (vm, "---------------------");
1298  vlib_cli_output (vm, "IP4 reassembly status");
1299  vlib_cli_output (vm, "---------------------");
1300  bool details = false;
1301  if (unformat (input, "details"))
1302  {
1303  details = true;
1304  }
1305 
1306  u32 sum_reass_n = 0;
1307  ip4_sv_reass_t *reass;
1309  const uword nthreads = vlib_num_workers () + 1;
1310  for (thread_index = 0; thread_index < nthreads; ++thread_index)
1311  {
1313  clib_spinlock_lock (&rt->lock);
1314  if (details)
1315  {
1316  /* *INDENT-OFF* */
1317  pool_foreach (reass, rt->pool) {
1318  vlib_cli_output (vm, "%U", format_ip4_sv_reass, vm, reass);
1319  }
1320  /* *INDENT-ON* */
1321  }
1322  sum_reass_n += rt->reass_n;
1323  clib_spinlock_unlock (&rt->lock);
1324  }
1325  vlib_cli_output (vm, "---------------------");
1326  vlib_cli_output (vm, "Current IP4 reassemblies count: %lu\n",
1327  (long unsigned) sum_reass_n);
1329  "Maximum configured concurrent shallow virtual IP4 reassemblies per worker-thread: %lu\n",
1330  (long unsigned) rm->max_reass_n);
1332  "Maximum configured amount of fragments per shallow "
1333  "virtual IP4 reassembly: %lu\n",
1334  (long unsigned) rm->max_reass_len);
1336  "Maximum configured shallow virtual IP4 reassembly timeout: %lums\n",
1337  (long unsigned) rm->timeout_ms);
1339  "Maximum configured shallow virtual IP4 reassembly expire walk interval: %lums\n",
1340  (long unsigned) rm->expire_walk_interval_ms);
1341  return 0;
1342 }
1343 
1344 /* *INDENT-OFF* */
1346  .path = "show ip4-sv-reassembly",
1347  .short_help = "show ip4-sv-reassembly [details]",
1348  .function = show_ip4_reass,
1349 };
1350 /* *INDENT-ON* */
1351 
1352 #ifndef CLIB_MARCH_VARIANT
1355 {
1357  enable_disable);
1358 }
1359 #endif /* CLIB_MARCH_VARIANT */
1360 
1361 
1362 #define foreach_ip4_sv_reass_handoff_error \
1363 _(CONGESTION_DROP, "congestion drop")
1364 
1365 
1366 typedef enum
1367 {
1368 #define _(sym,str) IP4_SV_REASSEMBLY_HANDOFF_ERROR_##sym,
1370 #undef _
1373 
1375 #define _(sym,string) string,
1377 #undef _
1378 };
1379 
1380 typedef struct
1381 {
1384 
1385 static u8 *
1387 {
1388  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1389  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1391  va_arg (*args, ip4_sv_reass_handoff_trace_t *);
1392 
1393  s =
1394  format (s, "ip4-sv-reassembly-handoff: next-worker %d",
1395  t->next_worker_index);
1396 
1397  return s;
1398 }
1399 
1403  vlib_frame_t * frame, bool is_feature)
1404 {
1406 
1408  u32 n_enq, n_left_from, *from;
1409  u16 thread_indices[VLIB_FRAME_SIZE], *ti;
1410  u32 fq_index;
1411 
1413  n_left_from = frame->n_vectors;
1415 
1416  b = bufs;
1417  ti = thread_indices;
1418 
1419  fq_index = (is_feature) ? rm->fq_feature_index : rm->fq_index;
1420 
1421  while (n_left_from > 0)
1422  {
1423  ti[0] = vnet_buffer (b[0])->ip.reass.owner_thread_index;
1424 
1425  if (PREDICT_FALSE
1426  ((node->flags & VLIB_NODE_FLAG_TRACE)
1427  && (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
1428  {
1430  vlib_add_trace (vm, node, b[0], sizeof (*t));
1431  t->next_worker_index = ti[0];
1432  }
1433 
1434  n_left_from -= 1;
1435  ti += 1;
1436  b += 1;
1437  }
1438  n_enq = vlib_buffer_enqueue_to_thread (vm, node, fq_index, from,
1439  thread_indices, frame->n_vectors, 1);
1440 
1441  if (n_enq < frame->n_vectors)
1442  vlib_node_increment_counter (vm, node->node_index,
1443  IP4_SV_REASSEMBLY_HANDOFF_ERROR_CONGESTION_DROP,
1444  frame->n_vectors - n_enq);
1445  return frame->n_vectors;
1446 }
1447 
1450  vlib_frame_t * frame)
1451 {
1453  false /* is_feature */ );
1454 }
1455 
1456 
1457 /* *INDENT-OFF* */
1459  .name = "ip4-sv-reassembly-handoff",
1460  .vector_size = sizeof (u32),
1462  .error_strings = ip4_sv_reass_handoff_error_strings,
1463  .format_trace = format_ip4_sv_reass_handoff_trace,
1464 
1465  .n_next_nodes = 1,
1466 
1467  .next_nodes = {
1468  [0] = "error-drop",
1469  },
1470 };
1471 /* *INDENT-ON* */
1472 
1473 
1474 /* *INDENT-OFF* */
1477  node,
1478  vlib_frame_t * frame)
1479 {
1481  true /* is_feature */ );
1482 }
1483 /* *INDENT-ON* */
1484 
1485 
1486 /* *INDENT-OFF* */
1488  .name = "ip4-sv-reass-feature-hoff",
1489  .vector_size = sizeof (u32),
1491  .error_strings = ip4_sv_reass_handoff_error_strings,
1492  .format_trace = format_ip4_sv_reass_handoff_trace,
1493 
1494  .n_next_nodes = 1,
1495 
1496  .next_nodes = {
1497  [0] = "error-drop",
1498  },
1499 };
1500 /* *INDENT-ON* */
1501 
1502 #ifndef CLIB_MARCH_VARIANT
1503 int
1505 {
1508  if (is_enable)
1509  {
1511  {
1513  return vnet_feature_enable_disable ("ip4-unicast",
1514  "ip4-sv-reassembly-feature",
1515  sw_if_index, 1, 0, 0);
1516  }
1518  }
1519  else
1520  {
1524  return vnet_feature_enable_disable ("ip4-unicast",
1525  "ip4-sv-reassembly-feature",
1526  sw_if_index, 0, 0, 0);
1527  }
1528  return 0;
1529 }
1530 
1531 uword
1533 {
1535  node_index);
1536 }
1537 
1538 int
1540  int is_enable)
1541 {
1544  if (is_enable)
1545  {
1547  {
1549  return vnet_feature_enable_disable ("ip4-output",
1550  "ip4-sv-reassembly-output-feature",
1551  sw_if_index, 1, 0, 0);
1552  }
1554  }
1555  else
1556  {
1560  return vnet_feature_enable_disable ("ip4-output",
1561  "ip4-sv-reassembly-output-feature",
1562  sw_if_index, 0, 0, 0);
1563  }
1564  return 0;
1565 }
1566 #endif
1567 
1568 /*
1569  * fd.io coding-style-patch-verification: ON
1570  *
1571  * Local Variables:
1572  * eval: (c-set-style "gnu")
1573  * End:
1574  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
IP4_SV_REASS_RC_OK
@ IP4_SV_REASS_RC_OK
Definition: ip4_sv_reass.c:40
vlib_buffer_t::next_buffer
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:149
ip4_sv_reass_main_t::max_reass_n
u32 max_reass_n
Definition: ip4_sv_reass.c:135
ip4_sv_reass_kv_t::v
ip4_sv_reass_val_t v
Definition: ip4_sv_reass.c:77
ip4_sv_reass_node_feature
vlib_node_registration_t ip4_sv_reass_node_feature
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_node_feature)
Definition: ip4_sv_reass.c:925
vlib_buffer_free
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:979
ip4_sv_reass_handoff_trace_t::next_worker_index
u32 next_worker_index
Definition: ip4_sv_reass.c:1382
vlib_num_workers
static u32 vlib_num_workers()
Definition: threads.h:333
ip4_sv_reass_key_t
Definition: ip4_sv_reass.c:45
IP4_SV_REASS_MAX_REASSEMBLIES_DEFAULT
#define IP4_SV_REASS_MAX_REASSEMBLIES_DEFAULT
Definition: ip4_sv_reass.c:34
while
while(n_left_from > 0)
Definition: nat44_ei_hairpinning.c:419
ip4_sv_reass_trace_t
Definition: ip4_sv_reass.c:184
ip4_sv_reass_per_thread_t::lru_last
u32 lru_last
Definition: ip4_sv_reass.c:122
ip4_sv_reass_main_t::vlib_main
vlib_main_t * vlib_main
Definition: ip4_sv_reass.c:143
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
ip4_sv_reass_custom_register_next_node
uword ip4_sv_reass_custom_register_next_node(uword node_index)
Definition: ip4_sv_reass.c:1532
bufs
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:717
ip4_sv_reass_walk_expired
static uword ip4_sv_reass_walk_expired(vlib_main_t *vm, CLIB_UNUSED(vlib_node_runtime_t *node), CLIB_UNUSED(vlib_frame_t *f))
Definition: ip4_sv_reass.c:1166
ip4_sv_reass_update
static ip4_sv_reass_rc_t ip4_sv_reass_update(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_sv_reass_main_t *rm, ip4_header_t *ip0, ip4_sv_reass_t *reass, u32 bi0)
Definition: ip4_sv_reass.c:381
u8_ptr_add
#define u8_ptr_add(ptr, index)
Definition: ip_types.h:56
ip4_sv_reass_t::l4_src_port
u16 l4_src_port
Definition: ip4_sv_reass.c:105
vlib_buffer_enqueue_to_thread
static_always_inline u32 vlib_buffer_enqueue_to_thread(vlib_main_t *vm, vlib_node_runtime_t *node, u32 frame_queue_index, u32 *buffer_indices, u16 *thread_indices, u32 n_packets, int drop_on_congestion)
Definition: buffer_node.h:383
ip4_sv_reass_t::last_heard
f64 last_heard
Definition: ip4_sv_reass.c:87
vlib_prefetch_buffer_header
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:231
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
ip4_sv_reass_trace_t::ip_proto
u8 ip_proto
Definition: ip4_sv_reass.c:189
ip4_sv_reass_main_t::vnet_main
vnet_main_t * vnet_main
Definition: ip4_sv_reass.c:144
IP4_SV_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT
#define IP4_SV_REASS_MAX_REASSEMBLY_LENGTH_DEFAULT
Definition: ip4_sv_reass.c:35
ip4_sv_reass_add_trace
static void ip4_sv_reass_add_trace(vlib_main_t *vm, vlib_node_runtime_t *node, ip4_sv_reass_t *reass, u32 bi, ip4_sv_reass_trace_operation_e action, u32 ip_proto, u16 l4_src_port, u16 l4_dst_port)
Definition: ip4_sv_reass.c:232
REASS_FINISH
@ REASS_FINISH
Definition: ip4_sv_reass.c:179
ip4_sv_reass_trace_t::op_id
u32 op_id
Definition: ip4_sv_reass.c:188
vlib_node_add_next
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1177
ip4_sv_reass_main_t::hash
clib_bihash_16_8_t hash
Definition: ip4_sv_reass.c:138
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
ip_proto
ip_proto
Definition: ip_types.api:75
ip4_sv_reass_main_t::ip4_drop_idx
u32 ip4_drop_idx
Definition: ip4_sv_reass.c:147
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
show_ip4_sv_reass_cmd
static vlib_cli_command_t show_ip4_sv_reass_cmd
(constructor) VLIB_CLI_COMMAND (show_ip4_sv_reass_cmd)
Definition: ip4_sv_reass.c:1345
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1104
IP4_SV_REASSEMBLY_NEXT_INPUT
@ IP4_SV_REASSEMBLY_NEXT_INPUT
Definition: ip4_sv_reass.c:170
ip4_sv_reass_main_t::timeout_ms
u32 timeout_ms
Definition: ip4_sv_reass.c:129
ip4_sv_reass_feature_handoff_node
vlib_node_registration_t ip4_sv_reass_feature_handoff_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_feature_handoff_node)
Definition: ip4_sv_reass.c:1487
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
f
vlib_frame_t * f
Definition: interface_output.c:1098
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
ip4_sv_reass_kv_t::kv
clib_bihash_kv_16_8_t kv
Definition: ip4_sv_reass.c:79
show_ip4_reass
static clib_error_t * show_ip4_reass(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
Definition: ip4_sv_reass.c:1291
ip4_sv_reass_t
Definition: ip4_sv_reass.c:82
format_ip4_sv_reass_handoff_trace
static u8 * format_ip4_sv_reass_handoff_trace(u8 *s, va_list *args)
Definition: ip4_sv_reass.c:1386
tcp_header_t
struct _tcp_header tcp_header_t
vlib_get_buffers
vlib_get_buffers(vm, from, b, n_left_from)
ip4_sv_reass_t::icmp_type_or_tcp_flags
u8 icmp_type_or_tcp_flags
Definition: ip4_sv_reass.c:101
next
u16 * next
Definition: nat44_ei_out2in.c:718
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
ip4_sv_reass_main_t::fq_index
u32 fq_index
Worker handoff.
Definition: ip4_sv_reass.c:151
ip4_sv_reass_handoff_error_strings
static char * ip4_sv_reass_handoff_error_strings[]
Definition: ip4_sv_reass.c:1374
IP4_SV_REASSEMBLY_N_NEXT
@ IP4_SV_REASSEMBLY_N_NEXT
Definition: ip4_sv_reass.c:173
ip4_sv_reass_get
vnet_api_error_t ip4_sv_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip4 reassembly configuration
Definition: ip4_sv_reass.c:1106
vlib_cli_command_t::path
char * path
Definition: cli.h:96
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
ip4_sv_reass_set_params
static void ip4_sv_reass_set_params(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
Definition: ip4_sv_reass.c:1056
ip4_get_fragment_offset_bytes
static int ip4_get_fragment_offset_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:184
u16
unsigned short u16
Definition: types.h:57
REASS_FRAGMENT_FORWARD
@ REASS_FRAGMENT_FORWARD
Definition: ip4_sv_reass.c:180
ip4_sv_reass_key_t::src
ip4_address_t src
Definition: ip4_sv_reass.c:52
ip4_rehash_cb_ctx
Definition: ip4_full_reass.c:1388
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
IP4_SV_REASSEMBLY_HANDOFF_N_ERROR
@ IP4_SV_REASSEMBLY_HANDOFF_N_ERROR
Definition: ip4_sv_reass.c:1371
ip4_sv_reass_key_t::xx_id
u32 xx_id
Definition: ip4_sv_reass.c:51
fifo.h
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
node_index
node node_index
Definition: interface_output.c:440
IP4_SV_REASS_RC_TOO_MANY_FRAGMENTS
@ IP4_SV_REASS_RC_TOO_MANY_FRAGMENTS
Definition: ip4_sv_reass.c:41
ip4_sv_reass_event_t
ip4_sv_reass_event_t
Definition: ip4_sv_reass.c:1032
ip4_sv_reass_main_t::output_feature_use_refcount_per_intf
u32 * output_feature_use_refcount_per_intf
Definition: ip4_sv_reass.c:158
vlib_buffer_enqueue_to_next
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
unformat_input_t
struct _unformat_input_t unformat_input_t
ip4_sv_reass_output_enable_disable_with_refcnt
int ip4_sv_reass_output_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
Definition: ip4_sv_reass.c:1539
ip4_sv_reass_t::is_complete
bool is_complete
Definition: ip4_sv_reass.c:98
vlib_frame_t
Definition: node.h:372
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
ip4_header_t
Definition: ip4_packet.h:87
error
Definition: cJSON.c:88
ip4_sv_reass_rc_t
ip4_sv_reass_rc_t
Definition: ip4_sv_reass.c:38
ip4_header_t::length
u16 length
Definition: ip4_packet.h:99
key
typedef key
Definition: ipsec_types.api:91
ip4_sv_reass_set
vnet_api_error_t ip4_sv_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip4 reassembly configuration
Definition: ip4_sv_reass.c:1068
vlib_frame_queue_main_init
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
Definition: threads.c:1561
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
vec_elt
#define vec_elt(v, i)
Get vector value at index i.
Definition: vec_bootstrap.h:210
IP4_SV_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS
#define IP4_SV_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS
Definition: ip4_sv_reass.c:33
ip4_sv_reass_init
static void ip4_sv_reass_init(ip4_sv_reass_t *reass)
Definition: ip4_sv_reass.c:303
ip4_get_port
static u16 ip4_get_port(ip4_header_t *ip, u8 sender)
Get TCP/UDP port number or ICMP id from IPv4 packet.
Definition: ip4_to_ip6.h:51
ip4_main_t::fib_index_by_sw_if_index
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:120
vlib_process_get_events
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:583
ti
u32 ti
Definition: interface_output.c:425
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
format_ip4_sv_reass
static u8 * format_ip4_sv_reass(u8 *s, va_list *args)
Definition: ip4_sv_reass.c:1263
ip4_sv_reass_node_output_feature
vlib_node_registration_t ip4_sv_reass_node_output_feature
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_node_output_feature)
Definition: ip4_sv_reass.c:961
format_ip4_sv_reass_trace
static u8 * format_ip4_sv_reass_trace(u8 *s, va_list *args)
Definition: ip4_sv_reass.c:198
ip4_sv_reass_key_t::unused
u8 unused
Definition: ip4_sv_reass.c:56
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
ip4_sv_reass.h
IPv4 shallow virtual reassembly.
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
ip4_sv_reass_val_t::reass_index
u32 reass_index
Definition: ip4_sv_reass.c:66
VLIB_NODE_FLAG_TRACE
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:291
ip4_sv_reass_main_t::feature_use_refcount_per_intf
u32 * feature_use_refcount_per_intf
Definition: ip4_sv_reass.c:155
ip4_sv_reass_key_t::proto
u8 proto
Definition: ip4_sv_reass.c:55
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ip4_sv_reass_trace_operation_e
ip4_sv_reass_trace_operation_e
Definition: ip4_sv_reass.c:176
vnet_feature_next
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:322
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
ip4_sv_reass_t::ip_proto
u8 ip_proto
Definition: ip4_sv_reass.c:100
ip4_get_fragment_offset
static u16 ip4_get_fragment_offset(const ip4_header_t *i)
Definition: ip4_packet.h:155
foreach_ip4_sv_reass_handoff_error
#define foreach_ip4_sv_reass_handoff_error
Definition: ip4_sv_reass.c:1362
clib_spinlock_lock
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
Definition: lock.h:82
clib_bihash_copied
__clib_export void clib_bihash_copied(void *dst, void *src)
Definition: bihash_all_vector.c:36
ip4_sv_reass_t::l4_dst_port
u16 l4_dst_port
Definition: ip4_sv_reass.c:107
ip4_sv_reass_free
static void ip4_sv_reass_free(vlib_main_t *vm, ip4_sv_reass_main_t *rm, ip4_sv_reass_per_thread_t *rt, ip4_sv_reass_t *reass)
Definition: ip4_sv_reass.c:267
clib_spinlock_s
Definition: lock.h:51
ip4_sv_reass_node
vlib_node_registration_t ip4_sv_reass_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_node)
Definition: ip4_sv_reass.c:898
IP4_SV_REASS_TIMEOUT_DEFAULT_MS
#define IP4_SV_REASS_TIMEOUT_DEFAULT_MS
Definition: ip4_sv_reass.c:32
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
uword
u64 uword
Definition: types.h:112
ip4_sv_reass_main_t::timeout
f64 timeout
Definition: ip4_sv_reass.c:130
ip4_sv_reass_t::lru_next
u32 lru_next
Definition: ip4_sv_reass.c:111
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
ip4_sv_reass_trace_t::reass_id
u32 reass_id
Definition: ip4_sv_reass.c:187
IP4_SV_REASSEMBLY_NEXT_HANDOFF
@ IP4_SV_REASSEMBLY_NEXT_HANDOFF
Definition: ip4_sv_reass.c:172
ip4_sv_reass_init_function
static clib_error_t * ip4_sv_reass_init_function(vlib_main_t *vm)
Definition: ip4_sv_reass.c:1117
f64
double f64
Definition: types.h:142
ip4_sv_reass_handoff_node_inline
static uword ip4_sv_reass_handoff_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature)
Definition: ip4_sv_reass.c:1401
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
ip4_sv_reass_t::next_index
u32 next_index
Definition: ip4_sv_reass.c:108
ip4_sv_reass_per_thread_t::lock
clib_spinlock_t lock
Definition: ip4_sv_reass.c:119
ip4_address_t
Definition: ip4_packet.h:50
ip4_sv_reass_kv_t::k
ip4_sv_reass_key_t k
Definition: ip4_sv_reass.c:76
ip4_sv_reass_per_thread_t
Definition: ip4_sv_reass.c:114
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
ip4_header_t::dst_address
ip4_address_t dst_address
Definition: ip4_packet.h:125
ip4_sv_reass_trace_t::action
ip4_sv_reass_trace_operation_e action
Definition: ip4_sv_reass.c:186
ip4_sv_reass_main_t::expire_walk_interval_ms
u32 expire_walk_interval_ms
Definition: ip4_sv_reass.c:131
ip4_header_t::fragment_id
u16 fragment_id
Definition: ip4_packet.h:102
ip4_get_fragment_more
static u16 ip4_get_fragment_more(const ip4_header_t *i)
Definition: ip4_packet.h:161
ip4_sv_reass_t::cached_buffers
u32 * cached_buffers
Definition: ip4_sv_reass.c:96
ip4_sv_reass_expire_node
vlib_node_registration_t ip4_sv_reass_expire_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_expire_node)
Definition: ip4_sv_reass.c:1239
ip4_sv_reass_t::lru_prev
u32 lru_prev
Definition: ip4_sv_reass.c:110
ip4_sv_reass_key_t::frag_id
u16 frag_id
Definition: ip4_sv_reass.c:54
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vlib_validate_buffer_enqueue_x1
#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:224
index
u32 index
Definition: flow_types.api:221
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
vlib_get_node_by_name
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
ip4_header_t::src_address
ip4_address_t src_address
Definition: ip4_packet.h:125
ip4_sv_reass_main_t
Definition: ip4_sv_reass.c:126
pool_foreach_index
#define pool_foreach_index(i, v)
Definition: pool.h:572
ip4_sv_reass_main_t::ip4_sv_reass_expire_node_idx
u32 ip4_sv_reass_expire_node_idx
Definition: ip4_sv_reass.c:148
clib_bihash_kv_16_8_t
Definition: bihash_16_8.h:40
MSEC_PER_SEC
#define MSEC_PER_SEC
Definition: ip4_sv_reass.c:31
ip4_sv_reass_val_t::as_u64
u64 as_u64
Definition: ip4_sv_reass.c:69
ip4_sv_reass_key_t::as_u64
u64 as_u64[2]
Definition: ip4_sv_reass.c:58
u64
unsigned long u64
Definition: types.h:89
vlib_trace_main_t::trace_buffer_pool
vlib_trace_header_t ** trace_buffer_pool
Definition: trace.h:86
ip4_sv_reass_per_thread_t::pool
ip4_sv_reass_t * pool
Definition: ip4_sv_reass.c:116
vlib_process_wait_for_event_or_clock
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:755
ip4_sv_reass_handoff_node
vlib_node_registration_t ip4_sv_reass_handoff_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_handoff_node)
Definition: ip4_sv_reass.c:1458
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
clib_bihash_kv_16_8_t::key
u64 key[2]
Definition: bihash_16_8.h:42
ip.h
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
ip4_sv_reass_error_strings
static char * ip4_sv_reass_error_strings[]
Definition: ip4_sv_reass.c:882
ip4_sv_reass_t::key
ip4_sv_reass_key_t key
Definition: ip4_sv_reass.c:85
VNET_FEATURE_INIT
VNET_FEATURE_INIT(ip4_sv_reass_feature)
ip4_sv_reass_get_nbuckets
static u32 ip4_sv_reass_get_nbuckets()
Definition: ip4_sv_reass.c:1015
ip4_sv_reass_per_thread_t::id_counter
u32 id_counter
Definition: ip4_sv_reass.c:118
ip4_sv_reass_key_t::dst
ip4_address_t dst
Definition: ip4_sv_reass.c:53
clib_prefetch_load
static_always_inline void clib_prefetch_load(void *p)
Definition: cache.h:92
ip4_sv_reass_main
ip4_sv_reass_main_t ip4_sv_reass_main
Definition: ip4_sv_reass.c:165
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
format_ip4_sv_reass_key
static u8 * format_ip4_sv_reass_key(u8 *s, va_list *args)
Definition: ip4_sv_reass.c:1251
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
ip4_sv_reass_per_thread_t::reass_n
u32 reass_n
Definition: ip4_sv_reass.c:117
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
as_u64
u64 as_u64
Definition: bihash_doc.h:63
n_vectors
return frame n_vectors
Definition: nat44_ei_hairpinning.c:488
ip4_sv_reass_val_t::thread_index
u32 thread_index
Definition: ip4_sv_reass.c:67
ip4_sv_reass_main_t::per_thread_data
ip4_sv_reass_per_thread_t * per_thread_data
Definition: ip4_sv_reass.c:140
ip4_sv_reass_handoff_trace_t
Definition: ip4_sv_reass.c:1380
clib_spinlock_unlock
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
Definition: lock.h:121
bihash_16_8.h
ip4_sv_reass_find_or_create
static ip4_sv_reass_t * ip4_sv_reass_find_or_create(vlib_main_t *vm, ip4_sv_reass_main_t *rm, ip4_sv_reass_per_thread_t *rt, ip4_sv_reass_kv_t *kv, u8 *do_handoff)
Definition: ip4_sv_reass.c:310
ip4_sv_reass_t::trace_op_counter
u32 trace_op_counter
Definition: ip4_sv_reass.c:91
vnet_feature_enable_disable
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: pnat_test_stubs.h:50
vec.h
now
f64 now
Definition: nat44_ei_out2in.c:710
foreach_ip4_error
#define foreach_ip4_error
Definition: ip4_error.h:43
slow_path
static u32 slow_path(nat44_ei_main_t *nm, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t i2o_addr, u16 i2o_port, u32 rx_fib_index0, nat_protocol_t nat_proto, nat44_ei_session_t **sessionp, vlib_node_runtime_t *node, u32 next0, u32 thread_index, f64 now)
Definition: nat44_ei_in2out.c:304
ip4_sv_reass_trace_t::l4_dst_port
u16 l4_dst_port
Definition: ip4_sv_reass.c:191
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
IP4_SV_REASS_HT_LOAD_FACTOR
#define IP4_SV_REASS_HT_LOAD_FACTOR
Definition: ip4_sv_reass.c:36
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
VNET_FEATURES
#define VNET_FEATURES(...)
Definition: feature.h:470
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
ip4_sv_reass_t::min_fragment_length
u16 min_fragment_length
Definition: ip4_sv_reass.c:93
ip4_rehash_cb
static int ip4_rehash_cb(clib_bihash_kv_16_8_t *kv, void *_ctx)
Definition: ip4_sv_reass.c:1045
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:419
ip
vl_api_address_t ip
Definition: l2.api:558
IP4_SV_REASSEMBLY_NEXT_DROP
@ IP4_SV_REASSEMBLY_NEXT_DROP
Definition: ip4_sv_reass.c:171
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
ip4_sv_reass_t::id
u64 id
Definition: ip4_sv_reass.c:89
i
int i
Definition: flowhash_template.h:376
ip4_to_ip6.h
IPv4 to IPv6 translation.
ip4_sv_reass_main_t::max_reass_len
u32 max_reass_len
Definition: ip4_sv_reass.c:133
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
pool_alloc
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
Definition: pool.h:367
nexts
u16 nexts[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:718
ip4_header_bytes
static int ip4_header_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:190
ip4_sv_reass_t::tcp_seq_number
u32 tcp_seq_number
Definition: ip4_sv_reass.c:103
ip4_sv_reass_handoff_error_t
ip4_sv_reass_handoff_error_t
Definition: ip4_sv_reass.c:1366
ip4_sv_reass_t::tcp_ack_number
u32 tcp_ack_number
Definition: ip4_sv_reass.c:102
IP4_EVENT_CONFIG_CHANGED
@ IP4_EVENT_CONFIG_CHANGED
Definition: ip4_sv_reass.c:1034
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
ip4_sv_reass_per_thread_t::lru_first
u32 lru_first
Definition: ip4_sv_reass.c:121
ip4_sv_reass_val_t
Definition: ip4_sv_reass.c:62
vnet.h
vlib_main_t::trace_main
vlib_trace_main_t trace_main
Definition: main.h:176
vlib_node_runtime_t
Definition: node.h:454
ip4_sv_reass_trace_t::l4_src_port
u16 l4_src_port
Definition: ip4_sv_reass.c:190
ip4_sv_reass_main_t::fq_feature_index
u32 fq_feature_index
Definition: ip4_sv_reass.c:152
IP4_SV_REASS_RC_UNSUPP_IP_PROTO
@ IP4_SV_REASS_RC_UNSUPP_IP_PROTO
Definition: ip4_sv_reass.c:42
vlib_buffer_get_trace_index
static u32 vlib_buffer_get_trace_index(vlib_buffer_t *b)
Extract the trace (pool) index from a trace handle.
Definition: buffer.h:416
vlib_cli_command_t
Definition: cli.h:92
from
from
Definition: nat44_ei_hairpinning.c:415
ip4_sv_reass_inline
static uword ip4_sv_reass_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, bool is_feature, bool is_output_feature, bool is_custom)
Definition: ip4_sv_reass.c:432
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
ip4_sv_reass_next_t
ip4_sv_reass_next_t
Definition: ip4_sv_reass.c:168
action
vl_api_mac_event_action_t action
Definition: l2.api:211
REASS_FRAGMENT_CACHE
@ REASS_FRAGMENT_CACHE
Definition: ip4_sv_reass.c:178
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
ip4_sv_reass_enable_disable_with_refcnt
int ip4_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
Definition: ip4_sv_reass.c:1504
vlib_get_next_frame
#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:395
ip4_sv_reass_custom_node
vlib_node_registration_t ip4_sv_reass_custom_node
(constructor) VLIB_REGISTER_NODE (ip4_sv_reass_custom_node)
Definition: ip4_sv_reass.c:987
ip4_sv_reass_enable_disable
vnet_api_error_t ip4_sv_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
Definition: ip4_sv_reass.c:1354
REASS_PASSTHROUGH
@ REASS_PASSTHROUGH
Definition: ip4_sv_reass.c:181
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
ip4_sv_reass_kv_t
Definition: ip4_sv_reass.c:72
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
ip4_header_t::protocol
u8 protocol
Definition: ip4_packet.h:115
vnet_api_error_t
vnet_api_error_t
Definition: api_errno.h:162
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105