FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
fib_path.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 /**
17  * Given a route of the form;
18  * q.r.s.t/Y
19  * via <interface> <next-hop>
20  *
21  * The prefix is: q.r.s.t./Y
22  * the path is: 'via <interface> <next-hop>
23  *
24  * The path is the description of where to send the traffic, and the
25  * the prefix is a description of which traffic to send.
26  * It is the aim of the FIB to resolve the path, i.e. to find the corresponding
27  * adjacency to match the path's description.
28  */
29 
30 #ifndef __FIB_PATH_H__
31 #define __FIB_PATH_H__
32 
33 #include <vnet/ip/ip.h>
34 #include <vnet/dpo/load_balance.h>
35 
36 #include <vnet/fib/fib_types.h>
37 #include <vnet/adj/adj_types.h>
38 #include <vnet/bier/bier_types.h>
39 
40 /**
41  * Enurmeration of path configuration attributes
42  */
44  /**
45  * Marker. Add new types after this one.
46  */
48  /**
49  * The path is forced to a drop, whatever the next-hop info says.
50  * something somewhere knows better...
51  */
53  /**
54  * The path uses an adj that is exclusive. I.e. it is known only by
55  * the source of the route.
56  */
58  /**
59  * Recursion constraint via host
60  */
62  /**
63  * Recursion constraint via attached
64  */
66  /**
67  * The path is attached
68  */
70  /**
71  * The path is a for-us path
72  */
74  /**
75  * The path is a deag with rpf-id
76  */
78  /**
79  * The path is an interface recieve
80  */
82  /**
83  * The path reolves via an ICMP unreachable
84  */
86  /**
87  * The path reolves via an ICMP prohibit
88  */
90  /**
91  * The path reolves via a classify
92  */
94  /**
95  * The deag path does a source lookup
96  */
98  /**
99  * The path pops a Psuedo Wire Control Word
100  */
102  /**
103  * The path is a glean
104  */
106  /**
107  * Marker. Add new types before this one, then update it.
108  */
110 } __attribute__ ((packed)) fib_path_cfg_attribute_t;
111 
112 /**
113  * The maximum number of path attributes
114  */
115 #define FIB_PATH_CFG_ATTRIBUTE_MAX (FIB_PATH_CFG_ATTRIBUTE_LAST + 1)
116 
117 #define FIB_PATH_CFG_ATTRIBUTES { \
118  [FIB_PATH_CFG_ATTRIBUTE_DROP] = "drop", \
119  [FIB_PATH_CFG_ATTRIBUTE_EXCLUSIVE] = "exclusive", \
120  [FIB_PATH_CFG_ATTRIBUTE_RESOLVE_HOST] = "resolve-host", \
121  [FIB_PATH_CFG_ATTRIBUTE_RESOLVE_ATTACHED] = "resolve-attached", \
122  [FIB_PATH_CFG_ATTRIBUTE_LOCAL] = "local", \
123  [FIB_PATH_CFG_ATTRIBUTE_ICMP_UNREACH] = "icmp-unreach", \
124  [FIB_PATH_CFG_ATTRIBUTE_ICMP_PROHIBIT] = "icmp-prohibit", \
125  [FIB_PATH_CFG_ATTRIBUTE_CLASSIFY] = "classify", \
126  [FIB_PATH_CFG_ATTRIBUTE_ATTACHED] = "attached", \
127  [FIB_PATH_CFG_ATTRIBUTE_INTF_RX] = "interface-rx", \
128  [FIB_PATH_CFG_ATTRIBUTE_RPF_ID] = "rpf-id", \
129  [FIB_PATH_CFG_ATTRIBUTE_DEAG_SRC] = "deag-src", \
130  [FIB_PATH_CFG_ATTRIBUTE_POP_PW_CW] = "pop-pw-cw", \
131  [FIB_PATH_CFG_ATTRIBUTE_GLEAN] = "glean", \
132 }
133 
134 #define FOR_EACH_FIB_PATH_CFG_ATTRIBUTE(_item) \
135  for (_item = FIB_PATH_CFG_ATTRIBUTE_FIRST; \
136  _item <= FIB_PATH_CFG_ATTRIBUTE_LAST; \
137  _item++)
138 
139 /**
140  * Path config flags from the attributes
141  */
142 typedef enum fib_path_cfg_flags_t_ {
158 } __attribute__ ((packed)) fib_path_cfg_flags_t;
159 
161 {
165 
166 extern u8 *format_fib_path(u8 *s, va_list *args);
167 
169  const fib_route_path_t *path);
171  dpo_proto_t nh_proto,
173  const dpo_id_t *dpo);
174 
175 extern int fib_path_cmp(fib_node_index_t path_index1,
176  fib_node_index_t path_index2);
177 extern int fib_path_cmp_for_sort(void * a1, void * a2);
178 extern int fib_path_cmp_w_route_path(fib_node_index_t path_index,
179  const fib_route_path_t *rpath);
181  fib_node_index_t path_list_index);
182 extern int fib_path_resolve(fib_node_index_t path_index);
183 extern int fib_path_is_resolved(fib_node_index_t path_index);
185 extern int fib_path_is_exclusive(fib_node_index_t path_index);
186 extern int fib_path_is_deag(fib_node_index_t path_index);
187 extern int fib_path_is_looped(fib_node_index_t path_index);
189 extern void fib_path_destroy(fib_node_index_t path_index);
190 extern uword fib_path_hash(fib_node_index_t path_index);
192  fib_node_index_t path_index,
194  load_balance_path_t *hash_key);
195 extern void fib_path_stack_mpls_disp(fib_node_index_t path_index,
196  dpo_proto_t payload_proto,
198  dpo_id_t *dpo);
199 extern void fib_path_contribute_forwarding(fib_node_index_t path_index,
201  dpo_id_t *dpo);
202 extern void fib_path_contribute_urpf(fib_node_index_t path_index,
203  index_t urpf);
206  fib_node_index_t **entry_indicies);
209 extern u16 fib_path_get_weight(fib_node_index_t path_index);
210 extern u16 fib_path_get_preference(fib_node_index_t path_index);
211 extern u32 fib_path_get_rpf_id(fib_node_index_t path_index);
212 
213 extern void fib_path_module_init(void);
214 
215 /**
216  * Path encode context to use when walking a path-list
217  * to encode paths
218  */
220 {
223 
225  fib_node_index_t path_index,
226  const struct fib_path_ext_t_ *ext_list,
227  void *ctx);
228 
229 #endif
fib_path_format_flags_t_
fib_path_format_flags_t_
Definition: fib_path.h:160
load_balance.h
FIB_PATH_CFG_FLAG_RESOLVE_HOST
@ FIB_PATH_CFG_FLAG_RESOLVE_HOST
Definition: fib_path.h:146
adj_types.h
FIB_PATH_CFG_FLAG_RESOLVE_ATTACHED
@ FIB_PATH_CFG_FLAG_RESOLVE_ATTACHED
Definition: fib_path.h:147
fib_path_get_weight
u16 fib_path_get_weight(fib_node_index_t path_index)
Definition: fib_path.c:2240
FIB_PATH_CFG_FLAG_DROP
@ FIB_PATH_CFG_FLAG_DROP
Definition: fib_path.h:144
FIB_PATH_CFG_FLAG_POP_PW_CW
@ FIB_PATH_CFG_FLAG_POP_PW_CW
Definition: fib_path.h:156
fib_path_encode_ctx_t_
Path encode context to use when walking a path-list to encode paths.
Definition: fib_path.h:219
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
FIB_PATH_CFG_FLAG_ICMP_UNREACH
@ FIB_PATH_CFG_FLAG_ICMP_UNREACH
Definition: fib_path.h:149
path
vl_api_fib_path_t path
Definition: mfib_types.api:44
fib_path_destroy
void fib_path_destroy(fib_node_index_t path_index)
Definition: fib_path.c:1514
fib_path_hash
uword fib_path_hash(fib_node_index_t path_index)
Definition: fib_path.c:1535
fib_path_list_walk_rc_t
enum fib_path_list_walk_rc_t_ fib_path_list_walk_rc_t
return code to control pat-hlist walk
u16
unsigned short u16
Definition: types.h:57
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
fib_path_cmp
int fib_path_cmp(fib_node_index_t path_index1, fib_node_index_t path_index2)
Definition: fib_path.c:1675
fib_format_path_flags_t
enum fib_path_format_flags_t_ fib_format_path_flags_t
FIB_PATH_CFG_FLAG_INTF_RX
@ FIB_PATH_CFG_FLAG_INTF_RX
Definition: fib_path.h:153
fib_path_copy
fib_node_index_t fib_path_copy(fib_node_index_t path_index, fib_node_index_t path_list_index)
Definition: fib_path.c:1481
FIB_PATH_CFG_FLAG_ICMP_PROHIBIT
@ FIB_PATH_CFG_FLAG_ICMP_PROHIBIT
Definition: fib_path.h:150
FIB_PATH_CFG_FLAG_RPF_ID
@ FIB_PATH_CFG_FLAG_RPF_ID
Definition: fib_path.h:154
fib_path_stack_mpls_disp
void fib_path_stack_mpls_disp(fib_node_index_t path_index, dpo_proto_t payload_proto, fib_mpls_lsp_mode_t mode, dpo_id_t *dpo)
Definition: fib_path.c:2356
FIB_PATH_CFG_ATTRIBUTE_RPF_ID
@ FIB_PATH_CFG_ATTRIBUTE_RPF_ID
The path is a deag with rpf-id.
Definition: fib_path.h:77
fib_path_get_rpf_id
u32 fib_path_get_rpf_id(fib_node_index_t path_index)
Definition: fib_path.c:2264
FIB_PATH_CFG_ATTRIBUTE_DROP
@ FIB_PATH_CFG_ATTRIBUTE_DROP
The path is forced to a drop, whatever the next-hop info says.
Definition: fib_path.h:52
fib_path_encode_ctx_t_::rpaths
fib_route_path_t * rpaths
Definition: fib_path.h:221
FIB_PATH_CFG_ATTRIBUTE_POP_PW_CW
@ FIB_PATH_CFG_ATTRIBUTE_POP_PW_CW
The path pops a Psuedo Wire Control Word.
Definition: fib_path.h:101
FIB_PATH_CFG_ATTRIBUTE_RESOLVE_HOST
@ FIB_PATH_CFG_ATTRIBUTE_RESOLVE_HOST
Recursion constraint via host.
Definition: fib_path.h:61
fib_path_is_recursive_constrained
int fib_path_is_recursive_constrained(fib_node_index_t path_index)
Definition: fib_path.c:2655
FIB_PATH_FORMAT_FLAGS_NONE
@ FIB_PATH_FORMAT_FLAGS_NONE
Definition: fib_path.h:162
fib_path_resolve
int fib_path_resolve(fib_node_index_t path_index)
Definition: fib_path.c:1907
fib_path_module_init
void fib_path_module_init(void)
Definition: fib_path.c:2804
fib_path_contribute_forwarding
void fib_path_contribute_forwarding(fib_node_index_t path_index, fib_forward_chain_type_t type, dpo_id_t *dpo)
Definition: fib_path.c:2417
fib_forward_chain_type_t
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
fib_path_cmp_for_sort
int fib_path_cmp_for_sort(void *a1, void *a2)
Definition: fib_path.c:1648
fib_types.h
fib_path_is_exclusive
int fib_path_is_exclusive(fib_node_index_t path_index)
Definition: fib_path.c:2667
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
uword
u64 uword
Definition: types.h:112
FIB_PATH_CFG_FLAG_ATTACHED
@ FIB_PATH_CFG_FLAG_ATTACHED
Definition: fib_path.h:152
fib_path_get_preference
u16 fib_path_get_preference(fib_node_index_t path_index)
Definition: fib_path.c:2252
FIB_PATH_CFG_ATTRIBUTE_LAST
@ FIB_PATH_CFG_ATTRIBUTE_LAST
Marker.
Definition: fib_path.h:109
fib_path_get_proto
dpo_proto_t fib_path_get_proto(fib_node_index_t path_index)
Definition: fib_path.c:2794
fib_mpls_lsp_mode_t
enum fib_mpls_lsp_mode_t_ fib_mpls_lsp_mode_t
MPLS LSP mode - only valid at the head and tail.
fib_path_is_resolved
int fib_path_is_resolved(fib_node_index_t path_index)
Definition: fib_path.c:2687
FIB_PATH_CFG_ATTRIBUTE_INTF_RX
@ FIB_PATH_CFG_ATTRIBUTE_INTF_RX
The path is a for-us path.
Definition: fib_path.h:73
fib_path_encode
fib_path_list_walk_rc_t fib_path_encode(fib_node_index_t path_list_index, fib_node_index_t path_index, const struct fib_path_ext_t_ *ext_list, void *ctx)
FIB_PATH_CFG_ATTRIBUTE_EXCLUSIVE
@ FIB_PATH_CFG_ATTRIBUTE_EXCLUSIVE
The path uses an adj that is exclusive.
Definition: fib_path.h:57
format_fib_path
u8 * format_fib_path(u8 *s, va_list *args)
Definition: fib_path.c:443
FIB_PATH_FORMAT_FLAGS_ONE_LINE
@ FIB_PATH_FORMAT_FLAGS_ONE_LINE
Definition: fib_path.h:163
fib_path_get_resolving_interface
u32 fib_path_get_resolving_interface(fib_node_index_t fib_entry_index)
Definition: fib_path.c:2158
FIB_PATH_CFG_FLAG_LOCAL
@ FIB_PATH_CFG_FLAG_LOCAL
Definition: fib_path.h:148
FIB_PATH_CFG_FLAG_EXCLUSIVE
@ FIB_PATH_CFG_FLAG_EXCLUSIVE
Definition: fib_path.h:145
fib_path_create
fib_node_index_t fib_path_create(fib_node_index_t pl_index, const fib_route_path_t *path)
Definition: fib_path.c:1280
fib_path_is_deag
int fib_path_is_deag(fib_node_index_t path_index)
Definition: fib_path.c:2677
fib_path_get_resolving_index
index_t fib_path_get_resolving_index(fib_node_index_t path_index)
Definition: fib_path.c:2194
fib_path_is_looped
int fib_path_is_looped(fib_node_index_t path_index)
Definition: fib_path.c:2700
fib_path_contribute_urpf
void fib_path_contribute_urpf(fib_node_index_t path_index, index_t urpf)
Contribute the path's adjacency to the list passed.
Definition: fib_path.c:2287
fib_path_cfg_attribute_t
enum fib_path_cfg_attribute_t_ fib_path_cfg_attribute_t
Given a route of the form; q.r.s.t/Y via <interface> <next-hop>
FIB_PATH_CFG_FLAG_DEAG_SRC
@ FIB_PATH_CFG_FLAG_DEAG_SRC
Definition: fib_path.h:155
FIB_PATH_CFG_FLAG_CLASSIFY
@ FIB_PATH_CFG_FLAG_CLASSIFY
Definition: fib_path.h:151
ip.h
u32
unsigned int u32
Definition: types.h:88
fib_path_recursive_loop_detect
int fib_path_recursive_loop_detect(fib_node_index_t path_index, fib_node_index_t **entry_indicies)
Definition: fib_path.c:1809
FIB_PATH_CFG_ATTRIBUTE_LOCAL
@ FIB_PATH_CFG_ATTRIBUTE_LOCAL
The path is an interface recieve.
Definition: fib_path.h:81
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
fib_path_get_adj
adj_index_t fib_path_get_adj(fib_node_index_t path_index)
Definition: fib_path.c:2226
FIB_PATH_CFG_ATTRIBUTE_RESOLVE_ATTACHED
@ FIB_PATH_CFG_ATTRIBUTE_RESOLVE_ATTACHED
Recursion constraint via attached.
Definition: fib_path.h:65
bier_types.h
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
u8
unsigned char u8
Definition: types.h:56
FIB_PATH_CFG_ATTRIBUTE_GLEAN
@ FIB_PATH_CFG_ATTRIBUTE_GLEAN
The path is a glean.
Definition: fib_path.h:105
fib_path_cmp_w_route_path
int fib_path_cmp_w_route_path(fib_node_index_t path_index, const fib_route_path_t *rpath)
Definition: fib_path.c:1687
fib_path_ext_t_
A path extension is a per-entry addition to the forwarding information when packets are sent for that...
Definition: fib_path_ext.h:98
FIB_PATH_CFG_ATTRIBUTE_FIRST
@ FIB_PATH_CFG_ATTRIBUTE_FIRST
Marker.
Definition: fib_path.h:47
fib_path_cfg_flags_t_
fib_path_cfg_flags_t_
Path config flags from the attributes.
Definition: fib_path.h:142
FIB_PATH_CFG_FLAG_GLEAN
@ FIB_PATH_CFG_FLAG_GLEAN
Definition: fib_path.h:157
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_PATH_CFG_ATTRIBUTE_ATTACHED
@ FIB_PATH_CFG_ATTRIBUTE_ATTACHED
The path is attached.
Definition: fib_path.h:69
fib_path_encode_ctx_t
struct fib_path_encode_ctx_t_ fib_path_encode_ctx_t
Path encode context to use when walking a path-list to encode paths.
fib_path_create_special
fib_node_index_t fib_path_create_special(fib_node_index_t pl_index, dpo_proto_t nh_proto, fib_path_cfg_flags_t flags, const dpo_id_t *dpo)
Definition: fib_path.c:1435
fib_path_cfg_attribute_t_
fib_path_cfg_attribute_t_
Given a route of the form; q.r.s.t/Y via <interface> <next-hop>
Definition: fib_path.h:43
FIB_PATH_CFG_ATTRIBUTE_CLASSIFY
@ FIB_PATH_CFG_ATTRIBUTE_CLASSIFY
The path reolves via a classify.
Definition: fib_path.h:93
FIB_PATH_CFG_ATTRIBUTE_DEAG_SRC
@ FIB_PATH_CFG_ATTRIBUTE_DEAG_SRC
The deag path does a source lookup.
Definition: fib_path.h:97
fib_path_cfg_flags_t
enum fib_path_cfg_flags_t_ fib_path_cfg_flags_t
Path config flags from the attributes.
load_balance_path_t_
One path from an [EU]CMP set that the client wants to add to a load-balance object.
Definition: load_balance.h:62
FIB_PATH_CFG_ATTRIBUTE_ICMP_PROHIBIT
@ FIB_PATH_CFG_ATTRIBUTE_ICMP_PROHIBIT
The path reolves via an ICMP prohibit.
Definition: fib_path.h:89
FIB_PATH_CFG_FLAG_NONE
@ FIB_PATH_CFG_FLAG_NONE
Definition: fib_path.h:143
fib_path_append_nh_for_multipath_hash
load_balance_path_t * fib_path_append_nh_for_multipath_hash(fib_node_index_t path_index, fib_forward_chain_type_t fct, load_balance_path_t *hash_key)
Definition: fib_path.c:2626
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
FIB_PATH_CFG_ATTRIBUTE_ICMP_UNREACH
@ FIB_PATH_CFG_ATTRIBUTE_ICMP_UNREACH
The path reolves via an ICMP unreachable.
Definition: fib_path.h:85
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105