FD.io VPP  v17.07.01-10-g3be13f0
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  ip6_fib_t *v6_fib;
57 
60 
61  memset(fib_table, 0, sizeof(*fib_table));
62  memset(v6_fib, 0, sizeof(*v6_fib));
63 
64  ASSERT((fib_table - ip6_main.fibs) ==
65  (v6_fib - ip6_main.v6_fibs));
66 
67  fib_table->ft_proto = FIB_PROTOCOL_IP6;
68  fib_table->ft_index =
69  v6_fib->index =
70  (fib_table - ip6_main.fibs);
71 
72  hash_set(ip6_main.fib_index_by_table_id, table_id, fib_table->ft_index);
73 
74  fib_table->ft_table_id =
75  v6_fib->table_id =
76  table_id;
78 
79  vnet_ip6_fib_init(fib_table->ft_index);
81 
82  return (fib_table->ft_index);
83 }
84 
85 u32
87 {
88  uword * p;
89 
90  p = hash_get (ip6_main.fib_index_by_table_id, table_id);
91  if (NULL == p)
92  return create_fib_with_table_id(table_id);
93 
95 
96  return (p[0]);
97 }
98 
99 u32
101 {
102  return (create_fib_with_table_id(~0));
103 }
104 
105 void
107 {
108  fib_prefix_t pfx = {
110  .fp_len = 0,
111  .fp_addr = {
112  .ip6 = {
113  { 0, 0, },
114  },
115  }
116  };
117 
118  /*
119  * the default route.
120  */
122  &pfx,
124 
125 
126  /*
127  * ff02::1:ff00:0/104
128  */
130  pfx.fp_len = 104;
132  &pfx,
134 
135  /*
136  * all-routers multicast address
137  */
139  IP6_MULTICAST_SCOPE_link_local,
140  IP6_MULTICAST_GROUP_ID_all_routers);
141  pfx.fp_len = 128;
143  &pfx,
145 
146  /*
147  * all-nodes multicast address
148  */
150  IP6_MULTICAST_SCOPE_link_local,
151  IP6_MULTICAST_GROUP_ID_all_hosts);
152  pfx.fp_len = 128;
154  &pfx,
156 
157  /*
158  * all-mldv2 multicast address
159  */
161  IP6_MULTICAST_SCOPE_link_local,
162  IP6_MULTICAST_GROUP_ID_mldv2_routers);
163  pfx.fp_len = 128;
165  &pfx,
167 
168  /*
169  * all link local
170  */
171  pfx.fp_addr.ip6.as_u64[0] = clib_host_to_net_u64 (0xFE80000000000000ULL);
172  pfx.fp_addr.ip6.as_u64[1] = 0;
173  pfx.fp_len = 10;
175  &pfx,
177 
178  fib_table_t *fib_table = fib_table_get(fib_index, FIB_PROTOCOL_IP6);
179  fib_source_t source;
180 
181  /*
182  * validate no more routes.
183  */
184  ASSERT(0 == fib_table->ft_total_route_counts);
185  FOR_EACH_FIB_SOURCE(source)
186  {
187  ASSERT(0 == fib_table->ft_src_route_counts[source]);
188  }
189 
190  if (~0 != fib_table->ft_table_id)
191  {
193  }
195  pool_put(ip6_main.fibs, fib_table);
196 }
197 
200  const ip6_address_t *addr,
201  u32 len)
202 {
203  const ip6_fib_table_instance_t *table;
204  BVT(clib_bihash_kv) kv, value;
205  int i, n_p, rv;
206  u64 fib;
207 
210 
211  kv.key[0] = addr->as_u64[0];
212  kv.key[1] = addr->as_u64[1];
213  fib = ((u64)((fib_index))<<32);
214 
215  /*
216  * start search from a mask length same length or shorter.
217  * we don't want matches longer than the mask passed
218  */
219  i = 0;
220  while (i < n_p && table->prefix_lengths_in_search_order[i] > len)
221  {
222  i++;
223  }
224 
225  for (; i < n_p; i++)
226  {
227  int dst_address_length = table->prefix_lengths_in_search_order[i];
228  ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
229 
230  ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
231  //As lengths are decreasing, masks are increasingly specific.
232  kv.key[0] &= mask->as_u64[0];
233  kv.key[1] &= mask->as_u64[1];
234  kv.key[2] = fib | dst_address_length;
235 
236  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
237  if (rv == 0)
238  return value.value;
239  }
240 
241  return (FIB_NODE_INDEX_INVALID);
242 }
243 
246  const ip6_address_t *addr,
247  u32 len)
248 {
249  const ip6_fib_table_instance_t *table;
250  BVT(clib_bihash_kv) kv, value;
251  ip6_address_t *mask;
252  u64 fib;
253  int rv;
254 
256  mask = &ip6_main.fib_masks[len];
257  fib = ((u64)((fib_index))<<32);
258 
259  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
260  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
261  kv.key[2] = fib | len;
262 
263  rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
264  if (rv == 0)
265  return value.value;
266 
267  return (FIB_NODE_INDEX_INVALID);
268 }
269 
270 static void
272 {
273  int i;
275  /* Note: bitmap reversed so this is in fact a longest prefix match */
277  ({
278  int dst_address_length = 128 - i;
279  vec_add1(table->prefix_lengths_in_search_order, dst_address_length);
280  }));
281 }
282 
283 void
285  const ip6_address_t *addr,
286  u32 len)
287 {
289  BVT(clib_bihash_kv) kv;
290  ip6_address_t *mask;
291  u64 fib;
292 
294  mask = &ip6_main.fib_masks[len];
295  fib = ((u64)((fib_index))<<32);
296 
297  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
298  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
299  kv.key[2] = fib | len;
300 
301  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 0);
302 
303  /* refcount accounting */
304  ASSERT (table->dst_address_length_refcounts[len] > 0);
305  if (--table->dst_address_length_refcounts[len] == 0)
306  {
309  128 - len, 0);
311  }
312 }
313 
314 void
316  const ip6_address_t *addr,
317  u32 len,
318  fib_node_index_t fib_entry_index)
319 {
321  BVT(clib_bihash_kv) kv;
322  ip6_address_t *mask;
323  u64 fib;
324 
326  mask = &ip6_main.fib_masks[len];
327  fib = ((u64)((fib_index))<<32);
328 
329  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
330  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
331  kv.key[2] = fib | len;
332  kv.value = fib_entry_index;
333 
334  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 1);
335 
336  table->dst_address_length_refcounts[len]++;
337 
340  128 - len, 1);
342 }
343 
345  u32 sw_if_index,
346  const ip6_address_t * dst)
347 {
348  u32 fib_index = vec_elt (im->fib_index_by_sw_if_index, sw_if_index);
349  return ip6_fib_table_fwding_lookup(im, fib_index, dst);
350 }
351 
352 u32
354 {
355  if (sw_if_index >= vec_len(ip6_main.fib_index_by_sw_if_index))
356  {
357  /*
358  * This is the case for interfaces that are not yet mapped to
359  * a IP table
360  */
361  return (~0);
362  }
363  return (ip6_main.fib_index_by_sw_if_index[sw_if_index]);
364 }
365 
366 void
368  const ip6_address_t *addr,
369  u32 len,
370  const dpo_id_t *dpo)
371 {
373  BVT(clib_bihash_kv) kv;
374  ip6_address_t *mask;
375  u64 fib;
376 
378  mask = &ip6_main.fib_masks[len];
379  fib = ((u64)((fib_index))<<32);
380 
381  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
382  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
383  kv.key[2] = fib | len;
384  kv.value = dpo->dpoi_index;
385 
386  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 1);
387 
388  table->dst_address_length_refcounts[len]++;
389 
392  128 - len, 1);
394 }
395 
396 void
398  const ip6_address_t *addr,
399  u32 len,
400  const dpo_id_t *dpo)
401 {
403  BVT(clib_bihash_kv) kv;
404  ip6_address_t *mask;
405  u64 fib;
406 
408  mask = &ip6_main.fib_masks[len];
409  fib = ((u64)((fib_index))<<32);
410 
411  kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
412  kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
413  kv.key[2] = fib | len;
414  kv.value = dpo->dpoi_index;
415 
416  BV(clib_bihash_add_del)(&table->ip6_hash, &kv, 0);
417 
418  /* refcount accounting */
419  ASSERT (table->dst_address_length_refcounts[len] > 0);
420  if (--table->dst_address_length_refcounts[len] == 0)
421  {
424  128 - len, 0);
426  }
427 }
428 
429 /**
430  * @brief Context when walking the IPv6 table. Since all VRFs are in the
431  * same hash table, we need to filter only those we need as we walk
432  */
433 typedef struct ip6_fib_walk_ctx_t_
434 {
437  void *i6w_ctx;
439 
440 static int
442  void *arg)
443 {
444  ip6_fib_walk_ctx_t *ctx = arg;
445 
446  if ((kvp->key[2] >> 32) == ctx->i6w_fib_index)
447  {
448  ctx->i6w_fn(kvp->value, ctx->i6w_ctx);
449  }
450 
451  return (1);
452 }
453 
454 void
457  void *arg)
458 {
459  ip6_fib_walk_ctx_t ctx = {
460  .i6w_fib_index = fib_index,
461  .i6w_fn = fn,
462  .i6w_ctx = arg,
463  };
464  ip6_main_t *im = &ip6_main;
465 
468  &ctx);
469 
470 }
471 
472 typedef struct ip6_fib_show_ctx_t_ {
475 
476 static int
478  void *arg)
479 {
480  ip6_fib_show_ctx_t *ctx = arg;
481 
482  vec_add1(ctx->entries, fib_entry_index);
483 
484  return (1);
485 }
486 
487 static void
489  vlib_main_t * vm)
490 {
491  fib_node_index_t *fib_entry_index;
492  ip6_fib_show_ctx_t ctx = {
493  .entries = NULL,
494  };
495 
498 
499  vec_foreach(fib_entry_index, ctx.entries)
500  {
501  vlib_cli_output(vm, "%U",
503  *fib_entry_index,
505  }
506 
507  vec_free(ctx.entries);
508 }
509 
510 static void
512  vlib_main_t * vm,
513  ip6_address_t *address,
514  u32 mask_len,
515  int detail)
516 {
517  vlib_cli_output(vm, "%U",
519  ip6_fib_table_lookup(fib->index, address, mask_len),
520  (detail ?
523 }
524 
525 typedef struct {
527  u64 count_by_prefix_length[129];
529 
530 static void
532  void *arg)
533 {
535  int mask_width;
536 
537  if ((kvp->key[2]>>32) != ap->fib_index)
538  return;
539 
540  mask_width = kvp->key[2] & 0xFF;
541 
542  ap->count_by_prefix_length[mask_width]++;
543 }
544 
545 static clib_error_t *
547  unformat_input_t * input,
548  vlib_cli_command_t * cmd)
549 {
551  ip6_main_t * im6 = &ip6_main;
552  fib_table_t *fib_table;
553  ip6_fib_t * fib;
554  int verbose, matching;
555  ip6_address_t matching_address;
556  u32 mask_len = 128;
557  int table_id = -1, fib_index = ~0;
558  int detail = 0;
559 
560  verbose = 1;
561  matching = 0;
562 
564  {
565  if (unformat (input, "brief") ||
566  unformat (input, "summary") ||
567  unformat (input, "sum"))
568  verbose = 0;
569 
570  else if (unformat (input, "detail") ||
571  unformat (input, "det"))
572  detail = 1;
573 
574  else if (unformat (input, "%U/%d",
575  unformat_ip6_address, &matching_address, &mask_len))
576  matching = 1;
577 
578  else if (unformat (input, "%U", unformat_ip6_address, &matching_address))
579  matching = 1;
580 
581  else if (unformat (input, "table %d", &table_id))
582  ;
583  else if (unformat (input, "index %d", &fib_index))
584  ;
585  else
586  break;
587  }
588 
589  pool_foreach (fib_table, im6->fibs,
590  ({
591  fib = pool_elt_at_index(im6->v6_fibs, fib_table->ft_index);
592  if (table_id >= 0 && table_id != (int)fib->table_id)
593  continue;
594  if (fib_index != ~0 && fib_index != (int)fib->index)
595  continue;
596 
597  vlib_cli_output (vm, "%s, fib_index:%d, flow hash:[%U] locks:%d",
598  fib_table->ft_desc, fib->index,
599  format_ip_flow_hash_config, fib_table->ft_flow_hash_config,
600  fib_table->ft_locks);
601 
602  /* Show summary? */
603  if (! verbose)
604  {
605  BVT(clib_bihash) * h = &im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash;
606  int len;
607 
608  vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count");
609 
610  memset (ca, 0, sizeof(*ca));
611  ca->fib_index = fib->index;
612 
613  BV(clib_bihash_foreach_key_value_pair)
614  (h, count_routes_in_fib_at_prefix_length, ca);
615 
616  for (len = 128; len >= 0; len--)
617  {
618  if (ca->count_by_prefix_length[len])
619  vlib_cli_output (vm, "%=20d%=16lld",
620  len, ca->count_by_prefix_length[len]);
621  }
622  continue;
623  }
624 
625  if (!matching)
626  {
627  ip6_fib_table_show_all(fib, vm);
628  }
629  else
630  {
631  ip6_fib_table_show_one(fib, vm, &matching_address, mask_len, detail);
632  }
633  }));
634 
635  return 0;
636 }
637 
638 /*?
639  * This command displays the IPv6 FIB Tables (VRF Tables) and the route
640  * entries for each table.
641  *
642  * @note This command will run for a long time when the FIB tables are
643  * comprised of millions of entries. For those senarios, consider displaying
644  * in summary mode.
645  *
646  * @cliexpar
647  * @parblock
648  * Example of how to display all the IPv6 FIB tables:
649  * @cliexstart{show ip6 fib}
650  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
651  * @::/0
652  * unicast-ip6-chain
653  * [@0]: dpo-load-balance: [index:5 buckets:1 uRPF:5 to:[0:0]]
654  * [0] [@0]: dpo-drop ip6
655  * fe80::/10
656  * unicast-ip6-chain
657  * [@0]: dpo-load-balance: [index:10 buckets:1 uRPF:10 to:[0:0]]
658  * [0] [@2]: dpo-receive
659  * ff02::1/128
660  * unicast-ip6-chain
661  * [@0]: dpo-load-balance: [index:8 buckets:1 uRPF:8 to:[0:0]]
662  * [0] [@2]: dpo-receive
663  * ff02::2/128
664  * unicast-ip6-chain
665  * [@0]: dpo-load-balance: [index:7 buckets:1 uRPF:7 to:[0:0]]
666  * [0] [@2]: dpo-receive
667  * ff02::16/128
668  * unicast-ip6-chain
669  * [@0]: dpo-load-balance: [index:9 buckets:1 uRPF:9 to:[0:0]]
670  * [0] [@2]: dpo-receive
671  * ff02::1:ff00:0/104
672  * unicast-ip6-chain
673  * [@0]: dpo-load-balance: [index:6 buckets:1 uRPF:6 to:[0:0]]
674  * [0] [@2]: dpo-receive
675  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
676  * @::/0
677  * unicast-ip6-chain
678  * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]]
679  * [0] [@0]: dpo-drop ip6
680  * @::a:1:1:0:4/126
681  * unicast-ip6-chain
682  * [@0]: dpo-load-balance: [index:27 buckets:1 uRPF:26 to:[0:0]]
683  * [0] [@4]: ipv6-glean: af_packet0
684  * @::a:1:1:0:7/128
685  * unicast-ip6-chain
686  * [@0]: dpo-load-balance: [index:28 buckets:1 uRPF:27 to:[0:0]]
687  * [0] [@2]: dpo-receive: @::a:1:1:0:7 on af_packet0
688  * fe80::/10
689  * unicast-ip6-chain
690  * [@0]: dpo-load-balance: [index:26 buckets:1 uRPF:25 to:[0:0]]
691  * [0] [@2]: dpo-receive
692  * fe80::fe:3eff:fe3e:9222/128
693  * unicast-ip6-chain
694  * [@0]: dpo-load-balance: [index:29 buckets:1 uRPF:28 to:[0:0]]
695  * [0] [@2]: dpo-receive: fe80::fe:3eff:fe3e:9222 on af_packet0
696  * ff02::1/128
697  * unicast-ip6-chain
698  * [@0]: dpo-load-balance: [index:24 buckets:1 uRPF:23 to:[0:0]]
699  * [0] [@2]: dpo-receive
700  * ff02::2/128
701  * unicast-ip6-chain
702  * [@0]: dpo-load-balance: [index:23 buckets:1 uRPF:22 to:[0:0]]
703  * [0] [@2]: dpo-receive
704  * ff02::16/128
705  * unicast-ip6-chain
706  * [@0]: dpo-load-balance: [index:25 buckets:1 uRPF:24 to:[0:0]]
707  * [0] [@2]: dpo-receive
708  * ff02::1:ff00:0/104
709  * unicast-ip6-chain
710  * [@0]: dpo-load-balance: [index:22 buckets:1 uRPF:21 to:[0:0]]
711  * [0] [@2]: dpo-receive
712  * @cliexend
713  *
714  * Example of how to display a summary of all IPv6 FIB tables:
715  * @cliexstart{show ip6 fib summary}
716  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
717  * Prefix length Count
718  * 128 3
719  * 104 1
720  * 10 1
721  * 0 1
722  * ipv6-VRF:8, fib_index 1, flow hash: src dst sport dport proto
723  * Prefix length Count
724  * 128 5
725  * 126 1
726  * 104 1
727  * 10 1
728  * 0 1
729  * @cliexend
730  * @endparblock
731  ?*/
732 /* *INDENT-OFF* */
733 VLIB_CLI_COMMAND (ip6_show_fib_command, static) = {
734  .path = "show ip6 fib",
735  .short_help = "show ip6 fib [summary] [table <table-id>] [index <fib-id>] [<ip6-addr>[/<width>]] [detail]",
736  .function = ip6_show_fib,
737 };
738 /* *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:87
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:34
ip6_fib_t * v6_fibs
Definition: ip6.h:154
#define hash_unset(h, key)
Definition: hash.h:260
void fib_table_lock(u32 fib_index, fib_protocol_t proto)
Release a reference counting lock on the table.
Definition: fib_table.c:1159
The table that stores ALL routes learned by the DP.
Definition: ip6.h:122
#define FIB_ENTRY_FORMAT_DETAIL
Definition: fib_entry.h:435
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:751
#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 u32 ip6_fib_table_fwding_lookup(ip6_main_t *im, u32 fib_index, const ip6_address_t *dst)
Definition: ip6_fib.h:67
static void ip6_fib_table_show_all(ip6_fib_t *fib, vlib_main_t *vm)
Definition: ip6_fib.c:488
u8 * prefix_lengths_in_search_order
Definition: ip6.h:137
#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
static int ip6_fib_table_show_walk(fib_node_index_t fib_entry_index, void *arg)
Definition: ip6_fib.c:477
fib_node_index_t ip6_fib_table_lookup_exact_match(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:245
#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:390
static BVT(clib_bihash)
Definition: adj_nbr.c:26
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:130
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:1484
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_fib.c:353
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:152
Definition: fib_entry.h:238
#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:367
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:397
u32 ft_total_route_counts
Total route counters.
Definition: fib_table.h:64
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:455
void ip6_fib_table_entry_remove(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:284
Context when walking the IPv6 table.
Definition: ip6_fib.c:433
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
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:371
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:49
u32 ip6_fib_table_create_and_lock(void)
Definition: ip6_fib.c:100
void ip6_fib_table_destroy(u32 fib_index)
Definition: ip6_fib.c:106
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:44
u32 ft_flow_hash_config
flow hash configuration
Definition: fib_table.h:54
#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:236
This table stores the routes that are used to forward traffic.
Definition: ip6.h:115
static void compute_prefix_lengths_in_search_order(ip6_fib_table_instance_t *table)
Definition: ip6_fib.c:271
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:473
fib_table_walk_fn_t i6w_fn
Definition: ip6_fib.c:436
static int ip6_fib_walk_cb(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: ip6_fib.c:441
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:255
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
ip6_main_t ip6_main
Definition: ip6_forward.c:2926
The default route source.
Definition: fib_entry.h:121
i32 dst_address_length_refcounts[129]
Definition: ip6.h:138
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:511
u32 ft_src_route_counts[FIB_SOURCE_MAX]
Per-source route counters.
Definition: fib_table.h:59
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
Definition: lookup.h:69
ip6_fib_table_instance_t ip6_table[IP6_FIB_NUM_TABLES]
The two FIB tables; fwding and non-fwding.
Definition: ip6.h:146
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:434
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:344
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:168
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:86
#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:546
#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:315
static void count_routes_in_fib_at_prefix_length(BVT(clib_bihash_kv)*kvp, void *arg)
Definition: ip6_fib.c:531
uword * non_empty_dst_address_length_bitmap
Definition: ip6.h:136
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 FIB_ENTRY_FORMAT_DETAIL2
Definition: fib_entry.h:436
#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:199
u32 table_id
Definition: ip6.h:70
vhost_vring_addr_t addr
Definition: vhost-user.h:82
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
struct fib_table_t_ * fibs
Definition: ip6.h:151
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
u32 * fib_index_by_sw_if_index
Definition: ip6.h:163
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
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