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