FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ip6_mfib.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 Multicast-FIB
17  *
18  * FIXME
19  *
20  * This IPv4 FIB is used by the protocol independent FIB. So directly using
21  * this APIs in client code is not encouraged. However, this IPv4 FIB can be
22  * used if all the client wants is an IPv4 prefix data-base
23  */
24 
25 #ifndef __IP6_MFIB_H__
26 #define __IP6_MFIB_H__
27 
28 #include <vppinfra/bihash_40_8.h>
30 
31 #include <vlib/vlib.h>
32 #include <vnet/ip/ip.h>
33 
34 #include <vnet/mfib/mfib_table.h>
35 
36 /*
37  * Default size of the ip6 fib hash table
38  */
39 #define IP6_MFIB_DEFAULT_HASH_NUM_BUCKETS (64 * 1024)
40 #define IP6_MFIB_DEFAULT_HASH_MEMORY_SIZE (32<<20)
41 
42 
43 /**
44  * A representation of a single IP6 mfib table
45  */
47 {
48  /* The hash table */
49  clib_bihash_40_8_t ip6_mhash;
50 
51  /* bitmap / refcounts / vector of mask widths to search */
56 
57 /**
58  * the single MFIB table
59  */
61 
63  const ip6_address_t *src,
64  const ip6_address_t *grp,
65  u32 len);
67  const ip6_address_t *src,
68  const ip6_address_t *grp);
70  const ip6_address_t *grp,
71  const ip6_address_t *src,
72  u32 len);
74  const ip6_address_t *src,
75  const ip6_address_t *grp,
76  u32 len);
77 
79  const ip6_address_t *grp,
80  const ip6_address_t *src,
81  u32 len);
82 
84  const ip6_address_t *grp,
85  const ip6_address_t *src,
86  u32 len,
87  fib_node_index_t fib_entry_index);
88 extern void ip6_mfib_table_destroy(ip6_mfib_t *fib);
89 
90 /**
91  * @brief
92  * Add/remove the interface from the accepting list of the special MFIB entries
93  */
95  int is_enable);
96 
97 /**
98  * @brief Get the FIB at the given index
99  */
100 static inline ip6_mfib_t *
102 {
103  return (&(pool_elt_at_index(ip6_main.mfibs, index)->v6));
104 }
105 
106 /**
107  * @brief Get or create an IPv4 fib.
108  *
109  * Get or create an IPv4 fib with the provided table ID.
110  *
111  * @param table_id
112  * When set to \c ~0, an arbitrary and unused fib ID is picked
113  * and can be retrieved with \c ret->table_id.
114  * Otherwise, the fib ID to be used to retrieve or create the desired fib.
115  * @returns A pointer to the retrieved or created fib.
116  *
117  */
121 
122 
123 static inline
125 {
126  ip6_main_t * im = &ip6_main;
127  uword * p;
128 
129  p = hash_get (im->mfib_index_by_table_id, table_id);
130  if (!p)
131  return ~0;
132 
133  return p[0];
134 }
135 
137 
138 /**
139  * @brief Data-plane lookup function
140  */
142  const ip6_address_t *src,
143  const ip6_address_t *grp);
144 
145 /**
146  * @brief Walk the IP6 mfib table.
147  *
148  * @param mfib the table to walk
149  * @param fn The function to invoke on each entry visited
150  * @param ctx A context passed in the visit function
151  */
152 extern void ip6_mfib_table_walk (ip6_mfib_t *mfib,
154  void *ctx);
155 
156 /**
157  * @brief format (display) ipv6 MFIB mempry usage
158  */
159 extern u8 *format_ip6_mfib_table_memory(u8 * s, va_list * args);
160 
161 #endif
162 
vlib.h
ip6_mfib_table_lookup2
fib_node_index_t ip6_mfib_table_lookup2(const ip6_mfib_t *mfib, const ip6_address_t *src, const ip6_address_t *grp)
Data-plane lookup function.
im
vnet_interface_main_t * im
Definition: interface_output.c:395
ip6_mfib_table_lookup_exact_match
fib_node_index_t ip6_mfib_table_lookup_exact_match(const ip6_mfib_t *fib, const ip6_address_t *grp, const ip6_address_t *src, u32 len)
Definition: ip6_mfib.c:328
ip6_mfib_get
static ip6_mfib_t * ip6_mfib_get(u32 index)
Get the FIB at the given index.
Definition: ip6_mfib.h:101
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
bihash_template.h
ip6_mfib_table_entry_remove
void ip6_mfib_table_entry_remove(ip6_mfib_t *fib, const ip6_address_t *grp, const ip6_address_t *src, u32 len)
Definition: ip6_mfib.c:492
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
ip6_mfib_table_lookup
fib_node_index_t ip6_mfib_table_lookup(const ip6_mfib_t *fib, const ip6_address_t *src, const ip6_address_t *grp, u32 len)
Definition: ip6_mfib.c:417
ip6_mfib_table_instance_t_::prefix_lengths_in_search_order
u16 * prefix_lengths_in_search_order
Definition: ip6_mfib.h:53
ip6_mfib_interface_enable_disable
void ip6_mfib_interface_enable_disable(u32 sw_if_index, int is_enable)
Add/remove the interface from the accepting list of the special MFIB entries.
Definition: ip6_mfib.c:234
ip6_mfib_table_instance_t_
A representation of a single IP6 mfib table.
Definition: ip6_mfib.h:46
u16
unsigned short u16
Definition: types.h:57
i32
signed int i32
Definition: types.h:77
mfib_source_t
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
len
u8 len
Definition: ip_types.api:103
ip6_mfib_table_instance_t_::non_empty_dst_address_length_bitmap
uword * non_empty_dst_address_length_bitmap
Definition: ip6_mfib.h:52
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
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
uword
u64 uword
Definition: types.h:112
ip6_mfib_index_from_table_id
static u32 ip6_mfib_index_from_table_id(u32 table_id)
Definition: ip6_mfib.h:124
hash_get
#define hash_get(h, key)
Definition: hash.h:249
ip6_main_t::mfibs
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip6.h:121
src
vl_api_address_t src
Definition: gre.api:54
mfib_table.h
ip6_mfib_table_instance_t_::ip6_mhash
clib_bihash_40_8_t ip6_mhash
Definition: ip6_mfib.h:49
ip6_mfib_table_walk
void ip6_mfib_table_walk(ip6_mfib_t *mfib, mfib_table_walk_fn_t fn, void *ctx)
Walk the IP6 mfib table.
Definition: ip6_mfib.c:628
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2787
index
u32 index
Definition: flow_types.api:221
ip.h
u32
unsigned int u32
Definition: types.h:88
bihash_40_8.h
table_id
u32 table_id
Definition: wireguard.api:102
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
ip6_mfib_table_entry_insert
void ip6_mfib_table_entry_insert(ip6_mfib_t *fib, const ip6_address_t *grp, const ip6_address_t *src, u32 len, fib_node_index_t fib_entry_index)
Definition: ip6_mfib.c:467
ip6_mfib_t
Definition: ip6.h:73
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
ip6_main_t
Definition: ip6.h:110
ip6_mfib_table_instance_t
struct ip6_mfib_table_instance_t_ ip6_mfib_table_instance_t
A representation of a single IP6 mfib table.
ip6_mfib_table_fwd_lookup
fib_node_index_t ip6_mfib_table_fwd_lookup(const ip6_mfib_t *fib, const ip6_address_t *src, const ip6_address_t *grp)
Definition: ip6_mfib.c:352
ip6_mfib_table_instance_t_::dst_address_length_refcounts
i32 dst_address_length_refcounts[257]
Definition: ip6_mfib.h:54
u8
unsigned char u8
Definition: types.h:56
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
ip6_mfib_table_destroy
void ip6_mfib_table_destroy(ip6_mfib_t *fib)
Definition: ip6_mfib.c:193
ip6_mfib_table
ip6_mfib_table_instance_t ip6_mfib_table
the single MFIB table
Definition: ip6_mfib.c:22
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
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
ip6_mfib_table_create_and_lock
u32 ip6_mfib_table_create_and_lock(mfib_source_t src)