FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
fib_source.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_SOURCE_H__
17 #define __FIB_SOURCE_H__
18 
19 #include <vnet/vnet.h>
20 
21 /**
22  * The different sources that can create a route.
23  *
24  * A source is a combination of two concepts; priority and behaviour.
25  * Priority determines whether the source is contributing forwarding.
26  * Behaviour determines how FIB entries with this source interact with
27  * other elements of FIB.
28  */
29 typedef enum fib_source_t_ {
30  /**
31  * An invalid source
32  * This is not a real source, so don't use it to source a prefix.
33  * It exists here to provide a value for inexistant/uninitialized source
34  */
36  /**
37  * Marker. Add new values after this one.
38  */
40  /**
41  * Special sources. These are for entries that are added to all
42  * FIBs by default, and should never be over-ridden (hence they
43  * are the highest priority)
44  */
46  /**
47  * Classify. A route that links directly to a classify adj
48  */
50  /**
51  * A route the is being 'proxied' on behalf of another device
52  */
54  /**
55  * Route added as a result of interface configuration.
56  * this will also come from the API/CLI, but the distinction is
57  * that is from confiiguration on an interface, not a 'ip route' command
58  */
60  /**
61  * SRv6 and SR-MPLS
62  */
64  /**
65  * From the BIER subsystem
66  */
68  /**
69  * From 6RD.
70  */
72  /**
73  * From the control plane API
74  */
76  /**
77  * From the CLI.
78  */
80  /**
81  * LISP
82  */
84  /**
85  * IPv[46] Mapping
86  */
88  /**
89  * DHCP
90  */
92  /**
93  * IPv6 Proxy ND
94  */
96  /**
97  * IPv6 ND (seen in the link-local tables)
98  */
100  /**
101  * Adjacency source.
102  * routes created as a result of ARP/ND entries. This is lower priority
103  * then the API/CLI. This is on purpose. trust me.
104  */
106  /**
107  * MPLS label. The prefix has been assigned a local label. This source
108  * never provides forwarding information, instead it acts as a place-holder
109  * so the association of label to prefix can be maintained
110  */
112  /**
113  * Attached Export source.
114  * routes created as a result of attahced export. routes thus sourced
115  * will be present in the export tables
116  */
118  /**
119  * Recursive resolution source.
120  * Used to install an entry that is the resolution traget of another.
121  */
123  /**
124  * uRPF bypass/exemption.
125  * Used to install an entry that is exempt from the loose uRPF check
126  */
128  /**
129  * The default route source.
130  * The default route is always added to the FIB table (like the
131  * special sources) but we need to be able to over-ride it with
132  * 'ip route' sources when provided
133  */
135  /**
136  * The interpose source.
137  * This is not a real source, so don't use it to source a prefix.
138  * It exists here to provide a value against which to register to the
139  * VFT for providing the interpose actions to a real source.
140  */
142  /**
143  * Marker. add new entries before this one.
144  */
146 } __attribute__ ((packed)) fib_source_t;
147 
148 STATIC_ASSERT (sizeof(fib_source_t) == 1,
149  "FIB too many sources");
150 
151 #define FIB_SOURCES { \
152  [FIB_SOURCE_INVALID] = "invalid", \
153  [FIB_SOURCE_SPECIAL] = "special", \
154  [FIB_SOURCE_INTERFACE] = "interface", \
155  [FIB_SOURCE_PROXY] = "proxy", \
156  [FIB_SOURCE_BIER] = "BIER", \
157  [FIB_SOURCE_6RD] = "6RD", \
158  [FIB_SOURCE_API] = "API", \
159  [FIB_SOURCE_CLI] = "CLI", \
160  [FIB_SOURCE_ADJ] = "adjacency", \
161  [FIB_SOURCE_MAP] = "MAP", \
162  [FIB_SOURCE_SR] = "SR", \
163  [FIB_SOURCE_LISP] = "LISP", \
164  [FIB_SOURCE_CLASSIFY] = "classify", \
165  [FIB_SOURCE_DHCP] = "DHCP", \
166  [FIB_SOURCE_IP6_ND_PROXY] = "IPv6-proxy-nd", \
167  [FIB_SOURCE_IP6_ND] = "IPv6-nd", \
168  [FIB_SOURCE_RR] = "recursive-resolution", \
169  [FIB_SOURCE_AE] = "attached_export", \
170  [FIB_SOURCE_MPLS] = "mpls", \
171  [FIB_SOURCE_URPF_EXEMPT] = "urpf-exempt", \
172  [FIB_SOURCE_DEFAULT_ROUTE] = "default-route", \
173  [FIB_SOURCE_INTERPOSE] = "interpose", \
174 }
175 
176 /**
177  * Each source is assigned a priority. lower priority is better.
178  * the source with the best source with have its contribution added
179  * to forwarding. the lesser sources will be 'remembered' by FIB and
180  * added to forwarding should the best source be removed.
181  */
183 
184 /**
185  * source comparison
186  */
188 {
193 
194 /**
195  * Each source has a defined behaviour that controls how entries
196  * behave that have that source.
197  * Sources with non-default behaviour may have a private data area
198  * in the fib_entry_src_t union.
199  */
201 {
202  /**
203  * If you're adding a new source from a plugin pick one of these
204  */
205  /** Default behaviour - always install a drop */
207  /** add paths with [mpls] path extensions */
209  /** add paths without path extensions */
211 
212  /**
213  * If your adding a new source from a plugin
214  * these are probably not the behaviour you're lokking for.
215  */
216  /** recursive resolution w/ cover tracking*/
218  /** associated label stored in private data */
220  /** cover tracking w/ glean management */
222  /** interpose */
224  /**
225  * simple behaviour, plus the source specific data stores the
226  * FIB index that is used for subsequent lookups using the
227  * packet's source address.
228  * This doesn't need to be a LISP specific source, it's just
229  * 'simple' behaviour with a u32 stored in the source specific data.
230  */
232  /** adj w/ cover tracking + refinement */
235 
236 #define FIB_SOURCE_BH_MAX (FIB_SOURCE_BH_ADJ+1)
237 
238 #define FIB_SOURCE_BEHAVIOURS { \
239  [FIB_SOURCE_BH_DROP] = "drop", \
240  [FIB_SOURCE_BH_RR] = "rr", \
241  [FIB_SOURCE_BH_MPLS] = "mpls", \
242  [FIB_SOURCE_BH_INTERFACE] = "interface", \
243  [FIB_SOURCE_BH_INTERPOSE] = "interpose", \
244  [FIB_SOURCE_BH_LISP] = "lisp", \
245  [FIB_SOURCE_BH_ADJ] = "adjacency", \
246  [FIB_SOURCE_BH_API] = "api", \
247  [FIB_SOURCE_BH_SIMPLE] = "simple", \
248 }
249 
250 /**
251  * The fixed source to priority mappings.
252  * Declared here so those adding new sources can better determine their respective
253  * priority values.
254  */
255 #define foreach_fib_source \
256  /** you can't do better then the special source */ \
257  _(FIB_SOURCE_SPECIAL, 0x00, FIB_SOURCE_BH_SIMPLE) \
258  _(FIB_SOURCE_CLASSIFY, 0x01, FIB_SOURCE_BH_SIMPLE) \
259  _(FIB_SOURCE_PROXY, 0x02, FIB_SOURCE_BH_SIMPLE) \
260  _(FIB_SOURCE_INTERFACE, 0x03, FIB_SOURCE_BH_INTERFACE) \
261  _(FIB_SOURCE_SR, 0x10, FIB_SOURCE_BH_API) \
262  _(FIB_SOURCE_BIER, 0x20, FIB_SOURCE_BH_SIMPLE) \
263  _(FIB_SOURCE_6RD, 0x30, FIB_SOURCE_BH_API) \
264  _(FIB_SOURCE_API, 0x80, FIB_SOURCE_BH_API) \
265  _(FIB_SOURCE_CLI, 0x81, FIB_SOURCE_BH_API) \
266  _(FIB_SOURCE_LISP, 0x90, FIB_SOURCE_BH_LISP) \
267  _(FIB_SOURCE_MAP, 0xa0, FIB_SOURCE_BH_SIMPLE) \
268  _(FIB_SOURCE_DHCP, 0xb0, FIB_SOURCE_BH_API) \
269  _(FIB_SOURCE_IP6_ND_PROXY, 0xc0, FIB_SOURCE_BH_API) \
270  _(FIB_SOURCE_IP6_ND, 0xc1, FIB_SOURCE_BH_API) \
271  _(FIB_SOURCE_ADJ, 0xd0, FIB_SOURCE_BH_ADJ) \
272  _(FIB_SOURCE_MPLS, 0xe0, FIB_SOURCE_BH_MPLS) \
273  _(FIB_SOURCE_AE, 0xf0, FIB_SOURCE_BH_SIMPLE) \
274  _(FIB_SOURCE_RR, 0xfb, FIB_SOURCE_BH_RR) \
275  _(FIB_SOURCE_URPF_EXEMPT, 0xfc, FIB_SOURCE_BH_RR) \
276  _(FIB_SOURCE_DEFAULT_ROUTE, 0xfd, FIB_SOURCE_BH_DROP) \
277  _(FIB_SOURCE_INTERPOSE, 0xfe, FIB_SOURCE_BH_INTERPOSE) \
278  _(FIB_SOURCE_INVALID, 0xff, FIB_SOURCE_BH_DROP)
279 
280 /**
281  * Some priority values that plugins might use when they are not to concerned
282  * where in the list they'll go.
283  */
284 #define FIB_SOURCE_PRIORITY_HI 0x10
285 #define FIB_SOURCE_PRIORITY_LOW 0xd0
286 
287 
291  fib_source_t s2);
292 
293 extern u8 *format_fib_source(u8 *s, va_list *a);
294 
295 extern fib_source_t fib_source_allocate(const char *name,
298 
302 
304  const char *name,
307  void *ctx);
308 extern void fib_source_walk(fib_source_walk_t fn,
309  void *ctx);
310 
311 extern void fib_source_module_init(void);
312 
313 #endif
FIB_SOURCE_CMP_WORSE
@ FIB_SOURCE_CMP_WORSE
Definition: fib_source.h:190
FIB_SOURCE_IP6_ND
@ FIB_SOURCE_IP6_ND
IPv6 ND (seen in the link-local tables)
Definition: fib_source.h:99
fib_source_get_prio
u16 fib_source_get_prio(fib_source_t src)
Definition: fib_source.c:49
FIB_SOURCE_BIER
@ FIB_SOURCE_BIER
From the BIER subsystem.
Definition: fib_source.h:67
name
string name[64]
Definition: fib.api:25
FIB_SOURCE_DHCP
@ FIB_SOURCE_DHCP
DHCP.
Definition: fib_source.h:91
fib_source_behaviour_t_
fib_source_behaviour_t_
Each source has a defined behaviour that controls how entries behave that have that source.
Definition: fib_source.h:200
u16
unsigned short u16
Definition: types.h:57
fib_source_priority_cmp_t_
fib_source_priority_cmp_t_
source comparison
Definition: fib_source.h:187
FIB_SOURCE_INTERPOSE
@ FIB_SOURCE_INTERPOSE
The interpose source.
Definition: fib_source.h:141
fib_source_walk_t
walk_rc_t(* fib_source_walk_t)(fib_source_t id, const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh, void *ctx)
Definition: fib_source.h:303
FIB_SOURCE_BH_MPLS
@ FIB_SOURCE_BH_MPLS
associated label stored in private data
Definition: fib_source.h:219
FIB_SOURCE_BH_INTERFACE
@ FIB_SOURCE_BH_INTERFACE
cover tracking w/ glean management
Definition: fib_source.h:221
FIB_SOURCE_URPF_EXEMPT
@ FIB_SOURCE_URPF_EXEMPT
uRPF bypass/exemption.
Definition: fib_source.h:127
fib_source_t_
fib_source_t_
The different sources that can create a route.
Definition: fib_source.h:29
FIB_SOURCE_PROXY
@ FIB_SOURCE_PROXY
A route the is being 'proxied' on behalf of another device.
Definition: fib_source.h:53
FIB_SOURCE_BH_DROP
@ FIB_SOURCE_BH_DROP
If you're adding a new source from a plugin pick one of these.
Definition: fib_source.h:206
FIB_SOURCE_ADJ
@ FIB_SOURCE_ADJ
Adjacency source.
Definition: fib_source.h:105
fib_source_allocate
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
Definition: fib_source.c:118
FIB_SOURCE_CMP_EQUAL
@ FIB_SOURCE_CMP_EQUAL
Definition: fib_source.h:191
FIB_SOURCE_INTERFACE
@ FIB_SOURCE_INTERFACE
Route added as a result of interface configuration.
Definition: fib_source.h:59
FIB_SOURCE_INVALID
@ FIB_SOURCE_INVALID
An invalid source This is not a real source, so don't use it to source a prefix.
Definition: fib_source.h:35
format_fib_source
u8 * format_fib_source(u8 *s, va_list *a)
Definition: fib_source.c:66
FIB_SOURCE_BH_ADJ
@ FIB_SOURCE_BH_ADJ
adj w/ cover tracking + refinement
Definition: fib_source.h:233
FIB_SOURCE_CLASSIFY
@ FIB_SOURCE_CLASSIFY
Classify.
Definition: fib_source.h:49
fib_source_module_init
void fib_source_module_init(void)
Definition: fib_source.c:217
src
vl_api_address_t src
Definition: gre.api:54
fib_source_get_behaviour
fib_source_behaviour_t fib_source_get_behaviour(fib_source_t src)
Definition: fib_source.c:58
STATIC_ASSERT
STATIC_ASSERT(sizeof(fib_source_t)==1, "FIB too many sources")
FIB_SOURCE_LAST
@ FIB_SOURCE_LAST
Marker.
Definition: fib_source.h:145
fib_source_behaviour_t
enum fib_source_behaviour_t_ fib_source_behaviour_t
Each source has a defined behaviour that controls how entries behave that have that source.
FIB_SOURCE_BH_INTERPOSE
@ FIB_SOURCE_BH_INTERPOSE
interpose
Definition: fib_source.h:223
FIB_SOURCE_SR
@ FIB_SOURCE_SR
SRv6 and SR-MPLS.
Definition: fib_source.h:63
FIB_SOURCE_BH_API
@ FIB_SOURCE_BH_API
add paths with [mpls] path extensions
Definition: fib_source.h:208
fib_source_priority_t
u8 fib_source_priority_t
Each source is assigned a priority.
Definition: fib_source.h:182
id
u8 id[64]
Definition: dhcp.api:160
fib_source_cmp
fib_source_priority_cmp_t fib_source_cmp(fib_source_t s1, fib_source_t s2)
Definition: fib_source.c:76
FIB_SOURCE_DEFAULT_ROUTE
@ FIB_SOURCE_DEFAULT_ROUTE
The default route source.
Definition: fib_source.h:134
FIB_SOURCE_IP6_ND_PROXY
@ FIB_SOURCE_IP6_ND_PROXY
IPv6 Proxy ND.
Definition: fib_source.h:95
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
FIB_SOURCE_CLI
@ FIB_SOURCE_CLI
From the CLI.
Definition: fib_source.h:79
FIB_SOURCE_API
@ FIB_SOURCE_API
From the control plane API.
Definition: fib_source.h:75
FIB_SOURCE_BH_LISP
@ FIB_SOURCE_BH_LISP
simple behaviour, plus the source specific data stores the FIB index that is used for subsequent look...
Definition: fib_source.h:231
fib_source_register
void fib_source_register(fib_source_t src, fib_source_priority_t prio, fib_source_behaviour_t bh)
Definition: fib_source.c:137
FIB_SOURCE_SPECIAL
@ FIB_SOURCE_SPECIAL
Special sources.
Definition: fib_source.h:45
FIB_SOURCE_FIRST
@ FIB_SOURCE_FIRST
Marker.
Definition: fib_source.h:39
FIB_SOURCE_BH_RR
@ FIB_SOURCE_BH_RR
If your adding a new source from a plugin these are probably not the behaviour you're lokking for.
Definition: fib_source.h:217
u8
unsigned char u8
Definition: types.h:56
a
a
Definition: bitmap.h:525
FIB_SOURCE_MPLS
@ FIB_SOURCE_MPLS
MPLS label.
Definition: fib_source.h:111
FIB_SOURCE_AE
@ FIB_SOURCE_AE
Attached Export source.
Definition: fib_source.h:117
FIB_SOURCE_BH_SIMPLE
@ FIB_SOURCE_BH_SIMPLE
add paths without path extensions
Definition: fib_source.h:210
fib_source_walk
void fib_source_walk(fib_source_walk_t fn, void *ctx)
Definition: fib_source.c:169
FIB_SOURCE_RR
@ FIB_SOURCE_RR
Recursive resolution source.
Definition: fib_source.h:122
FIB_SOURCE_CMP_BETTER
@ FIB_SOURCE_CMP_BETTER
Definition: fib_source.h:189
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
FIB_SOURCE_6RD
@ FIB_SOURCE_6RD
From 6RD.
Definition: fib_source.h:71
FIB_SOURCE_LISP
@ FIB_SOURCE_LISP
LISP.
Definition: fib_source.h:83
vnet.h
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
fib_source_priority_cmp_t
enum fib_source_priority_cmp_t_ fib_source_priority_cmp_t
source comparison
FIB_SOURCE_MAP
@ FIB_SOURCE_MAP
IPv[46] Mapping.
Definition: fib_source.h:87