Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 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_H__ |
| 17 | #define __FIB_ENTRY_H__ |
| 18 | |
| 19 | #include <vnet/fib/fib_node.h> |
Neale Ranns | 3bab8f9 | 2019-12-04 06:11:00 +0000 | [diff] [blame] | 20 | #include <vnet/fib/fib_source.h> |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 21 | #include <vnet/adj/adj.h> |
| 22 | #include <vnet/ip/ip.h> |
| 23 | #include <vnet/dpo/dpo.h> |
| 24 | |
| 25 | /** |
| 26 | * The different sources that can create a route. |
Lijian.Zhang | 33af8c1 | 2019-09-16 16:22:36 +0800 | [diff] [blame] | 27 | * The sources are defined here with their relative priority order. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 28 | * The lower the value the higher the priority |
| 29 | */ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 30 | typedef enum fib_entry_attribute_t_ { |
| 31 | /** |
| 32 | * Marker. Add new values after this one. |
| 33 | */ |
| 34 | FIB_ENTRY_ATTRIBUTE_FIRST, |
| 35 | /** |
| 36 | * Connected. The prefix is configured on an interface. |
| 37 | */ |
| 38 | FIB_ENTRY_ATTRIBUTE_CONNECTED = FIB_ENTRY_ATTRIBUTE_FIRST, |
| 39 | /** |
| 40 | * Attached. The prefix is attached to an interface. |
| 41 | */ |
| 42 | FIB_ENTRY_ATTRIBUTE_ATTACHED, |
| 43 | /** |
| 44 | * The route is an explicit drop. |
| 45 | */ |
| 46 | FIB_ENTRY_ATTRIBUTE_DROP, |
| 47 | /** |
| 48 | * The route is exclusive. The client creating the route is |
| 49 | * providing an exclusive adjacency. |
| 50 | */ |
| 51 | FIB_ENTRY_ATTRIBUTE_EXCLUSIVE, |
| 52 | /** |
| 53 | * The route is attached cross tables and thus imports covered |
| 54 | * prefixes from the other table. |
| 55 | */ |
| 56 | FIB_ENTRY_ATTRIBUTE_IMPORT, |
| 57 | /** |
| 58 | * The prefix/address is local to this device |
| 59 | */ |
| 60 | FIB_ENTRY_ATTRIBUTE_LOCAL, |
| 61 | /** |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 62 | * The prefix/address is a multicast prefix. |
| 63 | * this aplies only to MPLS. IP multicast is handled by mfib |
| 64 | */ |
| 65 | FIB_ENTRY_ATTRIBUTE_MULTICAST, |
| 66 | /** |
Shwetha Bhandari | 78372a9 | 2017-01-18 12:43:54 +0530 | [diff] [blame] | 67 | * The prefix/address exempted from loose uRPF check |
| 68 | * To be used with caution |
| 69 | */ |
| 70 | FIB_ENTRY_ATTRIBUTE_URPF_EXEMPT, |
| 71 | /** |
Neale Ranns | 53da221 | 2018-02-24 02:11:19 -0800 | [diff] [blame] | 72 | * The prefix/address exempted from attached export |
| 73 | */ |
| 74 | FIB_ENTRY_ATTRIBUTE_NO_ATTACHED_EXPORT, |
| 75 | /** |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 76 | * This FIB entry imposes its source information on all prefixes |
| 77 | * that is covers |
| 78 | */ |
| 79 | FIB_ENTRY_ATTRIBUTE_COVERED_INHERIT, |
| 80 | /** |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 81 | * The interpose attribute. |
| 82 | * place the forwarding provided by the source infront of the forwarding |
| 83 | * provided by the best source, or failing that, by the cover. |
| 84 | */ |
| 85 | FIB_ENTRY_ATTRIBUTE_INTERPOSE, |
| 86 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 87 | * Marker. add new entries before this one. |
| 88 | */ |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 89 | FIB_ENTRY_ATTRIBUTE_LAST = FIB_ENTRY_ATTRIBUTE_INTERPOSE, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 90 | } fib_entry_attribute_t; |
| 91 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 92 | #define FIB_ENTRY_ATTRIBUTES { \ |
| 93 | [FIB_ENTRY_ATTRIBUTE_CONNECTED] = "connected", \ |
| 94 | [FIB_ENTRY_ATTRIBUTE_ATTACHED] = "attached", \ |
| 95 | [FIB_ENTRY_ATTRIBUTE_IMPORT] = "import", \ |
| 96 | [FIB_ENTRY_ATTRIBUTE_DROP] = "drop", \ |
| 97 | [FIB_ENTRY_ATTRIBUTE_EXCLUSIVE] = "exclusive", \ |
| 98 | [FIB_ENTRY_ATTRIBUTE_LOCAL] = "local", \ |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 99 | [FIB_ENTRY_ATTRIBUTE_URPF_EXEMPT] = "uRPF-exempt", \ |
| 100 | [FIB_ENTRY_ATTRIBUTE_MULTICAST] = "multicast", \ |
Neale Ranns | 53da221 | 2018-02-24 02:11:19 -0800 | [diff] [blame] | 101 | [FIB_ENTRY_ATTRIBUTE_NO_ATTACHED_EXPORT] = "no-attached-export", \ |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 102 | [FIB_ENTRY_ATTRIBUTE_COVERED_INHERIT] = "covered-inherit", \ |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 103 | [FIB_ENTRY_ATTRIBUTE_INTERPOSE] = "interpose", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | #define FOR_EACH_FIB_ATTRIBUTE(_item) \ |
| 107 | for (_item = FIB_ENTRY_ATTRIBUTE_FIRST; \ |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 108 | _item <= FIB_ENTRY_ATTRIBUTE_LAST; \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 109 | _item++) |
| 110 | |
| 111 | typedef enum fib_entry_flag_t_ { |
| 112 | FIB_ENTRY_FLAG_NONE = 0, |
| 113 | FIB_ENTRY_FLAG_CONNECTED = (1 << FIB_ENTRY_ATTRIBUTE_CONNECTED), |
| 114 | FIB_ENTRY_FLAG_ATTACHED = (1 << FIB_ENTRY_ATTRIBUTE_ATTACHED), |
| 115 | FIB_ENTRY_FLAG_DROP = (1 << FIB_ENTRY_ATTRIBUTE_DROP), |
| 116 | FIB_ENTRY_FLAG_EXCLUSIVE = (1 << FIB_ENTRY_ATTRIBUTE_EXCLUSIVE), |
| 117 | FIB_ENTRY_FLAG_LOCAL = (1 << FIB_ENTRY_ATTRIBUTE_LOCAL), |
| 118 | FIB_ENTRY_FLAG_IMPORT = (1 << FIB_ENTRY_ATTRIBUTE_IMPORT), |
Neale Ranns | 53da221 | 2018-02-24 02:11:19 -0800 | [diff] [blame] | 119 | FIB_ENTRY_FLAG_NO_ATTACHED_EXPORT = (1 << FIB_ENTRY_ATTRIBUTE_NO_ATTACHED_EXPORT), |
Shwetha Bhandari | 78372a9 | 2017-01-18 12:43:54 +0530 | [diff] [blame] | 120 | FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT = (1 << FIB_ENTRY_ATTRIBUTE_URPF_EXEMPT), |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 121 | FIB_ENTRY_FLAG_MULTICAST = (1 << FIB_ENTRY_ATTRIBUTE_MULTICAST), |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 122 | FIB_ENTRY_FLAG_COVERED_INHERIT = (1 << FIB_ENTRY_ATTRIBUTE_COVERED_INHERIT), |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 123 | FIB_ENTRY_FLAG_INTERPOSE = (1 << FIB_ENTRY_ATTRIBUTE_INTERPOSE), |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 124 | } __attribute__((packed)) fib_entry_flag_t; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 125 | |
Neale Ranns | 710071b | 2018-09-24 12:36:26 +0000 | [diff] [blame] | 126 | extern u8 * format_fib_entry_flags(u8 *s, va_list *args); |
| 127 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 128 | /** |
| 129 | * Flags for the source data |
| 130 | */ |
| 131 | typedef enum fib_entry_src_attribute_t_ { |
| 132 | /** |
| 133 | * Marker. Add new values after this one. |
| 134 | */ |
| 135 | FIB_ENTRY_SRC_ATTRIBUTE_FIRST, |
| 136 | /** |
| 137 | * the source has been added to the entry |
| 138 | */ |
| 139 | FIB_ENTRY_SRC_ATTRIBUTE_ADDED = FIB_ENTRY_SRC_ATTRIBUTE_FIRST, |
| 140 | /** |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 141 | * the source is contributing forwarding |
| 142 | */ |
| 143 | FIB_ENTRY_SRC_ATTRIBUTE_CONTRIBUTING, |
| 144 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 145 | * the source is active/best |
| 146 | */ |
| 147 | FIB_ENTRY_SRC_ATTRIBUTE_ACTIVE, |
| 148 | /** |
Neale Ranns | 9db6ada | 2019-11-08 12:42:31 +0000 | [diff] [blame] | 149 | * the source is stale |
| 150 | */ |
| 151 | FIB_ENTRY_SRC_ATTRIBUTE_STALE, |
| 152 | /** |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 153 | * the source is inherited from its cover |
| 154 | */ |
| 155 | FIB_ENTRY_SRC_ATTRIBUTE_INHERITED, |
| 156 | /** |
Matthew Smith | 9e5694b | 2023-09-26 13:08:26 +0000 | [diff] [blame^] | 157 | * the source is currently used as glean src address |
| 158 | */ |
| 159 | FIB_ENTRY_SRC_ATTRIBUTE_PROVIDES_GLEAN, |
| 160 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 161 | * Marker. add new entries before this one. |
| 162 | */ |
Matthew Smith | 9e5694b | 2023-09-26 13:08:26 +0000 | [diff] [blame^] | 163 | FIB_ENTRY_SRC_ATTRIBUTE_LAST = FIB_ENTRY_SRC_ATTRIBUTE_PROVIDES_GLEAN, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 164 | } fib_entry_src_attribute_t; |
| 165 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 166 | |
| 167 | #define FIB_ENTRY_SRC_ATTRIBUTES { \ |
| 168 | [FIB_ENTRY_SRC_ATTRIBUTE_ADDED] = "added", \ |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 169 | [FIB_ENTRY_SRC_ATTRIBUTE_CONTRIBUTING] = "contributing", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 170 | [FIB_ENTRY_SRC_ATTRIBUTE_ACTIVE] = "active", \ |
Neale Ranns | 9db6ada | 2019-11-08 12:42:31 +0000 | [diff] [blame] | 171 | [FIB_ENTRY_SRC_ATTRIBUTE_STALE] = "stale", \ |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 172 | [FIB_ENTRY_SRC_ATTRIBUTE_INHERITED] = "inherited", \ |
Matthew Smith | 9e5694b | 2023-09-26 13:08:26 +0000 | [diff] [blame^] | 173 | [FIB_ENTRY_SRC_ATTRIBUTE_PROVIDES_GLEAN] = "provides-glean", \ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 174 | } |
| 175 | |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 176 | #define FOR_EACH_FIB_SRC_ATTRIBUTE(_item) \ |
| 177 | for (_item = FIB_ENTRY_SRC_ATTRIBUTE_FIRST; \ |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 178 | _item <= FIB_ENTRY_SRC_ATTRIBUTE_LAST; \ |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 179 | _item++) |
| 180 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 181 | typedef enum fib_entry_src_flag_t_ { |
| 182 | FIB_ENTRY_SRC_FLAG_NONE = 0, |
| 183 | FIB_ENTRY_SRC_FLAG_ADDED = (1 << FIB_ENTRY_SRC_ATTRIBUTE_ADDED), |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 184 | FIB_ENTRY_SRC_FLAG_CONTRIBUTING = (1 << FIB_ENTRY_SRC_ATTRIBUTE_CONTRIBUTING), |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 185 | FIB_ENTRY_SRC_FLAG_ACTIVE = (1 << FIB_ENTRY_SRC_ATTRIBUTE_ACTIVE), |
Neale Ranns | 9db6ada | 2019-11-08 12:42:31 +0000 | [diff] [blame] | 186 | FIB_ENTRY_SRC_FLAG_STALE = (1 << FIB_ENTRY_SRC_ATTRIBUTE_STALE), |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 187 | FIB_ENTRY_SRC_FLAG_INHERITED = (1 << FIB_ENTRY_SRC_ATTRIBUTE_INHERITED), |
Matthew Smith | 9e5694b | 2023-09-26 13:08:26 +0000 | [diff] [blame^] | 188 | FIB_ENTRY_SRC_FLAG_PROVIDES_GLEAN = (1 << FIB_ENTRY_SRC_ATTRIBUTE_PROVIDES_GLEAN), |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 189 | } __attribute__ ((packed)) fib_entry_src_flag_t; |
| 190 | |
Neale Ranns | 710071b | 2018-09-24 12:36:26 +0000 | [diff] [blame] | 191 | extern u8 * format_fib_entry_src_flags(u8 *s, va_list *args); |
| 192 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 193 | /* |
| 194 | * Keep the size of the flags field to 2 bytes, so it |
| 195 | * can be placed next to the 2 bytes reference count |
| 196 | */ |
Damjan Marion | cf47894 | 2016-11-07 14:57:50 +0100 | [diff] [blame] | 197 | STATIC_ASSERT (sizeof(fib_entry_src_flag_t) <= 2, |
| 198 | "FIB entry flags field size too big"); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * Information related to the source of a FIB entry |
| 202 | */ |
| 203 | typedef struct fib_entry_src_t_ { |
| 204 | /** |
Neale Ranns | 6c3ebcc | 2016-10-02 21:20:15 +0100 | [diff] [blame] | 205 | * A vector of path extensions |
| 206 | */ |
Neale Ranns | 8142499 | 2017-05-18 03:03:22 -0700 | [diff] [blame] | 207 | fib_path_ext_list_t fes_path_exts; |
Neale Ranns | 6c3ebcc | 2016-10-02 21:20:15 +0100 | [diff] [blame] | 208 | |
| 209 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 210 | * The path-list created by the source |
| 211 | */ |
| 212 | fib_node_index_t fes_pl; |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 213 | |
| 214 | /** |
| 215 | * Flags the source contributes to the entry |
| 216 | */ |
| 217 | fib_entry_flag_t fes_entry_flags; |
| 218 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 219 | /** |
| 220 | * Which source this info block is for |
| 221 | */ |
| 222 | fib_source_t fes_src; |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 223 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 224 | /** |
| 225 | * Flags on the source |
| 226 | */ |
| 227 | fib_entry_src_flag_t fes_flags; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 228 | |
| 229 | /** |
| 230 | * 1 bytes ref count. This is not the number of users of the Entry |
| 231 | * (which is itself not large, due to path-list sharing), but the number |
| 232 | * of times a given source has been added. Which is even fewer |
| 233 | */ |
| 234 | u8 fes_ref_count; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 235 | |
| 236 | /** |
| 237 | * Source specific info |
| 238 | */ |
| 239 | union { |
| 240 | struct { |
| 241 | /** |
| 242 | * the index of the FIB entry that is the covering entry |
| 243 | */ |
| 244 | fib_node_index_t fesr_cover; |
| 245 | /** |
| 246 | * This source's index in the cover's list |
| 247 | */ |
| 248 | u32 fesr_sibling; |
| 249 | } rr; |
| 250 | struct { |
| 251 | /** |
| 252 | * the index of the FIB entry that is the covering entry |
| 253 | */ |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 254 | fib_node_index_t fesi_cover; |
| 255 | /** |
| 256 | * This source's index in the cover's list |
| 257 | */ |
| 258 | u32 fesi_sibling; |
| 259 | /** |
| 260 | * DPO type to interpose. The dpo type needs to have registered |
| 261 | * it's 'contribute interpose' callback function. |
| 262 | */ |
| 263 | dpo_id_t fesi_dpo; |
| 264 | } interpose; |
| 265 | struct { |
| 266 | /** |
| 267 | * the index of the FIB entry that is the covering entry |
| 268 | */ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 269 | fib_node_index_t fesa_cover; |
| 270 | /** |
| 271 | * This source's index in the cover's list |
| 272 | */ |
| 273 | u32 fesa_sibling; |
| 274 | } adj; |
| 275 | struct { |
| 276 | /** |
| 277 | * the index of the FIB entry that is the covering entry |
| 278 | */ |
| 279 | fib_node_index_t fesi_cover; |
| 280 | /** |
| 281 | * This source's index in the cover's list |
| 282 | */ |
| 283 | u32 fesi_sibling; |
| 284 | } interface; |
| 285 | struct { |
| 286 | /** |
| 287 | * This MPLS local label associated with the prefix. |
| 288 | */ |
| 289 | mpls_label_t fesm_label; |
| 290 | |
| 291 | /** |
| 292 | * the indicies of the LFIB entries created |
| 293 | */ |
| 294 | fib_node_index_t fesm_lfes[2]; |
| 295 | } mpls; |
| 296 | struct { |
| 297 | /** |
| 298 | * The source FIB index. |
| 299 | */ |
| 300 | fib_node_index_t fesl_fib_index; |
| 301 | } lisp; |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 302 | } u; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 303 | } fib_entry_src_t; |
| 304 | |
| 305 | /** |
| 306 | * An entry in a FIB table. |
| 307 | * |
| 308 | * This entry represents a route added to the FIB that is stored |
| 309 | * in one of the FIB tables. |
| 310 | */ |
| 311 | typedef struct fib_entry_t_ { |
| 312 | /** |
| 313 | * Base class. The entry's node representation in the graph. |
| 314 | */ |
| 315 | fib_node_t fe_node; |
| 316 | /** |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 317 | * The prefix of the route. this is const just to be sure. |
| 318 | * It is the entry's key/identity and so should never change. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 319 | */ |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 320 | const fib_prefix_t fe_prefix; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 321 | /** |
| 322 | * The index of the FIB table this entry is in |
| 323 | */ |
| 324 | u32 fe_fib_index; |
| 325 | /** |
| 326 | * The load-balance used for forwarding. |
| 327 | * |
| 328 | * We don't share the EOS and non-EOS even in case when they could be |
| 329 | * because: |
| 330 | * - complexity & reliability v. memory |
| 331 | * determining the conditions where sharing is possible is non-trivial. |
| 332 | * - separate LBs means we can get the EOS bit right in the MPLS label DPO |
| 333 | * and so save a few clock cycles in the DP imposition node since we can |
| 334 | * paint the header straight on without the need to check the packet |
| 335 | * type to derive the EOS bit value. |
| 336 | */ |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 337 | dpo_id_t fe_lb; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 338 | /** |
Neale Ranns | a4e7766 | 2017-12-04 20:00:30 +0000 | [diff] [blame] | 339 | * Vector of source infos. |
| 340 | * Most entries will only have 1 source. So we optimise for memory usage, |
| 341 | * which is preferable since we have many entries. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 342 | */ |
Neale Ranns | a4e7766 | 2017-12-04 20:00:30 +0000 | [diff] [blame] | 343 | fib_entry_src_t *fe_srcs; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 344 | /** |
| 345 | * the path-list for which this entry is a child. This is also the path-list |
| 346 | * that is contributing forwarding for this entry. |
| 347 | */ |
| 348 | fib_node_index_t fe_parent; |
| 349 | /** |
| 350 | * index of this entry in the parent's child list. |
| 351 | * This is set when this entry is added as a child, but can also |
| 352 | * be changed by the parent as it manages its list. |
| 353 | */ |
| 354 | u32 fe_sibling; |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 355 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 356 | /** |
Neale Ranns | 1f50bf8 | 2019-07-16 15:28:52 +0000 | [diff] [blame] | 357 | * A vector of delegate indices. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 358 | */ |
Neale Ranns | 1f50bf8 | 2019-07-16 15:28:52 +0000 | [diff] [blame] | 359 | index_t *fe_delegates; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 360 | } fib_entry_t; |
| 361 | |
| 362 | #define FOR_EACH_FIB_ENTRY_FLAG(_item) \ |
| 363 | for (_item = FIB_ENTRY_FLAG_FIRST; _item < FIB_ENTRY_FLAG_MAX; _item++) |
| 364 | |
| 365 | #define FIB_ENTRY_FORMAT_BRIEF (0x0) |
| 366 | #define FIB_ENTRY_FORMAT_DETAIL (0x1) |
| 367 | #define FIB_ENTRY_FORMAT_DETAIL2 (0x2) |
| 368 | |
| 369 | extern u8 *format_fib_entry (u8 * s, va_list * args); |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 370 | extern u8 *format_fib_source (u8 * s, va_list * args); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 371 | |
| 372 | extern fib_node_index_t fib_entry_create_special(u32 fib_index, |
| 373 | const fib_prefix_t *prefix, |
| 374 | fib_source_t source, |
| 375 | fib_entry_flag_t flags, |
| 376 | const dpo_id_t *dpo); |
| 377 | |
| 378 | extern fib_node_index_t fib_entry_create (u32 fib_index, |
| 379 | const fib_prefix_t *prefix, |
| 380 | fib_source_t source, |
| 381 | fib_entry_flag_t flags, |
| 382 | const fib_route_path_t *paths); |
| 383 | extern void fib_entry_update (fib_node_index_t fib_entry_index, |
| 384 | fib_source_t source, |
| 385 | fib_entry_flag_t flags, |
| 386 | const fib_route_path_t *paths); |
| 387 | |
| 388 | extern void fib_entry_path_add(fib_node_index_t fib_entry_index, |
| 389 | fib_source_t source, |
| 390 | fib_entry_flag_t flags, |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 391 | const fib_route_path_t *rpaths); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 392 | extern void fib_entry_special_add(fib_node_index_t fib_entry_index, |
| 393 | fib_source_t source, |
| 394 | fib_entry_flag_t flags, |
| 395 | const dpo_id_t *dpo); |
Neale Ranns | 948e00f | 2016-10-20 13:39:34 +0100 | [diff] [blame] | 396 | extern void fib_entry_special_update(fib_node_index_t fib_entry_index, |
| 397 | fib_source_t source, |
| 398 | fib_entry_flag_t flags, |
| 399 | const dpo_id_t *dpo); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 400 | extern fib_entry_src_flag_t fib_entry_special_remove(fib_node_index_t fib_entry_index, |
| 401 | fib_source_t source); |
| 402 | |
| 403 | extern fib_entry_src_flag_t fib_entry_path_remove(fib_node_index_t fib_entry_index, |
| 404 | fib_source_t source, |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 405 | const fib_route_path_t *rpaths); |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 406 | |
| 407 | extern void fib_entry_inherit(fib_node_index_t cover, |
| 408 | fib_node_index_t covered); |
| 409 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 410 | extern fib_entry_src_flag_t fib_entry_delete(fib_node_index_t fib_entry_index, |
| 411 | fib_source_t source); |
| 412 | |
Neale Ranns | 2303cb1 | 2018-02-21 04:57:17 -0800 | [diff] [blame] | 413 | extern void fib_entry_recalculate_forwarding( |
| 414 | fib_node_index_t fib_entry_index); |
Neale Ranns | 3ee4404 | 2016-10-03 13:05:48 +0100 | [diff] [blame] | 415 | extern void fib_entry_contribute_urpf(fib_node_index_t path_index, |
| 416 | index_t urpf); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 417 | extern void fib_entry_contribute_forwarding( |
| 418 | fib_node_index_t fib_entry_index, |
| 419 | fib_forward_chain_type_t type, |
| 420 | dpo_id_t *dpo); |
| 421 | extern const dpo_id_t * fib_entry_contribute_ip_forwarding( |
| 422 | fib_node_index_t fib_entry_index); |
| 423 | extern adj_index_t fib_entry_get_adj_for_source( |
| 424 | fib_node_index_t fib_entry_index, |
| 425 | fib_source_t source); |
| 426 | extern const int fib_entry_get_dpo_for_source ( |
| 427 | fib_node_index_t fib_entry_index, |
| 428 | fib_source_t source, |
| 429 | dpo_id_t *dpo); |
Damjan Marion | 9260b88 | 2022-10-04 18:08:51 +0200 | [diff] [blame] | 430 | extern fib_node_index_t fib_entry_get_path_list_for_source ( |
| 431 | fib_node_index_t fib_entry_index, |
| 432 | fib_source_t source); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 433 | |
| 434 | extern adj_index_t fib_entry_get_adj(fib_node_index_t fib_entry_index); |
| 435 | |
| 436 | extern int fib_entry_cmp_for_sort(void *i1, void *i2); |
| 437 | |
| 438 | extern void fib_entry_cover_changed(fib_node_index_t fib_entry); |
| 439 | extern void fib_entry_cover_updated(fib_node_index_t fib_entry); |
| 440 | extern int fib_entry_recursive_loop_detect(fib_node_index_t entry_index, |
| 441 | fib_node_index_t **entry_indicies); |
| 442 | |
| 443 | extern void fib_entry_lock(fib_node_index_t fib_entry_index); |
| 444 | extern void fib_entry_unlock(fib_node_index_t fib_entry_index); |
| 445 | |
| 446 | extern u32 fib_entry_child_add(fib_node_index_t fib_entry_index, |
| 447 | fib_node_type_t type, |
| 448 | fib_node_index_t child_index); |
| 449 | extern void fib_entry_child_remove(fib_node_index_t fib_entry_index, |
| 450 | u32 sibling_index); |
| 451 | extern u32 fib_entry_get_resolving_interface(fib_node_index_t fib_entry_index); |
Neale Ranns | cc4f7e1 | 2020-10-26 10:44:54 +0000 | [diff] [blame] | 452 | extern u32 fib_entry_get_any_resolving_interface(fib_node_index_t fib_entry_index); |
Neale Ranns | df089a8 | 2016-10-02 16:39:06 +0100 | [diff] [blame] | 453 | extern u32 fib_entry_get_resolving_interface_for_source( |
| 454 | fib_node_index_t fib_entry_index, |
| 455 | fib_source_t source); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 456 | |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 457 | extern fib_route_path_t* fib_entry_encode(fib_node_index_t fib_entry_index); |
| 458 | extern const fib_prefix_t* fib_entry_get_prefix(fib_node_index_t fib_entry_index); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 459 | extern u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index); |
| 460 | extern void fib_entry_set_source_data(fib_node_index_t fib_entry_index, |
| 461 | fib_source_t source, |
| 462 | const void *data); |
| 463 | extern const void* fib_entry_get_source_data(fib_node_index_t fib_entry_index, |
| 464 | fib_source_t source); |
| 465 | |
| 466 | extern fib_entry_flag_t fib_entry_get_flags(fib_node_index_t fib_entry_index); |
Neale Ranns | df089a8 | 2016-10-02 16:39:06 +0100 | [diff] [blame] | 467 | extern fib_entry_flag_t fib_entry_get_flags_for_source( |
| 468 | fib_node_index_t fib_entry_index, |
| 469 | fib_source_t source); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 470 | extern fib_source_t fib_entry_get_best_source(fib_node_index_t fib_entry_index); |
| 471 | extern int fib_entry_is_sourced(fib_node_index_t fib_entry_index, |
| 472 | fib_source_t source); |
| 473 | |
| 474 | extern fib_node_index_t fib_entry_get_path_list(fib_node_index_t fib_entry_index); |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 475 | extern int fib_entry_is_resolved(fib_node_index_t fib_entry_index); |
Neale Ranns | 56f949b | 2018-04-25 01:41:24 -0700 | [diff] [blame] | 476 | extern int fib_entry_is_host(fib_node_index_t fib_entry_index); |
Neale Ranns | 9db6ada | 2019-11-08 12:42:31 +0000 | [diff] [blame] | 477 | extern int fib_entry_is_marked(fib_node_index_t fib_entry_index, fib_source_t source); |
| 478 | extern void fib_entry_mark(fib_node_index_t fib_entry_index, fib_source_t source); |
Neale Ranns | 227038a | 2017-04-21 01:07:59 -0700 | [diff] [blame] | 479 | extern void fib_entry_set_flow_hash_config(fib_node_index_t fib_entry_index, |
| 480 | flow_hash_config_t hash_config); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 481 | |
| 482 | extern void fib_entry_module_init(void); |
| 483 | |
Neale Ranns | 008dbe1 | 2018-09-07 09:32:36 -0700 | [diff] [blame] | 484 | extern u32 fib_entry_get_stats_index(fib_node_index_t fib_entry_index); |
| 485 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 486 | /* |
| 487 | * unsafe... beware the raw pointer. |
| 488 | */ |
| 489 | extern fib_node_index_t fib_entry_get_index(const fib_entry_t * fib_entry); |
| 490 | extern fib_entry_t * fib_entry_get(fib_node_index_t fib_entry_index); |
| 491 | |
| 492 | /* |
| 493 | * for testing purposes. |
| 494 | */ |
| 495 | extern u32 fib_entry_pool_size(void); |
| 496 | |
| 497 | #endif |