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