FD.io VPP  v19.08.2-294-g37e99c22d
Vector Packet Processing
ip6_fib.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/fib/ip6_fib.h>
17 #include <vnet/fib/fib_table.h>
18 #include <vnet/dpo/ip6_ll_dpo.h>
19 
20 #include <vppinfra/bihash_24_8.h>
22 
23 static void
25 {
26  fib_prefix_t pfx = {
28  .fp_len = 0,
29  .fp_addr = {
30  .ip6 = {
31  { 0, 0, },
32  },
33  }
34  };
35 
36  /*
37  * Add the default route.
38  */
40  &pfx,
43 
44  /*
45  * all link local via the link local lookup DPO
46  */
47  pfx.fp_addr.ip6.as_u64[0] = clib_host_to_net_u64 (0xFE80000000000000ULL);
48  pfx.fp_addr.ip6.as_u64[1] = 0;
49  pfx.fp_len = 10;
51  &pfx,
54  ip6_ll_dpo_get());
55 }
56 
57 static u32
61  u8 *desc)
62 {
63  fib_table_t *fib_table;
64  ip6_fib_t *v6_fib;
65 
66  pool_get(ip6_main.fibs, fib_table);
68 
69  clib_memset(fib_table, 0, sizeof(*fib_table));
70  clib_memset(v6_fib, 0, sizeof(*v6_fib));
71 
72  ASSERT((fib_table - ip6_main.fibs) ==
73  (v6_fib - ip6_main.v6_fibs));
74 
75  fib_table->ft_proto = FIB_PROTOCOL_IP6;
76  fib_table->ft_index =
77  v6_fib->index =
78  (fib_table - ip6_main.fibs);
79 
80  hash_set(ip6_main.fib_index_by_table_id, table_id, fib_table->ft_index);
81 
82  fib_table->ft_table_id =
83  v6_fib->table_id =
84  table_id;
86  fib_table->ft_flags = flags;
87  fib_table->ft_desc = desc;
88 
89  vnet_ip6_fib_init(fib_table->ft_index);
90  fib_table_lock(fib_table->ft_index, FIB_PROTOCOL_IP6, src);
91 
92  return (fib_table->ft_index);
93 }
94 
95 u32
98 {
99  uword * p;
100 
101  p = hash_get (ip6_main.fib_index_by_table_id, table_id);
102  if (NULL == p)
103  return create_fib_with_table_id(table_id, src,
105  NULL);
106 
107  fib_table_lock(p[0], FIB_PROTOCOL_IP6, src);
108 
109  return (p[0]);
110 }
111 
112 u32
115  u8 *desc)
116 {
117  return (create_fib_with_table_id(~0, src, flags, desc));
118 }
119 
120 void
122 {
123  /*
124  * all link local first ...
125  */
126  fib_prefix_t pfx = {
128  .fp_len = 10,
129  .fp_addr = {
130  .ip6 = {
131  .as_u8 = {
132  [0] = 0xFE,
133  [1] = 0x80,
134  },
135  },
136  }
137  };
138  fib_table_entry_delete(fib_index,
139  &pfx,
141 
142  /*
143  * ... then the default route.
144  */
145  pfx.fp_addr.ip6.as_u64[0] = 0;
146  pfx.fp_len = 00;
148  &pfx,
150 
151  fib_table_t *fib_table = fib_table_get(fib_index, FIB_PROTOCOL_IP6);
152  fib_source_t source;
153 
154  /*
155  * validate no more routes.
156  */
157  ASSERT(0 == fib_table->ft_total_route_counts);
158  FOR_EACH_FIB_SOURCE(source)
159  {
160  ASSERT(0 == fib_table->ft_src_route_counts[source]);
161  }
162 
163  if (~0 != fib_table->ft_table_id)
164  {
166  }
168  pool_put(ip6_main.fibs, fib_table);
169 }
170 
173  const ip6_address_t *addr,
174  u32 len)
175 {
178  int i, n_p, rv;
179  u64 fib;
180 
183 
184  kv.key[0] = addr->as_u64[0];
185  kv.key[1] = addr->as_u64[1];
186  fib = ((u64)((fib_index))<<32);
187 
188  /*
189  * start search from a mask length same length or shorter.
190  * we don't want matches longer than the mask passed
191  */
192  i = 0;
193  while (i < n_p && table->prefix_lengths_in_search_order[i] > len)
194  {
195  i++;
196  }
197 
198  for (; i < n_p; i++)
199  {
200  int dst_address_length = table->prefix_lengths_in_search_order[i];
201  ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
202 
203  ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
204  //As lengths are decreasing, masks are increasingly specific.
205  kv.key[0] &= mask->as_u64[0];
206  kv.key[1] &= mask->as_u64[1];
207  kv.key[2] = fib | dst_address_length;
208 
209  rv = clib_bihash_search_inline_2_24_8(&table->ip6_hash, &kv, &value);
210  if (rv == 0)
211  return value.value;
212  }
213 
214  return (FIB_NODE_INDEX_INVALID);
215 }
216 
219  const ip6_address_t *addr,
220  u32 len)
221 {
224  ip6_address_t *mask;
225  u64 fib;
226  int rv;
227 
229  mask = &ip6_main.fib_masks[len];
230  fib = ((u64)((fib_index))<<32);
231 
232  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
233  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
234  kv.key[2] = fib | len;
235 
236  rv = clib_bihash_search_inline_2_24_8(&table->ip6_hash, &kv, &value);
237  if (rv == 0)
238  return value.value;
239 
240  return (FIB_NODE_INDEX_INVALID);
241 }
242 
243 static void
245 {
246  u8 *old, *prefix_lengths_in_search_order = NULL;
247  int i;
248 
249  /*
250  * build the list in a scratch space then cutover so the workers
251  * can continue uninterrupted.
252  */
253  old = table->prefix_lengths_in_search_order;
254 
255  /* Note: bitmap reversed so this is in fact a longest prefix match */
257  ({
258  int dst_address_length = 128 - i;
259  vec_add1(prefix_lengths_in_search_order, dst_address_length);
260  }));
261 
262  table->prefix_lengths_in_search_order = prefix_lengths_in_search_order;
263 
264  /*
265  * let the workers go once round the track before we free the old set
266  */
268  vec_free(old);
269 }
270 
271 void
273  const ip6_address_t *addr,
274  u32 len)
275 {
278  ip6_address_t *mask;
279  u64 fib;
280 
282  mask = &ip6_main.fib_masks[len];
283  fib = ((u64)((fib_index))<<32);
284 
285  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
286  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
287  kv.key[2] = fib | len;
288 
289  clib_bihash_add_del_24_8(&table->ip6_hash, &kv, 0);
290 
291  /* refcount accounting */
292  ASSERT (table->dst_address_length_refcounts[len] > 0);
293  if (--table->dst_address_length_refcounts[len] == 0)
294  {
297  128 - len, 0);
299  }
300 }
301 
302 void
304  const ip6_address_t *addr,
305  u32 len,
306  fib_node_index_t fib_entry_index)
307 {
310  ip6_address_t *mask;
311  u64 fib;
312 
314  mask = &ip6_main.fib_masks[len];
315  fib = ((u64)((fib_index))<<32);
316 
317  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
318  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
319  kv.key[2] = fib | len;
320  kv.value = fib_entry_index;
321 
322  clib_bihash_add_del_24_8(&table->ip6_hash, &kv, 1);
323 
324  if (0 == table->dst_address_length_refcounts[len]++)
325  {
328  128 - len, 1);
330  }
331 }
332 
335  const ip6_address_t * dst)
336 {
337  u32 fib_index = vec_elt (im->fib_index_by_sw_if_index, sw_if_index);
338  return ip6_fib_table_fwding_lookup(fib_index, dst);
339 }
340 
341 u32
343 {
344  if (sw_if_index >= vec_len(ip6_main.fib_index_by_sw_if_index))
345  {
346  /*
347  * This is the case for interfaces that are not yet mapped to
348  * a IP table
349  */
350  return (~0);
351  }
352  return (ip6_main.fib_index_by_sw_if_index[sw_if_index]);
353 }
354 
355 void
357  const ip6_address_t *addr,
358  u32 len,
359  const dpo_id_t *dpo)
360 {
363  ip6_address_t *mask;
364  u64 fib;
365 
367  mask = &ip6_main.fib_masks[len];
368  fib = ((u64)((fib_index))<<32);
369 
370  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
371  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
372  kv.key[2] = fib | len;
373  kv.value = dpo->dpoi_index;
374 
375  clib_bihash_add_del_24_8(&table->ip6_hash, &kv, 1);
376 
377  if (0 == table->dst_address_length_refcounts[len]++)
378  {
381  128 - len, 1);
383  }
384 }
385 
386 void
388  const ip6_address_t *addr,
389  u32 len,
390  const dpo_id_t *dpo)
391 {
394  ip6_address_t *mask;
395  u64 fib;
396 
398  mask = &ip6_main.fib_masks[len];
399  fib = ((u64)((fib_index))<<32);
400 
401  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
402  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
403  kv.key[2] = fib | len;
404  kv.value = dpo->dpoi_index;
405 
406  clib_bihash_add_del_24_8(&table->ip6_hash, &kv, 0);
407 
408  /* refcount accounting */
409  ASSERT (table->dst_address_length_refcounts[len] > 0);
410  if (--table->dst_address_length_refcounts[len] == 0)
411  {
414  128 - len, 0);
416  }
417 }
418 
419 /**
420  * @brief Context when walking the IPv6 table. Since all VRFs are in the
421  * same hash table, we need to filter only those we need as we walk
422  */
423 typedef struct ip6_fib_walk_ctx_t_
424 {
427  void *i6w_ctx;
431 
432 static int
434  void *arg)
435 {
436  ip6_fib_walk_ctx_t *ctx = arg;
438 
439  if ((kvp->key[2] >> 32) == ctx->i6w_fib_index)
440  {
441  key.as_u64[0] = kvp->key[0];
442  key.as_u64[1] = kvp->key[1];
443 
445  &key,
446  &ctx->i6w_root.fp_addr.ip6,
447  ctx->i6w_root.fp_len))
448  {
449  const fib_prefix_t *sub_tree;
450  int skip = 0;
451 
452  /*
453  * exclude sub-trees the walk does not want to explore
454  */
455  vec_foreach(sub_tree, ctx->i6w_sub_trees)
456  {
458  &key,
459  &sub_tree->fp_addr.ip6,
460  sub_tree->fp_len))
461  {
462  skip = 1;
463  break;
464  }
465  }
466 
467  if (!skip)
468  {
469  switch (ctx->i6w_fn(kvp->value, ctx->i6w_ctx))
470  {
472  break;
474  fib_prefix_t pfx = {
476  .fp_len = kvp->key[2] & 0xffffffff,
477  .fp_addr.ip6 = key,
478  };
479  vec_add1(ctx->i6w_sub_trees, pfx);
480  break;
481  }
482  case FIB_TABLE_WALK_STOP:
483  goto done;
484  }
485  }
486  }
487  }
488 done:
489 
490  return (1);
491 }
492 
493 void
496  void *arg)
497 {
499  .i6w_fib_index = fib_index,
500  .i6w_fn = fn,
501  .i6w_ctx = arg,
502  .i6w_root = {
503  .fp_proto = FIB_PROTOCOL_IP6,
504  },
505  .i6w_sub_trees = NULL,
506  };
507 
508  clib_bihash_foreach_key_value_pair_24_8(
511  &ctx);
512 
513  vec_free(ctx.i6w_sub_trees);
514 }
515 
516 void
518  const fib_prefix_t *root,
520  void *arg)
521 {
523  .i6w_fib_index = fib_index,
524  .i6w_fn = fn,
525  .i6w_ctx = arg,
526  .i6w_root = *root,
527  };
528 
529  clib_bihash_foreach_key_value_pair_24_8(
532  &ctx);
533 }
534 
535 typedef struct ip6_fib_show_ctx_t_ {
538 
539 static fib_table_walk_rc_t
541  void *arg)
542 {
543  ip6_fib_show_ctx_t *ctx = arg;
544 
545  vec_add1(ctx->entries, fib_entry_index);
546 
547  return (FIB_TABLE_WALK_CONTINUE);
548 }
549 
550 static void
552  vlib_main_t * vm)
553 {
554  fib_node_index_t *fib_entry_index;
556  .entries = NULL,
557  };
558 
561 
562  vec_foreach(fib_entry_index, ctx.entries)
563  {
564  vlib_cli_output(vm, "%U",
566  *fib_entry_index,
568  }
569 
570  vec_free(ctx.entries);
571 }
572 
573 static void
575  vlib_main_t * vm,
577  u32 mask_len,
578  int detail)
579 {
580  vlib_cli_output(vm, "%U",
582  ip6_fib_table_lookup(fib->index, address, mask_len),
583  (detail ?
586 }
587 
588 u8 *
589 format_ip6_fib_table_memory (u8 * s, va_list * args)
590 {
591  uword bytes_inuse;
592 
593  bytes_inuse = (alloc_arena_next(&(ip6_main.ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash)) +
594  alloc_arena_next(&(ip6_main.ip6_table[IP6_FIB_TABLE_FWDING].ip6_hash)));
595 
596  s = format(s, "%=30s %=6d %=12ld\n",
597  "IPv6 unicast",
599  bytes_inuse);
600  return (s);
601 }
602 
603 typedef struct {
605  u64 count_by_prefix_length[129];
607 
608 static void
610  void *arg)
611 {
613  int mask_width;
614 
615  if ((kvp->key[2]>>32) != ap->fib_index)
616  return;
617 
618  mask_width = kvp->key[2] & 0xFF;
619 
621 }
622 
623 static clib_error_t *
625  unformat_input_t * input,
626  vlib_cli_command_t * cmd)
627 {
629  ip6_main_t * im6 = &ip6_main;
630  fib_table_t *fib_table;
631  ip6_fib_t * fib;
632  int verbose, matching;
633  ip6_address_t matching_address;
634  u32 mask_len = 128;
635  int table_id = -1, fib_index = ~0;
636  int detail = 0;
637  int hash = 0;
638 
639  verbose = 1;
640  matching = 0;
641 
643  {
644  if (unformat (input, "brief") ||
645  unformat (input, "summary") ||
646  unformat (input, "sum"))
647  verbose = 0;
648 
649  else if (unformat (input, "detail") ||
650  unformat (input, "det"))
651  detail = 1;
652 
653  else if (unformat (input, "hash") ||
654  unformat (input, "mem") ||
655  unformat (input, "memory"))
656  hash = 1;
657 
658  else if (unformat (input, "%U/%d",
659  unformat_ip6_address, &matching_address, &mask_len))
660  matching = 1;
661 
662  else if (unformat (input, "%U", unformat_ip6_address, &matching_address))
663  matching = 1;
664 
665  else if (unformat (input, "table %d", &table_id))
666  ;
667  else if (unformat (input, "index %d", &fib_index))
668  ;
669  else
670  break;
671  }
672 
673  if (hash)
674  {
675  vlib_cli_output (vm, "IPv6 Non-Forwarding Hash Table:\n%U\n",
676  BV (format_bihash),
678  detail);
679  vlib_cli_output (vm, "IPv6 Forwarding Hash Table:\n%U\n",
680  BV (format_bihash),
682  detail);
683  return (NULL);
684  }
685 
686  pool_foreach (fib_table, im6->fibs,
687  ({
688  fib_source_t source;
689  u8 *s = NULL;
690 
691  fib = pool_elt_at_index(im6->v6_fibs, fib_table->ft_index);
692  if (table_id >= 0 && table_id != (int)fib->table_id)
693  continue;
694  if (fib_index != ~0 && fib_index != (int)fib->index)
695  continue;
696  if (fib_table->ft_flags & FIB_TABLE_FLAG_IP6_LL)
697  continue;
698 
699  s = format(s, "%U, fib_index:%d, flow hash:[%U] locks:[",
700  format_fib_table_name, fib->index,
701  FIB_PROTOCOL_IP6,
702  fib->index,
703  format_ip_flow_hash_config,
704  fib_table->ft_flow_hash_config);
705  FOR_EACH_FIB_SOURCE(source)
706  {
707  if (0 != fib_table->ft_locks[source])
708  {
709  s = format(s, "%U:%d, ",
710  format_fib_source, source,
711  fib_table->ft_locks[source]);
712  }
713  }
714  s = format (s, "]");
715  vlib_cli_output (vm, "%v", s);
716  vec_free(s);
717 
718  /* Show summary? */
719  if (! verbose)
720  {
721  clib_bihash_24_8_t * h = &im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash;
722  int len;
723 
724  vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count");
725 
726  clib_memset (ca, 0, sizeof(*ca));
727  ca->fib_index = fib->index;
728 
729  clib_bihash_foreach_key_value_pair_24_8
731 
732  for (len = 128; len >= 0; len--)
733  {
734  if (ca->count_by_prefix_length[len])
735  vlib_cli_output (vm, "%=20d%=16lld",
736  len, ca->count_by_prefix_length[len]);
737  }
738  continue;
739  }
740 
741  if (!matching)
742  {
743  ip6_fib_table_show_all(fib, vm);
744  }
745  else
746  {
747  ip6_fib_table_show_one(fib, vm, &matching_address, mask_len, detail);
748  }
749  }));
750 
751  return 0;
752 }
753 
754 /*?
755  * This command displays the IPv6 FIB Tables (VRF Tables) and the route
756  * entries for each table.
757  *
758  * @note This command will run for a long time when the FIB tables are
759  * comprised of millions of entries. For those senarios, consider displaying
760  * in summary mode.
761  *
762  * @cliexpar
763  * @parblock
764  * Example of how to display all the IPv6 FIB tables:
765  * @cliexstart{show ip6 fib}
766  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
767  * @::/0
768  * unicast-ip6-chain
769  * [@0]: dpo-load-balance: [index:5 buckets:1 uRPF:5 to:[0:0]]
770  * [0] [@0]: dpo-drop ip6
771  * fe80::/10
772  * unicast-ip6-chain
773  * [@0]: dpo-load-balance: [index:10 buckets:1 uRPF:10 to:[0:0]]
774  * [0] [@2]: dpo-receive
775  * ff02::1/128
776  * unicast-ip6-chain
777  * [@0]: dpo-load-balance: [index:8 buckets:1 uRPF:8 to:[0:0]]
778  * [0] [@2]: dpo-receive
779  * ff02::2/128
780  * unicast-ip6-chain
781  * [@0]: dpo-load-balance: [index:7 buckets:1 uRPF:7 to:[0:0]]
782  * [0] [@2]: dpo-receive
783  * ff02::16/128
784  * unicast-ip6-chain
785  * [@0]: dpo-load-balance: [index:9 buckets:1 uRPF:9 to:[0:0]]
786  * [0] [@2]: dpo-receive
787  * ff02::1:ff00:0/104
788  * unicast-ip6-chain
789  * [@0]: dpo-load-balance: [index:6 buckets:1 uRPF:6 to:[0:0]]
790  * [0] [@2]: dpo-receive
791  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
792  * @::/0
793  * unicast-ip6-chain
794  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
795  * [0] [@0]: dpo-drop ip6
796  * @::a:1:1:0:4/126
797  * unicast-ip6-chain
798  * [@0]: dpo-load-balance: [index:27 buckets:1 uRPF:26 to:[0:0]]
799  * [0] [@4]: ipv6-glean: af_packet0
800  * @::a:1:1:0:7/128
801  * unicast-ip6-chain
802  * [@0]: dpo-load-balance: [index:28 buckets:1 uRPF:27 to:[0:0]]
803  * [0] [@2]: dpo-receive: @::a:1:1:0:7 on af_packet0
804  * fe80::/10
805  * unicast-ip6-chain
806  * [@0]: dpo-load-balance: [index:26 buckets:1 uRPF:25 to:[0:0]]
807  * [0] [@2]: dpo-receive
808  * fe80::fe:3eff:fe3e:9222/128
809  * unicast-ip6-chain
810  * [@0]: dpo-load-balance: [index:29 buckets:1 uRPF:28 to:[0:0]]
811  * [0] [@2]: dpo-receive: fe80::fe:3eff:fe3e:9222 on af_packet0
812  * ff02::1/128
813  * unicast-ip6-chain
814  * [@0]: dpo-load-balance: [index:24 buckets:1 uRPF:23 to:[0:0]]
815  * [0] [@2]: dpo-receive
816  * ff02::2/128
817  * unicast-ip6-chain
818  * [@0]: dpo-load-balance: [index:23 buckets:1 uRPF:22 to:[0:0]]
819  * [0] [@2]: dpo-receive
820  * ff02::16/128
821  * unicast-ip6-chain
822  * [@0]: dpo-load-balance: [index:25 buckets:1 uRPF:24 to:[0:0]]
823  * [0] [@2]: dpo-receive
824  * ff02::1:ff00:0/104
825  * unicast-ip6-chain
826  * [@0]: dpo-load-balance: [index:22 buckets:1 uRPF:21 to:[0:0]]
827  * [0] [@2]: dpo-receive
828  * @cliexend
829  *
830  * Example of how to display a summary of all IPv6 FIB tables:
831  * @cliexstart{show ip6 fib summary}
832  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
833  * Prefix length Count
834  * 128 3
835  * 104 1
836  * 10 1
837  * 0 1
838  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
839  * Prefix length Count
840  * 128 5
841  * 126 1
842  * 104 1
843  * 10 1
844  * 0 1
845  * @cliexend
846  * @endparblock
847  ?*/
848 /* *INDENT-OFF* */
849 VLIB_CLI_COMMAND (ip6_show_fib_command, static) = {
850  .path = "show ip6 fib",
851  .short_help = "show ip6 fib [summary] [table <table-id>] [index <fib-id>] [<ip6-addr>[/<width>]] [detail]",
852  .function = ip6_show_fib,
853 };
854 /* *INDENT-ON* */
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:212
u8 * format_fib_entry(u8 *s, va_list *args)
Definition: fib_entry.c:141
Continue on to the next entry.
Definition: fib_table.h:868
typedef address
Definition: ip_types.api:83
#define hash_set(h, key, value)
Definition: hash.h:255
u32 flags
Definition: vhost_user.h:141
void vlib_worker_wait_one_loop(void)
Wait until each of the workers has been once around the track.
Definition: threads.c:1629
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:74
static u32 ip6_fib_table_fwding_lookup(u32 fib_index, const ip6_address_t *dst)
Definition: ip6_fib.h:67
ip6_fib_t * v6_fibs
Definition: ip6.h:185
#define hash_unset(h, key)
Definition: hash.h:261
The table that stores ALL routes learned by the DP.
Definition: ip6.h:134
#define FIB_ENTRY_FORMAT_DETAIL
Definition: fib_entry.h:523
u64 as_u64[2]
Definition: ip6_packet.h:51
unsigned long u64
Definition: types.h:89
static fib_table_walk_rc_t ip6_fib_table_show_walk(fib_node_index_t fib_entry_index, void *arg)
Definition: ip6_fib.c:540
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u8 * format_ip6_fib_table_memory(u8 *s, va_list *args)
Definition: ip6_fib.c:589
enum fib_table_flags_t_ fib_table_flags_t
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
vl_api_address_t src
Definition: gre.api:51
int i
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Definition: bitmap.h:167
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
vhost_vring_addr_t addr
Definition: vhost_user.h:147
static void ip6_fib_table_show_all(ip6_fib_t *fib, vlib_main_t *vm)
Definition: ip6_fib.c:551
u8 * prefix_lengths_in_search_order
Definition: ip6.h:149
unsigned char u8
Definition: types.h:56
static void vnet_ip6_fib_init(u32 fib_index)
Definition: ip6_fib.c:24
fib_node_index_t ip6_fib_table_lookup_exact_match(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:218
clib_bihash_24_8_t ip6_hash
Definition: ip6.h:145
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a &#39;special&#39; entry from the FIB.
Definition: fib_table.c:407
static uword ip6_destination_matches_route(const ip6_main_t *im, const ip6_address_t *key, const ip6_address_t *dest, uword dest_length)
Definition: ip6.h:266
fib_prefix_t * i6w_sub_trees
Definition: ip6_fib.c:429
Aggregate type for a prefix.
Definition: fib_types.h:203
A representation of a single IP6 table.
Definition: ip6.h:142
unsigned int u32
Definition: types.h:88
u16 fp_len
The mask length.
Definition: fib_types.h:207
static u32 create_fib_with_table_id(u32 table_id, fib_source_t src, fib_table_flags_t flags, u8 *desc)
Definition: ip6_fib.c:58
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1631
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_fib.c:342
Definition: fib_entry.h:281
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:170
#define hash_get(h, key)
Definition: hash.h:249
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
enum fib_source_t_ fib_source_t
The different sources that can create a route.
void ip6_fib_table_fwding_dpo_update(u32 fib_index, const ip6_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip6_fib.c:356
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:226
long ctx[MAX_CONNS]
Definition: main.c:144
struct _unformat_input_t unformat_input_t
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
void ip6_fib_table_fwding_dpo_remove(u32 fib_index, const ip6_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip6_fib.c:387
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:109
u32 index
Definition: ip6.h:78
vl_api_address_t dst
Definition: gre.api:52
void ip6_fib_table_walk(u32 fib_index, fib_table_walk_fn_t fn, void *arg)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: ip6_fib.c:494
u32 ip6_fib_table_find_or_create_and_lock(u32 table_id, fib_source_t src)
Get or create an IPv6 fib.
Definition: ip6_fib.c:96
Stop the walk completely.
Definition: fib_table.h:876
void ip6_fib_table_entry_remove(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:272
Context when walking the IPv6 table.
Definition: ip6_fib.c:423
u8 len
Definition: ip_types.api:90
uword * fib_index_by_table_id
Definition: ip6.h:204
unformat_function_t unformat_ip6_address
Definition: format.h:91
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:230
ip6_address_t fib_masks[129]
Definition: ip6.h:191
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a &#39;special&#39; entry to the FIB.
Definition: fib_table.c:388
fib_node_index_t ft_index
Index into FIB vector.
Definition: fib_table.h:94
void ip6_fib_table_destroy(u32 fib_index)
Definition: ip6_fib.c:121
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:89
vlib_main_t * vm
Definition: buffer.c:323
uint32_t mask_width(const boost::asio::ip::address &addr)
Get the prefix mask length of a host route from the boost address.
Definition: prefix.cpp:273
fib_prefix_t i6w_root
Definition: ip6_fib.c:428
u32 ft_flow_hash_config
flow hash configuration
Definition: fib_table.h:99
enum fib_table_walk_rc_t_ fib_table_walk_rc_t
return code controlling how a table walk proceeds
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:869
u32 ip6_fib_table_create_and_lock(fib_source_t src, fib_table_flags_t flags, u8 *desc)
Definition: ip6_fib.c:113
#define FOR_EACH_FIB_SOURCE(_item)
Definition: fib_entry.h:191
Definition: ip6.h:69
u8 * ft_desc
Table description.
Definition: fib_table.h:114
fib_table_flags_t ft_flags
Table flags.
Definition: fib_table.h:79
const dpo_id_t * ip6_ll_dpo_get(void)
The IP6 link-local DPO represents the lookup of a packet in the link-local IPv6 FIB.
Definition: ip6_ll_dpo.c:34
Definition: fib_entry.h:284
This table stores the routes that are used to forward traffic.
Definition: ip6.h:127
static void compute_prefix_lengths_in_search_order(ip6_fib_table_instance_t *table)
Definition: ip6_fib.c:244
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
fib_node_index_t * entries
Definition: ip6_fib.c:536
fib_table_walk_fn_t i6w_fn
Definition: ip6_fib.c:426
fib_table_walk_rc_t(* fib_table_walk_fn_t)(fib_node_index_t fei, void *ctx)
Call back function when walking entries in a FIB table.
Definition: fib_table.h:882
static int ip6_fib_walk_cb(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: ip6_fib.c:433
void fib_table_lock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Release a reference counting lock on the table.
Definition: fib_table.c:1273
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:161
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a &#39;special&#39; entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
Definition: fib_table.c:307
u8 value
Definition: qos.api:53
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:311
#define ASSERT(truth)
ip6_main_t ip6_main
Definition: ip6_forward.c:2805
The default route source.
Definition: fib_entry.h:142
i32 dst_address_length_refcounts[129]
Definition: ip6.h:150
static void ip6_fib_table_show_one(ip6_fib_t *fib, vlib_main_t *vm, ip6_address_t *address, u32 mask_len, int detail)
Definition: ip6_fib.c:574
u32 ft_src_route_counts[FIB_SOURCE_MAX]
Per-source route counters.
Definition: fib_table.h:104
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
Definition: lookup.h:70
ip6_fib_table_instance_t ip6_table[IP6_FIB_NUM_TABLES]
The two FIB tables; fwding and non-fwding.
Definition: ip6.h:172
Do no traverse down this sub-tree.
Definition: fib_table.h:872
#define vec_elt(v, i)
Get vector value at index i.
static void count_routes_in_fib_at_prefix_length(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: ip6_fib.c:609
#define FIB_ENTRY_FORMAT_BRIEF
Definition: fib_entry.h:522
struct ip6_fib_show_ctx_t_ ip6_fib_show_ctx_t
u32 ip6_fib_table_fwding_lookup_with_if_index(ip6_main_t *im, u32 sw_if_index, const ip6_address_t *dst)
Definition: ip6_fib.c:333
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:186
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:31
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * ip6_show_fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip6_fib.c:624
u64 uword
Definition: types.h:112
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:983
void ip6_fib_table_entry_insert(u32 fib_index, const ip6_address_t *addr, u32 len, fib_node_index_t fib_entry_index)
Definition: ip6_fib.c:303
typedef key
Definition: ipsec.api:247
uword * non_empty_dst_address_length_bitmap
Definition: ip6.h:148
Special sources.
Definition: fib_entry.h:45
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: fib_table.c:27
struct ip6_fib_walk_ctx_t_ ip6_fib_walk_ctx_t
Context when walking the IPv6 table.
#define FIB_ENTRY_FORMAT_DETAIL2
Definition: fib_entry.h:524
#define vec_foreach(var, vec)
Vector iterator.
fib_node_index_t ip6_fib_table_lookup(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:172
u32 table_id
Definition: ip6.h:75
u32 table_id
Definition: fib_types.api:118
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
void ip6_fib_table_sub_tree_walk(u32 fib_index, const fib_prefix_t *root, fib_table_walk_fn_t fn, void *arg)
Walk all entries in a sub-tree of the FIB table N.B: This is NOT safe to deletes. ...
Definition: ip6_fib.c:517
struct fib_table_t_ * fibs
Definition: ip6.h:182
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:772
u32 * fib_index_by_sw_if_index
Definition: ip6.h:194
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
A protocol Independent FIB table.
Definition: fib_table.h:69
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128