FD.io VPP  v17.01.1-3-gc6833f8
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 
19 static void
21 {
22  fib_prefix_t pfx = {
24  .fp_len = 0,
25  .fp_addr = {
26  .ip6 = {
27  { 0, 0, },
28  },
29  }
30  };
31 
32  /*
33  * Add the default route.
34  */
36  &pfx,
40 
41  /*
42  * Add ff02::1:ff00:0/104 via local route for all tables.
43  * This is required for neighbor discovery to work.
44  */
46  pfx.fp_len = 104;
48  &pfx,
52 
53  /*
54  * Add all-routers multicast address via local route for all tables
55  */
57  IP6_MULTICAST_SCOPE_link_local,
58  IP6_MULTICAST_GROUP_ID_all_routers);
59  pfx.fp_len = 128;
61  &pfx,
65 
66  /*
67  * Add all-nodes multicast address via local route for all tables
68  */
70  IP6_MULTICAST_SCOPE_link_local,
71  IP6_MULTICAST_GROUP_ID_all_hosts);
72  pfx.fp_len = 128;
74  &pfx,
78 
79  /*
80  * Add all-mldv2 multicast address via local route for all tables
81  */
83  IP6_MULTICAST_SCOPE_link_local,
84  IP6_MULTICAST_GROUP_ID_mldv2_routers);
85  pfx.fp_len = 128;
87  &pfx,
91 
92  /*
93  * all link local for us
94  */
95  pfx.fp_addr.ip6.as_u64[0] = clib_host_to_net_u64 (0xFE80000000000000ULL);
96  pfx.fp_addr.ip6.as_u64[1] = 0;
97  pfx.fp_len = 10;
99  &pfx,
103 }
104 
105 static u32
107 {
108  fib_table_t *fib_table;
109 
111  memset(fib_table, 0, sizeof(*fib_table));
112 
113  fib_table->ft_proto = FIB_PROTOCOL_IP6;
114  fib_table->ft_index =
115  fib_table->v6.index =
116  (fib_table - ip6_main.fibs);
117 
118  hash_set(ip6_main.fib_index_by_table_id, table_id, fib_table->ft_index);
119 
120  fib_table->ft_table_id =
121  fib_table->v6.table_id =
122  table_id;
123  fib_table->ft_flow_hash_config =
124  fib_table->v6.flow_hash_config =
126 
127  vnet_ip6_fib_init(fib_table->ft_index);
129 
130  return (fib_table->ft_index);
131 }
132 
133 u32
135 {
136  uword * p;
137 
138  p = hash_get (ip6_main.fib_index_by_table_id, table_id);
139  if (NULL == p)
140  return create_fib_with_table_id(table_id);
141 
143 
144  return (p[0]);
145 }
146 
147 u32
149 {
150  return (create_fib_with_table_id(~0));
151 }
152 
153 void
155 {
156  fib_prefix_t pfx = {
158  .fp_len = 0,
159  .fp_addr = {
160  .ip6 = {
161  { 0, 0, },
162  },
163  }
164  };
165 
166  /*
167  * the default route.
168  */
170  &pfx,
172 
173 
174  /*
175  * ff02::1:ff00:0/104
176  */
178  pfx.fp_len = 104;
180  &pfx,
182 
183  /*
184  * all-routers multicast address
185  */
187  IP6_MULTICAST_SCOPE_link_local,
188  IP6_MULTICAST_GROUP_ID_all_routers);
189  pfx.fp_len = 128;
191  &pfx,
193 
194  /*
195  * all-nodes multicast address
196  */
198  IP6_MULTICAST_SCOPE_link_local,
199  IP6_MULTICAST_GROUP_ID_all_hosts);
200  pfx.fp_len = 128;
202  &pfx,
204 
205  /*
206  * all-mldv2 multicast address
207  */
209  IP6_MULTICAST_SCOPE_link_local,
210  IP6_MULTICAST_GROUP_ID_mldv2_routers);
211  pfx.fp_len = 128;
213  &pfx,
215 
216  /*
217  * all link local
218  */
219  pfx.fp_addr.ip6.as_u64[0] = clib_host_to_net_u64 (0xFE80000000000000ULL);
220  pfx.fp_addr.ip6.as_u64[1] = 0;
221  pfx.fp_len = 10;
223  &pfx,
225 
226  fib_table_t *fib_table = fib_table_get(fib_index, FIB_PROTOCOL_IP6);
227  fib_source_t source;
228 
229  /*
230  * validate no more routes.
231  */
232  ASSERT(0 == fib_table->ft_total_route_counts);
233  FOR_EACH_FIB_SOURCE(source)
234  {
235  ASSERT(0 == fib_table->ft_src_route_counts[source]);
236  }
237 
238  if (~0 != fib_table->ft_table_id)
239  {
241  }
242  pool_put(ip6_main.fibs, fib_table);
243 }
244 
247  const ip6_address_t *addr,
248  u32 len)
249 {
250  const ip6_fib_table_instance_t *table;
251  BVT(clib_bihash_kv) kv, value;
252  int i, n_p, rv;
253  u64 fib;
254 
257 
258  kv.key[0] = addr->as_u64[0];
259  kv.key[1] = addr->as_u64[1];
260  fib = ((u64)((fib_index))<<32);
261 
262  /*
263  * start search from a mask length same length or shorter.
264  * we don't want matches longer than the mask passed
265  */
266  i = 0;
267  while (i < n_p && table->prefix_lengths_in_search_order[i] > len)
268  {
269  i++;
270  }
271 
272  for (; i < n_p; i++)
273  {
274  int dst_address_length = table->prefix_lengths_in_search_order[i];
275  ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
276 
277  ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
278  //As lengths are decreasing, masks are increasingly specific.
279  kv.key[0] &= mask->as_u64[0];
280  kv.key[1] &= mask->as_u64[1];
281  kv.key[2] = fib | dst_address_length;
282 
283  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
284  if (rv == 0)
285  return value.value;
286  }
287 
288  return (FIB_NODE_INDEX_INVALID);
289 }
290 
293  const ip6_address_t *addr,
294  u32 len)
295 {
296  const ip6_fib_table_instance_t *table;
297  BVT(clib_bihash_kv) kv, value;
298  ip6_address_t *mask;
299  u64 fib;
300  int rv;
301 
303  mask = &ip6_main.fib_masks[len];
304  fib = ((u64)((fib_index))<<32);
305 
306  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
307  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
308  kv.key[2] = fib | len;
309 
310  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
311  if (rv == 0)
312  return value.value;
313 
314  return (FIB_NODE_INDEX_INVALID);
315 }
316 
317 static void
319 {
320  int i;
322  /* Note: bitmap reversed so this is in fact a longest prefix match */
324  ({
325  int dst_address_length = 128 - i;
326  vec_add1(table->prefix_lengths_in_search_order, dst_address_length);
327  }));
328 }
329 
330 void
332  const ip6_address_t *addr,
333  u32 len)
334 {
336  BVT(clib_bihash_kv) kv;
337  ip6_address_t *mask;
338  u64 fib;
339 
341  mask = &ip6_main.fib_masks[len];
342  fib = ((u64)((fib_index))<<32);
343 
344  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
345  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
346  kv.key[2] = fib | len;
347 
348  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 0);
349 
350  /* refcount accounting */
351  ASSERT (table->dst_address_length_refcounts[len] > 0);
352  if (--table->dst_address_length_refcounts[len] == 0)
353  {
356  128 - len, 0);
358  }
359 }
360 
361 void
363  const ip6_address_t *addr,
364  u32 len,
365  fib_node_index_t fib_entry_index)
366 {
368  BVT(clib_bihash_kv) kv;
369  ip6_address_t *mask;
370  u64 fib;
371 
373  mask = &ip6_main.fib_masks[len];
374  fib = ((u64)((fib_index))<<32);
375 
376  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
377  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
378  kv.key[2] = fib | len;
379  kv.value = fib_entry_index;
380 
381  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 1);
382 
383  table->dst_address_length_refcounts[len]++;
384 
387  128 - len, 1);
389 }
390 
391 u32
393  u32 fib_index,
394  const ip6_address_t * dst)
395 {
396  const ip6_fib_table_instance_t *table;
397  int i, len;
398  int rv;
399  BVT(clib_bihash_kv) kv, value;
400  u64 fib;
401 
404 
405  kv.key[0] = dst->as_u64[0];
406  kv.key[1] = dst->as_u64[1];
407  fib = ((u64)((fib_index))<<32);
408 
409  for (i = 0; i < len; i++)
410  {
411  int dst_address_length = table->prefix_lengths_in_search_order[i];
412  ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
413 
414  ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
415  //As lengths are decreasing, masks are increasingly specific.
416  kv.key[0] &= mask->as_u64[0];
417  kv.key[1] &= mask->as_u64[1];
418  kv.key[2] = fib | dst_address_length;
419 
420  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
421  if (rv == 0)
422  return value.value;
423  }
424 
425  /* default route is always present */
426  ASSERT(0);
427  return 0;
428 }
429 
431  u32 sw_if_index,
432  const ip6_address_t * dst)
433 {
434  u32 fib_index = vec_elt (im->fib_index_by_sw_if_index, sw_if_index);
435  return ip6_fib_table_fwding_lookup(im, fib_index, dst);
436 }
437 
440 {
441  return (ip6_fib_get(fib_index)->flow_hash_config);
442 }
443 
444 u32
446 {
447  if (sw_if_index >= vec_len(ip6_main.fib_index_by_sw_if_index))
448  {
449  /*
450  * This is the case for interfaces that are not yet mapped to
451  * a IP table
452  */
453  return (~0);
454  }
455  return (ip6_main.fib_index_by_sw_if_index[sw_if_index]);
456 }
457 
458 void
460  const ip6_address_t *addr,
461  u32 len,
462  const dpo_id_t *dpo)
463 {
465  BVT(clib_bihash_kv) kv;
466  ip6_address_t *mask;
467  u64 fib;
468 
470  mask = &ip6_main.fib_masks[len];
471  fib = ((u64)((fib_index))<<32);
472 
473  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
474  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
475  kv.key[2] = fib | len;
476  kv.value = dpo->dpoi_index;
477 
478  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 1);
479 
480  table->dst_address_length_refcounts[len]++;
481 
484  128 - len, 1);
486 }
487 
488 void
490  const ip6_address_t *addr,
491  u32 len,
492  const dpo_id_t *dpo)
493 {
495  BVT(clib_bihash_kv) kv;
496  ip6_address_t *mask;
497  u64 fib;
498 
500  mask = &ip6_main.fib_masks[len];
501  fib = ((u64)((fib_index))<<32);
502 
503  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
504  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
505  kv.key[2] = fib | len;
506  kv.value = dpo->dpoi_index;
507 
508  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 0);
509 
510  /* refcount accounting */
511  ASSERT (table->dst_address_length_refcounts[len] > 0);
512  if (--table->dst_address_length_refcounts[len] == 0)
513  {
516  128 - len, 0);
518  }
519 }
520 
521 typedef struct ip6_fib_show_ctx_t_ {
525 
526 static void
528  void *arg)
529 {
530  ip6_fib_show_ctx_t *ctx = arg;
531 
532  if ((kvp->key[2] >> 32) == ctx->fib_index)
533  {
534  vec_add1(ctx->entries, kvp->value);
535  }
536 }
537 
538 static void
540  vlib_main_t * vm)
541 {
542  fib_node_index_t *fib_entry_index;
543  ip6_fib_show_ctx_t ctx = {
544  .fib_index = fib->index,
545  .entries = NULL,
546  };
547  ip6_main_t *im = &ip6_main;
548 
551  &ctx);
552 
554 
555  vec_foreach(fib_entry_index, ctx.entries)
556  {
557  vlib_cli_output(vm, "%U",
559  *fib_entry_index,
561  }
562 
563  vec_free(ctx.entries);
564 }
565 
566 static void
568  vlib_main_t * vm,
569  ip6_address_t *address,
570  u32 mask_len)
571 {
572  vlib_cli_output(vm, "%U",
574  ip6_fib_table_lookup(fib->index, address, mask_len),
576 }
577 
578 typedef struct {
580  u64 count_by_prefix_length[129];
582 
584 (BVT(clib_bihash_kv) * kvp, void *arg)
585 {
587  int mask_width;
588 
589  if ((kvp->key[2]>>32) != ap->fib_index)
590  return;
591 
592  mask_width = kvp->key[2] & 0xFF;
593 
594  ap->count_by_prefix_length[mask_width]++;
595 }
596 
597 static clib_error_t *
599  unformat_input_t * input,
600  vlib_cli_command_t * cmd)
601 {
603  ip6_main_t * im6 = &ip6_main;
604  fib_table_t *fib_table;
605  ip6_fib_t * fib;
606  int verbose, matching;
607  ip6_address_t matching_address;
608  u32 mask_len = 128;
609  int table_id = -1, fib_index = ~0;
610 
611  verbose = 1;
612  matching = 0;
613 
615  {
616  if (unformat (input, "brief") ||
617  unformat (input, "summary") ||
618  unformat (input, "sum"))
619  verbose = 0;
620 
621  else if (unformat (input, "%U/%d",
622  unformat_ip6_address, &matching_address, &mask_len))
623  matching = 1;
624 
625  else if (unformat (input, "%U", unformat_ip6_address, &matching_address))
626  matching = 1;
627 
628  else if (unformat (input, "table %d", &table_id))
629  ;
630  else if (unformat (input, "index %d", &fib_index))
631  ;
632  else
633  break;
634  }
635 
636  pool_foreach (fib_table, im6->fibs,
637  ({
638  fib = &(fib_table->v6);
639  if (table_id >= 0 && table_id != (int)fib->table_id)
640  continue;
641  if (fib_index != ~0 && fib_index != (int)fib->index)
642  continue;
643 
644  vlib_cli_output (vm, "%s, fib_index %d, flow hash: %U",
645  fib_table->ft_desc, fib->index,
646  format_ip_flow_hash_config, fib->flow_hash_config);
647 
648  /* Show summary? */
649  if (! verbose)
650  {
651  BVT(clib_bihash) * h = &im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash;
652  int len;
653 
654  vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count");
655 
656  memset (ca, 0, sizeof(*ca));
657  ca->fib_index = fib->index;
658 
659  BV(clib_bihash_foreach_key_value_pair)
660  (h, count_routes_in_fib_at_prefix_length, ca);
661 
662  for (len = 128; len >= 0; len--)
663  {
664  if (ca->count_by_prefix_length[len])
665  vlib_cli_output (vm, "%=20d%=16lld",
666  len, ca->count_by_prefix_length[len]);
667  }
668  continue;
669  }
670 
671  if (!matching)
672  {
673  ip6_fib_table_show_all(fib, vm);
674  }
675  else
676  {
677  ip6_fib_table_show_one(fib, vm, &matching_address, mask_len);
678  }
679  }));
680 
681  return 0;
682 }
683 
684 /*?
685  * This command displays the IPv6 FIB Tables (VRF Tables) and the route
686  * entries for each table.
687  *
688  * @note This command will run for a long time when the FIB tables are
689  * comprised of millions of entries. For those senarios, consider displaying
690  * in summary mode.
691  *
692  * @cliexpar
693  * @parblock
694  * Example of how to display all the IPv6 FIB tables:
695  * @cliexstart{show ip6 fib}
696  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
697  * @::/0
698  * unicast-ip6-chain
699  * [@0]: dpo-load-balance: [index:5 buckets:1 uRPF:5 to:[0:0]]
700  * [0] [@0]: dpo-drop ip6
701  * fe80::/10
702  * unicast-ip6-chain
703  * [@0]: dpo-load-balance: [index:10 buckets:1 uRPF:10 to:[0:0]]
704  * [0] [@2]: dpo-receive
705  * ff02::1/128
706  * unicast-ip6-chain
707  * [@0]: dpo-load-balance: [index:8 buckets:1 uRPF:8 to:[0:0]]
708  * [0] [@2]: dpo-receive
709  * ff02::2/128
710  * unicast-ip6-chain
711  * [@0]: dpo-load-balance: [index:7 buckets:1 uRPF:7 to:[0:0]]
712  * [0] [@2]: dpo-receive
713  * ff02::16/128
714  * unicast-ip6-chain
715  * [@0]: dpo-load-balance: [index:9 buckets:1 uRPF:9 to:[0:0]]
716  * [0] [@2]: dpo-receive
717  * ff02::1:ff00:0/104
718  * unicast-ip6-chain
719  * [@0]: dpo-load-balance: [index:6 buckets:1 uRPF:6 to:[0:0]]
720  * [0] [@2]: dpo-receive
721  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
722  * @::/0
723  * unicast-ip6-chain
724  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
725  * [0] [@0]: dpo-drop ip6
726  * @::a:1:1:0:4/126
727  * unicast-ip6-chain
728  * [@0]: dpo-load-balance: [index:27 buckets:1 uRPF:26 to:[0:0]]
729  * [0] [@4]: ipv6-glean: af_packet0
730  * @::a:1:1:0:7/128
731  * unicast-ip6-chain
732  * [@0]: dpo-load-balance: [index:28 buckets:1 uRPF:27 to:[0:0]]
733  * [0] [@2]: dpo-receive: @::a:1:1:0:7 on af_packet0
734  * fe80::/10
735  * unicast-ip6-chain
736  * [@0]: dpo-load-balance: [index:26 buckets:1 uRPF:25 to:[0:0]]
737  * [0] [@2]: dpo-receive
738  * fe80::fe:3eff:fe3e:9222/128
739  * unicast-ip6-chain
740  * [@0]: dpo-load-balance: [index:29 buckets:1 uRPF:28 to:[0:0]]
741  * [0] [@2]: dpo-receive: fe80::fe:3eff:fe3e:9222 on af_packet0
742  * ff02::1/128
743  * unicast-ip6-chain
744  * [@0]: dpo-load-balance: [index:24 buckets:1 uRPF:23 to:[0:0]]
745  * [0] [@2]: dpo-receive
746  * ff02::2/128
747  * unicast-ip6-chain
748  * [@0]: dpo-load-balance: [index:23 buckets:1 uRPF:22 to:[0:0]]
749  * [0] [@2]: dpo-receive
750  * ff02::16/128
751  * unicast-ip6-chain
752  * [@0]: dpo-load-balance: [index:25 buckets:1 uRPF:24 to:[0:0]]
753  * [0] [@2]: dpo-receive
754  * ff02::1:ff00:0/104
755  * unicast-ip6-chain
756  * [@0]: dpo-load-balance: [index:22 buckets:1 uRPF:21 to:[0:0]]
757  * [0] [@2]: dpo-receive
758  * @cliexend
759  *
760  * Example of how to display a summary of all IPv6 FIB tables:
761  * @cliexstart{show ip6 fib summary}
762  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
763  * Prefix length Count
764  * 128 3
765  * 104 1
766  * 10 1
767  * 0 1
768  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
769  * Prefix length Count
770  * 128 5
771  * 126 1
772  * 104 1
773  * 10 1
774  * 0 1
775  * @cliexend
776  * @endparblock
777  ?*/
778 /* *INDENT-OFF* */
779 VLIB_CLI_COMMAND (ip6_show_fib_command, static) = {
780  .path = "show ip6 fib",
781  .short_help = "show ip6 fib [summary] [table <table-id>] [index <fib-id>] [<ip6-addr>[/<width>]]",
782  .function = ip6_show_fib,
783 };
784 /* *INDENT-ON* */
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:154
u8 * format_fib_entry(u8 *s, va_list *args)
Definition: fib_entry.c:93
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:46
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
#define hash_unset(h, key)
Definition: hash.h:260
static ip6_fib_t * ip6_fib_get(fib_node_index_t index)
Definition: ip6_fib.h:106
void fib_table_lock(u32 fib_index, fib_protocol_t proto)
Release a reference counting lock on the table.
Definition: fib_table.c:1062
The table that stores ALL routes learned by the DP.
Definition: ip6.h:109
#define FIB_ENTRY_FORMAT_DETAIL
Definition: fib_entry.h:416
u64 as_u64[2]
Definition: ip6_packet.h:51
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
#define NULL
Definition: clib.h:55
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
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
static void ip6_fib_table_show_all(ip6_fib_t *fib, vlib_main_t *vm)
Definition: ip6_fib.c:539
u8 * prefix_lengths_in_search_order
Definition: ip6.h:124
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void vnet_ip6_fib_init(u32 fib_index)
Definition: ip6_fib.c:20
static u32 create_fib_with_table_id(u32 table_id)
Definition: ip6_fib.c:106
flow_hash_config_t flow_hash_config
Definition: ip6.h:75
fib_node_index_t ip6_fib_table_lookup_exact_match(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:292
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
int clib_bihash_add_del(clib_bihash *h, clib_bihash_kv *add_v, int is_add)
Add or delete a (key,value) pair from a bi-hash table.
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:399
static BVT(clib_bihash)
Definition: adj_nbr.c:26
flow_hash_config_t ip6_fib_table_get_flow_hash_config(u32 fib_index)
Definition: ip6_fib.c:439
Aggregrate type for a prefix.
Definition: fib_types.h:145
unsigned long u64
Definition: types.h:89
A represenation of a single IP6 table.
Definition: ip6.h:117
u16 fp_len
The mask length.
Definition: fib_types.h:149
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1388
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_fib.c:445
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:138
Definition: fib_entry.h:221
#define hash_get(h, key)
Definition: hash.h:248
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
Definition: adj_types.h:36
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, adj_index_t adj_index)
Add a &#39;special&#39; entry to the FIB that links to the adj passed A special entry is an entry that the FI...
Definition: fib_table.c:369
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:459
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:168
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
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:489
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:76
u32 index
Definition: ip6.h:72
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:576
unformat_function_t unformat_ip6_address
Definition: format.h:94
void ip6_fib_table_entry_remove(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:331
static void ip6_fib_table_show_one(ip6_fib_t *fib, vlib_main_t *vm, ip6_address_t *address, u32 mask_len)
Definition: ip6_fib.c:567
uword * fib_index_by_table_id
Definition: ip6.h:151
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Definition: pool.h:169
ip6_address_t fib_masks[129]
Definition: ip6.h:141
u32 ip6_fib_table_fwding_lookup(ip6_main_t *im, u32 fib_index, const ip6_address_t *dst)
Definition: ip6_fib.c:392
void clib_bihash_foreach_key_value_pair(clib_bihash *h, void *callback, void *arg)
Visit active (key,value) pairs in a bi-hash table.
fib_node_index_t ft_index
Index into FIB vector.
Definition: fib_table.h:61
u32 ip6_fib_table_create_and_lock(void)
Definition: ip6_fib.c:148
void ip6_fib_table_destroy(u32 fib_index)
Definition: ip6_fib.c:154
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:56
u32 ft_flow_hash_config
flow hash configuration
Definition: fib_table.h:66
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
#define FOR_EACH_FIB_SOURCE(_item)
Definition: fib_entry.h:151
Definition: ip6.h:66
Definition: fib_entry.h:219
This table stores the routes that are used to forward traffic.
Definition: ip6.h:102
static void compute_prefix_lengths_in_search_order(ip6_fib_table_instance_t *table)
Definition: ip6_fib.c:318
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
fib_node_index_t * entries
Definition: ip6_fib.c:523
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
ip6_main_t ip6_main
Definition: ip6_forward.c:2828
The default route source.
Definition: fib_entry.h:117
i32 dst_address_length_refcounts[129]
Definition: ip6.h:125
u32 ft_src_route_counts[FIB_SOURCE_MAX]
Per-source route counters.
Definition: fib_table.h:71
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
Definition: lookup.h:147
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:160
static void ip6_fib_table_collect_entries(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: ip6_fib.c:527
ip6_fib_table_instance_t ip6_table[IP6_FIB_NUM_TABLES]
The two FIB tables; fwding and non-fwding.
Definition: ip6.h:133
u64 uword
Definition: types.h:112
#define vec_elt(v, i)
Get vector value at index i.
#define FIB_ENTRY_FORMAT_BRIEF
Definition: fib_entry.h:415
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:430
ip6_fib_t v6
Definition: fib_table.h:39
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:154
static void ip6_set_solicited_node_multicast_address(ip6_address_t *a, u32 id)
Definition: ip6_packet.h:164
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:29
u32 ip6_fib_table_find_or_create_and_lock(u32 table_id)
Get or create an IPv6 fib.
Definition: ip6_fib.c:134
#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:598
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:920
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:362
static void count_routes_in_fib_at_prefix_length(BVT(clib_bihash_kv)*kvp, void *arg)
Definition: ip6_fib.c:584
uword * non_empty_dst_address_length_bitmap
Definition: ip6.h:123
Special sources.
Definition: fib_entry.h:40
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
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
#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:246
u32 table_id
Definition: ip6.h:69
vhost_vring_addr_t addr
Definition: vhost-user.h:81
struct _unformat_input_t unformat_input_t
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
struct fib_table_t_ * fibs
Definition: ip6.h:138
u32 * fib_index_by_sw_if_index
Definition: ip6.h:144
static void ip6_set_reserved_multicast_address(ip6_address_t *a, ip6_multicast_address_scope_t scope, u16 id)
Definition: ip6_packet.h:154
A protocol Independent FIB table.
Definition: fib_table.h:29