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.
18 * FIBs are composed of two prefix data-bases (akak tables). The non-forwarding
19 * table contains all the routes that the control plane has programmed, the
20 * forwarding table contains the sub-set of those routes that can be used to
22 * In the IPv4 FIB the non-forwarding table is an array of hash tables indexed
23 * by mask length, the forwarding table is an mtrie
25 * This IPv4 FIB is used by the protocol independent FIB. So directly using
26 * this APIs in client code is not encouraged. However, this IPv4 FIB can be
27 * used if all the client wants is an IPv4 prefix data-base
30 #ifndef __IP4_FIB_8_H__
31 #define __IP4_FIB_8_H__
33 #include <vnet/fib/ip4_fib_hash.h>
34 #include <vnet/ip/ip4_mtrie.h>
36 typedef struct ip4_fib_8_t_
38 /** Required for pool_get_aligned */
39 CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
42 * Mtrie for fast lookups. Hash is used to maintain overlapping prefixes.
43 * First member so it's in the first cacheline.
53 extern ip4_fib_8_t *ip4_fib_8s;
55 extern fib_node_index_t ip4_fib_8_table_lookup(const ip4_fib_8_t *fib,
56 const ip4_address_t *addr,
58 extern fib_node_index_t ip4_fib_8_table_lookup_exact_match(const ip4_fib_8_t *fib,
59 const ip4_address_t *addr,
62 extern void ip4_fib_8_table_entry_remove(ip4_fib_8_t *fib,
63 const ip4_address_t *addr,
66 extern void ip4_fib_8_table_entry_insert(ip4_fib_8_t *fib,
67 const ip4_address_t *addr,
69 fib_node_index_t fib_entry_index);
70 extern void ip4_fib_8_table_free(ip4_fib_8_t *fib);
71 extern void ip4_fib_8_table_init(ip4_fib_8_t *fib);
73 extern void ip4_fib_8_table_fwding_dpo_update(ip4_fib_8_t *fib,
74 const ip4_address_t *addr,
78 extern void ip4_fib_8_table_fwding_dpo_remove(ip4_fib_8_t *fib,
79 const ip4_address_t *addr,
82 fib_node_index_t cover_index);
83 extern u32 ip4_fib_8_table_lookup_lb (ip4_fib_8_t *fib,
84 const ip4_address_t * dst);
87 * @brief Walk all entries in a FIB table
88 * N.B: This is NOT safe to deletes. If you need to delete walk the whole
89 * table and store elements in a vector, then delete the elements
91 extern void ip4_fib_8_table_walk(ip4_fib_8_t *fib,
92 fib_table_walk_fn_t fn,
96 * @brief Walk all entries in a sub-tree of the FIB table
97 * N.B: This is NOT safe to deletes. If you need to delete walk the whole
98 * table and store elements in a vector, then delete the elements
100 extern void ip4_fib_8_table_sub_tree_walk(ip4_fib_8_t *fib,
101 const fib_prefix_t *root,
102 fib_table_walk_fn_t fn,