FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip6_mfib.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/mfib/ip6_mfib.h>
17 
18 #include <vnet/mfib/mfib_table.h>
19 #include <vnet/mfib/mfib_entry.h>
20 #include <vnet/fib/ip6_fib.h>
21 
23 
24 /**
25  * Key and mask for radix
26  */
28 
29 static const mfib_prefix_t all_zeros = {
30  /* (*,*) */
31  .fp_src_addr = {
32  .ip6.as_u64 = {0, 0},
33  },
34  .fp_grp_addr = {
35  .ip6.as_u64 = {0, 0},
36  },
37  .fp_len = 0,
38  .fp_proto = FIB_PROTOCOL_IP6,
39 };
40 
45 
46 typedef struct ip6_mfib_special_t_ {
47  /**
48  * @brief solicited or not
49  */
51 
52  /**
53  * @brief the Prefix length
54  */
56 
57  /**
58  * @brief The last byte of the mcast address
59  */
61  /**
62  * @brief The scope of the address
63  */
66 
68 {
69  {
70  /*
71  * Add ff02::1:ff00:0/104 via local route for all tables.
72  * This is required for neighbor discovery to work.
73  */
75  .ims_len = 104,
76  },
77  {
78  /*
79  * all-routers multicast address
80  */
81  .ims_type = IP6_MFIB_SPECIAL_TYPE_NONE,
82  .ims_scope = IP6_MULTICAST_SCOPE_link_local,
83  .ims_byte = IP6_MULTICAST_GROUP_ID_all_routers,
84  .ims_len = 128,
85  },
86  {
87  /*
88  * all-nodes multicast address
89  */
90  .ims_type = IP6_MFIB_SPECIAL_TYPE_NONE,
91  .ims_scope = IP6_MULTICAST_SCOPE_link_local,
92  .ims_byte = IP6_MULTICAST_GROUP_ID_all_hosts,
93  .ims_len = 128,
94  },
95  {
96  /*
97  * Add all-mldv2 multicast address via local route for all tables
98  */
99  .ims_type = IP6_MFIB_SPECIAL_TYPE_NONE,
100  .ims_len = 128,
101  .ims_scope = IP6_MULTICAST_SCOPE_link_local,
102  .ims_byte = IP6_MULTICAST_GROUP_ID_mldv2_routers,
103  }
104 };
105 
106 #define FOR_EACH_IP6_SPECIAL(_pfx, _body) \
107 { \
108  const ip6_mfib_special_t *_spec; \
109  u8 _ii; \
110  for (_ii = 0; \
111  _ii < ARRAY_LEN(ip6_mfib_specials); \
112  _ii++) \
113  { \
114  _spec = &ip6_mfib_specials[_ii]; \
115  if (IP6_MFIB_SPECIAL_TYPE_SOLICITED == _spec->ims_type) \
116  { \
117  ip6_set_solicited_node_multicast_address( \
118  &(_pfx)->fp_grp_addr.ip6, 0); \
119  } \
120  else \
121  { \
122  ip6_set_reserved_multicast_address ( \
123  &(_pfx)->fp_grp_addr.ip6, \
124  _spec->ims_scope, \
125  _spec->ims_byte); \
126  } \
127  (_pfx)->fp_len = _spec->ims_len; \
128  do { _body; } while (0); \
129  } \
130 }
131 
132 
133 static u32
136 {
137  mfib_table_t *mfib_table;
138  mfib_prefix_t pfx = {
140  };
141  const fib_route_path_t path_for_us = {
143  .frp_addr = zero_addr,
144  .frp_sw_if_index = 0xffffffff,
145  .frp_fib_index = ~0,
146  .frp_weight = 1,
147  .frp_flags = FIB_ROUTE_PATH_LOCAL,
148  .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD,
149  };
150 
152  clib_memset(mfib_table, 0, sizeof(*mfib_table));
153 
154  mfib_table->mft_proto = FIB_PROTOCOL_IP6;
155  mfib_table->mft_index =
156  mfib_table->v6.index =
157  (mfib_table - ip6_main.mfibs);
158 
160  table_id,
161  mfib_table->mft_index);
162 
163  mfib_table->mft_table_id =
164  mfib_table->v6.table_id =
165  table_id;
166 
168 
169  /*
170  * add the special entries into the new FIB
171  */
173  &all_zeros,
177 
178  /*
179  * Add each of the specials
180  */
182  ({
184  &pfx,
186  &path_for_us);
187  }));
188 
189  return (mfib_table->mft_index);
190 }
191 
192 void
194 {
195  mfib_table_t *mfib_table = (mfib_table_t*)mfib;
196  fib_node_index_t mfei;
197  mfib_prefix_t pfx = {
199  };
200  const fib_route_path_t path_for_us = {
202  .frp_addr = zero_addr,
203  .frp_sw_if_index = 0xffffffff,
204  .frp_fib_index = ~0,
205  .frp_weight = 1,
206  .frp_flags = FIB_ROUTE_PATH_LOCAL,
207  };
208 
209  /*
210  * remove all the specials we added when the table was created.
211  */
213  {
215  &pfx,
217  &path_for_us);
218  });
219 
220  mfei = mfib_table_lookup_exact_match(mfib_table->mft_index, &all_zeros);
222 
223  /*
224  * validate no more routes.
225  */
226  ASSERT(0 == mfib_table->mft_total_route_counts);
227  ASSERT(~0 != mfib_table->mft_table_id);
228 
230  pool_put(ip6_main.mfibs, mfib_table);
231 }
232 
233 void
235 {
236  const fib_route_path_t path = {
237  .frp_proto = DPO_PROTO_IP6,
238  .frp_addr = zero_addr,
239  .frp_sw_if_index = sw_if_index,
240  .frp_fib_index = ~0,
241  .frp_weight = 1,
242  .frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT,
243  };
244  mfib_prefix_t pfx = {
246  };
247  u32 mfib_index;
248 
250 
251  if (is_enable)
252  {
254  {
255  mfib_table_entry_path_update(mfib_index,
256  &pfx,
258  &path);
259  });
260  }
261  else
262  {
264  {
265  mfib_table_entry_path_remove(mfib_index,
266  &pfx,
268  &path);
269  });
270  }
271 }
272 
273 u32
276 {
277  u32 index;
278 
280  if (~0 == index)
283 
284  return (index);
285 }
286 
287 u32
289 {
291  {
292  /*
293  * This is the case for interfaces that are not yet mapped to
294  * a IP table
295  */
296  return (~0);
297  }
299 }
300 
301 #define IPV6_MFIB_GRP_LEN(_len) \
302  (_len > 128 ? 128 : _len)
303 
304 #define IP6_MFIB_MK_KEY(_mfib, _grp, _src, _len, _key) \
305 { \
306  _key.key[0] = (_grp->as_u64[0] & \
307  ip6_main.fib_masks[IPV6_MFIB_GRP_LEN(_len)].as_u64[0]); \
308  _key.key[1] = (_grp->as_u64[1] & \
309  ip6_main.fib_masks[IPV6_MFIB_GRP_LEN(_len)].as_u64[1]); \
310  if (_len == 256) { \
311  _key.key[2] = _src->as_u64[0]; \
312  _key.key[3] = _src->as_u64[1]; \
313  } else { \
314  _key.key[2] = 0; \
315  _key.key[3] = 0; \
316  } \
317  _key.key[4] = _mfib->index; \
318  _key.key[4] = (_key.key[4] << 32) | len; \
319 }
320 
321 /*
322  * ip6_fib_table_lookup_exact_match
323  *
324  * Exact match prefix lookup
325  */
328  const ip6_address_t *grp,
329  const ip6_address_t *src,
330  u32 len)
331 {
333  int rv;
334 
335  IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
336 
337  rv = clib_bihash_search_inline_2_40_8(&ip6_mfib_table.ip6_mhash,
338  &key, &value);
339  if (rv == 0)
340  return value.value;
341 
342  return (FIB_NODE_INDEX_INVALID);
343 }
344 
345 /*
346  * ip6_fib_table_lookup
347  *
348  * Longest prefix match for the forwarding plane (no mask given)
349  */
352  const ip6_address_t *src,
353  const ip6_address_t *grp)
354 {
357  int i, n, len;
358  int rv;
359 
360  table = &ip6_mfib_table;
362 
363  for (i = 0; i < n; i++)
364  {
366 
367  ASSERT(len >= 0 && len <= 256);
368  IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
369  rv = clib_bihash_search_inline_2_40_8(&table->ip6_mhash, &key, &value);
370  if (rv == 0)
371  return value.value;
372  }
373 
374  return (FIB_NODE_INDEX_INVALID);
375 }
376 
377 
380  const ip6_address_t *src,
381  const ip6_address_t *grp,
382  u32 len)
383 {
384  u32 mask_len;
385 
386  /*
387  * in the absence of a tree structure for the table that allows for an O(1)
388  * parent get, a cheeky way to find the cover is to LPM for the prefix with
389  * mask-1.
390  * there should always be a cover, though it may be the default route. the
391  * default route's cover is the default route.
392  */
393  if (len == 256)
394  {
395  /* go from (S,G) to (*,G*) */
396  mask_len = 128;
397  }
398  else if (len != 0)
399  {
400  mask_len = len - 1;
401  }
402  else
403  {
404  mask_len = len;
405  }
406 
407  return (ip6_mfib_table_lookup(mfib, src, grp, mask_len));
408 }
409 
410 /*
411  * ip6_fib_table_lookup
412  *
413  * Longest prefix match
414  */
417  const ip6_address_t *src,
418  const ip6_address_t *grp,
419  u32 len)
420 {
423  int i, n, rv;
424 
425  table = &ip6_mfib_table;
427 
428  /*
429  * start search from a mask length same length or shorter.
430  * we don't want matches longer than the mask passed
431  */
432  i = 0;
433  while (i < n && table->prefix_lengths_in_search_order[i] > len)
434  {
435  i++;
436  }
437 
438  for (; i < n; i++)
439  {
441 
442  ASSERT(len <= 256);
443  IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
444 
445  rv = clib_bihash_search_inline_2_40_8(&table->ip6_mhash, &key, &value);
446  if (rv == 0)
447  return value.value;
448  }
449 
450  return (FIB_NODE_INDEX_INVALID);
451 }
452 
453 static void
455 {
456  int i;
458  /* Note: bitmap reversed so this is in fact a longest prefix match */
460  {
461  vec_add1(table->prefix_lengths_in_search_order, (256 - i));
462  }
463 }
464 
465 void
467  const ip6_address_t *grp,
468  const ip6_address_t *src,
469  u32 len,
470  fib_node_index_t mfib_entry_index)
471 {
474 
475  table = &ip6_mfib_table;
476  IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
477  key.value = mfib_entry_index;
478 
479  clib_bihash_add_del_40_8(&table->ip6_mhash, &key, 1);
480 
481  if (0 == table->dst_address_length_refcounts[len]++)
482  {
485  256 - len, 1);
487  }
488 }
489 
490 void
492  const ip6_address_t *grp,
493  const ip6_address_t *src,
494  u32 len)
495 {
498 
499  IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
500 
501  table = &ip6_mfib_table;
502  clib_bihash_add_del_40_8(&table->ip6_mhash, &key, 0);
503 
505  if (--table->dst_address_length_refcounts[len] == 0)
506  {
509  256 - len, 0);
511  }
512 }
513 
514 static clib_error_t *
516 {
517  return (NULL);
518 }
519 
521 
522 u8 *
523 format_ip6_mfib_table_memory (u8 * s, va_list * args)
524 {
525  u64 bytes_inuse;
526 
527  bytes_inuse = alloc_arena_next(&(ip6_mfib_table.ip6_mhash));
528 
529  s = format(s, "%=30s %=6d %=12ld\n",
530  "IPv6 multicast",
532  bytes_inuse);
533 
534  return (s);
535 }
536 
537 static void
539  vlib_main_t * vm,
540  ip6_address_t *src,
541  ip6_address_t *grp,
542  u32 mask_len,
543  u32 cover)
544 {
545  if (cover)
546  {
547  vlib_cli_output(vm, "%U",
549  ip6_mfib_table_get_less_specific(mfib, src, grp, mask_len),
551  }
552  else
553  {
554  vlib_cli_output(vm, "%U",
556  ip6_mfib_table_lookup(mfib, src, grp, mask_len),
558  }
559 }
560 
561 typedef struct ip6_mfib_show_ctx_t_ {
564 
565 
566 static walk_rc_t
568 {
569  ip6_mfib_show_ctx_t *ctx = arg;
570 
571  vec_add1(ctx->entries, mfei);
572 
573  return (WALK_CONTINUE);
574 }
575 
576 static void
578  vlib_main_t * vm)
579 {
580  fib_node_index_t *mfib_entry_index;
582  .entries = NULL,
583  };
584 
585  ip6_mfib_table_walk(mfib,
587  &ctx);
588 
590 
591  vec_foreach(mfib_entry_index, ctx.entries)
592  {
593  vlib_cli_output(vm, "%U",
595  *mfib_entry_index,
597  }
598 
599  vec_free(ctx.entries);
600 }
601 
602 /**
603  * @brief Context when walking the IPv6 table. Since all VRFs are in the
604  * same hash table, we need to filter only those we need as we walk
605  */
606 typedef struct ip6_mfib_walk_ctx_t_
607 {
610  void *i6w_ctx;
612 
613 static int
615  void *arg)
616 {
617  ip6_mfib_walk_ctx_t *ctx = arg;
618 
619  if ((kvp->key[4] >> 32) == ctx->i6w_mfib_index)
620  {
621  ctx->i6w_fn(kvp->value, ctx->i6w_ctx);
622  }
623  return (BIHASH_WALK_CONTINUE);
624 }
625 
626 void
629  void *arg)
630 {
632  .i6w_mfib_index = mfib->index,
633  .i6w_fn = fn,
634  .i6w_ctx = arg,
635  };
636 
637  clib_bihash_foreach_key_value_pair_40_8(
640  &ctx);
641 }
642 
643 static clib_error_t *
645  unformat_input_t * input,
646  vlib_cli_command_t * cmd)
647 {
648  ip6_main_t * im6 = &ip6_main;
649  mfib_table_t *mfib_table;
650  int verbose, matching;
651  ip6_address_t grp, src = {{0}};
652  u32 mask = 128, cover;
653  int table_id = -1, fib_index = ~0;
654 
655  verbose = 1;
656  matching = 0;
657  cover = 0;
658 
660  {
661  if (unformat (input, "brief") || unformat (input, "summary")
662  || unformat (input, "sum"))
663  verbose = 0;
664 
665  else if (unformat (input, "%U %U",
667  unformat_ip6_address, &grp))
668  {
669  matching = 1;
670  mask = 256;
671  }
672  else if (unformat (input, "%U/%d", unformat_ip6_address, &grp, &mask))
673  {
674  clib_memset(&src, 0, sizeof(src));
675  matching = 1;
676  }
677  else if (unformat (input, "%U", unformat_ip6_address, &grp))
678  {
679  clib_memset(&src, 0, sizeof(src));
680  matching = 1;
681  mask = 128;
682  }
683  else if (unformat (input, "table %d", &table_id))
684  ;
685  else if (unformat (input, "index %d", &fib_index))
686  ;
687  else if (unformat (input, "cover"))
688  cover = 1;
689  else
690  break;
691  }
692 
693  pool_foreach (mfib_table, im6->mfibs)
694  {
695  ip6_mfib_t *mfib = &mfib_table->v6;
696 
697  if (table_id >= 0 && table_id != (int)mfib->table_id)
698  continue;
699  if (fib_index != ~0 && fib_index != (int)mfib->index)
700  continue;
701 
702  vlib_cli_output (vm, "%U, fib_index %d",
704  mfib->index);
705 
706  /* Show summary? */
707  if (! verbose)
708  {
709  /* vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count"); */
710  /* for (i = 0; i < ARRAY_LEN (mfib->fib_entry_by_dst_address); i++) */
711  /* { */
712  /* uword * hash = mfib->fib_entry_by_dst_address[i]; */
713  /* uword n_elts = hash_elts (hash); */
714  /* if (n_elts > 0) */
715  /* vlib_cli_output (vm, "%20d%16d", i, n_elts); */
716  /* } */
717  continue;
718  }
719 
720  if (!matching)
721  {
723  }
724  else
725  {
726  ip6_mfib_table_show_one(mfib, vm, &src, &grp, mask, cover);
727  }
728  }
729 
730  return 0;
731 }
732 
733 /*
734  * This command displays the IPv6 MulticasrFIB Tables (VRF Tables) and
735  * the route entries for each table.
736  *
737  * @note This command will run for a long time when the FIB tables are
738  * comprised of millions of entries. For those senarios, consider displaying
739  * a single table or summary mode.
740  *
741  * @cliexpar
742  * Example of how to display all the IPv6 Multicast FIB tables:
743  * @cliexstart{show ip fib}
744  * ipv6-VRF:0, fib_index 0
745  * (*, 0.0.0.0/0): flags:D,
746  * Interfaces:
747  * multicast-ip6-chain
748  * [@1]: dpo-drop ip6
749  * (*, 232.1.1.1/32):
750  * Interfaces:
751  * test-eth1: Forward,
752  * test-eth2: Forward,
753  * test-eth0: Accept,
754  * multicast-ip6-chain
755  * [@2]: dpo-replicate: [index:1 buckets:2 to:[0:0]]
756  * [0] [@1]: ipv6-mcast: test-eth1: IP6: d0:d1:d2:d3:d4:01 -> 01:00:05:00:00:00
757  * [1] [@1]: ipv6-mcast: test-eth2: IP6: d0:d1:d2:d3:d4:02 -> 01:00:05:00:00:00
758  *
759  * @cliexend
760  * Example of how to display a summary of all IPv6 FIB tables:
761  * @cliexstart{show ip fib summary}
762  * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto
763  * Prefix length Count
764  * 0 1
765  * 8 2
766  * 32 4
767  * ipv6-VRF:7, fib_index 1, flow hash: src dst sport dport proto
768  * Prefix length Count
769  * 0 1
770  * 8 2
771  * 24 2
772  * 32 4
773  * @cliexend
774  */
775 /* *INDENT-OFF* */
777  .path = "show ip6 mfib",
778  .short_help = "show ip mfib [summary] [table <table-id>] [index <fib-id>] [<grp-addr>[/<mask>]] [<grp-addr>] [<src-addr> <grp-addr>]",
779  .function = ip6_show_mfib,
780 };
781 /* *INDENT-ON* */
782 
783 static clib_error_t *
785 {
786  clib_bihash_init_40_8 (&ip6_mfib_table.ip6_mhash,
787  "ip6 mFIB table",
790 
791  return (NULL);
792 }
793 
795 {
796  .runs_before = VLIB_INITS("ip6_lookup_init"),
797 };
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
clib_bihash_kv_40_8_t::value
u64 value
Definition: bihash_40_8.h:44
ip6_mfib_table_destroy
void ip6_mfib_table_destroy(ip6_mfib_t *mfib)
Definition: ip6_mfib.c:193
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
ip6_mfib_t::table_id
u32 table_id
Definition: ip6.h:79
ip6_mfib_show_ctx_t_
Definition: ip6_mfib.c:561
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
ip6_show_fib_command
static vlib_cli_command_t ip6_show_fib_command
(constructor) VLIB_CLI_COMMAND (ip6_show_fib_command)
Definition: ip6_mfib.c:776
zero_addr
const ip46_address_t zero_addr
#include <vnet/feature/feature.h>
Definition: lookup.c:182
ip6_mfib_table
ip6_mfib_table_instance_t ip6_mfib_table
the single MFIB table
Definition: ip6_mfib.c:22
ip6_mfib_walk_ctx_t_::i6w_ctx
void * i6w_ctx
Definition: ip6_mfib.c:610
ip6_mfib_key_t
clib_bihash_kv_40_8_t ip6_mfib_key_t
Key and mask for radix.
Definition: ip6_mfib.c:27
mfib_table_t_::v6
ip6_mfib_t v6
Definition: mfib_table.h:86
MFIB_ITF_FLAG_ACCEPT
@ MFIB_ITF_FLAG_ACCEPT
Definition: mfib_types.h:152
ip6_mfib_table_lookup
fib_node_index_t ip6_mfib_table_lookup(const ip6_mfib_t *mfib, const ip6_address_t *src, const ip6_address_t *grp, u32 len)
Definition: ip6_mfib.c:416
pool_get_aligned
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:249
mfib_table_t_::mft_total_route_counts
u32 mft_total_route_counts
Total route counters.
Definition: mfib_table.h:122
mfib_prefix_t_
Aggregate type for a prefix.
Definition: mfib_types.h:24
ip6_mfib_table_instance_t_::prefix_lengths_in_search_order
u16 * prefix_lengths_in_search_order
Definition: ip6_mfib.h:53
all_zeros
static const mfib_prefix_t all_zeros
Definition: ip6_mfib.c:29
path
vl_api_fib_path_t path
Definition: mfib_types.api:44
mfib_table_entry_delete_index
void mfib_table_entry_delete_index(fib_node_index_t mfib_entry_index, mfib_source_t source)
Delete a FIB entry.
Definition: mfib_table.c:517
vlib_cli_command_t::path
char * path
Definition: cli.h:96
ip6_mfib_table_instance_t_
A representation of a single IP6 mfib table.
Definition: ip6_mfib.h:46
mfib_entry.h
FIB_NODE_INDEX_INVALID
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:30
IP6_MFIB_MK_KEY
#define IP6_MFIB_MK_KEY(_mfib, _grp, _src, _len, _key)
Definition: ip6_mfib.c:304
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
ip6_mfib_table_entry_insert
void ip6_mfib_table_entry_insert(ip6_mfib_t *mfib, const ip6_address_t *grp, const ip6_address_t *src, u32 len, fib_node_index_t mfib_entry_index)
Definition: ip6_mfib.c:466
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
clib_bihash_kv_40_8_t
Definition: bihash_40_8.h:41
ip6_mfib_table_show_one
static void ip6_mfib_table_show_one(ip6_mfib_t *mfib, vlib_main_t *vm, ip6_address_t *src, ip6_address_t *grp, u32 mask_len, u32 cover)
Definition: ip6_mfib.c:538
MFIB_ENTRY_FORMAT_BRIEF
#define MFIB_ENTRY_FORMAT_BRIEF
Definition: mfib_entry.h:110
unformat_input_t
struct _unformat_input_t unformat_input_t
fib_route_path_t_::frp_proto
dpo_proto_t frp_proto
The protocol of the address below.
Definition: fib_types.h:505
mfib_table_t_
A protocol Independent IP multicast FIB table.
Definition: mfib_table.h:71
IP6_MFIB_SPECIAL_TYPE_NONE
@ IP6_MFIB_SPECIAL_TYPE_NONE
Definition: ip6_mfib.c:42
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
key
typedef key
Definition: ipsec_types.api:91
ip6_mfib.h
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
clib_bihash_kv_40_8_t::key
u64 key[5]
Definition: bihash_40_8.h:43
MFIB_SOURCE_SPECIAL
@ MFIB_SOURCE_SPECIAL
Definition: mfib_types.h:163
mfib_prefix_t_::fp_src_addr
ip46_address_t fp_src_addr
Definition: mfib_types.h:47
ip6_mfib_special_t_
Definition: ip6_mfib.c:46
mfib_table_lock
void mfib_table_lock(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Release a reference counting lock on the table.
Definition: mfib_table.c:806
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
IP6_MFIB_DEFAULT_HASH_MEMORY_SIZE
#define IP6_MFIB_DEFAULT_HASH_MEMORY_SIZE
Definition: ip6_mfib.h:40
mfib_source_t
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
mfib_table_t_::mft_index
fib_node_index_t mft_index
Index into FIB vector.
Definition: mfib_table.h:117
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
len
u8 len
Definition: ip_types.api:103
ip6_mfib_interface_enable_disable
void ip6_mfib_interface_enable_disable(u32 sw_if_index, int is_enable)
Add/remove the interface from the accepting list of the special MFIB entries.
Definition: ip6_mfib.c:234
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
ip6_mfib_walk_ctx_t_::i6w_mfib_index
u32 i6w_mfib_index
Definition: ip6_mfib.c:608
format_ip6_mfib_table_memory
u8 * format_ip6_mfib_table_memory(u8 *s, va_list *args)
format (display) ipv6 MFIB mempry usage
Definition: ip6_mfib.c:523
ip6_mfib_table_instance_t_::non_empty_dst_address_length_bitmap
uword * non_empty_dst_address_length_bitmap
Definition: ip6_mfib.h:52
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
mfib_table_walk_fn_t
walk_rc_t(* mfib_table_walk_fn_t)(fib_node_index_t fei, void *ctx)
Call back function when walking entries in a FIB table.
Definition: mfib_table.h:554
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
ip6_mfib_walk_cb
static int ip6_mfib_walk_cb(clib_bihash_kv_40_8_t *kvp, void *arg)
Definition: ip6_mfib.c:614
ip6_mfib_index_from_table_id
static u32 ip6_mfib_index_from_table_id(u32 table_id)
Definition: ip6_mfib.h:124
MFIB_SOURCE_DEFAULT_ROUTE
@ MFIB_SOURCE_DEFAULT_ROUTE
Definition: mfib_types.h:177
ip6_main_t::mfibs
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip6.h:121
ip6_main_t::mfib_index_by_table_id
uword * mfib_index_by_table_id
Hash table mapping table id to multicast fib index.
Definition: ip6.h:141
ip6_mfib_show_ctx_t
struct ip6_mfib_show_ctx_t_ ip6_mfib_show_ctx_t
ip6_mfib_special_t_::ims_byte
u8 ims_byte
The last byte of the mcast address.
Definition: ip6_mfib.c:60
ip6_mfib_table_find_or_create_and_lock
u32 ip6_mfib_table_find_or_create_and_lock(u32 table_id, mfib_source_t src)
Get or create an IPv4 fib.
Definition: ip6_mfib.c:274
compute_prefix_lengths_in_search_order
static void compute_prefix_lengths_in_search_order(ip6_mfib_table_instance_t *table)
Definition: ip6_mfib.c:454
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
src
vl_api_address_t src
Definition: gre.api:54
ip6_mfib_show_ctx_t_::entries
fib_node_index_t * entries
Definition: ip6_mfib.c:562
format_mfib_entry
u8 * format_mfib_entry(u8 *s, va_list *args)
Definition: mfib_entry.c:126
clib_bitmap_set
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
mfib_table.h
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
ip6_mfib_table_instance_t_::ip6_mhash
clib_bihash_40_8_t ip6_mhash
Definition: ip6_mfib.h:49
ip6_mfib_specials
static const ip6_mfib_special_t ip6_mfib_specials[]
Definition: ip6_mfib.c:67
mfib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: mfib_types.h:33
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
ip6_mfib_walk_ctx_t_::i6w_fn
mfib_table_walk_fn_t i6w_fn
Definition: ip6_mfib.c:609
mfib_table_lookup_exact_match
fib_node_index_t mfib_table_lookup_exact_match(u32 fib_index, const mfib_prefix_t *prefix)
Perfom an exact match in the non-forwarding table.
Definition: mfib_table.c:98
ip6_mfib_t::index
u32 index
Definition: ip6.h:82
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2785
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
mfib_entry_cmp_for_sort
int mfib_entry_cmp_for_sort(void *i1, void *i2)
Definition: mfib_entry.c:1313
index
u32 index
Definition: flow_types.api:221
mfib_table_t_::mft_proto
fib_protocol_t mft_proto
Which protocol this table serves.
Definition: mfib_table.h:92
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
mfib_table_t_::mft_table_id
u32 mft_table_id
Table ID (hash key) for this FIB.
Definition: mfib_table.h:107
ip6_main_t::mfib_index_by_sw_if_index
u32 * mfib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip6.h:130
u32
unsigned int u32
Definition: types.h:88
MFIB_RPF_ID_NONE
#define MFIB_RPF_ID_NONE
Definition: fib_types.h:423
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
table_id
u32 table_id
Definition: wireguard.api:102
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
ip6_mfib_module_init
static clib_error_t * ip6_mfib_module_init(vlib_main_t *vm)
Definition: ip6_mfib.c:515
ip6_show_mfib
static clib_error_t * ip6_show_mfib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip6_mfib.c:644
ip6_mfib_special_type_t
enum ip6_mfib_special_type_t_ ip6_mfib_special_type_t
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
ip6_mfib_t
Definition: ip6.h:73
ip6_mfib_table_get_less_specific
fib_node_index_t ip6_mfib_table_get_less_specific(const ip6_mfib_t *mfib, const ip6_address_t *src, const ip6_address_t *grp, u32 len)
Definition: ip6_mfib.c:379
ip6_mfib_special_t_::ims_len
u8 ims_len
the Prefix length
Definition: ip6_mfib.c:55
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
ip6_mfib_table_lookup_exact_match
fib_node_index_t ip6_mfib_table_lookup_exact_match(const ip6_mfib_t *mfib, const ip6_address_t *grp, const ip6_address_t *src, u32 len)
Definition: ip6_mfib.c:327
value
u8 value
Definition: qos.api:54
ip6_main_t
Definition: ip6.h:110
ip6_mfib_table_fwd_lookup
fib_node_index_t ip6_mfib_table_fwd_lookup(const ip6_mfib_t *mfib, const ip6_address_t *src, const ip6_address_t *grp)
Definition: ip6_mfib.c:351
ip6_fib.h
ip6_mfib_table_collect_entries
static walk_rc_t ip6_mfib_table_collect_entries(fib_node_index_t mfei, void *arg)
Definition: ip6_mfib.c:567
ip6_mfib_special_t_::ims_type
ip6_mfib_special_type_t ims_type
solicited or not
Definition: ip6_mfib.c:50
ip6_create_mfib_with_table_id
static u32 ip6_create_mfib_with_table_id(u32 table_id, mfib_source_t src)
Definition: ip6_mfib.c:134
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
mfib_table_entry_path_remove
void mfib_table_entry_path_remove(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath)
Remove n paths to an entry (aka route) in the FIB.
Definition: mfib_table.c:407
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
ip6_mfib_table_instance_t_::dst_address_length_refcounts
i32 dst_address_length_refcounts[257]
Definition: ip6_mfib.h:54
ip6_mfib_init
static clib_error_t * ip6_mfib_init(vlib_main_t *vm)
Definition: ip6_mfib.c:784
VLIB_INITS
#define VLIB_INITS(...)
Definition: init.h:352
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
MFIB_ENTRY_FLAG_DROP
@ MFIB_ENTRY_FLAG_DROP
Definition: mfib_types.h:109
ip6_mfib_special_t
struct ip6_mfib_special_t_ ip6_mfib_special_t
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
mfib_table_entry_update
fib_node_index_t mfib_table_entry_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags)
Add a new (with no replication) or lock an existing entry.
Definition: mfib_table.c:237
ip6_mfib_walk_ctx_t_
Context when walking the IPv6 table.
Definition: ip6_mfib.c:606
mfib_table_entry_path_update
fib_node_index_t mfib_table_entry_path_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath)
Add n paths to an entry (aka route) in the FIB.
Definition: mfib_table.c:325
IP6_MFIB_DEFAULT_HASH_NUM_BUCKETS
#define IP6_MFIB_DEFAULT_HASH_NUM_BUCKETS
The IPv4 Multicast-FIB.
Definition: ip6_mfib.h:39
i
int i
Definition: flowhash_template.h:376
MFIB_ITF_FLAG_FORWARD
@ MFIB_ITF_FLAG_FORWARD
Definition: mfib_types.h:153
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
rv
int __clib_unused rv
Definition: application.c:491
ip6_mfib_table_entry_remove
void ip6_mfib_table_entry_remove(ip6_mfib_t *mfib, const ip6_address_t *grp, const ip6_address_t *src, u32 len)
Definition: ip6_mfib.c:491
ip6_mfib_table_walk
void ip6_mfib_table_walk(ip6_mfib_t *mfib, mfib_table_walk_fn_t fn, void *arg)
Walk the IP6 mfib table.
Definition: ip6_mfib.c:627
clib_bitmap_foreach
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
ip6_mfib_special_t_::ims_scope
u8 ims_scope
The scope of the address.
Definition: ip6_mfib.c:64
vlib_cli_command_t
Definition: cli.h:92
format_mfib_table_name
u8 * format_mfib_table_name(u8 *s, va_list *ap)
Format the description/name of the table.
Definition: mfib_table.c:868
ip6_mfib_walk_ctx_t
struct ip6_mfib_walk_ctx_t_ ip6_mfib_walk_ctx_t
Context when walking the IPv6 table.
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
IP6_MFIB_SPECIAL_TYPE_SOLICITED
@ IP6_MFIB_SPECIAL_TYPE_SOLICITED
Definition: ip6_mfib.c:43
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
FIB_ROUTE_PATH_LOCAL
@ FIB_ROUTE_PATH_LOCAL
A for-us/local path.
Definition: fib_types.h:344
ip6_mfib_table_show_all
static void ip6_mfib_table_show_all(ip6_mfib_t *mfib, vlib_main_t *vm)
Definition: ip6_mfib.c:577
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
MFIB_ENTRY_FORMAT_DETAIL
#define MFIB_ENTRY_FORMAT_DETAIL
Definition: mfib_entry.h:111
ip6_mfib_special_type_t_
ip6_mfib_special_type_t_
Definition: ip6_mfib.c:41
ip6_mfib_table_get_index_for_sw_if_index
u32 ip6_mfib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_mfib.c:288
FOR_EACH_IP6_SPECIAL
#define FOR_EACH_IP6_SPECIAL(_pfx, _body)
Definition: ip6_mfib.c:106