FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip4_fib_16.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/fib/fib_table.h>
17 #include <vnet/fib/fib_entry.h>
18 #include <vnet/fib/ip4_fib.h>
19 
21 
22 void
24 {
25  ip4_mtrie_16_init(&fib->mtrie);
26 }
27 
28 void
30 {
31  ip4_mtrie_16_free(&fib->mtrie);
32 }
33 
34 /*
35  * ip4_fib_16_table_lookup_exact_match
36  *
37  * Exact match prefix lookup
38  */
41  const ip4_address_t *addr,
42  u32 len)
43 {
45 }
46 
47 /*
48  * ip4_fib_16_table_lookup_adj
49  *
50  * Longest prefix match
51  */
52 index_t
54  const ip4_address_t *addr)
55 {
56  return (ip4_fib_hash_table_lookup_lb(&fib->hash, addr));
57 }
58 
59 /*
60  * ip4_fib_16_table_lookup
61  *
62  * Longest prefix match
63  */
66  const ip4_address_t *addr,
67  u32 len)
68 {
69  return (ip4_fib_hash_table_lookup(&fib->hash, addr, len));
70 }
71 
72 void
74  const ip4_address_t *addr,
75  u32 len,
76  fib_node_index_t fib_entry_index)
77 {
78  return (ip4_fib_hash_table_entry_insert(&fib->hash, addr, len, fib_entry_index));
79 }
80 
81 void
83  const ip4_address_t *addr,
84  u32 len)
85 {
86  return (ip4_fib_hash_table_entry_remove(&fib->hash, addr, len));
87 }
88 
89 void
91  const ip4_address_t *addr,
92  u32 len,
93  const dpo_id_t *dpo)
94 {
96 }
97 
98 void
100  const ip4_address_t *addr,
101  u32 len,
102  const dpo_id_t *dpo,
103  u32 cover_index)
104 {
105  const fib_prefix_t *cover_prefix;
106  const dpo_id_t *cover_dpo;
107 
108  /*
109  * We need to pass the MTRIE the LB index and address length of the
110  * covering prefix, so it can fill the plys with the correct replacement
111  * for the entry being removed
112  */
113  cover_prefix = fib_entry_get_prefix(cover_index);
114  cover_dpo = fib_entry_contribute_ip_forwarding(cover_index);
115 
117  addr, len, dpo->dpoi_index,
118  cover_prefix->fp_len,
119  cover_dpo->dpoi_index);
120 }
121 
122 void
125  void *ctx)
126 {
127  ip4_fib_hash_table_walk(&fib->hash, fn, ctx);
128 }
129 
130 void
132  const fib_prefix_t *root,
134  void *ctx)
135 {
136  ip4_fib_hash_table_sub_tree_walk(&fib->hash, root, fn, ctx);
137 }
fib_entry.h
dpo_id_t_::dpoi_index
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:190
ip4_mtrie_16_init
void ip4_mtrie_16_init(ip4_mtrie_16_t *m)
Initialise an mtrie.
Definition: ip4_mtrie.c:205
fib_entry_get_prefix
const fib_prefix_t * fib_entry_get_prefix(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1728
ip4_fib_hash_table_lookup_lb
index_t ip4_fib_hash_table_lookup_lb(const ip4_fib_hash_t *fib, const ip4_address_t *addr)
Definition: ip4_fib_hash.c:50
ip4_fib_hash_table_entry_remove
void ip4_fib_hash_table_entry_remove(ip4_fib_hash_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib_hash.c:129
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, u32 cover_index)
Definition: ip4_fib_16.c:99
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_::hash
ip4_fib_hash_t hash
The hash table DB.
Definition: ip4_fib_16.h:50
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
fib_table.h
fib_prefix_t_::fp_len
u16 fp_len
The mask length.
Definition: fib_types.h:206
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_mtrie_16_free
void ip4_mtrie_16_free(ip4_mtrie_16_t *m)
Free an mtrie, It must be empty when free'd.
Definition: ip4_mtrie.c:189
ip4_fib_hash_table_entry_insert
void ip4_fib_hash_table_entry_insert(ip4_fib_hash_t *fib, const ip4_address_t *addr, u32 len, fib_node_index_t fib_entry_index)
Definition: ip4_fib_hash.c:97
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
ip4_fib_hash_table_sub_tree_walk
void ip4_fib_hash_table_sub_tree_walk(ip4_fib_hash_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_hash.c:172
ip4_fib_hash_table_lookup_exact_match
fib_node_index_t ip4_fib_hash_table_lookup_exact_match(const ip4_fib_hash_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib_hash.c:26
ip4_fib_16_table_free
void ip4_fib_16_table_free(ip4_fib_16_t *fib)
Definition: ip4_fib_16.c:29
len
u8 len
Definition: ip_types.api:103
fib_entry_contribute_ip_forwarding
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:506
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
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
ip4_fib_16s
ip4_fib_16_t * ip4_fib_16s
Definition: ip4_fib_16.c:20
ip4_address_t
Definition: ip4_packet.h:50
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_mtrie_16_route_del
void ip4_mtrie_16_route_del(ip4_mtrie_16_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index, u32 cover_address_length, u32 cover_adj_index)
remove a route/entry to the mtrie
Definition: ip4_mtrie.c:670
ip4_fib_hash_table_lookup
fib_node_index_t ip4_fib_hash_table_lookup(const ip4_fib_hash_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib_hash.c:74
u32
unsigned int u32
Definition: types.h:88
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
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
ip4_fib.h
ip4_fib_16_table_lookup_lb
index_t ip4_fib_16_table_lookup_lb(ip4_fib_16_t *fib, const ip4_address_t *addr)
Definition: ip4_fib_16.c:53
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_mtrie_16_route_add
void ip4_mtrie_16_route_add(ip4_mtrie_16_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index)
Add a route/entry to the mtrie.
Definition: ip4_mtrie.c:636
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_fib_16_table_init
void ip4_fib_16_table_init(ip4_fib_16_t *fib)
Definition: ip4_fib_16.c:23
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
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
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
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_fib_hash_table_walk
void ip4_fib_hash_table_walk(ip4_fib_hash_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_hash.c:155