FD.io VPP  v18.07.1-19-g511ce25
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 re-activation. Called when the source is updated and remains
64  * the best source.
65  */
67  const fib_entry_t *fib_entry);
68 
69 /**
70  * Source Deactivate.
71  * Called when the source is no longer best source on the entry
72  */
74  const fib_entry_t *fib_entry);
75 
76 /**
77  * Source Add.
78  * Called when the source is added to the entry
79  */
80 typedef void (*fib_entry_src_add_t)(fib_entry_src_t *src,
81  const fib_entry_t *entry,
83  dpo_proto_t proto,
84  const dpo_id_t *dpo);
85 
86 /**
87  * Source Remove.
88  */
90 
91 /**
92  * Result from a cover update/change
93  */
98 
99 /**
100  * Cover changed. the source should re-evaluate its cover.
101  */
103  fib_entry_src_t *src,
104  const fib_entry_t *fib_entry);
105 
106 /**
107  * Cover updated. The cover the source has, has updated (i.e. its forwarding)
108  * the source may need to re-evaluate.
109  */
111  fib_entry_src_t *src,
112  const fib_entry_t *fib_entry);
113 
114 /**
115  * Forwarding updated. Notification that the forwarding information for the
116  * entry has been updated. This notification is sent to all sources, not just
117  * the active best.
118  */
120  const fib_entry_t *fib_entry,
121  fib_source_t best_source);
122 
123 /**
124  * Installed. Notification that the source is now installed as
125  * the entry's forwarding source.
126  */
128  const fib_entry_t *fib_entry);
129 
130 /**
131  * format.
132  */
133 typedef u8* (*fib_entry_src_format_t)(fib_entry_src_t *src,
134  u8* s);
135 
136 /**
137  * Source path add
138  * the source is adding a new path
139  */
141  const fib_entry_t *fib_entry,
142  fib_path_list_flags_t pl_flags,
143  const fib_route_path_t *path);
144 
145 /**
146  * Source path remove
147  * the source is remoinvg a path
148  */
150  fib_path_list_flags_t pl_flags,
151  const fib_route_path_t *path);
152 
153 /**
154  * Source path replace/swap
155  * the source is providing a new set of paths
156  */
158  const fib_entry_t *fib_entry,
159  fib_path_list_flags_t pl_flags,
160  const fib_route_path_t *path);
161 
162 /**
163  * Set source specific opaque data
164  */
166  const fib_entry_t *fib_entry,
167  const void *data);
168 
169 /**
170  * Get source specific opaque data
171  */
172 typedef const void* (*fib_entry_src_get_data_t)(fib_entry_src_t *src,
173  const fib_entry_t *fib_entry);
174 
175 /**
176  * Contribute forwarding to interpose inthe chain
177  */
178 typedef const dpo_id_t* (*fib_entry_src_contribute_interpose_t)(const fib_entry_src_t *src,
179  const fib_entry_t *fib_entry);
180 
181 /**
182  * The fib entry flags for this source are changing
183  */
185  const fib_entry_t *fib_entry,
186  fib_entry_flag_t new_flags);
187 
188 /**
189  * The fib entry flags for this source are changing
190  */
191 typedef void (*fib_entry_src_copy_t)(const fib_entry_src_t *orig_src,
192  const fib_entry_t *fib_entry,
193  fib_entry_src_t *copy_src);
194 
195 /**
196  * Virtual function table each FIB entry source will register
197  */
198 typedef struct fib_entry_src_vft_t_ {
220 
221 #define FOR_EACH_SRC_ADDED(_entry, _src, _source, action) \
222 { \
223  vec_foreach(_src, (_entry)->fe_srcs) \
224  { \
225  if (_src->fes_flags & FIB_ENTRY_SRC_FLAG_ADDED) { \
226  _source = (_src)->fes_src; \
227  action; \
228  } \
229  } \
230 }
231 
232 #define FIB_ENTRY_SRC_VFT_INVOKE(esrc, func, args) \
233 { \
234  const fib_entry_src_vft_t *_vft; \
235  _vft = fib_entry_src_get_vft(esrc); \
236  if (_vft->func) \
237  _vft->func args; \
238 }
239 
240 #define FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, func, args) \
241 { \
242  const fib_entry_src_vft_t *_vft; \
243  _vft = fib_entry_src_get_vft(esrc); \
244  if (_vft->func) \
245  return (_vft->func args); \
246 }
247 
248 #define FIB_ENTRY_SRC_VFT_EXISTS(esrc, func) \
249 { \
250  const fib_entry_src_vft_t *_vft; \
251  _vft = fib_entry_src_get_vft(esrc); \
252  (_vft->func); \
253 }
254 
256  const fib_entry_src_t *esrc);
257 
258 extern u8* fib_entry_src_format(fib_entry_t *entry,
259  fib_source_t source,
260  u8* s);
261 
262 extern void fib_entry_src_register(fib_source_t source,
263  const fib_entry_src_vft_t *vft);
264 
266  fib_entry_t *entry,
267  fib_entry_src_t *esrc);
268 
270  fib_entry_t *fib_entry,
271  fib_entry_src_t *esrc);
272 
273 extern void fib_entry_src_action_activate(fib_entry_t *fib_entry,
274  fib_source_t source);
275 
276 extern void fib_entry_src_action_deactivate(fib_entry_t *fib_entry,
277  fib_source_t source);
278 extern void fib_entry_src_action_reactivate(fib_entry_t *fib_entry,
279  fib_source_t source);
280 
282  fib_source_t source,
284  const dpo_id_t *dpo);
286  fib_source_t source,
288  const dpo_id_t *dpo);
289 
291  fib_source_t source);
294  fib_source_t source);
295 
296 extern void fib_entry_src_action_install(fib_entry_t *fib_entry,
297  fib_source_t source);
298 
299 extern void fib_entry_src_action_uninstall(fib_entry_t *fib_entry);
300 
302  fib_source_t source,
304  const fib_route_path_t *path);
305 
307  fib_source_t source,
309  const fib_route_path_t *path);
310 
312  fib_source_t source,
313  const fib_route_path_t *path);
314 
315 extern void fib_entry_src_action_installed(const fib_entry_t *fib_entry,
316  fib_source_t source);
317 extern void fib_entry_src_inherit (const fib_entry_t *cover,
318  fib_entry_t *covered);
319 
321  const fib_entry_t *fib_entry);
322 extern fib_entry_flag_t fib_entry_get_flags_i(const fib_entry_t *fib_entry);
323 
325  fib_entry_flag_t eflags);
326 
329 
330 extern void fib_entry_src_mk_lb (fib_entry_t *fib_entry,
331  const fib_entry_src_t *esrc,
333  dpo_id_t *dpo_lb);
334 
335 extern fib_protocol_t fib_entry_get_proto(const fib_entry_t * fib_entry);
336 extern dpo_proto_t fib_entry_get_dpo_proto(const fib_entry_t * fib_entry);
337 
338 extern void fib_entry_source_change(fib_entry_t *fib_entry,
339  fib_source_t old_source,
340  fib_source_t new_source);
341 
342 /*
343  * Per-source registration. declared here so we save a separate .h file for each
344  */
345 extern void fib_entry_src_default_register(void);
346 extern void fib_entry_src_rr_register(void);
347 extern void fib_entry_src_interface_register(void);
348 extern void fib_entry_src_interpose_register(void);
349 extern void fib_entry_src_default_route_register(void);
350 extern void fib_entry_src_special_register(void);
351 extern void fib_entry_src_api_register(void);
352 extern void fib_entry_src_adj_register(void);
353 extern void fib_entry_src_mpls_register(void);
354 extern void fib_entry_src_lisp_register(void);
355 
356 extern void fib_entry_src_module_init(void);
357 
358 #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:458
dpo_proto_t fib_entry_get_dpo_proto(const fib_entry_t *fib_entry)
Definition: fib_entry.c:69
fib_entry_src_set_data_t fesv_set_data
fib_node_bw_reason_flag_t bw_reason
Definition: fib_entry_src.h:96
fib_entry_src_copy_t fesv_copy
const fib_entry_src_vft_t * fib_entry_src_get_vft(const fib_entry_src_t *esrc)
Get the VFT for a given source.
Definition: fib_entry_src.c:37
A representation of a path as described by a route producer.
Definition: fib_types.h:460
fib_entry_src_cover_res_t fib_entry_src_action_cover_update(fib_entry_t *fib_entry, fib_entry_src_t *esrc)
Virtual function table each FIB entry source will register.
Information related to the source of a FIB entry.
Definition: fib_entry.h:350
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)
Result from a cover update/change.
Definition: fib_entry_src.h:94
fib_entry_src_contribute_interpose_t fesv_contribute_interpose
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)
unsigned char u8
Definition: types.h:56
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:89
void(* fib_entry_src_add_t)(fib_entry_src_t *src, const fib_entry_t *entry, fib_entry_flag_t flags, dpo_proto_t proto, const dpo_id_t *dpo)
Source Add.
Definition: fib_entry_src.h:80
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_inherit(const fib_entry_t *cover, fib_entry_t *covered)
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
fib_protocol_t fib_entry_get_proto(const fib_entry_t *fib_entry)
Definition: fib_entry.c:63
void fib_entry_src_api_register(void)
u16 install
Definition: fib_entry_src.h:95
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)
fib_entry_src_flag_t fib_entry_src_action_remove_or_update_inherit(fib_entry_t *fib_entry, fib_source_t source)
void fib_entry_src_action_uninstall(fib_entry_t *fib_entry)
void(* fib_entry_src_copy_t)(const fib_entry_src_t *orig_src, const fib_entry_t *fib_entry, fib_entry_src_t *copy_src)
The fib entry flags for this source are changing.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:168
void(* fib_entry_src_deactivate_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Source Deactivate.
Definition: fib_entry_src.h:73
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
unsigned short u16
Definition: types.h:57
void fib_entry_src_interpose_register(void)
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.
void fib_entry_src_default_register(void)
u32 flags
Definition: vhost_user.h:110
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:56
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_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.
fib_entry_src_flag_change_t fesv_flags_change
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_flag_change_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry, fib_entry_flag_t new_flags)
The fib entry flags for this source are changing.
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
int(* fib_entry_src_reactivate_t)(fib_entry_src_t *src, const fib_entry_t *fib_entry)
Source re-activation.
Definition: fib_entry_src.h:66
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)
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)
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.
const dpo_id_t *(* fib_entry_src_contribute_interpose_t)(const fib_entry_src_t *src, const fib_entry_t *fib_entry)
Contribute forwarding to interpose inthe chain.
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)
fib_entry_src_installed_t fesv_installed
fib_entry_src_reactivate_t fesv_reactivate
void fib_entry_source_change(fib_entry_t *fib_entry, fib_source_t old_source, fib_source_t new_source)
Definition: fib_entry.c:826
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_entry_src_cover_res_t fib_entry_src_action_cover_change(fib_entry_t *entry, fib_entry_src_t *esrc)
fib_forward_chain_type_t fib_entry_get_default_chain_type(const fib_entry_t *fib_entry)
Definition: fib_entry.c:75