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