FD.io VPP  v17.07.01-10-g3be13f0
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>
22 #include <vnet/ip/ip.h>
23 #include <vnet/dpo/dpo.h>
24 
25 /**
26  * An entry in a FIB table.
27  *
28  * This entry represents a route added to the FIB that is stored
29  * in one of the FIB tables.
30  */
31 typedef struct mfib_entry_t_ {
32  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
33  /**
34  * Base class. The entry's node representation in the graph.
35  */
37  /**
38  * The prefix of the route
39  */
41  /**
42  * The index of the FIB table this entry is in
43  */
45 
46  /**
47  * A vector of sources contributing forwarding
48  */
50 
51  /**
52  * The path-list of which this entry is a child
53  */
55 
56  /**
57  * The sibling index on the path-list
58  */
60 
61  /**
62  * 2nd cache line has the members used in the data plane
63  */
64  CLIB_CACHE_LINE_ALIGN_MARK(cacheline1);
65 
66  /**
67  * The DPO used for forwarding; replicate, drop, etc..
68  */
70 
71  /**
72  * Route flags
73  */
75 
76  /**
77  * RPF-ID used when the packets ingress not from an interface
78  */
80 
81  /**
82  * A hash table of interfaces
83  */
85 } mfib_entry_t;
86 
87 #define MFIB_ENTRY_FORMAT_BRIEF (0x0)
88 #define MFIB_ENTRY_FORMAT_DETAIL (0x1)
89 #define MFIB_ENTRY_FORMAT_DETAIL2 (0x2)
90 
91 extern u8 *format_mfib_entry(u8 * s, va_list * args);
92 
93 
94 extern fib_node_index_t mfib_entry_create(u32 fib_index,
95  mfib_source_t source,
96  const mfib_prefix_t *prefix,
97  fib_rpf_id_t rpf_id,
98  mfib_entry_flags_t entry_flags);
99 
100 extern int mfib_entry_update(fib_node_index_t fib_entry_index,
101  mfib_source_t source,
102  mfib_entry_flags_t entry_flags,
103  fib_rpf_id_t rpf_id,
104  index_t rep_dpo);
105 
106 extern void mfib_entry_path_update(fib_node_index_t fib_entry_index,
107  mfib_source_t source,
108  const fib_route_path_t *rpath,
109  mfib_itf_flags_t itf_flags);
110 
111 
112 extern int mfib_entry_path_remove(fib_node_index_t fib_entry_index,
113  mfib_source_t source,
114  const fib_route_path_t *rpath);
115 
116 extern int mfib_entry_delete(fib_node_index_t mfib_entry_index,
117  mfib_source_t source);
118 
119 extern int mfib_entry_cmp_for_sort(void *i1, void *i2);
120 
121 extern u32 mfib_entry_child_add(fib_node_index_t mfib_entry_index,
122  fib_node_type_t type,
123  fib_node_index_t child_index);
124 extern void mfib_entry_child_remove(fib_node_index_t mfib_entry_index,
125  u32 sibling_index);
126 
127 extern void mfib_entry_lock(fib_node_index_t fib_entry_index);
128 extern void mfib_entry_unlock(fib_node_index_t fib_entry_index);
129 
130 extern void mfib_entry_get_prefix(fib_node_index_t fib_entry_index,
131  mfib_prefix_t *pfx);
132 extern u32 mfib_entry_get_fib_index(fib_node_index_t fib_entry_index);
133 
135  fib_node_index_t mfib_entry_index,
137  dpo_id_t *dpo);
138 
139 extern void mfib_entry_encode(fib_node_index_t fib_entry_index,
140  fib_route_path_encode_t **api_rpaths);
141 
142 extern void mfib_entry_module_init(void);
143 
144 
146 
147 static inline mfib_entry_t *
149 {
150  return (pool_elt_at_index(mfib_entry_pool, index));
151 }
152 static inline fib_node_index_t
154 {
155  return (mfe - mfib_entry_pool);
156 }
157 
158 
159 static inline mfib_itf_t *
161  u32 sw_if_index)
162 {
163  uword *p;
164 
165  p = hash_get(itfs, sw_if_index);
166 
167  if (NULL != p)
168  {
169  return (mfib_itf_get(p[0]));
170  }
171 
172  return (NULL);
173 }
174 
175 static inline mfib_itf_t *
177  u32 sw_if_index)
178 {
179  return (mfib_entry_itf_find(mfe->mfe_itfs, sw_if_index));
180 }
181 
182 #endif
A representation of a fib path for fib_path_encode to convey the information to the caller...
Definition: fib_types.h:398
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
enum mfib_entry_flags_t_ mfib_entry_flags_t
A representation of a path as described by a route producer.
Definition: fib_types.h:336
void mfib_entry_unlock(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1133
struct mfib_entry_src_t_ * mfe_srcs
A vector of sources contributing forwarding.
Definition: mfib_entry.h:49
#define NULL
Definition: clib.h:55
An entry in a FIB table.
Definition: mfib_entry.h:31
u32 mfe_sibling
The sibling index on the path-list.
Definition: mfib_entry.h:59
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:41
static fib_node_index_t mfib_entry_get_index(const mfib_entry_t *mfe)
Definition: mfib_entry.h:153
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)
Definition: mfib_entry.c:709
struct mfib_entry_t_ mfib_entry_t
An entry in a FIB table.
void mfib_entry_module_init(void)
Definition: mfib_entry.c:1176
void mfib_entry_lock(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1123
u32 mfib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1212
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
The source of an MFIB entry.
Definition: mfib_entry.c:63
void mfib_entry_child_remove(fib_node_index_t mfib_entry_index, u32 sibling_index)
Definition: mfib_entry.c:381
mfib_prefix_t mfe_prefix
The prefix of the route.
Definition: mfib_entry.h:40
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:152
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
dpo_id_t mfe_rep
The DPO used for forwarding; replicate, drop, etc.
Definition: mfib_entry.h:69
static mfib_itf_t * mfib_itf_get(index_t mi)
Definition: mfib_itf.h:53
fib_node_t mfe_node
Base class.
Definition: mfib_entry.h:36
An node in the FIB graph.
Definition: fib_node.h:279
u32 mfe_fib_index
The index of the FIB table this entry is in.
Definition: mfib_entry.h:44
static mfib_entry_t * mfib_entry_get(fib_node_index_t index)
Definition: mfib_entry.h:148
void mfib_entry_encode(fib_node_index_t fib_entry_index, fib_route_path_encode_t **api_rpaths)
Definition: mfib_entry.c:1183
static mfib_itf_t * mfib_entry_itf_find(mfib_itf_t *itfs, u32 sw_if_index)
Definition: mfib_entry.h:160
void mfib_entry_contribute_forwarding(fib_node_index_t mfib_entry_index, fib_forward_chain_type_t type, dpo_id_t *dpo)
Definition: mfib_entry.c:1222
mfib_itf_t * mfe_itfs
A hash table of interfaces.
Definition: mfib_entry.h:84
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
mfib_entry_flags_t mfe_flags
Route flags.
Definition: mfib_entry.h:74
u8 * format_mfib_entry(u8 *s, va_list *args)
Definition: mfib_entry.c:171
Aggregrate type for a prefix.
Definition: mfib_types.h:24
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:913
u32 fib_rpf_id_t
An RPF-ID is numerical value that is used RPF validate.
Definition: fib_types.h:315
fib_node_index_t mfe_pl
The path-list of which this entry is a child.
Definition: mfib_entry.h:54
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
unsigned int u32
Definition: types.h:88
mfib_entry_t * mfib_entry_pool
Definition: mfib_entry.c:111
An interface associated with a particular MFIB entry.
Definition: mfib_itf.h:25
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
fib_rpf_id_t mfe_rpf_id
RPF-ID used when the packets ingress not from an interface.
Definition: mfib_entry.h:79
u64 uword
Definition: types.h:112
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:744
static mfib_itf_t * mfib_entry_get_itf(const mfib_entry_t *mfe, u32 sw_if_index)
Definition: mfib_entry.h:176
unsigned char u8
Definition: types.h:56
void mfib_entry_get_prefix(fib_node_index_t fib_entry_index, mfib_prefix_t *pfx)
Definition: mfib_entry.c:1202
enum mfib_itf_flags_t_ mfib_itf_flags_t
int mfib_entry_cmp_for_sort(void *i1, void *i2)
Definition: mfib_entry.c:1058
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:370
int mfib_entry_delete(fib_node_index_t mfib_entry_index, mfib_source_t source)
mfib_entry_delete
Definition: mfib_entry.c:971
void mfib_entry_path_update(fib_node_index_t fib_entry_index, mfib_source_t source, const fib_route_path_t *rpath, mfib_itf_flags_t itf_flags)
Definition: mfib_entry.c:823