FD.io VPP  v17.04.2-2-ga8f93f8
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,
39 
40  /*
41  * all link local for us
42  */
43  pfx.fp_addr.ip6.as_u64[0] = clib_host_to_net_u64 (0xFE80000000000000ULL);
44  pfx.fp_addr.ip6.as_u64[1] = 0;
45  pfx.fp_len = 10;
47  &pfx,
50 }
51 
52 static u32
54 {
55  fib_table_t *fib_table;
56 
58  memset(fib_table, 0, sizeof(*fib_table));
59 
60  fib_table->ft_proto = FIB_PROTOCOL_IP6;
61  fib_table->ft_index =
62  fib_table->v6.index =
63  (fib_table - ip6_main.fibs);
64 
65  hash_set(ip6_main.fib_index_by_table_id, table_id, fib_table->ft_index);
66 
67  fib_table->ft_table_id =
68  fib_table->v6.table_id =
69  table_id;
70  fib_table->ft_flow_hash_config =
71  fib_table->v6.flow_hash_config =
73 
74  vnet_ip6_fib_init(fib_table->ft_index);
76 
77  return (fib_table->ft_index);
78 }
79 
80 u32
82 {
83  uword * p;
84 
85  p = hash_get (ip6_main.fib_index_by_table_id, table_id);
86  if (NULL == p)
87  return create_fib_with_table_id(table_id);
88 
90 
91  return (p[0]);
92 }
93 
94 u32
96 {
97  return (create_fib_with_table_id(~0));
98 }
99 
100 void
102 {
103  fib_prefix_t pfx = {
105  .fp_len = 0,
106  .fp_addr = {
107  .ip6 = {
108  { 0, 0, },
109  },
110  }
111  };
112 
113  /*
114  * the default route.
115  */
117  &pfx,
119 
120 
121  /*
122  * ff02::1:ff00:0/104
123  */
125  pfx.fp_len = 104;
127  &pfx,
129 
130  /*
131  * all-routers multicast address
132  */
134  IP6_MULTICAST_SCOPE_link_local,
135  IP6_MULTICAST_GROUP_ID_all_routers);
136  pfx.fp_len = 128;
138  &pfx,
140 
141  /*
142  * all-nodes multicast address
143  */
145  IP6_MULTICAST_SCOPE_link_local,
146  IP6_MULTICAST_GROUP_ID_all_hosts);
147  pfx.fp_len = 128;
149  &pfx,
151 
152  /*
153  * all-mldv2 multicast address
154  */
156  IP6_MULTICAST_SCOPE_link_local,
157  IP6_MULTICAST_GROUP_ID_mldv2_routers);
158  pfx.fp_len = 128;
160  &pfx,
162 
163  /*
164  * all link local
165  */
166  pfx.fp_addr.ip6.as_u64[0] = clib_host_to_net_u64 (0xFE80000000000000ULL);
167  pfx.fp_addr.ip6.as_u64[1] = 0;
168  pfx.fp_len = 10;
170  &pfx,
172 
173  fib_table_t *fib_table = fib_table_get(fib_index, FIB_PROTOCOL_IP6);
174  fib_source_t source;
175 
176  /*
177  * validate no more routes.
178  */
179  ASSERT(0 == fib_table->ft_total_route_counts);
180  FOR_EACH_FIB_SOURCE(source)
181  {
182  ASSERT(0 == fib_table->ft_src_route_counts[source]);
183  }
184 
185  if (~0 != fib_table->ft_table_id)
186  {
188  }
189  pool_put(ip6_main.fibs, fib_table);
190 }
191 
194  const ip6_address_t *addr,
195  u32 len)
196 {
197  const ip6_fib_table_instance_t *table;
198  BVT(clib_bihash_kv) kv, value;
199  int i, n_p, rv;
200  u64 fib;
201 
204 
205  kv.key[0] = addr->as_u64[0];
206  kv.key[1] = addr->as_u64[1];
207  fib = ((u64)((fib_index))<<32);
208 
209  /*
210  * start search from a mask length same length or shorter.
211  * we don't want matches longer than the mask passed
212  */
213  i = 0;
214  while (i < n_p && table->prefix_lengths_in_search_order[i] > len)
215  {
216  i++;
217  }
218 
219  for (; i < n_p; i++)
220  {
221  int dst_address_length = table->prefix_lengths_in_search_order[i];
222  ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
223 
224  ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
225  //As lengths are decreasing, masks are increasingly specific.
226  kv.key[0] &= mask->as_u64[0];
227  kv.key[1] &= mask->as_u64[1];
228  kv.key[2] = fib | dst_address_length;
229 
230  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
231  if (rv == 0)
232  return value.value;
233  }
234 
235  return (FIB_NODE_INDEX_INVALID);
236 }
237 
240  const ip6_address_t *addr,
241  u32 len)
242 {
243  const ip6_fib_table_instance_t *table;
244  BVT(clib_bihash_kv) kv, value;
245  ip6_address_t *mask;
246  u64 fib;
247  int rv;
248 
250  mask = &ip6_main.fib_masks[len];
251  fib = ((u64)((fib_index))<<32);
252 
253  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
254  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
255  kv.key[2] = fib | len;
256 
257  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
258  if (rv == 0)
259  return value.value;
260 
261  return (FIB_NODE_INDEX_INVALID);
262 }
263 
264 static void
266 {
267  int i;
269  /* Note: bitmap reversed so this is in fact a longest prefix match */
271  ({
272  int dst_address_length = 128 - i;
273  vec_add1(table->prefix_lengths_in_search_order, dst_address_length);
274  }));
275 }
276 
277 void
279  const ip6_address_t *addr,
280  u32 len)
281 {
283  BVT(clib_bihash_kv) kv;
284  ip6_address_t *mask;
285  u64 fib;
286 
288  mask = &ip6_main.fib_masks[len];
289  fib = ((u64)((fib_index))<<32);
290 
291  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
292  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
293  kv.key[2] = fib | len;
294 
295  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 0);
296 
297  /* refcount accounting */
298  ASSERT (table->dst_address_length_refcounts[len] > 0);
299  if (--table->dst_address_length_refcounts[len] == 0)
300  {
303  128 - len, 0);
305  }
306 }
307 
308 void
310  const ip6_address_t *addr,
311  u32 len,
312  fib_node_index_t fib_entry_index)
313 {
315  BVT(clib_bihash_kv) kv;
316  ip6_address_t *mask;
317  u64 fib;
318 
320  mask = &ip6_main.fib_masks[len];
321  fib = ((u64)((fib_index))<<32);
322 
323  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
324  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
325  kv.key[2] = fib | len;
326  kv.value = fib_entry_index;
327 
328  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 1);
329 
330  table->dst_address_length_refcounts[len]++;
331 
334  128 - len, 1);
336 }
337 
338 u32
340  u32 fib_index,
341  const ip6_address_t * dst)
342 {
343  const ip6_fib_table_instance_t *table;
344  int i, len;
345  int rv;
346  BVT(clib_bihash_kv) kv, value;
347  u64 fib;
348 
351 
352  kv.key[0] = dst->as_u64[0];
353  kv.key[1] = dst->as_u64[1];
354  fib = ((u64)((fib_index))<<32);
355 
356  for (i = 0; i < len; i++)
357  {
358  int dst_address_length = table->prefix_lengths_in_search_order[i];
359  ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
360 
361  ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
362  //As lengths are decreasing, masks are increasingly specific.
363  kv.key[0] &= mask->as_u64[0];
364  kv.key[1] &= mask->as_u64[1];
365  kv.key[2] = fib | dst_address_length;
366 
367  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
368  if (rv == 0)
369  return value.value;
370  }
371 
372  /* default route is always present */
373  ASSERT(0);
374  return 0;
375 }
376 
378  u32 sw_if_index,
379  const ip6_address_t * dst)
380 {
381  u32 fib_index = vec_elt (im->fib_index_by_sw_if_index, sw_if_index);
382  return ip6_fib_table_fwding_lookup(im, fib_index, dst);
383 }
384 
387 {
388  return (ip6_fib_get(fib_index)->flow_hash_config);
389 }
390 
391 u32
393 {
394  if (sw_if_index >= vec_len(ip6_main.fib_index_by_sw_if_index))
395  {
396  /*
397  * This is the case for interfaces that are not yet mapped to
398  * a IP table
399  */
400  return (~0);
401  }
402  return (ip6_main.fib_index_by_sw_if_index[sw_if_index]);
403 }
404 
405 void
407  const ip6_address_t *addr,
408  u32 len,
409  const dpo_id_t *dpo)
410 {
412  BVT(clib_bihash_kv) kv;
413  ip6_address_t *mask;
414  u64 fib;
415 
417  mask = &ip6_main.fib_masks[len];
418  fib = ((u64)((fib_index))<<32);
419 
420  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
421  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
422  kv.key[2] = fib | len;
423  kv.value = dpo->dpoi_index;
424 
425  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 1);
426 
427  table->dst_address_length_refcounts[len]++;
428 
431  128 - len, 1);
433 }
434 
435 void
437  const ip6_address_t *addr,
438  u32 len,
439  const dpo_id_t *dpo)
440 {
442  BVT(clib_bihash_kv) kv;
443  ip6_address_t *mask;
444  u64 fib;
445 
447  mask = &ip6_main.fib_masks[len];
448  fib = ((u64)((fib_index))<<32);
449 
450  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
451  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
452  kv.key[2] = fib | len;
453  kv.value = dpo->dpoi_index;
454 
455  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 0);
456 
457  /* refcount accounting */
458  ASSERT (table->dst_address_length_refcounts[len] > 0);
459  if (--table->dst_address_length_refcounts[len] == 0)
460  {
463  128 - len, 0);
465  }
466 }
467 
468 /**
469  * @brief Context when walking the IPv6 table. Since all VRFs are in the
470  * same hash table, we need to filter only those we need as we walk
471  */
472 typedef struct ip6_fib_walk_ctx_t_
473 {
476  void *i6w_ctx;
478 
479 static int
481  void *arg)
482 {
483  ip6_fib_walk_ctx_t *ctx = arg;
484 
485  if ((kvp->key[2] >> 32) == ctx->i6w_fib_index)
486  {
487  ctx->i6w_fn(kvp->value, ctx->i6w_ctx);
488  }
489 
490  return (1);
491 }
492 
493 void
496  void *arg)
497 {
498  ip6_fib_walk_ctx_t ctx = {
499  .i6w_fib_index = fib_index,
500  .i6w_fn = fn,
501  .i6w_ctx = arg,
502  };
503  ip6_main_t *im = &ip6_main;
504 
507  &ctx);
508 
509 }
510 
511 typedef struct ip6_fib_show_ctx_t_ {
514 
515 static int
517  void *arg)
518 {
519  ip6_fib_show_ctx_t *ctx = arg;
520 
521  vec_add1(ctx->entries, fib_entry_index);
522 
523  return (1);
524 }
525 
526 static void
528  vlib_main_t * vm)
529 {
530  fib_node_index_t *fib_entry_index;
531  ip6_fib_show_ctx_t ctx = {
532  .entries = NULL,
533  };
534 
537 
538  vec_foreach(fib_entry_index, ctx.entries)
539  {
540  vlib_cli_output(vm, "%U",
542  *fib_entry_index,
544  }
545 
546  vec_free(ctx.entries);
547 }
548 
549 static void
551  vlib_main_t * vm,
552  ip6_address_t *address,
553  u32 mask_len)
554 {
555  vlib_cli_output(vm, "%U",
557  ip6_fib_table_lookup(fib->index, address, mask_len),
559 }
560 
561 typedef struct {
563  u64 count_by_prefix_length[129];
565 
567 (BVT(clib_bihash_kv) * kvp, void *arg)
568 {
570  int mask_width;
571 
572  if ((kvp->key[2]>>32) != ap->fib_index)
573  return;
574 
575  mask_width = kvp->key[2] & 0xFF;
576 
577  ap->count_by_prefix_length[mask_width]++;
578 }
579 
580 static clib_error_t *
582  unformat_input_t * input,
583  vlib_cli_command_t * cmd)
584 {
586  ip6_main_t * im6 = &ip6_main;
587  fib_table_t *fib_table;
588  ip6_fib_t * fib;
589  int verbose, matching;
590  ip6_address_t matching_address;
591  u32 mask_len = 128;
592  int table_id = -1, fib_index = ~0;
593 
594  verbose = 1;
595  matching = 0;
596 
598  {
599  if (unformat (input, "brief") ||
600  unformat (input, "summary") ||
601  unformat (input, "sum"))
602  verbose = 0;
603 
604  else if (unformat (input, "%U/%d",
605  unformat_ip6_address, &matching_address, &mask_len))
606  matching = 1;
607 
608  else if (unformat (input, "%U", unformat_ip6_address, &matching_address))
609  matching = 1;
610 
611  else if (unformat (input, "table %d", &table_id))
612  ;
613  else if (unformat (input, "index %d", &fib_index))
614  ;
615  else
616  break;
617  }
618 
619  pool_foreach (fib_table, im6->fibs,
620  ({
621  fib = &(fib_table->v6);
622  if (table_id >= 0 && table_id != (int)fib->table_id)
623  continue;
624  if (fib_index != ~0 && fib_index != (int)fib->index)
625  continue;
626 
627  vlib_cli_output (vm, "%s, fib_index %d, flow hash: %U",
628  fib_table->ft_desc, fib->index,
629  format_ip_flow_hash_config, fib->flow_hash_config);
630 
631  /* Show summary? */
632  if (! verbose)
633  {
634  BVT(clib_bihash) * h = &im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash;
635  int len;
636 
637  vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count");
638 
639  memset (ca, 0, sizeof(*ca));
640  ca->fib_index = fib->index;
641 
642  BV(clib_bihash_foreach_key_value_pair)
643  (h, count_routes_in_fib_at_prefix_length, ca);
644 
645  for (len = 128; len >= 0; len--)
646  {
647  if (ca->count_by_prefix_length[len])
648  vlib_cli_output (vm, "%=20d%=16lld",
649  len, ca->count_by_prefix_length[len]);
650  }
651  continue;
652  }
653 
654  if (!matching)
655  {
656  ip6_fib_table_show_all(fib, vm);
657  }
658  else
659  {
660  ip6_fib_table_show_one(fib, vm, &matching_address, mask_len);
661  }
662  }));
663 
664  return 0;
665 }
666 
667 /*?
668  * This command displays the IPv6 FIB Tables (VRF Tables) and the route
669  * entries for each table.
670  *
671  * @note This command will run for a long time when the FIB tables are
672  * comprised of millions of entries. For those senarios, consider displaying
673  * in summary mode.
674  *
675  * @cliexpar
676  * @parblock
677  * Example of how to display all the IPv6 FIB tables:
678  * @cliexstart{show ip6 fib}
679  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
680  * @::/0
681  * unicast-ip6-chain
682  * [@0]: dpo-load-balance: [index:5 buckets:1 uRPF:5 to:[0:0]]
683  * [0] [@0]: dpo-drop ip6
684  * fe80::/10
685  * unicast-ip6-chain
686  * [@0]: dpo-load-balance: [index:10 buckets:1 uRPF:10 to:[0:0]]
687  * [0] [@2]: dpo-receive
688  * ff02::1/128
689  * unicast-ip6-chain
690  * [@0]: dpo-load-balance: [index:8 buckets:1 uRPF:8 to:[0:0]]
691  * [0] [@2]: dpo-receive
692  * ff02::2/128
693  * unicast-ip6-chain
694  * [@0]: dpo-load-balance: [index:7 buckets:1 uRPF:7 to:[0:0]]
695  * [0] [@2]: dpo-receive
696  * ff02::16/128
697  * unicast-ip6-chain
698  * [@0]: dpo-load-balance: [index:9 buckets:1 uRPF:9 to:[0:0]]
699  * [0] [@2]: dpo-receive
700  * ff02::1:ff00:0/104
701  * unicast-ip6-chain
702  * [@0]: dpo-load-balance: [index:6 buckets:1 uRPF:6 to:[0:0]]
703  * [0] [@2]: dpo-receive
704  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
705  * @::/0
706  * unicast-ip6-chain
707  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
708  * [0] [@0]: dpo-drop ip6
709  * @::a:1:1:0:4/126
710  * unicast-ip6-chain
711  * [@0]: dpo-load-balance: [index:27 buckets:1 uRPF:26 to:[0:0]]
712  * [0] [@4]: ipv6-glean: af_packet0
713  * @::a:1:1:0:7/128
714  * unicast-ip6-chain
715  * [@0]: dpo-load-balance: [index:28 buckets:1 uRPF:27 to:[0:0]]
716  * [0] [@2]: dpo-receive: @::a:1:1:0:7 on af_packet0
717  * fe80::/10
718  * unicast-ip6-chain
719  * [@0]: dpo-load-balance: [index:26 buckets:1 uRPF:25 to:[0:0]]
720  * [0] [@2]: dpo-receive
721  * fe80::fe:3eff:fe3e:9222/128
722  * unicast-ip6-chain
723  * [@0]: dpo-load-balance: [index:29 buckets:1 uRPF:28 to:[0:0]]
724  * [0] [@2]: dpo-receive: fe80::fe:3eff:fe3e:9222 on af_packet0
725  * ff02::1/128
726  * unicast-ip6-chain
727  * [@0]: dpo-load-balance: [index:24 buckets:1 uRPF:23 to:[0:0]]
728  * [0] [@2]: dpo-receive
729  * ff02::2/128
730  * unicast-ip6-chain
731  * [@0]: dpo-load-balance: [index:23 buckets:1 uRPF:22 to:[0:0]]
732  * [0] [@2]: dpo-receive
733  * ff02::16/128
734  * unicast-ip6-chain
735  * [@0]: dpo-load-balance: [index:25 buckets:1 uRPF:24 to:[0:0]]
736  * [0] [@2]: dpo-receive
737  * ff02::1:ff00:0/104
738  * unicast-ip6-chain
739  * [@0]: dpo-load-balance: [index:22 buckets:1 uRPF:21 to:[0:0]]
740  * [0] [@2]: dpo-receive
741  * @cliexend
742  *
743  * Example of how to display a summary of all IPv6 FIB tables:
744  * @cliexstart{show ip6 fib summary}
745  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
746  * Prefix length Count
747  * 128 3
748  * 104 1
749  * 10 1
750  * 0 1
751  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
752  * Prefix length Count
753  * 128 5
754  * 126 1
755  * 104 1
756  * 10 1
757  * 0 1
758  * @cliexend
759  * @endparblock
760  ?*/
761 /* *INDENT-OFF* */
762 VLIB_CLI_COMMAND (ip6_show_fib_command, static) = {
763  .path = "show ip6 fib",
764  .short_help = "show ip6 fib [summary] [table <table-id>] [index <fib-id>] [<ip6-addr>[/<width>]]",
765  .function = ip6_show_fib,
766 };
767 /* *INDENT-ON* */
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:169
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
#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:115
void fib_table_lock(u32 fib_index, fib_protocol_t proto)
Release a reference counting lock on the table.
Definition: fib_table.c:1072
The table that stores ALL routes learned by the DP.
Definition: ip6.h:125
#define FIB_ENTRY_FORMAT_DETAIL
Definition: fib_entry.h:428
u64 as_u64[2]
Definition: ip6_packet.h:51
#define NULL
Definition: clib.h:55
int(* 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:733
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
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:527
u8 * prefix_lengths_in_search_order
Definition: ip6.h:140
#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:53
flow_hash_config_t flow_hash_config
Definition: ip6.h:76
static int ip6_fib_table_show_walk(fib_node_index_t fib_entry_index, void *arg)
Definition: ip6_fib.c:516
fib_node_index_t ip6_fib_table_lookup_exact_match(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:239
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:376
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:388
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:386
Aggregrate type for a prefix.
Definition: fib_types.h:160
unsigned long u64
Definition: types.h:89
A represenation of a single IP6 table.
Definition: ip6.h:133
u16 fp_len
The mask length.
Definition: fib_types.h:164
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1408
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_fib.c:392
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:146
Definition: fib_entry.h:232
#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
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:406
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:183
struct _unformat_input_t unformat_input_t
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:241
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:436
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:76
u32 index
Definition: ip6.h:73
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
void ip6_fib_table_entry_remove(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:278
Context when walking the IPv6 table.
Definition: ip6_fib.c:472
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:550
uword * fib_index_by_table_id
Definition: ip6.h:173
unformat_function_t unformat_ip6_address
Definition: format.h:94
#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:160
u32 ip6_fib_table_fwding_lookup(ip6_main_t *im, u32 fib_index, const ip6_address_t *dst)
Definition: ip6_fib.c:339
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:369
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:95
void ip6_fib_table_destroy(u32 fib_index)
Definition: ip6_fib.c:101
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:56
vlib_main_t * vm
Definition: buffer.c:276
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:340
#define FOR_EACH_FIB_SOURCE(_item)
Definition: fib_entry.h:156
Definition: ip6.h:67
Definition: fib_entry.h:230
This table stores the routes that are used to forward traffic.
Definition: ip6.h:118
static void compute_prefix_lengths_in_search_order(ip6_fib_table_instance_t *table)
Definition: ip6_fib.c:265
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:512
fib_table_walk_fn_t i6w_fn
Definition: ip6_fib.c:475
static int ip6_fib_walk_cb(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: ip6_fib.c:480
#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:2846
The default route source.
Definition: fib_entry.h:121
i32 dst_address_length_refcounts[129]
Definition: ip6.h:141
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:152
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:165
ip6_fib_table_instance_t ip6_table[IP6_FIB_NUM_TABLES]
The two FIB tables; fwding and non-fwding.
Definition: ip6.h:149
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:427
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:377
ip6_fib_t v6
Definition: fib_table.h:39
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:162
static void ip6_set_solicited_node_multicast_address(ip6_address_t *a, u32 id)
Definition: ip6_packet.h:168
#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:81
#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:581
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:960
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:309
static void count_routes_in_fib_at_prefix_length(BVT(clib_bihash_kv)*kvp, void *arg)
Definition: ip6_fib.c:567
uword * non_empty_dst_address_length_bitmap
Definition: ip6.h:139
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
struct ip6_fib_walk_ctx_t_ ip6_fib_walk_ctx_t
Context when walking the IPv6 table.
#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:193
u32 table_id
Definition: ip6.h:70
vhost_vring_addr_t addr
Definition: vhost-user.h:84
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
struct fib_table_t_ * fibs
Definition: ip6.h:154
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:577
u32 * fib_index_by_sw_if_index
Definition: ip6.h:163
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:971
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
static void ip6_set_reserved_multicast_address(ip6_address_t *a, ip6_multicast_address_scope_t scope, u16 id)
Definition: ip6_packet.h:158
A protocol Independent FIB table.
Definition: fib_table.h:29