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 | #include <vnet/fib/fib_table.h> |
| 17 | #include <vnet/fib/fib_entry.h> |
| 18 | #include <vnet/fib/ip4_fib.h> |
| 19 | |
| 20 | /* |
Lijian.Zhang | 33af8c1 | 2019-09-16 16:22:36 +0800 | [diff] [blame] | 21 | * A table of prefixes to be added to tables and the sources for them |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 22 | */ |
| 23 | typedef struct ip4_fib_table_special_prefix_t_ { |
| 24 | fib_prefix_t ift_prefix; |
| 25 | fib_source_t ift_source; |
| 26 | fib_entry_flag_t ift_flag; |
| 27 | } ip4_fib_table_special_prefix_t; |
| 28 | |
| 29 | static const ip4_fib_table_special_prefix_t ip4_specials[] = { |
| 30 | { |
| 31 | /* 0.0.0.0/0*/ |
| 32 | .ift_prefix = { |
| 33 | .fp_addr = { |
| 34 | .ip4.data_u32 = 0, |
| 35 | }, |
| 36 | .fp_len = 0, |
| 37 | .fp_proto = FIB_PROTOCOL_IP4, |
| 38 | }, |
| 39 | .ift_source = FIB_SOURCE_DEFAULT_ROUTE, |
| 40 | .ift_flag = FIB_ENTRY_FLAG_DROP, |
| 41 | }, |
| 42 | { |
| 43 | /* 0.0.0.0/32*/ |
| 44 | .ift_prefix = { |
| 45 | .fp_addr = { |
| 46 | .ip4.data_u32 = 0, |
| 47 | }, |
| 48 | .fp_len = 32, |
| 49 | .fp_proto = FIB_PROTOCOL_IP4, |
| 50 | }, |
| 51 | .ift_source = FIB_SOURCE_DEFAULT_ROUTE, |
| 52 | .ift_flag = FIB_ENTRY_FLAG_DROP, |
| 53 | }, |
| 54 | { |
| 55 | /* |
Neale Ranns | 86fb04d | 2016-12-01 17:03:25 +0000 | [diff] [blame] | 56 | * 240.0.0.0/4 |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 57 | * drop class E |
| 58 | */ |
| 59 | .ift_prefix = { |
| 60 | .fp_addr = { |
| 61 | .ip4.data_u32 = 0xf0000000, |
| 62 | }, |
Neale Ranns | 86fb04d | 2016-12-01 17:03:25 +0000 | [diff] [blame] | 63 | .fp_len = 4, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 64 | .fp_proto = FIB_PROTOCOL_IP4, |
| 65 | }, |
| 66 | .ift_source = FIB_SOURCE_SPECIAL, |
| 67 | .ift_flag = FIB_ENTRY_FLAG_DROP, |
| 68 | |
| 69 | }, |
| 70 | { |
| 71 | /* |
Neale Ranns | 86fb04d | 2016-12-01 17:03:25 +0000 | [diff] [blame] | 72 | * 224.0.0.0/4 |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 73 | * drop all mcast |
| 74 | */ |
| 75 | .ift_prefix = { |
| 76 | .fp_addr = { |
| 77 | .ip4.data_u32 = 0xe0000000, |
| 78 | }, |
Neale Ranns | 86fb04d | 2016-12-01 17:03:25 +0000 | [diff] [blame] | 79 | .fp_len = 4, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 80 | .fp_proto = FIB_PROTOCOL_IP4, |
| 81 | }, |
| 82 | .ift_source = FIB_SOURCE_SPECIAL, |
| 83 | .ift_flag = FIB_ENTRY_FLAG_DROP, |
| 84 | }, |
| 85 | { |
| 86 | /* |
| 87 | * 255.255.255.255/32 |
| 88 | * drop, but we'll allow it to be usurped by the likes of DHCP |
| 89 | */ |
| 90 | .ift_prefix = { |
| 91 | .fp_addr = { |
| 92 | .ip4.data_u32 = 0xffffffff, |
| 93 | }, |
| 94 | .fp_len = 32, |
| 95 | .fp_proto = FIB_PROTOCOL_IP4, |
| 96 | }, |
| 97 | .ift_source = FIB_SOURCE_DEFAULT_ROUTE, |
| 98 | .ift_flag = FIB_ENTRY_FLAG_DROP, |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | static u32 |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 104 | ip4_create_fib_with_table_id (u32 table_id, |
| 105 | fib_source_t src) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 106 | { |
| 107 | fib_table_t *fib_table; |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 108 | ip4_fib_t *v4_fib; |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 109 | void *old_heap; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 110 | |
Dave Barach | eb987d3 | 2018-05-03 08:26:39 -0400 | [diff] [blame] | 111 | pool_get(ip4_main.fibs, fib_table); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 112 | clib_memset(fib_table, 0, sizeof(*fib_table)); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 113 | |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 114 | old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap); |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 115 | pool_get_aligned(ip4_main.v4_fibs, v4_fib, CLIB_CACHE_LINE_BYTES); |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 116 | clib_mem_set_heap (old_heap); |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 117 | |
| 118 | ASSERT((fib_table - ip4_main.fibs) == |
| 119 | (v4_fib - ip4_main.v4_fibs)); |
| 120 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 121 | fib_table->ft_proto = FIB_PROTOCOL_IP4; |
| 122 | fib_table->ft_index = |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 123 | v4_fib->index = |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 124 | (fib_table - ip4_main.fibs); |
| 125 | |
| 126 | hash_set (ip4_main.fib_index_by_table_id, table_id, fib_table->ft_index); |
| 127 | |
| 128 | fib_table->ft_table_id = |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 129 | v4_fib->table_id = |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 130 | table_id; |
Neale Ranns | 227038a | 2017-04-21 01:07:59 -0700 | [diff] [blame] | 131 | fib_table->ft_flow_hash_config = IP_FLOW_HASH_DEFAULT; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 132 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 133 | fib_table_lock(fib_table->ft_index, FIB_PROTOCOL_IP4, src); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 134 | |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 135 | ip4_mtrie_init(&v4_fib->mtrie); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 136 | |
| 137 | /* |
| 138 | * add the special entries into the new FIB |
| 139 | */ |
| 140 | int ii; |
| 141 | |
| 142 | for (ii = 0; ii < ARRAY_LEN(ip4_specials); ii++) |
| 143 | { |
| 144 | fib_prefix_t prefix = ip4_specials[ii].ift_prefix; |
| 145 | |
| 146 | prefix.fp_addr.ip4.data_u32 = |
| 147 | clib_host_to_net_u32(prefix.fp_addr.ip4.data_u32); |
| 148 | |
| 149 | fib_table_entry_special_add(fib_table->ft_index, |
| 150 | &prefix, |
| 151 | ip4_specials[ii].ift_source, |
Neale Ranns | a055830 | 2017-04-13 00:44:52 -0700 | [diff] [blame] | 152 | ip4_specials[ii].ift_flag); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | return (fib_table->ft_index); |
| 156 | } |
| 157 | |
| 158 | void |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 159 | ip4_fib_table_destroy (u32 fib_index) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 160 | { |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 161 | fib_table_t *fib_table = pool_elt_at_index(ip4_main.fibs, fib_index); |
| 162 | ip4_fib_t *v4_fib = pool_elt_at_index(ip4_main.v4_fibs, fib_index); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 163 | int ii; |
| 164 | |
| 165 | /* |
| 166 | * remove all the specials we added when the table was created. |
Neale Ranns | 04a75e3 | 2017-03-23 06:46:01 -0700 | [diff] [blame] | 167 | * In reverse order so the default route is last. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 168 | */ |
Neale Ranns | 04a75e3 | 2017-03-23 06:46:01 -0700 | [diff] [blame] | 169 | for (ii = ARRAY_LEN(ip4_specials) - 1; ii >= 0; ii--) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 170 | { |
| 171 | fib_prefix_t prefix = ip4_specials[ii].ift_prefix; |
| 172 | |
| 173 | prefix.fp_addr.ip4.data_u32 = |
| 174 | clib_host_to_net_u32(prefix.fp_addr.ip4.data_u32); |
| 175 | |
| 176 | fib_table_entry_special_remove(fib_table->ft_index, |
| 177 | &prefix, |
| 178 | ip4_specials[ii].ift_source); |
| 179 | } |
| 180 | |
| 181 | /* |
| 182 | * validate no more routes. |
| 183 | */ |
| 184 | ASSERT(0 == fib_table->ft_total_route_counts); |
| 185 | FOR_EACH_FIB_SOURCE(ii) |
| 186 | { |
| 187 | ASSERT(0 == fib_table->ft_src_route_counts[ii]); |
| 188 | } |
| 189 | |
| 190 | if (~0 != fib_table->ft_table_id) |
| 191 | { |
| 192 | hash_unset (ip4_main.fib_index_by_table_id, fib_table->ft_table_id); |
| 193 | } |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 194 | |
| 195 | ip4_mtrie_free(&v4_fib->mtrie); |
| 196 | |
| 197 | pool_put(ip4_main.v4_fibs, v4_fib); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 198 | pool_put(ip4_main.fibs, fib_table); |
| 199 | } |
| 200 | |
| 201 | |
| 202 | u32 |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 203 | ip4_fib_table_find_or_create_and_lock (u32 table_id, |
| 204 | fib_source_t src) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 205 | { |
| 206 | u32 index; |
| 207 | |
| 208 | index = ip4_fib_index_from_table_id(table_id); |
| 209 | if (~0 == index) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 210 | return ip4_create_fib_with_table_id(table_id, src); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 211 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 212 | fib_table_lock(index, FIB_PROTOCOL_IP4, src); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 213 | |
| 214 | return (index); |
| 215 | } |
| 216 | |
| 217 | u32 |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 218 | ip4_fib_table_create_and_lock (fib_source_t src) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 219 | { |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 220 | return (ip4_create_fib_with_table_id(~0, src)); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | u32 |
| 224 | ip4_fib_table_get_index_for_sw_if_index (u32 sw_if_index) |
| 225 | { |
| 226 | if (sw_if_index >= vec_len(ip4_main.fib_index_by_sw_if_index)) |
| 227 | { |
| 228 | /* |
| 229 | * This is the case for interfaces that are not yet mapped to |
| 230 | * a IP table |
| 231 | */ |
| 232 | return (~0); |
| 233 | } |
| 234 | return (ip4_main.fib_index_by_sw_if_index[sw_if_index]); |
| 235 | } |
| 236 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 237 | /* |
| 238 | * ip4_fib_table_lookup_exact_match |
| 239 | * |
| 240 | * Exact match prefix lookup |
| 241 | */ |
| 242 | fib_node_index_t |
| 243 | ip4_fib_table_lookup_exact_match (const ip4_fib_t *fib, |
| 244 | const ip4_address_t *addr, |
| 245 | u32 len) |
| 246 | { |
| 247 | uword * hash, * result; |
| 248 | u32 key; |
| 249 | |
| 250 | hash = fib->fib_entry_by_dst_address[len]; |
| 251 | key = (addr->data_u32 & ip4_main.fib_masks[len]); |
| 252 | |
| 253 | result = hash_get(hash, key); |
| 254 | |
| 255 | if (NULL != result) { |
| 256 | return (result[0]); |
| 257 | } |
| 258 | return (FIB_NODE_INDEX_INVALID); |
| 259 | } |
| 260 | |
| 261 | /* |
| 262 | * ip4_fib_table_lookup_adj |
| 263 | * |
| 264 | * Longest prefix match |
| 265 | */ |
| 266 | index_t |
| 267 | ip4_fib_table_lookup_lb (ip4_fib_t *fib, |
| 268 | const ip4_address_t *addr) |
| 269 | { |
| 270 | fib_node_index_t fei; |
| 271 | |
| 272 | fei = ip4_fib_table_lookup(fib, addr, 32); |
| 273 | |
| 274 | if (FIB_NODE_INDEX_INVALID != fei) |
| 275 | { |
| 276 | const dpo_id_t *dpo; |
| 277 | |
| 278 | dpo = fib_entry_contribute_ip_forwarding(fei); |
| 279 | |
| 280 | return (dpo->dpoi_index); |
| 281 | } |
| 282 | return (INDEX_INVALID); |
| 283 | } |
| 284 | |
| 285 | /* |
| 286 | * ip4_fib_table_lookup |
| 287 | * |
| 288 | * Longest prefix match |
| 289 | */ |
| 290 | fib_node_index_t |
| 291 | ip4_fib_table_lookup (const ip4_fib_t *fib, |
| 292 | const ip4_address_t *addr, |
| 293 | u32 len) |
| 294 | { |
| 295 | uword * hash, * result; |
| 296 | i32 mask_len; |
| 297 | u32 key; |
| 298 | |
| 299 | for (mask_len = len; mask_len >= 0; mask_len--) |
| 300 | { |
| 301 | hash = fib->fib_entry_by_dst_address[mask_len]; |
| 302 | key = (addr->data_u32 & ip4_main.fib_masks[mask_len]); |
| 303 | |
| 304 | result = hash_get (hash, key); |
| 305 | |
| 306 | if (NULL != result) { |
| 307 | return (result[0]); |
| 308 | } |
| 309 | } |
| 310 | return (FIB_NODE_INDEX_INVALID); |
| 311 | } |
| 312 | |
| 313 | void |
| 314 | ip4_fib_table_entry_insert (ip4_fib_t *fib, |
| 315 | const ip4_address_t *addr, |
| 316 | u32 len, |
| 317 | fib_node_index_t fib_entry_index) |
| 318 | { |
| 319 | uword * hash, * result; |
| 320 | u32 key; |
| 321 | |
| 322 | key = (addr->data_u32 & ip4_main.fib_masks[len]); |
| 323 | hash = fib->fib_entry_by_dst_address[len]; |
| 324 | result = hash_get (hash, key); |
| 325 | |
| 326 | if (NULL == result) { |
| 327 | /* |
| 328 | * adding a new entry |
| 329 | */ |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 330 | uword *old_heap; |
| 331 | old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap); |
| 332 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 333 | if (NULL == hash) { |
| 334 | hash = hash_create (32 /* elts */, sizeof (uword)); |
| 335 | hash_set_flags (hash, HASH_FLAG_NO_AUTO_SHRINK); |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 336 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 337 | } |
| 338 | hash = hash_set(hash, key, fib_entry_index); |
| 339 | fib->fib_entry_by_dst_address[len] = hash; |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 340 | clib_mem_set_heap (old_heap); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 341 | } |
| 342 | else |
| 343 | { |
| 344 | ASSERT(0); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | void |
| 349 | ip4_fib_table_entry_remove (ip4_fib_t *fib, |
| 350 | const ip4_address_t *addr, |
| 351 | u32 len) |
| 352 | { |
| 353 | uword * hash, * result; |
| 354 | u32 key; |
| 355 | |
| 356 | key = (addr->data_u32 & ip4_main.fib_masks[len]); |
| 357 | hash = fib->fib_entry_by_dst_address[len]; |
| 358 | result = hash_get (hash, key); |
| 359 | |
| 360 | if (NULL == result) |
| 361 | { |
| 362 | /* |
Jim Thompson | f324dec | 2019-04-08 03:22:21 -0500 | [diff] [blame] | 363 | * removing a non-existent entry. i'll allow it. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 364 | */ |
| 365 | } |
| 366 | else |
| 367 | { |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 368 | uword *old_heap; |
| 369 | |
| 370 | old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 371 | hash_unset(hash, key); |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 372 | clib_mem_set_heap (old_heap); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | fib->fib_entry_by_dst_address[len] = hash; |
| 376 | } |
| 377 | |
| 378 | void |
| 379 | ip4_fib_table_fwding_dpo_update (ip4_fib_t *fib, |
| 380 | const ip4_address_t *addr, |
| 381 | u32 len, |
| 382 | const dpo_id_t *dpo) |
| 383 | { |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 384 | ip4_fib_mtrie_route_add(&fib->mtrie, addr, len, dpo->dpoi_index); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | void |
| 388 | ip4_fib_table_fwding_dpo_remove (ip4_fib_t *fib, |
| 389 | const ip4_address_t *addr, |
| 390 | u32 len, |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 391 | const dpo_id_t *dpo, |
| 392 | u32 cover_index) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 393 | { |
Neale Ranns | c5d4317 | 2018-07-30 08:04:40 -0700 | [diff] [blame] | 394 | const fib_prefix_t *cover_prefix; |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 395 | const dpo_id_t *cover_dpo; |
| 396 | |
| 397 | /* |
| 398 | * We need to pass the MTRIE the LB index and address length of the |
| 399 | * covering prefix, so it can fill the plys with the correct replacement |
| 400 | * for the entry being removed |
| 401 | */ |
Neale Ranns | c5d4317 | 2018-07-30 08:04:40 -0700 | [diff] [blame] | 402 | cover_prefix = fib_entry_get_prefix(cover_index); |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 403 | cover_dpo = fib_entry_contribute_ip_forwarding(cover_index); |
| 404 | |
| 405 | ip4_fib_mtrie_route_del(&fib->mtrie, |
| 406 | addr, len, dpo->dpoi_index, |
Neale Ranns | c5d4317 | 2018-07-30 08:04:40 -0700 | [diff] [blame] | 407 | cover_prefix->fp_len, |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 408 | cover_dpo->dpoi_index); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 409 | } |
| 410 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 411 | void |
| 412 | ip4_fib_table_walk (ip4_fib_t *fib, |
| 413 | fib_table_walk_fn_t fn, |
| 414 | void *ctx) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 415 | { |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 416 | fib_prefix_t root = { |
| 417 | .fp_proto = FIB_PROTOCOL_IP4, |
| 418 | // address and length default to all 0 |
| 419 | }; |
| 420 | |
| 421 | /* |
| 422 | * A full tree walk is the dengenerate case of a sub-tree from |
| 423 | * the very root |
| 424 | */ |
| 425 | return (ip4_fib_table_sub_tree_walk(fib, &root, fn, ctx)); |
| 426 | } |
| 427 | |
| 428 | void |
| 429 | ip4_fib_table_sub_tree_walk (ip4_fib_t *fib, |
| 430 | const fib_prefix_t *root, |
| 431 | fib_table_walk_fn_t fn, |
| 432 | void *ctx) |
| 433 | { |
| 434 | fib_prefix_t *sub_trees = NULL; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 435 | int i; |
| 436 | |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 437 | /* |
Lijian.Zhang | 33af8c1 | 2019-09-16 16:22:36 +0800 | [diff] [blame] | 438 | * There is no efficient way to walk this array of hash tables. |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 439 | * so we walk each table with a mask length greater than and equal to |
| 440 | * the required root and check it is covered by the root. |
| 441 | */ |
| 442 | for (i = root->fp_len; |
| 443 | i < ARRAY_LEN (fib->fib_entry_by_dst_address); |
| 444 | i++) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 445 | { |
| 446 | uword * hash = fib->fib_entry_by_dst_address[i]; |
| 447 | |
| 448 | if (NULL != hash) |
| 449 | { |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 450 | ip4_address_t key; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 451 | hash_pair_t * p; |
| 452 | |
| 453 | hash_foreach_pair (p, hash, |
| 454 | ({ |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 455 | key.as_u32 = p->key; |
| 456 | if (ip4_destination_matches_route(&ip4_main, |
| 457 | &key, |
| 458 | &root->fp_addr.ip4, |
| 459 | root->fp_len)) |
| 460 | { |
| 461 | const fib_prefix_t *sub_tree; |
| 462 | int skip = 0; |
| 463 | |
| 464 | /* |
| 465 | * exclude sub-trees the walk does not want to explore |
| 466 | */ |
| 467 | vec_foreach(sub_tree, sub_trees) |
| 468 | { |
| 469 | if (ip4_destination_matches_route(&ip4_main, |
| 470 | &key, |
| 471 | &sub_tree->fp_addr.ip4, |
| 472 | sub_tree->fp_len)) |
| 473 | { |
| 474 | skip = 1; |
| 475 | break; |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | if (!skip) |
| 480 | { |
| 481 | switch (fn(p->value[0], ctx)) |
| 482 | { |
| 483 | case FIB_TABLE_WALK_CONTINUE: |
| 484 | break; |
| 485 | case FIB_TABLE_WALK_SUB_TREE_STOP: { |
| 486 | fib_prefix_t pfx = { |
| 487 | .fp_proto = FIB_PROTOCOL_IP4, |
| 488 | .fp_len = i, |
| 489 | .fp_addr.ip4 = key, |
| 490 | }; |
| 491 | vec_add1(sub_trees, pfx); |
| 492 | break; |
| 493 | } |
| 494 | case FIB_TABLE_WALK_STOP: |
| 495 | goto done; |
| 496 | } |
| 497 | } |
| 498 | } |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 499 | })); |
| 500 | } |
| 501 | } |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 502 | done: |
| 503 | vec_free(sub_trees); |
| 504 | return; |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 505 | } |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 506 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 507 | /** |
| 508 | * Walk show context |
| 509 | */ |
| 510 | typedef struct ip4_fib_show_walk_ctx_t_ |
| 511 | { |
| 512 | fib_node_index_t *ifsw_indicies; |
| 513 | } ip4_fib_show_walk_ctx_t; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 514 | |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 515 | static fib_table_walk_rc_t |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 516 | ip4_fib_show_walk_cb (fib_node_index_t fib_entry_index, |
| 517 | void *arg) |
| 518 | { |
| 519 | ip4_fib_show_walk_ctx_t *ctx = arg; |
| 520 | |
| 521 | vec_add1(ctx->ifsw_indicies, fib_entry_index); |
| 522 | |
Neale Ranns | 8954199 | 2017-04-06 04:41:02 -0700 | [diff] [blame] | 523 | return (FIB_TABLE_WALK_CONTINUE); |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | static void |
| 527 | ip4_fib_table_show_all (ip4_fib_t *fib, |
| 528 | vlib_main_t * vm) |
| 529 | { |
| 530 | ip4_fib_show_walk_ctx_t ctx = { |
| 531 | .ifsw_indicies = NULL, |
| 532 | }; |
| 533 | fib_node_index_t *fib_entry_index; |
| 534 | |
| 535 | ip4_fib_table_walk(fib, ip4_fib_show_walk_cb, &ctx); |
| 536 | vec_sort_with_function(ctx.ifsw_indicies, |
| 537 | fib_entry_cmp_for_sort); |
| 538 | |
| 539 | vec_foreach(fib_entry_index, ctx.ifsw_indicies) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 540 | { |
| 541 | vlib_cli_output(vm, "%U", |
| 542 | format_fib_entry, |
| 543 | *fib_entry_index, |
| 544 | FIB_ENTRY_FORMAT_BRIEF); |
| 545 | } |
| 546 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 547 | vec_free(ctx.ifsw_indicies); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | static void |
| 551 | ip4_fib_table_show_one (ip4_fib_t *fib, |
| 552 | vlib_main_t * vm, |
| 553 | ip4_address_t *address, |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 554 | u32 mask_len, |
| 555 | int detail) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 556 | { |
| 557 | vlib_cli_output(vm, "%U", |
| 558 | format_fib_entry, |
| 559 | ip4_fib_table_lookup(fib, address, mask_len), |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 560 | (detail ? |
| 561 | FIB_ENTRY_FORMAT_DETAIL2 : |
| 562 | FIB_ENTRY_FORMAT_DETAIL)); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 563 | } |
| 564 | |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 565 | u8 * |
| 566 | format_ip4_fib_table_memory (u8 * s, va_list * args) |
| 567 | { |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame] | 568 | #if USE_DLMALLOC == 0 |
Neale Ranns | 05cac30 | 2019-05-28 11:09:40 +0000 | [diff] [blame] | 569 | s = format(s, "%=30s %=6d %=12ld\n", |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 570 | "IPv4 unicast", |
Neale Ranns | 1ec3652 | 2017-11-29 05:20:37 -0800 | [diff] [blame] | 571 | pool_elts(ip4_main.fibs), |
| 572 | mheap_bytes(ip4_main.mtrie_mheap)); |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame] | 573 | #else |
Neale Ranns | 05cac30 | 2019-05-28 11:09:40 +0000 | [diff] [blame] | 574 | s = format(s, "%=30s %=6d %=12ld\n", |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame] | 575 | "IPv4 unicast", |
| 576 | pool_elts(ip4_main.fibs), |
| 577 | mspace_footprint(ip4_main.mtrie_mheap)); |
| 578 | #endif |
| 579 | |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 580 | |
| 581 | return (s); |
| 582 | } |
| 583 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 584 | static clib_error_t * |
| 585 | ip4_show_fib (vlib_main_t * vm, |
| 586 | unformat_input_t * input, |
| 587 | vlib_cli_command_t * cmd) |
| 588 | { |
| 589 | ip4_main_t * im4 = &ip4_main; |
| 590 | fib_table_t * fib_table; |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 591 | u64 total_mtrie_memory, total_hash_memory; |
| 592 | int verbose, matching, mtrie, memory; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 593 | ip4_address_t matching_address; |
| 594 | u32 matching_mask = 32; |
| 595 | int i, table_id = -1, fib_index = ~0; |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 596 | int detail = 0; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 597 | |
| 598 | verbose = 1; |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 599 | matching = mtrie = memory = 0; |
| 600 | total_hash_memory = total_mtrie_memory = 0; |
| 601 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 602 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 603 | { |
| 604 | if (unformat (input, "brief") || unformat (input, "summary") |
| 605 | || unformat (input, "sum")) |
| 606 | verbose = 0; |
| 607 | |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 608 | else if (unformat (input, "detail") || unformat (input, "det")) |
| 609 | detail = 1; |
| 610 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 611 | else if (unformat (input, "mtrie")) |
| 612 | mtrie = 1; |
| 613 | |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 614 | else if (unformat (input, "mem") || |
| 615 | unformat (input, "memory")) |
| 616 | memory = 1; |
| 617 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 618 | else if (unformat (input, "%U/%d", |
| 619 | unformat_ip4_address, &matching_address, &matching_mask)) |
| 620 | matching = 1; |
| 621 | |
| 622 | else if (unformat (input, "%U", unformat_ip4_address, &matching_address)) |
| 623 | matching = 1; |
| 624 | |
| 625 | else if (unformat (input, "table %d", &table_id)) |
| 626 | ; |
| 627 | else if (unformat (input, "index %d", &fib_index)) |
| 628 | ; |
| 629 | else |
| 630 | break; |
| 631 | } |
| 632 | |
| 633 | pool_foreach (fib_table, im4->fibs, |
| 634 | ({ |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 635 | ip4_fib_t *fib = pool_elt_at_index(im4->v4_fibs, fib_table->ft_index); |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 636 | fib_source_t source; |
| 637 | u8 *s = NULL; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 638 | |
| 639 | if (table_id >= 0 && table_id != (int)fib->table_id) |
| 640 | continue; |
| 641 | if (fib_index != ~0 && fib_index != (int)fib->index) |
| 642 | continue; |
| 643 | |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 644 | if (memory) |
| 645 | { |
Lollita Liu | e18b45c | 2019-01-11 05:23:12 -0500 | [diff] [blame] | 646 | uword mtrie_size, hash_size, *old_heap; |
| 647 | |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 648 | |
| 649 | mtrie_size = ip4_fib_mtrie_memory_usage(&fib->mtrie); |
| 650 | hash_size = 0; |
| 651 | |
Lollita Liu | e18b45c | 2019-01-11 05:23:12 -0500 | [diff] [blame] | 652 | old_heap = clib_mem_set_heap (ip4_main.mtrie_mheap); |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 653 | for (i = 0; i < ARRAY_LEN (fib->fib_entry_by_dst_address); i++) |
| 654 | { |
| 655 | uword * hash = fib->fib_entry_by_dst_address[i]; |
| 656 | if (NULL != hash) |
| 657 | { |
| 658 | hash_size += hash_bytes(hash); |
| 659 | } |
| 660 | } |
Lollita Liu | e18b45c | 2019-01-11 05:23:12 -0500 | [diff] [blame] | 661 | clib_mem_set_heap (old_heap); |
| 662 | |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 663 | if (verbose) |
| 664 | vlib_cli_output (vm, "%U mtrie:%d hash:%d", |
| 665 | format_fib_table_name, fib->index, |
| 666 | FIB_PROTOCOL_IP4, |
| 667 | mtrie_size, |
| 668 | hash_size); |
| 669 | total_mtrie_memory += mtrie_size; |
| 670 | total_hash_memory += hash_size; |
| 671 | continue; |
| 672 | } |
| 673 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 674 | s = format(s, "%U, fib_index:%d, flow hash:[%U] locks:[", |
| 675 | format_fib_table_name, fib->index, |
| 676 | FIB_PROTOCOL_IP4, |
| 677 | fib->index, |
| 678 | format_ip_flow_hash_config, |
| 679 | fib_table->ft_flow_hash_config); |
| 680 | FOR_EACH_FIB_SOURCE(source) |
| 681 | { |
| 682 | if (0 != fib_table->ft_locks[source]) |
| 683 | { |
| 684 | s = format(s, "%U:%d, ", |
| 685 | format_fib_source, source, |
| 686 | fib_table->ft_locks[source]); |
| 687 | } |
| 688 | } |
| 689 | s = format (s, "]"); |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 690 | vlib_cli_output (vm, "%v", s); |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 691 | vec_free(s); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 692 | |
| 693 | /* Show summary? */ |
Neale Ranns | 3919425 | 2017-11-27 01:03:25 -0800 | [diff] [blame] | 694 | if (mtrie) |
| 695 | { |
| 696 | vlib_cli_output (vm, "%U", format_ip4_fib_mtrie, &fib->mtrie, verbose); |
| 697 | continue; |
| 698 | } |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 699 | if (! verbose) |
| 700 | { |
| 701 | vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count"); |
| 702 | for (i = 0; i < ARRAY_LEN (fib->fib_entry_by_dst_address); i++) |
| 703 | { |
| 704 | uword * hash = fib->fib_entry_by_dst_address[i]; |
| 705 | uword n_elts = hash_elts (hash); |
| 706 | if (n_elts > 0) |
| 707 | vlib_cli_output (vm, "%20d%16d", i, n_elts); |
| 708 | } |
| 709 | continue; |
| 710 | } |
| 711 | |
| 712 | if (!matching) |
| 713 | { |
| 714 | ip4_fib_table_show_all(fib, vm); |
| 715 | } |
| 716 | else |
| 717 | { |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 718 | ip4_fib_table_show_one(fib, vm, &matching_address, |
| 719 | matching_mask, detail); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 720 | } |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 721 | })); |
| 722 | |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 723 | if (memory) |
Lollita Liu | e18b45c | 2019-01-11 05:23:12 -0500 | [diff] [blame] | 724 | { |
Neale Ranns | c87aafa | 2017-11-29 00:59:31 -0800 | [diff] [blame] | 725 | vlib_cli_output (vm, "totals: mtrie:%ld hash:%ld all:%ld", |
| 726 | total_mtrie_memory, |
| 727 | total_hash_memory, |
| 728 | total_mtrie_memory + total_hash_memory); |
Lollita Liu | e18b45c | 2019-01-11 05:23:12 -0500 | [diff] [blame] | 729 | vlib_cli_output (vm, "\nMtrie Mheap Usage: %U\n", |
| 730 | format_mheap, ip4_main.mtrie_mheap, 1); |
| 731 | } |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | /*? |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 736 | * This command displays the IPv4 FIB Tables (VRF Tables) and the route |
| 737 | * entries for each table. |
| 738 | * |
| 739 | * @note This command will run for a long time when the FIB tables are |
| 740 | * comprised of millions of entries. For those senarios, consider displaying |
| 741 | * a single table or summary mode. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 742 | * |
| 743 | * @cliexpar |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 744 | * Example of how to display all the IPv4 FIB tables: |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 745 | * @cliexstart{show ip fib} |
Billy McFall | ebb9a6a | 2016-10-17 11:35:32 -0400 | [diff] [blame] | 746 | * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto |
| 747 | * 0.0.0.0/0 |
| 748 | * unicast-ip4-chain |
| 749 | * [@0]: dpo-load-balance: [index:0 buckets:1 uRPF:0 to:[0:0]] |
| 750 | * [0] [@0]: dpo-drop ip6 |
| 751 | * 0.0.0.0/32 |
| 752 | * unicast-ip4-chain |
| 753 | * [@0]: dpo-load-balance: [index:1 buckets:1 uRPF:1 to:[0:0]] |
| 754 | * [0] [@0]: dpo-drop ip6 |
| 755 | * 6.0.1.2/32 |
| 756 | * unicast-ip4-chain |
| 757 | * [@0]: dpo-load-balance: [index:30 buckets:1 uRPF:29 to:[0:0]] |
| 758 | * [0] [@3]: arp-ipv4: via 6.0.0.1 af_packet0 |
| 759 | * 7.0.0.1/32 |
| 760 | * unicast-ip4-chain |
| 761 | * [@0]: dpo-load-balance: [index:31 buckets:4 uRPF:30 to:[0:0]] |
| 762 | * [0] [@3]: arp-ipv4: via 6.0.0.2 af_packet0 |
| 763 | * [1] [@3]: arp-ipv4: via 6.0.0.2 af_packet0 |
| 764 | * [2] [@3]: arp-ipv4: via 6.0.0.2 af_packet0 |
| 765 | * [3] [@3]: arp-ipv4: via 6.0.0.1 af_packet0 |
| 766 | * 224.0.0.0/8 |
| 767 | * unicast-ip4-chain |
| 768 | * [@0]: dpo-load-balance: [index:3 buckets:1 uRPF:3 to:[0:0]] |
| 769 | * [0] [@0]: dpo-drop ip6 |
| 770 | * 240.0.0.0/8 |
| 771 | * unicast-ip4-chain |
| 772 | * [@0]: dpo-load-balance: [index:2 buckets:1 uRPF:2 to:[0:0]] |
| 773 | * [0] [@0]: dpo-drop ip6 |
| 774 | * 255.255.255.255/32 |
| 775 | * unicast-ip4-chain |
| 776 | * [@0]: dpo-load-balance: [index:4 buckets:1 uRPF:4 to:[0:0]] |
| 777 | * [0] [@0]: dpo-drop ip6 |
| 778 | * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto |
| 779 | * 0.0.0.0/0 |
| 780 | * unicast-ip4-chain |
| 781 | * [@0]: dpo-load-balance: [index:12 buckets:1 uRPF:11 to:[0:0]] |
| 782 | * [0] [@0]: dpo-drop ip6 |
| 783 | * 0.0.0.0/32 |
| 784 | * unicast-ip4-chain |
| 785 | * [@0]: dpo-load-balance: [index:13 buckets:1 uRPF:12 to:[0:0]] |
| 786 | * [0] [@0]: dpo-drop ip6 |
| 787 | * 172.16.1.0/24 |
| 788 | * unicast-ip4-chain |
| 789 | * [@0]: dpo-load-balance: [index:17 buckets:1 uRPF:16 to:[0:0]] |
| 790 | * [0] [@4]: ipv4-glean: af_packet0 |
| 791 | * 172.16.1.1/32 |
| 792 | * unicast-ip4-chain |
| 793 | * [@0]: dpo-load-balance: [index:18 buckets:1 uRPF:17 to:[1:84]] |
| 794 | * [0] [@2]: dpo-receive: 172.16.1.1 on af_packet0 |
| 795 | * 172.16.1.2/32 |
| 796 | * unicast-ip4-chain |
| 797 | * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]] |
| 798 | * [0] [@5]: ipv4 via 172.16.1.2 af_packet0: IP4: 02:fe:9e:70:7a:2b -> 26:a5:f6:9c:3a:36 |
| 799 | * 172.16.2.0/24 |
| 800 | * unicast-ip4-chain |
| 801 | * [@0]: dpo-load-balance: [index:19 buckets:1 uRPF:18 to:[0:0]] |
| 802 | * [0] [@4]: ipv4-glean: af_packet1 |
| 803 | * 172.16.2.1/32 |
| 804 | * unicast-ip4-chain |
| 805 | * [@0]: dpo-load-balance: [index:20 buckets:1 uRPF:19 to:[0:0]] |
| 806 | * [0] [@2]: dpo-receive: 172.16.2.1 on af_packet1 |
| 807 | * 224.0.0.0/8 |
| 808 | * unicast-ip4-chain |
| 809 | * [@0]: dpo-load-balance: [index:15 buckets:1 uRPF:14 to:[0:0]] |
| 810 | * [0] [@0]: dpo-drop ip6 |
| 811 | * 240.0.0.0/8 |
| 812 | * unicast-ip4-chain |
| 813 | * [@0]: dpo-load-balance: [index:14 buckets:1 uRPF:13 to:[0:0]] |
| 814 | * [0] [@0]: dpo-drop ip6 |
| 815 | * 255.255.255.255/32 |
| 816 | * unicast-ip4-chain |
| 817 | * [@0]: dpo-load-balance: [index:16 buckets:1 uRPF:15 to:[0:0]] |
| 818 | * [0] [@0]: dpo-drop ip6 |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 819 | * @cliexend |
| 820 | * Example of how to display a single IPv4 FIB table: |
| 821 | * @cliexstart{show ip fib table 7} |
Billy McFall | ebb9a6a | 2016-10-17 11:35:32 -0400 | [diff] [blame] | 822 | * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto |
| 823 | * 0.0.0.0/0 |
| 824 | * unicast-ip4-chain |
| 825 | * [@0]: dpo-load-balance: [index:12 buckets:1 uRPF:11 to:[0:0]] |
| 826 | * [0] [@0]: dpo-drop ip6 |
| 827 | * 0.0.0.0/32 |
| 828 | * unicast-ip4-chain |
| 829 | * [@0]: dpo-load-balance: [index:13 buckets:1 uRPF:12 to:[0:0]] |
| 830 | * [0] [@0]: dpo-drop ip6 |
| 831 | * 172.16.1.0/24 |
| 832 | * unicast-ip4-chain |
| 833 | * [@0]: dpo-load-balance: [index:17 buckets:1 uRPF:16 to:[0:0]] |
| 834 | * [0] [@4]: ipv4-glean: af_packet0 |
| 835 | * 172.16.1.1/32 |
| 836 | * unicast-ip4-chain |
| 837 | * [@0]: dpo-load-balance: [index:18 buckets:1 uRPF:17 to:[1:84]] |
| 838 | * [0] [@2]: dpo-receive: 172.16.1.1 on af_packet0 |
| 839 | * 172.16.1.2/32 |
| 840 | * unicast-ip4-chain |
| 841 | * [@0]: dpo-load-balance: [index:21 buckets:1 uRPF:20 to:[0:0]] |
| 842 | * [0] [@5]: ipv4 via 172.16.1.2 af_packet0: IP4: 02:fe:9e:70:7a:2b -> 26:a5:f6:9c:3a:36 |
| 843 | * 172.16.2.0/24 |
| 844 | * unicast-ip4-chain |
| 845 | * [@0]: dpo-load-balance: [index:19 buckets:1 uRPF:18 to:[0:0]] |
| 846 | * [0] [@4]: ipv4-glean: af_packet1 |
| 847 | * 172.16.2.1/32 |
| 848 | * unicast-ip4-chain |
| 849 | * [@0]: dpo-load-balance: [index:20 buckets:1 uRPF:19 to:[0:0]] |
| 850 | * [0] [@2]: dpo-receive: 172.16.2.1 on af_packet1 |
| 851 | * 224.0.0.0/8 |
| 852 | * unicast-ip4-chain |
| 853 | * [@0]: dpo-load-balance: [index:15 buckets:1 uRPF:14 to:[0:0]] |
| 854 | * [0] [@0]: dpo-drop ip6 |
| 855 | * 240.0.0.0/8 |
| 856 | * unicast-ip4-chain |
| 857 | * [@0]: dpo-load-balance: [index:14 buckets:1 uRPF:13 to:[0:0]] |
| 858 | * [0] [@0]: dpo-drop ip6 |
| 859 | * 255.255.255.255/32 |
| 860 | * unicast-ip4-chain |
| 861 | * [@0]: dpo-load-balance: [index:16 buckets:1 uRPF:15 to:[0:0]] |
| 862 | * [0] [@0]: dpo-drop ip6 |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 863 | * @cliexend |
| 864 | * Example of how to display a summary of all IPv4 FIB tables: |
| 865 | * @cliexstart{show ip fib summary} |
Billy McFall | ebb9a6a | 2016-10-17 11:35:32 -0400 | [diff] [blame] | 866 | * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 867 | * Prefix length Count |
Billy McFall | ebb9a6a | 2016-10-17 11:35:32 -0400 | [diff] [blame] | 868 | * 0 1 |
| 869 | * 8 2 |
| 870 | * 32 4 |
| 871 | * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 872 | * Prefix length Count |
Billy McFall | ebb9a6a | 2016-10-17 11:35:32 -0400 | [diff] [blame] | 873 | * 0 1 |
| 874 | * 8 2 |
| 875 | * 24 2 |
| 876 | * 32 4 |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 877 | * @cliexend |
| 878 | ?*/ |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 879 | /* *INDENT-OFF* */ |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 880 | VLIB_CLI_COMMAND (ip4_show_fib_command, static) = { |
| 881 | .path = "show ip fib", |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 882 | .short_help = "show ip fib [summary] [table <table-id>] [index <fib-id>] [<ip4-addr>[/<mask>]] [mtrie] [detail]", |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 883 | .function = ip4_show_fib, |
| 884 | }; |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 885 | /* *INDENT-ON* */ |