FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip4_fib_16.h
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  * @brief The IPv4 FIB
17  *
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
21  * forward packets.
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
24  *
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
28  */
29 
30 #ifndef __IP4_FIB_16_H__
31 #define __IP4_FIB_16_H__
32 
33 #include <vnet/fib/ip4_fib_hash.h>
34 #include <vnet/ip/ip4_mtrie.h>
35 
36 typedef struct ip4_fib_16_t_
37 {
38  /** Required for pool_get_aligned */
39  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
40 
41  /**
42  * Mtrie for fast lookups. Hash is used to maintain overlapping prefixes.
43  * First member so it's in the first cacheline.
44  */
46 
47  /**
48  * The hash table DB
49  */
51 } ip4_fib_16_t;
52 
54 
56  const ip4_address_t *addr,
57  u32 len);
59  const ip4_address_t *addr,
60  u32 len);
61 
63  const ip4_address_t *addr,
64  u32 len);
65 
67  const ip4_address_t *addr,
68  u32 len,
69  fib_node_index_t fib_entry_index);
70 extern void ip4_fib_16_table_free(ip4_fib_16_t *fib);
71 extern void ip4_fib_16_table_init(ip4_fib_16_t *fib);
72 
74  const ip4_address_t *addr,
75  u32 len,
76  const dpo_id_t *dpo);
77 
79  const ip4_address_t *addr,
80  u32 len,
81  const dpo_id_t *dpo,
82  fib_node_index_t cover_index);
84  const ip4_address_t * dst);
85 
86 /**
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
90  */
91 extern void ip4_fib_16_table_walk(ip4_fib_16_t *fib,
93  void *ctx);
94 
95 /**
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
99  */
101  const fib_prefix_t *root,
103  void *ctx);
104 
105 #endif
106 
ip4_fib_16_table_entry_insert
void ip4_fib_16_table_entry_insert(ip4_fib_16_t *fib, const ip4_address_t *addr, u32 len, fib_node_index_t fib_entry_index)
Definition: ip4_fib_16.c:73
ip4_fib_16_t_::hash
ip4_fib_hash_t hash
The hash table DB.
Definition: ip4_fib_16.h:50
ip4_fib_16_table_lookup_exact_match
fib_node_index_t ip4_fib_16_table_lookup_exact_match(const ip4_fib_16_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib_16.c:40
ip4_fib_16_t
struct ip4_fib_16_t_ ip4_fib_16_t
The IPv4 FIB.
ip4_fib_16_table_sub_tree_walk
void ip4_fib_16_table_sub_tree_walk(ip4_fib_16_t *fib, const fib_prefix_t *root, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a sub-tree of the FIB table N.B: This is NOT safe to deletes.
Definition: ip4_fib_16.c:131
ip4_fib_hash.h
ip4_fib_16_table_fwding_dpo_remove
void ip4_fib_16_table_fwding_dpo_remove(ip4_fib_16_t *fib, const ip4_address_t *addr, u32 len, const dpo_id_t *dpo, fib_node_index_t cover_index)
Definition: ip4_fib_16.c:99
ip4_mtrie.h
ip4_fib_16_t_::CLIB_CACHE_LINE_ALIGN_MARK
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
Required for pool_get_aligned.
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
ip4_fib_16s
ip4_fib_16_t * ip4_fib_16s
Definition: ip4_fib_16.c:20
len
u8 len
Definition: ip_types.api:103
ip4_fib_hash_t_
The IPv4 FIB Hash table.
Definition: ip4_fib_hash.h:25
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
ip4_fib_16_table_fwding_dpo_update
void ip4_fib_16_table_fwding_dpo_update(ip4_fib_16_t *fib, const ip4_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip4_fib_16.c:90
ip4_address_t
Definition: ip4_packet.h:50
ip4_fib_16_table_init
void ip4_fib_16_table_init(ip4_fib_16_t *fib)
Definition: ip4_fib_16.c:23
ip4_fib_16_table_lookup
fib_node_index_t ip4_fib_16_table_lookup(const ip4_fib_16_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib_16.c:65
fib_table_walk_fn_t
fib_table_walk_rc_t(* fib_table_walk_fn_t)(fib_node_index_t fei, void *ctx)
Call back function when walking entries in a FIB table.
Definition: fib_table.h:930
ip4_fib_16_table_entry_remove
void ip4_fib_16_table_entry_remove(ip4_fib_16_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib_16.c:82
u32
unsigned int u32
Definition: types.h:88
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
ip4_fib_16_table_free
void ip4_fib_16_table_free(ip4_fib_16_t *fib)
Definition: ip4_fib_16.c:29
ip4_fib_16_table_lookup_lb
u32 ip4_fib_16_table_lookup_lb(ip4_fib_16_t *fib, const ip4_address_t *dst)
Definition: ip4_fib_16.c:53
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
ip4_mtrie_16_t
The mutiway-TRIE with a 16-8-8 stride.
Definition: ip4_mtrie.h:128
ip4_fib_16_table_walk
void ip4_fib_16_table_walk(ip4_fib_16_t *fib, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: ip4_fib_16.c:123
ip4_fib_16_t_::mtrie
ip4_mtrie_16_t mtrie
Mtrie for fast lookups.
Definition: ip4_fib_16.h:45
ip4_fib_16_t_
The IPv4 FIB.
Definition: ip4_fib_16.h:36
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202