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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include <vlib/vlib.h>
17 #include <vnet/dpo/drop_dpo.h>
19 #include <vnet/fib/fib_table.h>
20 #include <vnet/fib/fib_entry_cover.h>
21 #include <vnet/fib/fib_internal.h>
22 #include <vnet/fib/ip4_fib.h>
23 #include <vnet/fib/ip6_fib.h>
24 #include <vnet/fib/mpls_fib.h>
27 fib_table_get (fib_node_index_t index,
32 case FIB_PROTOCOL_IP4:
33 return (pool_elt_at_index(ip4_main.fibs, index));
34 case FIB_PROTOCOL_IP6:
35 return (pool_elt_at_index(ip6_main.fibs, index));
36 case FIB_PROTOCOL_MPLS:
37 return (pool_elt_at_index(mpls_main.fibs, index));
43 static inline fib_node_index_t
44 fib_table_lookup_i (fib_table_t *fib_table,
45 const fib_prefix_t *prefix)
47 switch (prefix->fp_proto)
49 case FIB_PROTOCOL_IP4:
50 return (ip4_fib_table_lookup(&fib_table->v4,
53 case FIB_PROTOCOL_IP6:
54 return (ip6_fib_table_lookup(fib_table->ft_index,
57 case FIB_PROTOCOL_MPLS:
58 return (mpls_fib_table_lookup(&fib_table->mpls,
62 return (FIB_NODE_INDEX_INVALID);
66 fib_table_lookup (u32 fib_index,
67 const fib_prefix_t *prefix)
69 return (fib_table_lookup_i(fib_table_get(fib_index, prefix->fp_proto), prefix));
72 static inline fib_node_index_t
73 fib_table_lookup_exact_match_i (const fib_table_t *fib_table,
74 const fib_prefix_t *prefix)
76 switch (prefix->fp_proto)
78 case FIB_PROTOCOL_IP4:
79 return (ip4_fib_table_lookup_exact_match(&fib_table->v4,
82 case FIB_PROTOCOL_IP6:
83 return (ip6_fib_table_lookup_exact_match(fib_table->ft_index,
86 case FIB_PROTOCOL_MPLS:
87 return (mpls_fib_table_lookup(&fib_table->mpls,
91 return (FIB_NODE_INDEX_INVALID);
95 fib_table_lookup_exact_match (u32 fib_index,
96 const fib_prefix_t *prefix)
98 return (fib_table_lookup_exact_match_i(fib_table_get(fib_index,
103 static fib_node_index_t
104 fib_table_get_less_specific_i (fib_table_t *fib_table,
105 const fib_prefix_t *prefix)
111 if (FIB_PROTOCOL_MPLS == pfx.fp_proto)
113 return (FIB_NODE_INDEX_INVALID);
117 * in the absence of a tree structure for the table that allows for an O(1)
118 * parent get, a cheeky way to find the cover is to LPM for the prefix with
120 * there should always be a cover, though it may be the default route. the
121 * default route's cover is the default route.
123 if (pfx.fp_len != 0) {
127 return (fib_table_lookup_i(fib_table, &pfx));
131 fib_table_get_less_specific (u32 fib_index,
132 const fib_prefix_t *prefix)
134 return (fib_table_get_less_specific_i(fib_table_get(fib_index,
140 fib_table_entry_remove (fib_table_t *fib_table,
141 const fib_prefix_t *prefix,
142 fib_node_index_t fib_entry_index)
144 vlib_smp_unsafe_warning();
146 fib_table->ft_total_route_counts--;
148 switch (prefix->fp_proto)
150 case FIB_PROTOCOL_IP4:
151 ip4_fib_table_entry_remove(&fib_table->v4,
152 &prefix->fp_addr.ip4,
155 case FIB_PROTOCOL_IP6:
156 ip6_fib_table_entry_remove(fib_table->ft_index,
157 &prefix->fp_addr.ip6,
160 case FIB_PROTOCOL_MPLS:
161 mpls_fib_table_entry_remove(&fib_table->mpls,
167 fib_entry_unlock(fib_entry_index);
171 fib_table_post_insert_actions (fib_table_t *fib_table,
172 const fib_prefix_t *prefix,
173 fib_node_index_t fib_entry_index)
175 fib_node_index_t fib_entry_cover_index;
178 * no cover relationships in the MPLS FIB
180 if (FIB_PROTOCOL_MPLS == prefix->fp_proto)
184 * find and inform the covering entry that a new more specific
185 * has been inserted beneath it
187 fib_entry_cover_index = fib_table_get_less_specific_i(fib_table, prefix);
189 * the indicies are the same when the default route is first added
191 if (fib_entry_cover_index != fib_entry_index)
193 fib_entry_cover_change_notify(fib_entry_cover_index,
199 fib_table_entry_insert (fib_table_t *fib_table,
200 const fib_prefix_t *prefix,
201 fib_node_index_t fib_entry_index)
203 vlib_smp_unsafe_warning();
205 fib_entry_lock(fib_entry_index);
206 fib_table->ft_total_route_counts++;
208 switch (prefix->fp_proto)
210 case FIB_PROTOCOL_IP4:
211 ip4_fib_table_entry_insert(&fib_table->v4,
212 &prefix->fp_addr.ip4,
216 case FIB_PROTOCOL_IP6:
217 ip6_fib_table_entry_insert(fib_table->ft_index,
218 &prefix->fp_addr.ip6,
222 case FIB_PROTOCOL_MPLS:
223 mpls_fib_table_entry_insert(&fib_table->mpls,
230 fib_table_post_insert_actions(fib_table, prefix, fib_entry_index);
234 fib_table_fwding_dpo_update (u32 fib_index,
235 const fib_prefix_t *prefix,
238 vlib_smp_unsafe_warning();
240 switch (prefix->fp_proto)
242 case FIB_PROTOCOL_IP4:
243 return (ip4_fib_table_fwding_dpo_update(ip4_fib_get(fib_index),
244 &prefix->fp_addr.ip4,
247 case FIB_PROTOCOL_IP6:
248 return (ip6_fib_table_fwding_dpo_update(fib_index,
249 &prefix->fp_addr.ip6,
252 case FIB_PROTOCOL_MPLS:
253 return (mpls_fib_forwarding_table_update(mpls_fib_get(fib_index),
261 fib_table_fwding_dpo_remove (u32 fib_index,
262 const fib_prefix_t *prefix,
265 vlib_smp_unsafe_warning();
267 switch (prefix->fp_proto)
269 case FIB_PROTOCOL_IP4:
270 return (ip4_fib_table_fwding_dpo_remove(ip4_fib_get(fib_index),
271 &prefix->fp_addr.ip4,
274 case FIB_PROTOCOL_IP6:
275 return (ip6_fib_table_fwding_dpo_remove(fib_index,
276 &prefix->fp_addr.ip6,
279 case FIB_PROTOCOL_MPLS:
280 return (mpls_fib_forwarding_table_reset(mpls_fib_get(fib_index),
288 fib_table_entry_special_dpo_add (u32 fib_index,
289 const fib_prefix_t *prefix,
291 fib_entry_flag_t flags,
294 fib_node_index_t fib_entry_index;
295 fib_table_t *fib_table;
297 fib_table = fib_table_get(fib_index, prefix->fp_proto);
298 fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
300 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
302 fib_entry_index = fib_entry_create_special(fib_index, prefix,
306 fib_table_entry_insert(fib_table, prefix, fib_entry_index);
307 fib_table->ft_src_route_counts[source]++;
313 was_sourced = fib_entry_is_sourced(fib_entry_index, source);
314 fib_entry_special_add(fib_entry_index, source, flags, dpo);
316 if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
318 fib_table->ft_src_route_counts[source]++;
323 return (fib_entry_index);
327 fib_table_entry_special_add (u32 fib_index,
328 const fib_prefix_t *prefix,
330 fib_entry_flag_t flags,
331 adj_index_t adj_index)
333 fib_node_index_t fib_entry_index;
334 dpo_id_t tmp_dpo = DPO_NULL;
336 if (ADJ_INDEX_INVALID != adj_index)
345 dpo_copy(&tmp_dpo, drop_dpo_get(fib_proto_to_dpo(prefix->fp_proto)));
348 fib_entry_index = fib_table_entry_special_dpo_add(fib_index, prefix, source,
351 dpo_unlock(&tmp_dpo);
353 return (fib_entry_index);
357 fib_table_entry_special_dpo_update (fib_node_index_t fib_entry_index,
359 fib_entry_flag_t flags,
365 fib_entry_get_prefix(fib_entry_index, &prefix);
366 fib_index = fib_entry_get_fib_index(fib_entry_index);
368 fib_table_entry_special_dpo_add(fib_index, &prefix, source, flags, dpo);
369 fib_table_entry_special_remove(fib_index, &prefix, source);
373 fib_table_entry_special_remove (u32 fib_index,
374 const fib_prefix_t *prefix,
379 * yes => remove source
380 * 2 - is it still sourced?
383 fib_node_index_t fib_entry_index;
384 fib_table_t *fib_table;
386 fib_table = fib_table_get(fib_index, prefix->fp_proto);
387 fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
389 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
392 * removing an etry that does not exist. i'll allow it.
397 fib_entry_src_flag_t src_flag;
401 * don't nobody go nowhere
403 fib_entry_lock(fib_entry_index);
404 was_sourced = fib_entry_is_sourced(fib_entry_index, source);
406 src_flag = fib_entry_special_remove(fib_entry_index, source);
408 if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
411 * last source gone. remove from the table
413 fib_table_entry_remove(fib_table, prefix, fib_entry_index);
416 * now the entry is no longer in the table, we can
417 * inform the entries that it covers to re-calculate their cover
419 fib_entry_cover_change_notify(fib_entry_index,
420 FIB_NODE_INDEX_INVALID);
424 * still has sources, leave it be.
426 if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
428 fib_table->ft_src_route_counts[source]--;
431 fib_entry_unlock(fib_entry_index);
436 * fib_table_route_path_fixup
438 * Convert attached hosts to attached next-hops.
440 * This special case is required because an attached path will link to a
441 * glean, and the FIB entry will have the interface or API/CLI source. When
442 * the ARP/ND process is completes then that source (which will provide a
443 * complete adjacency) will be lower priority and so the FIB entry will
444 * remain linked to a glean and traffic will never reach the hosts. For
445 * an ATTAHCED_HOST path we can link the path directly to the [incomplete]
449 fib_table_route_path_fixup (const fib_prefix_t *prefix,
450 fib_route_path_t *path)
452 if (fib_prefix_is_host(prefix) &&
453 ip46_address_is_zero(&path->frp_addr) &&
454 path->frp_sw_if_index != ~0)
456 path->frp_addr = prefix->fp_addr;
461 fib_table_entry_path_add (u32 fib_index,
462 const fib_prefix_t *prefix,
464 fib_entry_flag_t flags,
465 fib_protocol_t next_hop_proto,
466 const ip46_address_t *next_hop,
467 u32 next_hop_sw_if_index,
468 u32 next_hop_fib_index,
470 mpls_label_t next_hop_label,
471 fib_route_path_flags_t path_flags)
473 fib_route_path_t path = {
474 .frp_proto = next_hop_proto,
475 .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
476 .frp_sw_if_index = next_hop_sw_if_index,
477 .frp_fib_index = next_hop_fib_index,
478 .frp_weight = next_hop_weight,
479 .frp_flags = path_flags,
480 .frp_label = next_hop_label,
482 fib_node_index_t fib_entry_index;
483 fib_route_path_t *paths = NULL;
485 fib_table_route_path_fixup(prefix, &path);
486 vec_add1(paths, path);
488 fib_entry_index = fib_table_entry_path_add2(fib_index, prefix,
489 source, flags, paths);
492 return (fib_entry_index);
496 fib_table_entry_path_add2 (u32 fib_index,
497 const fib_prefix_t *prefix,
499 fib_entry_flag_t flags,
500 const fib_route_path_t *rpath)
502 fib_node_index_t fib_entry_index;
503 fib_table_t *fib_table;
505 fib_table = fib_table_get(fib_index, prefix->fp_proto);
506 fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
508 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
510 fib_entry_index = fib_entry_create(fib_index, prefix,
514 fib_table_entry_insert(fib_table, prefix, fib_entry_index);
515 fib_table->ft_src_route_counts[source]++;
521 was_sourced = fib_entry_is_sourced(fib_entry_index, source);
522 fib_entry_path_add(fib_entry_index, source, flags, rpath);;
524 if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
526 fib_table->ft_src_route_counts[source]++;
530 return (fib_entry_index);
534 fib_table_entry_path_remove2 (u32 fib_index,
535 const fib_prefix_t *prefix,
537 const fib_route_path_t *rpath)
541 * yes => remove source
542 * 2 - is it still sourced?
545 fib_node_index_t fib_entry_index;
546 fib_table_t *fib_table;
548 fib_table = fib_table_get(fib_index, prefix->fp_proto);
549 fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
551 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
554 * removing an etry that does not exist. i'll allow it.
559 fib_entry_src_flag_t src_flag;
563 * don't nobody go nowhere
565 fib_entry_lock(fib_entry_index);
566 was_sourced = fib_entry_is_sourced(fib_entry_index, source);
568 src_flag = fib_entry_path_remove(fib_entry_index, source, rpath);
570 if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
573 * last source gone. remove from the table
575 fib_table_entry_remove(fib_table, prefix, fib_entry_index);
578 * now the entry is no longer in the table, we can
579 * inform the entries that it covers to re-calculate their cover
581 fib_entry_cover_change_notify(fib_entry_index,
582 FIB_NODE_INDEX_INVALID);
586 * still has sources, leave it be.
588 if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
590 fib_table->ft_src_route_counts[source]--;
593 fib_entry_unlock(fib_entry_index);
598 fib_table_entry_path_remove (u32 fib_index,
599 const fib_prefix_t *prefix,
601 fib_protocol_t next_hop_proto,
602 const ip46_address_t *next_hop,
603 u32 next_hop_sw_if_index,
604 u32 next_hop_fib_index,
606 fib_route_path_flags_t path_flags)
610 * yes => remove source
611 * 2 - is it still sourced?
614 fib_route_path_t path = {
615 .frp_proto = next_hop_proto,
616 .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
617 .frp_sw_if_index = next_hop_sw_if_index,
618 .frp_fib_index = next_hop_fib_index,
619 .frp_weight = next_hop_weight,
620 .frp_flags = path_flags,
622 fib_route_path_t *paths = NULL;
624 fib_table_route_path_fixup(prefix, &path);
625 vec_add1(paths, path);
627 fib_table_entry_path_remove2(fib_index, prefix, source, paths);
633 fib_route_path_cmp_for_sort (void * v1,
636 return (fib_route_path_cmp(v1, v2));
640 fib_table_entry_update (u32 fib_index,
641 const fib_prefix_t *prefix,
643 fib_entry_flag_t flags,
644 const fib_route_path_t *paths)
646 fib_node_index_t fib_entry_index;
647 fib_table_t *fib_table;
649 fib_table = fib_table_get(fib_index, prefix->fp_proto);
650 fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
653 * sort the paths provided by the control plane. this means
654 * the paths and the extension on the entry will be sorted.
656 vec_sort_with_function(((fib_route_path_t*)paths), // const cast
657 fib_route_path_cmp_for_sort);
659 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
661 fib_entry_index = fib_entry_create(fib_index, prefix,
665 fib_table_entry_insert(fib_table, prefix, fib_entry_index);
666 fib_table->ft_src_route_counts[source]++;
672 was_sourced = fib_entry_is_sourced(fib_entry_index, source);
673 fib_entry_update(fib_entry_index, source, flags, paths);
675 if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
677 fib_table->ft_src_route_counts[source]++;
681 return (fib_entry_index);
685 fib_table_entry_update_one_path (u32 fib_index,
686 const fib_prefix_t *prefix,
688 fib_entry_flag_t flags,
689 fib_protocol_t next_hop_proto,
690 const ip46_address_t *next_hop,
691 u32 next_hop_sw_if_index,
692 u32 next_hop_fib_index,
694 mpls_label_t next_hop_label,
695 fib_route_path_flags_t path_flags)
697 fib_node_index_t fib_entry_index;
698 fib_route_path_t path = {
699 .frp_proto = next_hop_proto,
700 .frp_addr = (NULL == next_hop? zero_addr : *next_hop),
701 .frp_sw_if_index = next_hop_sw_if_index,
702 .frp_fib_index = next_hop_fib_index,
703 .frp_weight = next_hop_weight,
704 .frp_flags = path_flags,
705 .frp_label = next_hop_label,
707 fib_route_path_t *paths = NULL;
709 fib_table_route_path_fixup(prefix, &path);
710 vec_add1(paths, path);
713 fib_table_entry_update(fib_index, prefix, source, flags, paths);
717 return (fib_entry_index);
721 fib_table_entry_delete_i (u32 fib_index,
722 fib_node_index_t fib_entry_index,
723 const fib_prefix_t *prefix,
726 fib_entry_src_flag_t src_flag;
727 fib_table_t *fib_table;
730 fib_table = fib_table_get(fib_index, prefix->fp_proto);
731 was_sourced = fib_entry_is_sourced(fib_entry_index, source);
734 * don't nobody go nowhere
736 fib_entry_lock(fib_entry_index);
738 src_flag = fib_entry_delete(fib_entry_index, source);
740 if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
743 * last source gone. remove from the table
745 fib_table_entry_remove(fib_table, prefix, fib_entry_index);
748 * now the entry is no longer in the table, we can
749 * inform the entries that it covers to re-calculate their cover
751 fib_entry_cover_change_notify(fib_entry_index,
752 FIB_NODE_INDEX_INVALID);
756 * still has sources, leave it be.
758 if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
760 fib_table->ft_src_route_counts[source]--;
763 fib_entry_unlock(fib_entry_index);
767 fib_table_entry_delete (u32 fib_index,
768 const fib_prefix_t *prefix,
771 fib_node_index_t fib_entry_index;
773 fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
775 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
778 * removing an etry that does not exist.
779 * i'll allow it, but i won't like it.
781 clib_warning("%U not in FIB", format_fib_prefix, prefix);
785 fib_table_entry_delete_i(fib_index, fib_entry_index, prefix, source);
790 fib_table_entry_delete_index (fib_node_index_t fib_entry_index,
795 fib_entry_get_prefix(fib_entry_index, &prefix);
797 fib_table_entry_delete_i(fib_entry_get_fib_index(fib_entry_index),
798 fib_entry_index, &prefix, source);
802 fib_table_entry_local_label_add (u32 fib_index,
803 const fib_prefix_t *prefix,
806 fib_node_index_t fib_entry_index;
808 fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
810 if (FIB_NODE_INDEX_INVALID == fib_entry_index ||
811 !fib_entry_is_sourced(fib_entry_index, FIB_SOURCE_MPLS))
814 * only source the prefix once. this allows the label change
817 fib_entry_index = fib_table_entry_special_dpo_add(fib_index, prefix,
823 fib_entry_set_source_data(fib_entry_index, FIB_SOURCE_MPLS, &label);
825 return (fib_entry_index);
829 fib_table_entry_local_label_remove (u32 fib_index,
830 const fib_prefix_t *prefix,
833 fib_node_index_t fib_entry_index;
837 fib_entry_index = fib_table_lookup_exact_match(fib_index, prefix);
839 if (FIB_NODE_INDEX_INVALID == fib_entry_index)
842 data = fib_entry_get_source_data(fib_entry_index, FIB_SOURCE_MPLS);
847 pl = *(mpls_label_t*)data;
852 pl = MPLS_LABEL_INVALID;
854 fib_entry_set_source_data(fib_entry_index, FIB_SOURCE_MPLS, &pl);
855 fib_table_entry_special_remove(fib_index,
861 fib_table_get_index_for_sw_if_index (fib_protocol_t proto,
866 case FIB_PROTOCOL_IP4:
867 return (ip4_fib_table_get_index_for_sw_if_index(sw_if_index));
868 case FIB_PROTOCOL_IP6:
869 return (ip6_fib_table_get_index_for_sw_if_index(sw_if_index));
870 case FIB_PROTOCOL_MPLS:
871 return (mpls_fib_table_get_index_for_sw_if_index(sw_if_index));
877 fib_table_get_flow_hash_config (u32 fib_index,
878 fib_protocol_t proto)
882 case FIB_PROTOCOL_IP4:
883 return (ip4_fib_table_get_flow_hash_config(fib_index));
884 case FIB_PROTOCOL_IP6:
885 return (ip6_fib_table_get_flow_hash_config(fib_index));
886 case FIB_PROTOCOL_MPLS:
887 return (mpls_fib_table_get_flow_hash_config(fib_index));
894 fib_table_get_table_id_for_sw_if_index (fib_protocol_t proto,
897 fib_table_t *fib_table;
899 fib_table = fib_table_get(fib_table_get_index_for_sw_if_index(
903 return ((NULL != fib_table ? fib_table->ft_table_id : ~0));
907 fib_table_find (fib_protocol_t proto,
912 case FIB_PROTOCOL_IP4:
913 return (ip4_fib_index_from_table_id(table_id));
914 case FIB_PROTOCOL_IP6:
915 return (ip6_fib_index_from_table_id(table_id));
916 case FIB_PROTOCOL_MPLS:
917 return (mpls_fib_index_from_table_id(table_id));
923 fib_table_find_or_create_and_lock (fib_protocol_t proto,
926 fib_table_t *fib_table;
931 case FIB_PROTOCOL_IP4:
932 fi = ip4_fib_table_find_or_create_and_lock(table_id);
934 case FIB_PROTOCOL_IP6:
935 fi = ip6_fib_table_find_or_create_and_lock(table_id);
937 case FIB_PROTOCOL_MPLS:
938 fi = mpls_fib_table_find_or_create_and_lock(table_id);
944 fib_table = fib_table_get(fi, proto);
946 fib_table->ft_desc = format(NULL, "%U-VRF:%d",
947 format_fib_protocol, proto,
954 fib_table_create_and_lock (fib_protocol_t proto,
955 const char *const fmt,
958 fib_table_t *fib_table;
966 case FIB_PROTOCOL_IP4:
967 fi = ip4_fib_table_create_and_lock();
969 case FIB_PROTOCOL_IP6:
970 fi = ip6_fib_table_create_and_lock();
972 case FIB_PROTOCOL_MPLS:
973 fi = mpls_fib_table_create_and_lock();
979 fib_table = fib_table_get(fi, proto);
981 fib_table->ft_desc = va_format(fib_table->ft_desc, fmt, &ap);
988 fib_table_destroy (fib_table_t *fib_table)
990 vec_free(fib_table->ft_desc);
992 switch (fib_table->ft_proto)
994 case FIB_PROTOCOL_IP4:
995 ip4_fib_table_destroy(&fib_table->v4);
997 case FIB_PROTOCOL_IP6:
998 ip6_fib_table_destroy(fib_table->ft_index);
1000 case FIB_PROTOCOL_MPLS:
1001 mpls_fib_table_destroy(&fib_table->mpls);
1007 fib_table_unlock (u32 fib_index,
1008 fib_protocol_t proto)
1010 fib_table_t *fib_table;
1012 fib_table = fib_table_get(fib_index, proto);
1013 fib_table->ft_locks--;
1015 if (0 == fib_table->ft_locks)
1017 fib_table_destroy(fib_table);
1021 fib_table_lock (u32 fib_index,
1022 fib_protocol_t proto)
1024 fib_table_t *fib_table;
1026 fib_table = fib_table_get(fib_index, proto);
1027 fib_table->ft_locks++;
1031 fib_table_get_num_entries (u32 fib_index,
1032 fib_protocol_t proto,
1033 fib_source_t source)
1035 fib_table_t *fib_table;
1037 fib_table = fib_table_get(fib_index, proto);
1039 return (fib_table->ft_src_route_counts[source]);
1043 format_fib_table_name (u8* s, va_list ap)
1045 fib_node_index_t fib_index = va_arg(ap, fib_node_index_t);
1046 fib_protocol_t proto = va_arg(ap, int); // int promotion
1047 fib_table_t *fib_table;
1049 fib_table = fib_table_get(fib_index, proto);
1051 s = format(s, "%v", fib_table->ft_desc);
1057 fib_table_flush (u32 fib_index,
1058 fib_protocol_t proto,
1059 fib_source_t source)