FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
mfib_table.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 <vlib/vlib.h>
17 #include <vnet/dpo/drop_dpo.h>
18 
19 #include <vnet/mfib/mfib_table.h>
20 #include <vnet/mfib/ip4_mfib.h>
21 #include <vnet/mfib/ip6_mfib.h>
22 #include <vnet/mfib/mfib_entry.h>
25 #include <vnet/mfib/mfib_signal.h>
26 
28 
32 {
33  switch (proto)
34  {
35  case FIB_PROTOCOL_IP4:
37  case FIB_PROTOCOL_IP6:
39  case FIB_PROTOCOL_MPLS:
40  break;
41  }
42  ASSERT(0);
43  return (NULL);
44 }
45 
46 static inline fib_node_index_t
47 mfib_table_lookup_i (const mfib_table_t *mfib_table,
48  const mfib_prefix_t *prefix)
49 {
50  switch (prefix->fp_proto)
51  {
52  case FIB_PROTOCOL_IP4:
53  return (ip4_mfib_table_lookup(&mfib_table->v4,
54  &prefix->fp_src_addr.ip4,
55  &prefix->fp_grp_addr.ip4,
56  prefix->fp_len));
57  case FIB_PROTOCOL_IP6:
58  return (ip6_mfib_table_lookup(&mfib_table->v6,
59  &prefix->fp_src_addr.ip6,
60  &prefix->fp_grp_addr.ip6,
61  prefix->fp_len));
62  case FIB_PROTOCOL_MPLS:
63  break;
64  }
65  return (FIB_NODE_INDEX_INVALID);
66 }
67 
70  const mfib_prefix_t *prefix)
71 {
72  return (mfib_table_lookup_i(mfib_table_get(fib_index, prefix->fp_proto), prefix));
73 }
74 
75 static inline fib_node_index_t
77  const mfib_prefix_t *prefix)
78 {
79  switch (prefix->fp_proto)
80  {
81  case FIB_PROTOCOL_IP4:
82  return (ip4_mfib_table_lookup_exact_match(&mfib_table->v4,
83  &prefix->fp_grp_addr.ip4,
84  &prefix->fp_src_addr.ip4,
85  prefix->fp_len));
86  case FIB_PROTOCOL_IP6:
87  return (ip6_mfib_table_lookup_exact_match(&mfib_table->v6,
88  &prefix->fp_grp_addr.ip6,
89  &prefix->fp_src_addr.ip6,
90  prefix->fp_len));
91  case FIB_PROTOCOL_MPLS:
92  break;
93  }
94  return (FIB_NODE_INDEX_INVALID);
95 }
96 
99  const mfib_prefix_t *prefix)
100 {
102  prefix->fp_proto),
103  prefix));
104 }
105 
106 static fib_node_index_t
108  const mfib_prefix_t *prefix)
109 {
110  switch (prefix->fp_proto)
111  {
112  case FIB_PROTOCOL_IP4:
113  return (ip4_mfib_table_get_less_specific(&mfib_table->v4,
114  &prefix->fp_src_addr.ip4,
115  &prefix->fp_grp_addr.ip4,
116  prefix->fp_len));
117  case FIB_PROTOCOL_IP6:
118  return (ip6_mfib_table_get_less_specific(&mfib_table->v6,
119  &prefix->fp_src_addr.ip6,
120  &prefix->fp_grp_addr.ip6,
121  prefix->fp_len));
122  case FIB_PROTOCOL_MPLS:
123  break;
124  }
125  return (FIB_NODE_INDEX_INVALID);
126 }
127 
130  const mfib_prefix_t *prefix)
131 {
133  prefix->fp_proto),
134  prefix));
135 }
136 
137 static void
139  const mfib_prefix_t *prefix,
140  fib_node_index_t mfib_entry_index)
141 {
143 
144  mfib_table->mft_total_route_counts--;
145 
146  switch (prefix->fp_proto)
147  {
148  case FIB_PROTOCOL_IP4:
149  ip4_mfib_table_entry_remove(&mfib_table->v4,
150  &prefix->fp_grp_addr.ip4,
151  &prefix->fp_src_addr.ip4,
152  prefix->fp_len);
153  break;
154  case FIB_PROTOCOL_IP6:
155  ip6_mfib_table_entry_remove(&mfib_table->v6,
156  &prefix->fp_grp_addr.ip6,
157  &prefix->fp_src_addr.ip6,
158  prefix->fp_len);
159  break;
160  case FIB_PROTOCOL_MPLS:
161  ASSERT(0);
162  break;
163  }
164 
165  mfib_entry_cover_change_notify(mfib_entry_index,
167  mfib_entry_unlock(mfib_entry_index);
168 }
169 
170 static void
172  const mfib_prefix_t *prefix,
173  fib_node_index_t mfib_entry_index)
174 {
175  fib_node_index_t mfib_entry_cover_index;
176 
177  /*
178  * find the covering entry
179  */
180  mfib_entry_cover_index = mfib_table_get_less_specific_i(mfib_table,
181  prefix);
182  /*
183  * the indicies are the same when the default route is first added
184  */
185  if (mfib_entry_cover_index != mfib_entry_index)
186  {
187  /*
188  * inform the covering entry that a new more specific
189  * has been inserted beneath it.
190  * If the prefix that has been inserted is a host route
191  * then it is not possible that it will be the cover for any
192  * other entry, so we can elide the walk.
193  */
194  if (!mfib_entry_is_host(mfib_entry_index))
195  {
196  mfib_entry_cover_change_notify(mfib_entry_cover_index,
197  mfib_entry_index);
198  }
199  }
200 }
201 
202 
203 static void
205  const mfib_prefix_t *prefix,
206  fib_node_index_t mfib_entry_index)
207 {
209 
210  mfib_entry_lock(mfib_entry_index);
211  mfib_table->mft_total_route_counts++;
212 
213  switch (prefix->fp_proto)
214  {
215  case FIB_PROTOCOL_IP4:
216  ip4_mfib_table_entry_insert(&mfib_table->v4,
217  &prefix->fp_grp_addr.ip4,
218  &prefix->fp_src_addr.ip4,
219  prefix->fp_len,
220  mfib_entry_index);
221  break;
222  case FIB_PROTOCOL_IP6:
223  ip6_mfib_table_entry_insert(&mfib_table->v6,
224  &prefix->fp_grp_addr.ip6,
225  &prefix->fp_src_addr.ip6,
226  prefix->fp_len,
227  mfib_entry_index);
228  break;
229  case FIB_PROTOCOL_MPLS:
230  break;
231  }
232 
233  mfib_table_post_insert_actions(mfib_table, prefix, mfib_entry_index);
234 }
235 
238  const mfib_prefix_t *prefix,
239  mfib_source_t source,
242 {
243  fib_node_index_t mfib_entry_index;
244  mfib_table_t *mfib_table;
245 
246  mfib_table = mfib_table_get(fib_index, prefix->fp_proto);
247  mfib_entry_index = mfib_table_lookup_exact_match_i(mfib_table, prefix);
248 
249  if (FIB_NODE_INDEX_INVALID == mfib_entry_index)
250  {
252  {
253  /*
254  * update to a non-existing entry with non-zero flags
255  */
256  mfib_entry_index = mfib_entry_create(fib_index, source,
257  prefix, rpf_id,
258  entry_flags,
259  INDEX_INVALID);
260 
261  mfib_table_entry_insert(mfib_table, prefix, mfib_entry_index);
262  }
263  /*
264  * else
265  * the entry doesn't exist and the request is to set no flags
266  * the result would be an entry that doesn't exist - so do nothing
267  */
268  }
269  else
270  {
271  mfib_entry_lock(mfib_entry_index);
272 
273  if (mfib_entry_update(mfib_entry_index,
274  source,
275  entry_flags,
276  rpf_id,
277  INDEX_INVALID))
278  {
279  /*
280  * this update means we can now remove the entry.
281  */
282  mfib_table_entry_remove(mfib_table, prefix, mfib_entry_index);
283  }
284 
285  mfib_entry_unlock(mfib_entry_index);
286  }
287 
288  return (mfib_entry_index);
289 }
290 
291 static fib_node_index_t
293  const mfib_prefix_t *prefix,
294  mfib_source_t source,
295  const fib_route_path_t *rpaths)
296 {
297  fib_node_index_t mfib_entry_index;
298  mfib_table_t *mfib_table;
299 
300  mfib_table = mfib_table_get(fib_index, prefix->fp_proto);
301  mfib_entry_index = mfib_table_lookup_exact_match_i(mfib_table, prefix);
302 
303  if (FIB_NODE_INDEX_INVALID == mfib_entry_index)
304  {
305  mfib_entry_index = mfib_entry_create(fib_index,
306  source,
307  prefix,
310  INDEX_INVALID);
311 
312  mfib_entry_path_update(mfib_entry_index, source, rpaths);
313 
314  mfib_table_entry_insert(mfib_table, prefix, mfib_entry_index);
315  }
316  else
317  {
318  mfib_entry_path_update(mfib_entry_index, source, rpaths);
319  }
320  return (mfib_entry_index);
321 }
322 
323 
326  const mfib_prefix_t *prefix,
327  mfib_source_t source,
328  const fib_route_path_t *rpath)
329 {
330  fib_node_index_t mfib_entry_index;
331  fib_route_path_t *rpaths = NULL;
332 
333  vec_add1(rpaths, *rpath);
334 
335  mfib_entry_index = mfib_table_entry_paths_update_i(fib_index, prefix,
336  source, rpaths);
337 
338  vec_free(rpaths);
339  return (mfib_entry_index);
340 }
341 
344  const mfib_prefix_t *prefix,
345  mfib_source_t source,
346  const fib_route_path_t *rpaths)
347 {
348  return (mfib_table_entry_paths_update_i(fib_index, prefix,
349  source, rpaths));
350 }
351 
352 static void
354  const mfib_prefix_t *prefix,
355  mfib_source_t source,
356  const fib_route_path_t *rpaths)
357 {
358  fib_node_index_t mfib_entry_index;
359  mfib_table_t *mfib_table;
360 
361  mfib_table = mfib_table_get(fib_index, prefix->fp_proto);
362  mfib_entry_index = mfib_table_lookup_exact_match_i(mfib_table, prefix);
363 
364  if (FIB_NODE_INDEX_INVALID == mfib_entry_index)
365  {
366  /*
367  * removing an entry that does not exist. i'll allow it.
368  */
369  }
370  else
371  {
372  int no_more_sources;
373 
374  /*
375  * don't nobody go nowhere
376  */
377  mfib_entry_lock(mfib_entry_index);
378 
379  no_more_sources = mfib_entry_path_remove(mfib_entry_index,
380  source,
381  rpaths);
382 
383  if (no_more_sources)
384  {
385  /*
386  * last source gone. remove from the table
387  */
388  mfib_table_entry_remove(mfib_table, prefix, mfib_entry_index);
389  }
390 
391  mfib_entry_unlock(mfib_entry_index);
392  }
393 }
394 void
396  const mfib_prefix_t *prefix,
397  mfib_source_t source,
398  const fib_route_path_t *rpaths)
399 {
401  prefix,
402  source,
403  rpaths);
404 }
405 
406 void
408  const mfib_prefix_t *prefix,
409  mfib_source_t source,
410  const fib_route_path_t *rpath)
411 {
412  fib_route_path_t *rpaths = NULL;
413 
414  vec_add1(rpaths, *rpath);
415 
417  prefix,
418  source,
419  rpaths);
420 
421  vec_free(rpaths);
422 }
423 
426  const mfib_prefix_t *prefix,
427  mfib_source_t source,
429  index_t repi)
430 {
431  fib_node_index_t mfib_entry_index;
432  mfib_table_t *mfib_table;
433 
434  mfib_table = mfib_table_get(fib_index, prefix->fp_proto);
435  mfib_entry_index = mfib_table_lookup_exact_match_i(mfib_table, prefix);
436 
437  if (INDEX_INVALID != repi)
438  {
440  }
441 
442  if (FIB_NODE_INDEX_INVALID == mfib_entry_index)
443  {
444  mfib_entry_index = mfib_entry_create(fib_index,
445  source,
446  prefix,
448  entry_flags,
449  repi);
450 
451  mfib_table_entry_insert(mfib_table, prefix, mfib_entry_index);
452  }
453  else
454  {
455  mfib_entry_special_add(mfib_entry_index, source, entry_flags,
456  MFIB_RPF_ID_NONE, repi);
457  }
458 
459  return (mfib_entry_index);
460 }
461 
462 static void
464  fib_node_index_t mfib_entry_index,
465  const mfib_prefix_t *prefix,
466  mfib_source_t source)
467 {
468  mfib_table_t *mfib_table;
469 
470  mfib_table = mfib_table_get(fib_index, prefix->fp_proto);
471 
472  /*
473  * don't nobody go nowhere
474  */
475  mfib_entry_lock(mfib_entry_index);
476 
477  if (mfib_entry_delete(mfib_entry_index, source))
478  {
479  /*
480  * last source gone. remove from the table
481  */
482  mfib_table_entry_remove(mfib_table, prefix, mfib_entry_index);
483  }
484  /*
485  * else
486  * still has sources, leave it be.
487  */
488 
489  mfib_entry_unlock(mfib_entry_index);
490 }
491 
492 void
494  const mfib_prefix_t *prefix,
495  mfib_source_t source)
496 {
497  fib_node_index_t mfib_entry_index;
498 
499  mfib_entry_index = mfib_table_lookup_exact_match(fib_index, prefix);
500 
501  if (FIB_NODE_INDEX_INVALID == mfib_entry_index)
502  {
503  /*
504  * removing an etry that does not exist.
505  * i'll allow it, but i won't like it.
506  */
507  clib_warning("%U not in FIB", format_mfib_prefix, prefix);
508  }
509  else
510  {
511  mfib_table_entry_delete_i(fib_index, mfib_entry_index,
512  prefix, source);
513  }
514 }
515 
516 void
518  mfib_source_t source)
519 {
521  mfib_entry_index,
522  mfib_entry_get_prefix(mfib_entry_index),
523  source);
524 }
525 
526 u32
529 {
530  switch (proto)
531  {
532  case FIB_PROTOCOL_IP4:
534  case FIB_PROTOCOL_IP6:
536  case FIB_PROTOCOL_MPLS:
537  ASSERT(0);
538  break;
539  }
540  return (~0);
541 }
542 
543 u32
546 {
547  mfib_table_t *mfib_table;
548 
549  mfib_table = mfib_table_get(fib_index, proto);
550 
551  return ((NULL != mfib_table ? mfib_table->mft_table_id : ~0));
552 }
553 
554 u32
556  u32 table_id)
557 {
558  switch (proto)
559  {
560  case FIB_PROTOCOL_IP4:
562  case FIB_PROTOCOL_IP6:
564  case FIB_PROTOCOL_MPLS:
565  ASSERT(0);
566  break;
567  }
568  return (~0);
569 }
570 
571 static u32
573  u32 table_id,
575  const u8 *name)
576 {
577  mfib_table_t *mfib_table;
578  fib_node_index_t fi;
579 
580  switch (proto)
581  {
582  case FIB_PROTOCOL_IP4:
584  break;
585  case FIB_PROTOCOL_IP6:
587  break;
588  case FIB_PROTOCOL_MPLS:
589  default:
590  return (~0);
591  }
592 
593  mfib_table = mfib_table_get(fi, proto);
594 
595  if (NULL == mfib_table->mft_desc)
596  {
597  if (name && name[0])
598  {
599  mfib_table->mft_desc = format(NULL, "%s", name);
600  }
601  else
602  {
603  mfib_table->mft_desc = format(NULL, "%U-VRF:%d",
605  table_id);
606  }
607  }
608 
609  return (fi);
610 }
611 
612 u32
614  u32 table_id,
616 {
618  src, NULL));
619 }
620 
621 u32
623  u32 table_id,
625  const u8 *name)
626 {
628  src, name));
629 }
630 
631 /**
632  * @brief Table flush context. Store the indicies of matching FIB entries
633  * that need to be removed.
634  */
636 {
637  /**
638  * The list of entries to flush
639  */
641 
642  /**
643  * The source we are flushing
644  */
647 
648 static walk_rc_t
650  void *arg)
651 {
653 
654  if (mfib_entry_is_sourced(mfib_entry_index, ctx->mftf_source))
655  {
656  vec_add1(ctx->mftf_entries, mfib_entry_index);
657  }
658  return (WALK_CONTINUE);
659 }
660 
661 void
662 mfib_table_flush (u32 mfib_index,
664  mfib_source_t source)
665 {
666  fib_node_index_t *mfib_entry_index;
668  .mftf_entries = NULL,
669  .mftf_source = source,
670  };
671 
672  mfib_table_walk(mfib_index, proto,
674  &ctx);
675 
676  vec_foreach(mfib_entry_index, ctx.mftf_entries)
677  {
678  mfib_table_entry_delete_index(*mfib_entry_index, source);
679  }
680 
681  vec_free(ctx.mftf_entries);
682 }
683 
684 static walk_rc_t
686  void *arg)
687 {
689 
690  if (mfib_entry_is_sourced(fib_entry_index, ctx->mftf_source))
691  {
692  mfib_entry_mark(fib_entry_index, ctx->mftf_source);
693  }
694  return (WALK_CONTINUE);
695 }
696 
697 void
698 mfib_table_mark (u32 fib_index,
700  mfib_source_t source)
701 {
703  .mftf_source = source,
704  };
705  mfib_table_t *mfib_table;
706 
707  mfib_table = mfib_table_get(fib_index, proto);
708 
709  mfib_table->mft_epoch++;
710  mfib_table->mft_flags |= MFIB_TABLE_FLAG_RESYNC;
711 
712  mfib_table_walk(fib_index, proto,
714  &ctx);
715 }
716 
717 static walk_rc_t
719  void *arg)
720 {
722 
723  if (mfib_entry_is_marked(fib_entry_index, ctx->mftf_source))
724  {
725  vec_add1(ctx->mftf_entries, fib_entry_index);
726  }
727  return (WALK_CONTINUE);
728 }
729 
730 void
733  mfib_source_t source)
734 {
736  .mftf_source = source,
737  };
738  fib_node_index_t *fib_entry_index;
739  mfib_table_t *mfib_table;
740 
741  mfib_table = mfib_table_get(fib_index, proto);
742 
743  mfib_table->mft_flags &= ~MFIB_TABLE_FLAG_RESYNC;
744 
745  mfib_table_walk(fib_index, proto,
747  &ctx);
748 
749  vec_foreach(fib_entry_index, ctx.mftf_entries)
750  {
751  mfib_table_entry_delete_index(*fib_entry_index, source);
752  }
753 
754  vec_free(ctx.mftf_entries);
755 }
756 
757 static void
759 {
760  vec_free(mfib_table->mft_desc);
761 
762  switch (mfib_table->mft_proto)
763  {
764  case FIB_PROTOCOL_IP4:
765  ip4_mfib_table_destroy(&mfib_table->v4);
766  break;
767  case FIB_PROTOCOL_IP6:
768  ip6_mfib_table_destroy(&mfib_table->v6);
769  break;
770  case FIB_PROTOCOL_MPLS:
771  ASSERT(0);
772  break;
773  }
774 }
775 
776 void
779  mfib_source_t source)
780 {
781  mfib_table_t *mfib_table;
782 
783  mfib_table = mfib_table_get(fib_index, proto);
784  mfib_table->mft_locks[source]--;
785  mfib_table->mft_locks[MFIB_TABLE_TOTAL_LOCKS]--;
786 
787  if (0 == mfib_table->mft_locks[source])
788  {
789  /*
790  * The source no longer needs the table. flush any routes
791  * from it just in case
792  */
793  mfib_table_flush(fib_index, proto, source);
794  }
795 
796  if (0 == mfib_table->mft_locks[MFIB_TABLE_TOTAL_LOCKS])
797  {
798  /*
799  * no more locak from any source - kill it
800  */
801  mfib_table_destroy(mfib_table);
802  }
803 }
804 
805 void
806 mfib_table_lock (u32 fib_index,
808  mfib_source_t source)
809 {
810  mfib_table_t *mfib_table;
811 
812  mfib_table = mfib_table_get(fib_index, proto);
813  mfib_table->mft_locks[source]++;
814  mfib_table->mft_locks[MFIB_TABLE_TOTAL_LOCKS]++;
815 }
816 
817 u32
820 {
821  mfib_table_t *mfib_table;
822 
823  mfib_table = mfib_table_get(fib_index, proto);
824 
825  return (mfib_table->mft_total_route_counts);
826 }
827 
828 void
829 mfib_table_walk (u32 fib_index,
832  void *ctx)
833 {
834  switch (proto)
835  {
836  case FIB_PROTOCOL_IP4:
837  ip4_mfib_table_walk(ip4_mfib_get(fib_index), fn, ctx);
838  break;
839  case FIB_PROTOCOL_IP6:
840  ip6_mfib_table_walk(ip6_mfib_get(fib_index), fn, ctx);
841  break;
842  case FIB_PROTOCOL_MPLS:
843  break;
844  }
845 }
846 
847 u8*
848 format_mfib_table_flags (u8 *s, va_list *args)
849 {
850  mfib_table_flags_t flags = va_arg(*args, int);
852 
853  if (!flags)
854  {
855  return format(s, "none");
856  }
857 
859  if (1 << attr & flags) {
860  s = format(s, "%s", mfib_table_flags_strings[attr]);
861  }
862  }
863 
864  return (s);
865 }
866 
867 u8*
868 format_mfib_table_name (u8* s, va_list *ap)
869 {
870  fib_node_index_t fib_index = va_arg(*ap, fib_node_index_t);
871  fib_protocol_t proto = va_arg(*ap, int); // int promotion
872  mfib_table_t *mfib_table;
873 
874  mfib_table = mfib_table_get(fib_index, proto);
875 
876  s = format(s, "%v", mfib_table->mft_desc);
877 
878  return (s);
879 }
880 
881 u8 *
882 format_mfib_table_memory (u8 *s, va_list *args)
883 {
884  s = format(s, "%U", format_ip4_mfib_table_memory);
885  s = format(s, "%U", format_ip6_mfib_table_memory);
886 
887  return (s);
888 }
889 
890 static clib_error_t *
892 {
894 
898 
900  return (error);
902  return (error);
903 
904  return (error);
905 }
906 
vlib.h
MFIB_ENTRY_FLAG_EXCLUSIVE
@ MFIB_ENTRY_FLAG_EXCLUSIVE
Definition: mfib_types.h:112
mfib_table_t_::mft_locks
u32 mft_locks[MFIB_TABLE_N_LOCKS]
number of locks on the table
Definition: mfib_table.h:102
mfib_module_init
static clib_error_t * mfib_module_init(vlib_main_t *vm)
Definition: mfib_table.c:891
format_ip4_mfib_table_memory
u8 * format_ip4_mfib_table_memory(u8 *s, va_list *args)
format (display) the memory usage for IP4 mfibs
Definition: ip4_mfib.c:392
mfib_entry_is_host
int mfib_entry_is_host(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:397
MFIB_ENTRY_FLAG_NONE
@ MFIB_ENTRY_FLAG_NONE
Definition: mfib_types.h:107
ip6_mfib_table_destroy
void ip6_mfib_table_destroy(ip6_mfib_t *mfib)
Definition: ip6_mfib.c:193
mfib_entry_mark
void mfib_entry_mark(fib_node_index_t fib_entry_index, mfib_source_t source)
Definition: mfib_entry.c:380
ip6_mfib_get
static ip6_mfib_t * ip6_mfib_get(u32 index)
Get the FIB at the given index.
Definition: ip6_mfib.h:101
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
mfib_entry_is_marked
int mfib_entry_is_marked(fib_node_index_t mfib_entry_index, mfib_source_t source)
Definition: mfib_entry.c:359
mfib_table_flush_cb
static walk_rc_t mfib_table_flush_cb(fib_node_index_t mfib_entry_index, void *arg)
Definition: mfib_table.c:649
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
FOR_EACH_MFIB_TABLE_ATTRIBUTE
#define FOR_EACH_MFIB_TABLE_ATTRIBUTE(_item)
Definition: mfib_table.h:55
ip4_mfib_table_entry_insert
void ip4_mfib_table_entry_insert(ip4_mfib_t *mfib, const ip4_address_t *grp, const ip4_address_t *src, u32 len, fib_node_index_t fib_entry_index)
Definition: ip4_mfib.c:311
mfib_entry_src.h
mfib_entry_src_module_init
void mfib_entry_src_module_init(void)
Definition: mfib_entry_src.c:85
mfib_table_t_::v6
ip6_mfib_t v6
Definition: mfib_table.h:86
entry_flags
vl_api_mfib_entry_flags_t entry_flags
Definition: ip.api:414
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
name
string name[64]
Definition: fib.api:25
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:417
ip4_mfib_table_lookup_exact_match
fib_node_index_t ip4_mfib_table_lookup_exact_match(const ip4_mfib_t *mfib, const ip4_address_t *grp, const ip4_address_t *src, u32 len)
Definition: ip4_mfib.c:216
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
ip4_mfib_index_from_table_id
static u32 ip4_mfib_index_from_table_id(u32 table_id)
Definition: ip4_mfib.h:91
mfib_entry_path_update
void mfib_entry_path_update(fib_node_index_t mfib_entry_index, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_entry.c:987
mfib_entry_unlock
void mfib_entry_unlock(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1402
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
mfib_table_find_or_create_and_lock
u32 mfib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, mfib_source_t src)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:613
mfib_table_attribute_t
enum mfib_table_attribute_t_ mfib_table_attribute_t
Flags for the source data.
mfib_entry.h
mfib_table_entry_special_add
fib_node_index_t mfib_table_entry_special_add(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, mfib_entry_flags_t entry_flags, index_t repi)
Add a 'special' entry to the mFIB that links to the DPO passed A special entry is an entry that the F...
Definition: mfib_table.c:425
mfib_table_lookup
fib_node_index_t mfib_table_lookup(u32 fib_index, const mfib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
Definition: mfib_table.c:69
FIB_NODE_INDEX_INVALID
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:30
vlib_call_init_function
#define vlib_call_init_function(vm, x)
Definition: init.h:259
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:467
vlib_smp_unsafe_warning
static void vlib_smp_unsafe_warning(void)
Definition: threads.h:214
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
mfib_table_entry_paths_update
fib_node_index_t mfib_table_entry_paths_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_table.c:343
mfib_entry_flags_t
enum mfib_entry_flags_t_ mfib_entry_flags_t
mfib_entry_path_remove
int mfib_entry_path_remove(fib_node_index_t mfib_entry_index, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_entry.c:1123
mfib_entry_cover_change_notify
void mfib_entry_cover_change_notify(fib_node_index_t cover_index, fib_node_index_t covered)
Definition: mfib_entry_cover.c:150
ip4_mfib.h
mfib_table_walk
void mfib_table_walk(u32 fib_index, fib_protocol_t proto, mfib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: mfib_table.c:829
drop_dpo.h
mfib_table_t_
A protocol Independent IP multicast FIB table.
Definition: mfib_table.h:71
mfib_table_flush_ctx_t_::mftf_entries
fib_node_index_t * mftf_entries
The list of entries to flush.
Definition: mfib_table.c:640
error
Definition: cJSON.c:88
mfib_table_lookup_exact_match_i
static fib_node_index_t mfib_table_lookup_exact_match_i(const mfib_table_t *mfib_table, const mfib_prefix_t *prefix)
Definition: mfib_table.c:76
rn_module_init
static clib_error_t * rn_module_init(vlib_main_t *vm)
Definition: radix.c:1085
mfib_entry_module_init
void mfib_entry_module_init(void)
Definition: mfib_entry.c:1445
mfib_table_get_less_specific
fib_node_index_t mfib_table_get_less_specific(u32 fib_index, const mfib_prefix_t *prefix)
Get the less specific (covering) prefix.
Definition: mfib_table.c:129
mfib_table_entry_paths_remove
void mfib_table_entry_paths_remove(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_table.c:395
ip6_mfib.h
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
mfib_table_get_index_for_sw_if_index
u32 mfib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
Definition: mfib_table.c:527
mfib_table_flags_t
enum mfib_table_flags_t_ mfib_table_flags_t
mfib_source_t
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
fib_rpf_id_t
u32 fib_rpf_id_t
An RPF-ID is numerical value that is used RPF validate.
Definition: fib_types.h:421
mfib_table_entry_paths_remove_i
static void mfib_table_entry_paths_remove_i(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_table.c:353
mfib_table_entry_remove
static void mfib_table_entry_remove(mfib_table_t *mfib_table, const mfib_prefix_t *prefix, fib_node_index_t mfib_entry_index)
Definition: mfib_table.c:138
ip4_mfib_table_destroy
void ip4_mfib_table_destroy(ip4_mfib_t *mfib)
Definition: ip4_mfib.c:102
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
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:524
mfib_entry_get_fib_index
u32 mfib_entry_get_fib_index(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1499
format_mfib_table_flags
u8 * format_mfib_table_flags(u8 *s, va_list *args)
Definition: mfib_table.c:848
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
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
mfib_entry_update
int mfib_entry_update(fib_node_index_t mfib_entry_index, mfib_source_t source, mfib_entry_flags_t entry_flags, fib_rpf_id_t rpf_id, index_t repi)
Definition: mfib_entry.c:939
ip4_mfib_get
static ip4_mfib_t * ip4_mfib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_mfib.h:69
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
ip6_mfib_index_from_table_id
static u32 ip6_mfib_index_from_table_id(u32 table_id)
Definition: ip6_mfib.h:124
mfib_table_t_::mft_desc
u8 * mft_desc
Table description.
Definition: mfib_table.h:127
mfib_entry_delete
int mfib_entry_delete(fib_node_index_t mfib_entry_index, mfib_source_t source)
mfib_entry_delete
Definition: mfib_entry.c:1224
ip6_main_t::mfibs
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip6.h:121
mfib_table_flush
void mfib_table_flush(u32 mfib_index, fib_protocol_t proto, mfib_source_t source)
Flush all entries from a table for the source.
Definition: mfib_table.c:662
mfib_table_mark
void mfib_table_mark(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Resync all entries from a table for the source this is the mark part of the mark and sweep algorithm.
Definition: mfib_table.c:698
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:275
ip4_mfib_table_get_index_for_sw_if_index
u32 ip4_mfib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip4_mfib.c:182
mfib_table_sweep
void mfib_table_sweep(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Signal that the table has converged, i.e.
Definition: mfib_table.c:731
mfib_table_get
mfib_table_t * mfib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: mfib_table.c:30
mfib_table_flags_strings
const static char * mfib_table_flags_strings[]
Definition: mfib_table.c:27
mfib_table_post_insert_actions
static void mfib_table_post_insert_actions(mfib_table_t *mfib_table, const mfib_prefix_t *prefix, fib_node_index_t mfib_entry_index)
Definition: mfib_table.c:171
src
vl_api_address_t src
Definition: gre.api:54
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
MFIB_TABLE_FLAG_RESYNC
@ MFIB_TABLE_FLAG_RESYNC
Definition: mfib_table.h:62
format_mfib_prefix
u8 * format_mfib_prefix(u8 *s, va_list *args)
Definition: mfib_types.c:106
mfib_table_flush_ctx_t_::mftf_source
mfib_source_t mftf_source
The source we are flushing.
Definition: mfib_table.c:645
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
mfib_table.h
mfib_table_t_::mft_epoch
u32 mft_epoch
resync epoch
Definition: mfib_table.h:112
mfib_table_entry_insert
static void mfib_table_entry_insert(mfib_table_t *mfib_table, const mfib_prefix_t *prefix, fib_node_index_t mfib_entry_index)
Definition: mfib_table.c:204
mfib_table_unlock
void mfib_table_unlock(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Take a reference counting lock on the table.
Definition: mfib_table.c:777
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_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2787
mfib_table_find_or_create_and_lock_w_name
u32 mfib_table_find_or_create_and_lock_w_name(fib_protocol_t proto, u32 table_id, mfib_source_t src, const u8 *name)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:622
mfib_entry_special_add
int mfib_entry_special_add(fib_node_index_t mfib_entry_index, mfib_source_t source, mfib_entry_flags_t entry_flags, fib_rpf_id_t rpf_id, index_t repi)
Definition: mfib_entry.c:917
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
index
u32 index
Definition: flow_types.api:221
format_fib_protocol
u8 * format_fib_protocol(u8 *s, va_list *ap)
Definition: fib_types.c:33
mfib_signal_module_init
void mfib_signal_module_init(void)
Definition: mfib_signal.c:66
mfib_entry_create
fib_node_index_t mfib_entry_create(u32 fib_index, mfib_source_t source, const mfib_prefix_t *prefix, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags, index_t repi)
Definition: mfib_entry.c:803
mfib_table_t_::mft_proto
fib_protocol_t mft_proto
Which protocol this table serves.
Definition: mfib_table.h:92
mfib_entry_lock
void mfib_entry_lock(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1392
mfib_table_find
u32 mfib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:555
ip4_mfib_table_entry_remove
void ip4_mfib_table_entry_remove(ip4_mfib_t *mfib, const ip4_address_t *grp, const ip4_address_t *src, u32 len)
Definition: ip4_mfib.c:342
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
mfib_table_get_table_id
u32 mfib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: mfib_table.c:544
FIB_PROTOCOL_MPLS
@ FIB_PROTOCOL_MPLS
Definition: fib_types.h:38
fib_module_init
static clib_error_t * fib_module_init(vlib_main_t *vm)
Definition: fib.c:23
mfib_table_t_::mft_table_id
u32 mft_table_id
Table ID (hash key) for this FIB.
Definition: mfib_table.h:107
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
mfib_table_get_n_routes
u32 mfib_table_get_n_routes(fib_node_index_t fib_index, fib_protocol_t proto)
To assit UT.
Definition: mfib_table.c:818
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
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:380
ip4_mfib_table_lookup
fib_node_index_t ip4_mfib_table_lookup(const ip4_mfib_t *mfib, const ip4_address_t *src, const ip4_address_t *grp, u32 len)
The IPv4 Multicast-FIB.
Definition: ip4_mfib.c:241
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:328
mfib_table_flush_ctx_t
struct mfib_table_flush_ctx_t_ mfib_table_flush_ctx_t
Table flush context.
mfib_table_sweep_cb
static walk_rc_t mfib_table_sweep_cb(fib_node_index_t fib_entry_index, void *arg)
Definition: mfib_table.c:718
mfib_entry_get_prefix
const mfib_prefix_t * mfib_entry_get_prefix(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1489
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
ip4_main_t::mfibs
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip4.h:118
vlib_main_t
Definition: main.h:102
ip4_mfib_table_find_or_create_and_lock
u32 ip4_mfib_table_find_or_create_and_lock(u32 table_id, mfib_source_t src)
Get or create an IPv4 fib.
Definition: ip4_mfib.c:168
mfib_table_find_or_create_and_lock_i
static u32 mfib_table_find_or_create_and_lock_i(fib_protocol_t proto, u32 table_id, mfib_source_t src, const u8 *name)
Definition: mfib_table.c:572
ip4_mfib_table_get_less_specific
fib_node_index_t ip4_mfib_table_get_less_specific(const ip4_mfib_t *mfib, const ip4_address_t *src, const ip4_address_t *grp, u32 len)
Definition: ip4_mfib.c:279
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
MFIB_TABLE_TOTAL_LOCKS
#define MFIB_TABLE_TOTAL_LOCKS
Definition: mfib_table.h:29
mfib_signal.h
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
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
ip4_mfib_table_walk
void ip4_mfib_table_walk(ip4_mfib_t *mfib, mfib_table_walk_fn_t fn, void *ctx)
Walk the IP4 mfib table.
Definition: ip4_mfib.c:369
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
mfib_entry_cover.h
MFIB_TABLE_ATTRIBUTES
#define MFIB_TABLE_ATTRIBUTES
Definition: mfib_table.h:51
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:492
mfib_entry_is_sourced
int mfib_entry_is_sourced(fib_node_index_t mfib_entry_index, mfib_source_t source)
Definition: mfib_entry.c:348
mfib_table_entry_delete_i
static void mfib_table_entry_delete_i(u32 fib_index, fib_node_index_t mfib_entry_index, const mfib_prefix_t *prefix, mfib_source_t source)
Definition: mfib_table.c:463
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:628
mfib_table_flush_ctx_t_
Table flush context.
Definition: mfib_table.c:635
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
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
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
mfib_table_t_::v4
ip4_mfib_t v4
Definition: mfib_table.h:85
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
mfib_table_entry_paths_update_i
static fib_node_index_t mfib_table_entry_paths_update_i(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_table.c:292
mfib_table_lookup_i
static fib_node_index_t mfib_table_lookup_i(const mfib_table_t *mfib_table, const mfib_prefix_t *prefix)
Definition: mfib_table.c:47
mfib_table_t_::mft_flags
mfib_table_flags_t mft_flags
table falgs
Definition: mfib_table.h:97
mfib_table_destroy
static void mfib_table_destroy(mfib_table_t *mfib_table)
Definition: mfib_table.c:758
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
rpf_id
u32 rpf_id
Definition: fib_types.api:119
mfib_table_get_less_specific_i
static fib_node_index_t mfib_table_get_less_specific_i(const mfib_table_t *mfib_table, const mfib_prefix_t *prefix)
Definition: mfib_table.c:107
format_mfib_table_memory
u8 * format_mfib_table_memory(u8 *s, va_list *args)
format (display) the memory usage for mfibs
Definition: mfib_table.c:882
mfib_table_entry_delete
void mfib_table_entry_delete(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source)
Delete a FIB entry.
Definition: mfib_table.c:493
prefix
vl_api_prefix_t prefix
Definition: ip.api:146
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:289
mfib_table_mark_cb
static walk_rc_t mfib_table_mark_cb(fib_node_index_t fib_entry_index, void *arg)
Definition: mfib_table.c:685
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105