FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
mfib_entry.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 #ifndef __MFIB_ENTRY_H__
17 #define __MFIB_ENTRY_H__
18 
19 #include <vnet/fib/fib_node.h>
20 #include <vnet/mfib/mfib_types.h>
21 #include <vnet/mfib/mfib_itf.h>
23 #include <vnet/ip/ip.h>
24 #include <vnet/dpo/dpo.h>
25 
26 /**
27  * An entry in a FIB table.
28  *
29  * This entry represents a route added to the FIB that is stored
30  * in one of the FIB tables.
31  */
32 typedef struct mfib_entry_t_ {
33  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
34  /**
35  * Base class. The entry's node representation in the graph.
36  */
38 
39  /**
40  * The prefix of the route
41  */
43 
44  /**
45  * The index of the FIB table this entry is in
46  */
48 
49  /**
50  * A vector of sources contributing forwarding
51  */
53 
54  /**
55  * The path-list of which this entry is a child
56  */
58 
59  /**
60  * The sibling index on the path-list
61  */
63 
64  /**
65  * 2nd cache line has the members used in the data plane
66  */
67  CLIB_CACHE_LINE_ALIGN_MARK(cacheline1);
68 
69  /**
70  * The DPO used for forwarding; replicate, drop, etc..
71  */
73 
74  /**
75  * Route flags
76  */
78 
79  /**
80  * RPF-ID used when the packets ingress not from an interface
81  */
83 
84  /**
85  * A hash table of interfaces
86  */
88 
89  /**
90  * A vector of delegates.
91  */
93 } mfib_entry_t;
94 
95 /**
96  * Debug macro
97  */
99 
100 #define MFIB_ENTRY_DBG(_e, _fmt, _args...) \
101 { \
102  vlib_log_debug(mfib_entry_logger, \
103  "e:[%d:%U]: " _fmt, \
104  mfib_entry_get_index(_e), \
105  format_mfib_prefix, \
106  &_e->mfe_prefix, \
107  ##_args); \
108 }
109 
110 #define MFIB_ENTRY_FORMAT_BRIEF (0x0)
111 #define MFIB_ENTRY_FORMAT_DETAIL (0x1)
112 #define MFIB_ENTRY_FORMAT_DETAIL2 (0x2)
113 
114 extern u8 *format_mfib_entry(u8 * s, va_list * args);
115 
116 
117 extern fib_node_index_t mfib_entry_create(u32 fib_index,
118  mfib_source_t source,
119  const mfib_prefix_t *prefix,
122  index_t repi);
123 
124 extern int mfib_entry_update(fib_node_index_t fib_entry_index,
125  mfib_source_t source,
128  index_t rep_dpo);
129 
130 extern int mfib_entry_special_add(fib_node_index_t fib_entry_index,
131  mfib_source_t source,
134  index_t rep_dpo);
135 
136 extern void mfib_entry_path_update(fib_node_index_t fib_entry_index,
137  mfib_source_t source,
138  const fib_route_path_t *rpath);
139 
140 
141 extern int mfib_entry_path_remove(fib_node_index_t fib_entry_index,
142  mfib_source_t source,
143  const fib_route_path_t *rpath);
144 
145 extern int mfib_entry_delete(fib_node_index_t mfib_entry_index,
146  mfib_source_t source);
147 
148 extern int mfib_entry_cmp_for_sort(void *i1, void *i2);
149 
150 extern u32 mfib_entry_child_add(fib_node_index_t mfib_entry_index,
152  fib_node_index_t child_index);
153 extern void mfib_entry_child_remove(fib_node_index_t mfib_entry_index,
154  u32 sibling_index);
155 
156 extern void mfib_entry_lock(fib_node_index_t fib_entry_index);
157 extern void mfib_entry_unlock(fib_node_index_t fib_entry_index);
158 
159 extern const mfib_prefix_t *mfib_entry_get_prefix(fib_node_index_t fib_entry_index);
160 extern u32 mfib_entry_get_fib_index(fib_node_index_t fib_entry_index);
161 extern int mfib_entry_is_sourced(fib_node_index_t fib_entry_index,
162  mfib_source_t source);
163 extern int mfib_entry_is_host(fib_node_index_t fib_entry_index);
164 extern int mfib_entry_is_marked(fib_node_index_t fib_entry_index, mfib_source_t source);
165 extern void mfib_entry_mark(fib_node_index_t fib_entry_index, mfib_source_t source);
166 extern u32 mfib_entry_get_stats_index(fib_node_index_t fib_entry_index);
167 extern void mfib_entry_cover_changed(fib_node_index_t fib_entry_index);
168 extern void mfib_entry_cover_updated(fib_node_index_t fib_entry_index);
169 
171  fib_node_index_t mfib_entry_index);
172 
173 /**
174  * Flags to control what is present in the replicate DPO returned when
175  * the entry contributes forwarding
176  */
178 {
180  /**
181  * Do not reutrn any local replications in the set
182  */
185 
187  fib_node_index_t mfib_entry_index,
190  dpo_id_t *dpo);
191 
192 extern fib_route_path_t* mfib_entry_encode(fib_node_index_t fib_entry_index);
193 
194 extern void mfib_entry_module_init(void);
195 
196 
198 
199 static inline mfib_entry_t *
201 {
203 }
204 static inline fib_node_index_t
206 {
207  return (mfe - mfib_entry_pool);
208 }
209 
210 
211 static inline mfib_itf_t *
214 {
215  uword *p;
216 
217  p = hash_get(itfs, sw_if_index);
218 
219  if (NULL != p)
220  {
221  return (mfib_itf_get(p[0]));
222  }
223 
224  return (NULL);
225 }
226 
227 static inline mfib_itf_t *
230 {
231  return (mfib_entry_itf_find(mfe->mfe_itfs, sw_if_index));
232 }
233 
234 #endif
mfib_entry_cmp_for_sort
int mfib_entry_cmp_for_sort(void *i1, void *i2)
Definition: mfib_entry.c:1313
mfib_entry_t
struct mfib_entry_t_ mfib_entry_t
An entry in a FIB table.
mfib_entry_pool
mfib_entry_t * mfib_entry_pool
Definition: mfib_entry.c:46
entry_flags
vl_api_mfib_entry_flags_t entry_flags
Definition: ip.api:414
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
vlib_log_class_t
u32 vlib_log_class_t
Definition: vlib.h:52
mfib_prefix_t_
Aggregate type for a prefix.
Definition: mfib_types.h:24
mfib_entry_t_::mfe_prefix
mfib_prefix_t mfe_prefix
The prefix of the route.
Definition: mfib_entry.h:42
mfib_entry_module_init
void mfib_entry_module_init(void)
Definition: mfib_entry.c:1445
mfib_entry_cover_updated
void mfib_entry_cover_updated(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1595
mfib_entry_t_::mfe_node
fib_node_t mfe_node
Base class.
Definition: mfib_entry.h:37
mfib_entry_get_index
static fib_node_index_t mfib_entry_get_index(const mfib_entry_t *mfe)
Definition: mfib_entry.h:205
mfib_entry_fwd_flags_t
enum mfib_entry_fwd_flags_t_ mfib_entry_fwd_flags_t
Flags to control what is present in the replicate DPO returned when the entry contributes forwarding.
mfib_entry_flags_t
enum mfib_entry_flags_t_ mfib_entry_flags_t
mfib_entry_t_::mfe_fib_index
u32 mfe_fib_index
The index of the FIB table this entry is in.
Definition: mfib_entry.h:47
mfib_entry_path_remove
int mfib_entry_path_remove(fib_node_index_t fib_entry_index, mfib_source_t source, const fib_route_path_t *rpath)
Definition: mfib_entry.c:1123
fib_node.h
fib_node_type_t
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
mfib_entry_mark
void mfib_entry_mark(fib_node_index_t fib_entry_index, mfib_source_t source)
Definition: mfib_entry.c:380
mfib_entry_unlock
void mfib_entry_unlock(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1402
mfib_entry_t_::mfe_rep
dpo_id_t mfe_rep
The DPO used for forwarding; replicate, drop, etc.
Definition: mfib_entry.h:72
mfib_entry_fwd_flags_t_
mfib_entry_fwd_flags_t_
Flags to control what is present in the replicate DPO returned when the entry contributes forwarding.
Definition: mfib_entry.h:177
mfib_entry_child_remove
void mfib_entry_child_remove(fib_node_index_t mfib_entry_index, u32 sibling_index)
Definition: mfib_entry.c:458
mfib_entry_get_prefix
const mfib_prefix_t * mfib_entry_get_prefix(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1489
mfib_entry_src_t_
The source of an MFIB entry.
Definition: mfib_entry_src.h:75
mfib_entry_delete
int mfib_entry_delete(fib_node_index_t mfib_entry_index, mfib_source_t source)
mfib_entry_delete
Definition: mfib_entry.c:1224
mfib_entry_update
int mfib_entry_update(fib_node_index_t fib_entry_index, mfib_source_t source, mfib_entry_flags_t entry_flags, fib_rpf_id_t rpf_id, index_t rep_dpo)
Definition: mfib_entry.c:939
mfib_source_t
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
fib_rpf_id_t
u32 fib_rpf_id_t
An RPF-ID is numerical value that is used RPF validate.
Definition: fib_types.h:421
mfib_entry_t_::mfe_itfs
mfib_itf_t * mfe_itfs
A hash table of interfaces.
Definition: mfib_entry.h:87
mfib_entry_get
static mfib_entry_t * mfib_entry_get(fib_node_index_t index)
Definition: mfib_entry.h:200
dpo.h
fib_forward_chain_type_t
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
mfib_entry_t_::mfe_pl
fib_node_index_t mfe_pl
The path-list of which this entry is a child.
Definition: mfib_entry.h:57
mfib_entry_lock
void mfib_entry_lock(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1392
mfib_entry_t_::mfe_sibling
u32 mfe_sibling
The sibling index on the path-list.
Definition: mfib_entry.h:62
mfib_entry_t_::CLIB_CACHE_LINE_ALIGN_MARK
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
mfib_entry_itf_find
static mfib_itf_t * mfib_entry_itf_find(mfib_itf_t *itfs, u32 sw_if_index)
Definition: mfib_entry.h:212
mfib_entry_contribute_ip_forwarding
const dpo_id_t * mfib_entry_contribute_ip_forwarding(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1509
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
mfib_entry_t_::mfe_flags
mfib_entry_flags_t mfe_flags
Route flags.
Definition: mfib_entry.h:77
uword
u64 uword
Definition: types.h:112
hash_get
#define hash_get(h, key)
Definition: hash.h:249
mfib_entry_child_add
u32 mfib_entry_child_add(fib_node_index_t mfib_entry_index, fib_node_type_t type, fib_node_index_t child_index)
Definition: mfib_entry.c:447
mfib_entry_logger
vlib_log_class_t mfib_entry_logger
Debug macro.
Definition: mfib_entry.c:30
mfib_entry_is_sourced
int mfib_entry_is_sourced(fib_node_index_t fib_entry_index, mfib_source_t source)
Definition: mfib_entry.c:348
format_mfib_entry
u8 * format_mfib_entry(u8 *s, va_list *args)
Definition: mfib_entry.c:126
mfib_entry_is_marked
int mfib_entry_is_marked(fib_node_index_t fib_entry_index, mfib_source_t source)
Definition: mfib_entry.c:359
mfib_itf_get
static mfib_itf_t * mfib_itf_get(index_t mi)
Get the MFIB interface representation.
Definition: mfib_itf.h:83
index
u32 index
Definition: flow_types.api:221
mfib_entry_encode
fib_route_path_t * mfib_entry_encode(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1453
mfib_entry_t_::fe_delegates
mfib_entry_delegate_t * fe_delegates
A vector of delegates.
Definition: mfib_entry.h:92
mfib_entry_get_fib_index
u32 mfib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1499
mfib_itf.h
mfib_entry_delegate.h
ip.h
u32
unsigned int u32
Definition: types.h:88
mfib_types.h
mfib_entry_special_add
int mfib_entry_special_add(fib_node_index_t fib_entry_index, mfib_source_t source, mfib_entry_flags_t entry_flags, fib_rpf_id_t rpf_id, index_t rep_dpo)
Definition: mfib_entry.c:917
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
mfib_entry_t_
An entry in a FIB table.
Definition: mfib_entry.h:32
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
mfib_itf_t_
An interface associated with a particular MFIB entry.
Definition: mfib_itf.h:25
mfib_entry_is_host
int mfib_entry_is_host(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:397
mfib_entry_create
fib_node_index_t mfib_entry_create(u32 fib_index, mfib_source_t source, const mfib_prefix_t *prefix, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags, index_t repi)
Definition: mfib_entry.c:803
mfib_entry_cover_changed
void mfib_entry_cover_changed(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1570
mfib_entry_get_stats_index
u32 mfib_entry_get_stats_index(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1345
u8
unsigned char u8
Definition: types.h:56
MFIB_ENTRY_FWD_FLAG_NONE
@ MFIB_ENTRY_FWD_FLAG_NONE
Definition: mfib_entry.h:179
mfib_entry_get_itf
static mfib_itf_t * mfib_entry_get_itf(const mfib_entry_t *mfe, u32 sw_if_index)
Definition: mfib_entry.h:228
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
mfib_entry_delegate_t_
A Delagate is a means to implmenet the Delagation design pattern; the extension of an objects functio...
Definition: mfib_entry_delegate.h:52
mfib_entry_contribute_forwarding
void mfib_entry_contribute_forwarding(fib_node_index_t mfib_entry_index, fib_forward_chain_type_t type, mfib_entry_fwd_flags_t flags, dpo_id_t *dpo)
Definition: mfib_entry.c:1519
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
MFIB_ENTRY_FWD_FLAG_NO_LOCAL
@ MFIB_ENTRY_FWD_FLAG_NO_LOCAL
Do not reutrn any local replications in the set.
Definition: mfib_entry.h:183
rpf_id
u32 rpf_id
Definition: fib_types.api:119
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
mfib_entry_t_::mfe_srcs
struct mfib_entry_src_t_ * mfe_srcs
A vector of sources contributing forwarding.
Definition: mfib_entry.h:52
mfib_entry_t_::mfe_rpf_id
fib_rpf_id_t mfe_rpf_id
RPF-ID used when the packets ingress not from an interface.
Definition: mfib_entry.h:82
prefix
vl_api_prefix_t prefix
Definition: ip.api:146
mfib_entry_path_update
void mfib_entry_path_update(fib_node_index_t fib_entry_index, mfib_source_t source, const fib_route_path_t *rpath)
Definition: mfib_entry.c:987
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105