FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
fib_entry_delegate.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_DELEGATE_T__
17 #define __FIB_ENTRY_DELEGATE_T__
18 
19 #include <vnet/fib/fib_node.h>
20 #include <vnet/fib/fib_entry.h>
21 
22 /**
23  * Delegate types
24  */
26  /**
27  * Forwarding chain types:
28  * for the vast majority of FIB entries only one chain is required - the
29  * one that forwards traffic matching the fib_entry_t's fib_prefix_t. For those
30  * fib_entry_t that are a resolution target for other fib_entry_t's they will also
31  * need the chain to provide forwarding for those children. We store these additional
32  * chains in delegates to save memory in the common case.
33  */
40  /**
41  * Dependency list of covered entries.
42  * these are more specific entries that are interested in changes
43  * to their respective cover
44  */
46  /**
47  * BFD session state
48  */
50  /**
51  * Tracker
52  */
54  /**
55  * Attached import/export functionality
56  */
60 
61 #define FOR_EACH_DELEGATE_CHAIN(_entry, _fdt, _fed, _body) \
62 { \
63  for (_fdt = FIB_ENTRY_DELEGATE_CHAIN_UNICAST_IP4; \
64  _fdt <= FIB_ENTRY_DELEGATE_CHAIN_NSH; \
65  _fdt++) \
66  { \
67  _fed = fib_entry_delegate_find(_entry, _fdt); \
68  if (NULL != _fed) { \
69  _body; \
70  } \
71  } \
72 }
73 
74 /**
75  * Distillation of the BFD session states into a go/no-go for using
76  * the associated tracked FIB entry
77  */
78 typedef enum fib_bfd_state_t_
79 {
83 
84 /**
85  * State for FIB entry tracking
86  */
88 {
92 
93 /**
94  * A Delagate is a means to implmenet the Delagation design pattern; the extension of an
95  * objects functionality through the composition of, and delgation to, other objects.
96  * These 'other' objects are delegates. Delagates are thus attached to other FIB objects
97  * to extend their functionality.
98  */
99 typedef struct fib_entry_delegate_t_
100 {
101  /**
102  * The FIB entry object to which the delagate is attached
103  */
105 
106  /**
107  * The delagate type
108  */
110 
111  /**
112  * A union of data for the different delegate types
113  * These delegates are stored in a sparse vector on the entry, so they
114  * must all be of the same size. We could use indirection here for all types,
115  * i.e. store an index, that's ok for large delegates, like the attached export
116  * but for the chain delegates it's excessive
117  */
118  union
119  {
120  /**
121  * Valid for the forwarding chain delegates. The LB that is built.
122  */
124 
125  /**
126  * Valid for the attached import cases. An index of the importer/exporter
127  */
129 
130  /**
131  * For the cover tracking. The node list;
132  */
134 
135  /**
136  * BFD state
137  */
139 
140  /**
141  * tracker state
142  */
144  };
146 
147 struct fib_entry_t_;
148 
149 extern void fib_entry_delegate_remove(fib_entry_t *fib_entry,
151 
156 
159 
162 
163 extern u8 *format_fib_entry_delegate(u8 * s, va_list * args);
164 
167 
168 #endif
FIB_ENTRY_DELEGATE_ATTACHED_EXPORT
@ FIB_ENTRY_DELEGATE_ATTACHED_EXPORT
Definition: fib_entry_delegate.h:58
fib_entry.h
FIB_ENTRY_DELEGATE_CHAIN_UNICAST_IP6
@ FIB_ENTRY_DELEGATE_CHAIN_UNICAST_IP6
Definition: fib_entry_delegate.h:35
FIB_ENTRY_DELEGATE_ATTACHED_IMPORT
@ FIB_ENTRY_DELEGATE_ATTACHED_IMPORT
Attached import/export functionality.
Definition: fib_entry_delegate.h:57
fib_entry_delegate_track_t_::fedt_node
fib_node_t fedt_node
Definition: fib_entry_delegate.h:89
fib_entry_t_
An entry in a FIB table.
Definition: fib_entry.h:305
FIB_BFD_STATE_DOWN
@ FIB_BFD_STATE_DOWN
Definition: fib_entry_delegate.h:81
fib_entry_delegate_track_t_::fedt_sibling
u32 fedt_sibling
Definition: fib_entry_delegate.h:90
fib_node_list_t
u32 fib_node_list_t
A list of FIB nodes.
Definition: fib_node.h:209
fib_entry_delegate_get
fib_entry_delegate_t * fib_entry_delegate_get(fib_node_index_t fedi)
Definition: fib_entry_delegate.c:23
FIB_ENTRY_DELEGATE_CHAIN_ETHERNET
@ FIB_ENTRY_DELEGATE_CHAIN_ETHERNET
Definition: fib_entry_delegate.h:38
FIB_FORW_CHAIN_TYPE_MPLS_EOS
@ FIB_FORW_CHAIN_TYPE_MPLS_EOS
Contribute an object that is to be used to forward end-of-stack MPLS packets.
Definition: fib_types.h:128
FIB_FORW_CHAIN_TYPE_ETHERNET
@ FIB_FORW_CHAIN_TYPE_ETHERNET
Contribute an object that is to be used to forward Ethernet packets.
Definition: fib_types.h:140
fib_node.h
FIB_FORW_CHAIN_TYPE_NSH
@ FIB_FORW_CHAIN_TYPE_NSH
Contribute an object that is to be used to forward NSH packets.
Definition: fib_types.h:146
FIB_FORW_CHAIN_TYPE_UNICAST_IP4
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP4
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:108
fib_entry_delegate_track_t_
State for FIB entry tracking.
Definition: fib_entry_delegate.h:87
fib_bfd_state_t
enum fib_bfd_state_t_ fib_bfd_state_t
Distillation of the BFD session states into a go/no-go for using the associated tracked FIB entry.
fib_entry_delegate_find_or_add
fib_entry_delegate_t * fib_entry_delegate_find_or_add(fib_entry_t *fib_entry, fib_entry_delegate_type_t fdt)
Definition: fib_entry_delegate.c:118
fib_forward_chain_type_t
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
format_fib_entry_delegate
u8 * format_fib_entry_delegate(u8 *s, va_list *args)
Definition: fib_entry_delegate.c:296
fib_entry_delegate_get_index
fib_node_index_t fib_entry_delegate_get_index(const fib_entry_delegate_t *fed)
Definition: fib_entry_delegate.c:29
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
fib_entry_delegate_t_::fd_entry_index
fib_node_index_t fd_entry_index
The FIB entry object to which the delagate is attached.
Definition: fib_entry_delegate.h:104
fib_entry_delegate_t_::fd_index
fib_node_index_t fd_index
Valid for the attached import cases.
Definition: fib_entry_delegate.h:128
fib_entry_delegate_t_::fd_bfd_state
fib_bfd_state_t fd_bfd_state
BFD state.
Definition: fib_entry_delegate.h:138
FIB_ENTRY_DELEGATE_CHAIN_NSH
@ FIB_ENTRY_DELEGATE_CHAIN_NSH
Definition: fib_entry_delegate.h:39
FIB_ENTRY_DELEGATE_CHAIN_MPLS_EOS
@ FIB_ENTRY_DELEGATE_CHAIN_MPLS_EOS
Definition: fib_entry_delegate.h:36
FIB_ENTRY_DELEGATE_BFD
@ FIB_ENTRY_DELEGATE_BFD
BFD session state.
Definition: fib_entry_delegate.h:49
fib_entry_delegate_type_t_
fib_entry_delegate_type_t_
Delegate types.
Definition: fib_entry_delegate.h:25
fib_entry_delegate_type_t
enum fib_entry_delegate_type_t_ fib_entry_delegate_type_t
Delegate types.
fib_entry_delegate_remove
void fib_entry_delegate_remove(fib_entry_t *fib_entry, fib_entry_delegate_type_t type)
Definition: fib_entry_delegate.c:72
FIB_ENTRY_DELEGATE_COVERED
@ FIB_ENTRY_DELEGATE_COVERED
Dependency list of covered entries.
Definition: fib_entry_delegate.h:45
FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS
@ FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS
Contribute an object that is to be used to forward non-end-of-stack MPLS packets.
Definition: fib_types.h:117
fib_entry_delegate_t_::fd_list
fib_node_list_t fd_list
For the cover tracking.
Definition: fib_entry_delegate.h:133
fib_entry_delegate_t_::fd_track
fib_entry_delegate_track_t fd_track
tracker state
Definition: fib_entry_delegate.h:143
FIB_ENTRY_DELEGATE_CHAIN_MPLS_NON_EOS
@ FIB_ENTRY_DELEGATE_CHAIN_MPLS_NON_EOS
Definition: fib_entry_delegate.h:37
fib_entry_delegate_find
fib_entry_delegate_t * fib_entry_delegate_find(const fib_entry_t *fib_entry, fib_entry_delegate_type_t type)
Definition: fib_entry_delegate.c:65
u32
unsigned int u32
Definition: types.h:88
FIB_BFD_STATE_UP
@ FIB_BFD_STATE_UP
Definition: fib_entry_delegate.h:80
FIB_ENTRY_DELEGATE_CHAIN_UNICAST_IP4
@ FIB_ENTRY_DELEGATE_CHAIN_UNICAST_IP4
Forwarding chain types: for the vast majority of FIB entries only one chain is required - the one tha...
Definition: fib_entry_delegate.h:34
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
fib_entry_chain_type_to_delegate_type
fib_entry_delegate_type_t fib_entry_chain_type_to_delegate_type(fib_forward_chain_type_t type)
Definition: fib_entry_delegate.c:134
fib_entry_delegate_track_t
struct fib_entry_delegate_track_t_ fib_entry_delegate_track_t
State for FIB entry tracking.
u8
unsigned char u8
Definition: types.h:56
fib_bfd_state_t_
fib_bfd_state_t_
Distillation of the BFD session states into a go/no-go for using the associated tracked FIB entry.
Definition: fib_entry_delegate.h:78
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
fib_entry_delegate_t_::fd_type
fib_entry_delegate_type_t fd_type
The delagate type.
Definition: fib_entry_delegate.h:109
FIB_FORW_CHAIN_TYPE_UNICAST_IP6
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP6
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:112
fib_entry_delegate_t_
A Delagate is a means to implmenet the Delagation design pattern; the extension of an objects functio...
Definition: fib_entry_delegate.h:99
FIB_ENTRY_DELEGATE_TRACK
@ FIB_ENTRY_DELEGATE_TRACK
Tracker.
Definition: fib_entry_delegate.h:53
fib_entry_delegate_type_to_chain_type
fib_forward_chain_type_t fib_entry_delegate_type_to_chain_type(fib_entry_delegate_type_t type)
Definition: fib_entry_delegate.c:160
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
fib_entry_delegate_t_::fd_dpo
dpo_id_t fd_dpo
Valid for the forwarding chain delegates.
Definition: fib_entry_delegate.h:123
fib_entry_delegate_t
struct fib_entry_delegate_t_ fib_entry_delegate_t
A Delagate is a means to implmenet the Delagation design pattern; the extension of an objects functio...