FD.io VPP  v17.07-30-g839fa73
Vector Packet Processing
fib_entry_src.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 __FIB_ENTRY_SRC_H__
17 #define __FIB_ENTRY_SRC_H__
18 
19 #include "fib_entry.h"
20 #include "fib_path_list.h"
21 #include "fib_internal.h"
22 
23 /**
24  * Debug macro
25  */
26 #ifdef FIB_DEBUG
27 #define FIB_ENTRY_DBG(_e, _fmt, _args...) \
28 { \
29  u8*__tmp = NULL; \
30  __tmp = format(__tmp, "e:[%d:%U", \
31  fib_entry_get_index(_e), \
32  format_ip46_address, \
33  &_e->fe_prefix.fp_addr, \
34  IP46_TYPE_ANY); \
35  __tmp = format(__tmp, "/%d]:", \
36  _e->fe_prefix.fp_len); \
37  __tmp = format(__tmp, _fmt, ##_args); \
38  clib_warning("%s", __tmp); \
39  vec_free(__tmp); \
40 }
41 #else
42 #define FIB_ENTRY_DBG(_e, _fmt, _args...)
43 #endif
44 
45 /**
46  * Source initialisation Function
47  */
48 typedef void (*fib_entry_src_init_t)(fib_entry_src_t *src);
49 
50 /**
51  * Source deinitialisation Function
52  */
54 
55 /**
56  * Source activation. Called when the source is the new best source on the entry.
57  * Return non-zero if the entry can now install, 0 otherwise
58  */
60  const fib_entry_t *fib_entry);
61 
62 /**
63  * Source Deactivate.
64  * Called when the source is no longer best source on the entry
65  */
67  const fib_entry_t *fib_entry);
68 
69 /**
70  * Source Add.
71  * Called when the source is added to the entry
72  */
73 typedef void (*fib_entry_src_add_t)(fib_entry_src_t *src,
74  const fib_entry_t *entry,
76  fib_protocol_t proto,
77  const dpo_id_t *dpo);
78 
79 /**
80  * Source Remove.
81  */
83 
84 /**
85  * Result from a cover update/change
86  */
91 
92 /**
93  * Cover changed. the source should re-evaluate its cover.
94  */
96  fib_entry_src_t *src,
97  const fib_entry_t *fib_entry);
98 
99 /**
100  * Cover updated. The cover the source has, has updated (i.e. its forwarding)
101  * the source may need to re-evaluate.
102  */
104  fib_entry_src_t *src,
105  const fib_entry_t *fib_entry);
106 
107 /**
108  * Forwarding updated. Notification that the forwarding information for the
109  * entry has been updated. This notification is sent to all sources, not just
110  * the active best.
111  */
113  const fib_entry_t *fib_entry,
114  fib_source_t best_source);
115 
116 /**
117  * Installed. Notification that the source is now installed as
118  * the entry's forwarding source.
119  */
121  const fib_entry_t *fib_entry);
122 
123 /**
124  * format.
125  */
126 typedef u8* (*fib_entry_src_format_t)(fib_entry_src_t *src,
127  u8* s);
128 
129 /**
130  * Source path add
131  * the source is adding a new path
132  */
134  const fib_entry_t *fib_entry,
135  fib_path_list_flags_t pl_flags,
136  const fib_route_path_t *path);
137 
138 /**
139  * Source path remove
140  * the source is remoinvg a path
141  */
143  fib_path_list_flags_t pl_flags,
144  const fib_route_path_t *path);
145 
146 /**
147  * Source path replace/swap
148  * the source is providing a new set of paths
149  */
151  const fib_entry_t *fib_entry,
152  fib_path_list_flags_t pl_flags,
153  const fib_route_path_t *path);
154 
155 /**
156  * Set source specific opaque data
157  */
159  const fib_entry_t *fib_entry,
160  const void *data);
161 
162 /**
163  * Get source specific opaque data
164  */
165 typedef const void* (*fib_entry_src_get_data_t)(fib_entry_src_t *src,
166  const fib_entry_t *fib_entry);
167 
168 /**
169  * Virtual function table each FIB entry source will register
170  */
171 typedef struct fib_entry_src_vft_t_ {
189 
190 #define FOR_EACH_SRC_ADDED(_entry, _src, _source, action) \
191 { \
192  vec_foreach(_src, _entry->fe_srcs) \
193  { \
194  if (_src->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED) { \
195  _source = _src->fes_src; \
196  do { \
197  action; \
198  } while(0); \
199  } \
200  } \
201 }
202 
203 extern u8* fib_entry_src_format(fib_entry_t *entry,
204  fib_source_t source,
205  u8* s);
206 
207 extern void fib_entry_src_register(fib_source_t source,
208  const fib_entry_src_vft_t *vft);
209 
210 extern void fib_entry_src_action_init(fib_entry_t *entry,
211  fib_source_t source);
212 
213 extern void fib_entry_src_action_deinit(fib_entry_t *fib_entry,
214  fib_source_t source);
215 
217  fib_entry_t *entry,
218  fib_source_t source);
219 
221  fib_entry_t *fib_entry,
222  fib_source_t source);
223 
224 extern void fib_entry_src_action_activate(fib_entry_t *fib_entry,
225  fib_source_t source);
226 
227 extern void fib_entry_src_action_deactivate(fib_entry_t *fib_entry,
228  fib_source_t source);
229 extern void fib_entry_src_action_reactivate(fib_entry_t *fib_entry,
230  fib_source_t source);
231 
233  fib_source_t source,
235  const dpo_id_t *dpo);
237  fib_source_t source,
239  const dpo_id_t *dpo);
240 
242  fib_source_t source);
243 
244 extern void fib_entry_src_action_install(fib_entry_t *fib_entry,
245  fib_source_t source);
246 
247 extern void fib_entry_src_action_uninstall(fib_entry_t *fib_entry);
248 
250  fib_source_t source,
252  const fib_route_path_t *path);
253 
255  fib_source_t source,
257  const fib_route_path_t *path);
258 
260  fib_source_t source,
261  const fib_route_path_t *path);
262 
263 extern void fib_entry_src_action_installed(const fib_entry_t *fib_entry,
264  fib_source_t source);
265 
267  const fib_entry_t *fib_entry);
268 extern fib_entry_flag_t fib_entry_get_flags_i(const fib_entry_t *fib_entry);
270  fib_entry_flag_t eflags);
271 
274 
275 extern void fib_entry_src_mk_lb (fib_entry_t *fib_entry,
276  const fib_entry_src_t *esrc,
278  dpo_id_t *dpo_lb);
279 
280 
281 /*
282  * Per-source registration. declared here so we save a separate .h file for each
283  */
284 extern void fib_entry_src_default_register(void);
285 extern void fib_entry_src_rr_register(void);
286 extern void fib_entry_src_interface_register(void);
287 extern void fib_entry_src_default_route_register(void);
288 extern void fib_entry_src_special_register(void);
289 extern void fib_entry_src_api_register(void);
290 extern void fib_entry_src_adj_register(void);
291 extern void fib_entry_src_mpls_register(void);
292 extern void fib_entry_src_lisp_register(void);
293 
294 extern void fib_entry_src_module_init(void);
295 
296 #endif
int(* fib_entry_src_activate_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Source activation.
Definition: fib_entry_src.h:59
void(* fib_entry_src_path_add_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry, fib_path_list_flags_t pl_flags, const fib_route_path_t *path)
Source path add the source is adding a new path.
void fib_entry_src_action_install(fib_entry_t *fib_entry, fib_source_t source)
fib_entry_src_init_t fesv_init
void(* fib_entry_src_deinit_t)(fib_entry_src_t *src)
Source deinitialisation Function.
Definition: fib_entry_src.h:53
void(* fib_entry_src_path_remove_t)(fib_entry_src_t *src, fib_path_list_flags_t pl_flags, const fib_route_path_t *path)
Source path remove the source is remoinvg a path.
An entry in a FIB table.
Definition: fib_entry.h:380
fib_entry_src_set_data_t fesv_set_data
fib_node_bw_reason_flag_t bw_reason
Definition: fib_entry_src.h:89
A representation of a path as described by a route producer.
Definition: fib_types.h:336
Virtual function table each FIB entry source will register.
Information related to the source of a FIB entry.
Definition: fib_entry.h:289
fib_entry_src_cover_res_t fib_entry_src_action_cover_change(fib_entry_t *entry, fib_source_t source)
fib_entry_src_cover_res_t(* fib_entry_src_cover_update_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Cover updated.
void fib_entry_src_action_installed(const fib_entry_t *fib_entry, fib_source_t source)
void fib_entry_src_action_init(fib_entry_t *entry, fib_source_t source)
Definition: fib_entry_src.c:55
Result from a cover update/change.
Definition: fib_entry_src.h:87
void fib_entry_src_action_deactivate(fib_entry_t *fib_entry, fib_source_t source)
fib_entry_t * fib_entry_src_action_add(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
void fib_entry_src_mpls_register(void)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void fib_entry_src_adj_register(void)
void fib_entry_src_mk_lb(fib_entry_t *fib_entry, const fib_entry_src_t *esrc, fib_forward_chain_type_t fct, dpo_id_t *dpo_lb)
void fib_entry_src_lisp_register(void)
fib_entry_flag_t fib_entry_get_flags_i(const fib_entry_t *fib_entry)
fib_entry_src_cover_update_t fesv_cover_update
void(* fib_entry_src_init_t)(fib_entry_src_t *src)
Source initialisation Function.
Definition: fib_entry_src.h:48
fib_entry_src_cover_change_t fesv_cover_change
void(* fib_entry_src_remove_t)(fib_entry_src_t *src)
Source Remove.
Definition: fib_entry_src.h:82
u8 *(* fib_entry_src_format_t)(fib_entry_src_t *src, u8 *s)
format.
fib_entry_src_path_add_t fesv_path_add
const void *(* fib_entry_src_get_data_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Get source specific opaque data.
void(* fib_entry_src_installed_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Installed.
fib_entry_src_get_data_t fesv_get_data
void fib_entry_src_api_register(void)
u16 install
Definition: fib_entry_src.h:88
fib_entry_t * fib_entry_src_action_path_add(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const fib_route_path_t *path)
void fib_entry_src_action_uninstall(fib_entry_t *fib_entry)
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
void(* fib_entry_src_deactivate_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Source Deactivate.
Definition: fib_entry_src.h:66
void fib_entry_src_default_route_register(void)
fib_entry_src_flag_t fib_entry_src_action_remove(fib_entry_t *fib_entry, fib_source_t source)
enum fib_source_t_ fib_source_t
The different sources that can create a route.
fib_entry_src_fwd_update_t fesv_fwd_update
fib_entry_src_deinit_t fesv_deinit
fib_entry_src_format_t fesv_format
fib_entry_src_cover_res_t(* fib_entry_src_cover_change_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Cover changed.
Definition: fib_entry_src.h:95
void fib_entry_src_default_register(void)
enum fib_node_bw_reason_flag_t_ fib_node_bw_reason_flag_t
Flags enum constructed from the reaons.
void fib_entry_src_register(fib_source_t source, const fib_entry_src_vft_t *vft)
Definition: fib_entry_src.c:39
fib_entry_t * fib_entry_src_action_update(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
void fib_entry_src_rr_register(void)
fib_entry_src_remove_t fesv_remove
fib_entry_src_deactivate_t fesv_deactivate
void(* fib_entry_src_add_t)(fib_entry_src_t *src, const fib_entry_t *entry, fib_entry_flag_t flags, fib_protocol_t proto, const dpo_id_t *dpo)
Source Add.
Definition: fib_entry_src.h:73
void fib_entry_src_action_activate(fib_entry_t *fib_entry, fib_source_t source)
struct fib_entry_src_vft_t_ fib_entry_src_vft_t
Virtual function table each FIB entry source will register.
enum fib_entry_flag_t_ fib_entry_flag_t
void fib_entry_src_interface_register(void)
void fib_entry_src_module_init(void)
void fib_entry_src_special_register(void)
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
void(* fib_entry_src_set_data_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry, const void *data)
Set source specific opaque data.
enum fib_entry_src_flag_t_ fib_entry_src_flag_t
fib_entry_src_path_remove_t fesv_path_remove
fib_entry_src_path_swap_t fesv_path_swap
u8 * fib_entry_src_format(fib_entry_t *entry, fib_source_t source, u8 *s)
unsigned short u16
Definition: types.h:57
fib_entry_src_flag_t fib_entry_src_action_path_remove(fib_entry_t *fib_entry, fib_source_t source, const fib_route_path_t *path)
unsigned char u8
Definition: types.h:56
fib_entry_src_cover_res_t fib_entry_src_action_cover_update(fib_entry_t *fib_entry, fib_source_t source)
void fib_entry_src_action_deinit(fib_entry_t *fib_entry, fib_source_t source)
fib_forward_chain_type_t fib_entry_chain_type_fixup(const fib_entry_t *entry, fib_forward_chain_type_t fct)
Turn the chain type requested by the client into the one they really wanted.
fib_path_list_flags_t fib_entry_src_flags_2_path_list_flags(fib_entry_flag_t eflags)
fib_entry_src_activate_t fesv_activate
fib_entry_t * fib_entry_src_action_path_swap(fib_entry_t *fib_entry, fib_source_t source, fib_entry_flag_t flags, const fib_route_path_t *path)
struct fib_entry_src_cover_res_t_ fib_entry_src_cover_res_t
Result from a cover update/change.
fib_entry_src_add_t fesv_add
void(* fib_entry_src_fwd_update_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry, fib_source_t best_source)
Forwarding updated.
enum fib_path_list_flags_t_ fib_path_list_flags_t
void fib_entry_src_action_reactivate(fib_entry_t *fib_entry, fib_source_t source)
u32 flags
Definition: vhost-user.h:76
fib_entry_src_installed_t fesv_installed
void(* fib_entry_src_path_swap_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry, fib_path_list_flags_t pl_flags, const fib_route_path_t *path)
Source path replace/swap the source is providing a new set of paths.
fib_forward_chain_type_t fib_entry_get_default_chain_type(const fib_entry_t *fib_entry)
Definition: fib_entry.c:68