61 .ip4.data_u32 = 0xf0000000,
77 .ip4.data_u32 = 0xe0000000,
92 .ip4.data_u32 = 0xffffffff,
142 for (ii = 0; ii <
ARRAY_LEN(ip4_specials); ii++)
147 clib_host_to_net_u32(prefix.
fp_addr.ip4.data_u32);
170 for (ii =
ARRAY_LEN(ip4_specials) - 1; ii >= 0; ii--)
175 clib_host_to_net_u32(prefix.
fp_addr.ip4.data_u32);
253 uword * hash, * result;
261 if (
NULL != result) {
301 uword * hash, * result;
305 for (mask_len = len; mask_len >= 0; mask_len--)
312 if (
NULL != result) {
325 uword * hash, * result;
332 if (
NULL == result) {
344 hash =
hash_set(hash, key, fib_entry_index);
359 uword * hash, * result;
467 const fib_prefix_t *sub_tree;
473 vec_foreach(sub_tree, sub_trees)
475 if (ip4_destination_matches_route(&ip4_main,
477 &sub_tree->fp_addr.ip4,
487 switch (fn(p->
value[0], ctx))
489 case FIB_TABLE_WALK_CONTINUE:
491 case FIB_TABLE_WALK_SUB_TREE_STOP: {
493 .fp_proto = FIB_PROTOCOL_IP4,
497 vec_add1(sub_trees, pfx);
537 .ifsw_indicies =
NULL,
574 #if USE_DLMALLOC == 0 575 s =
format(s,
"%=30s %=6d %=12ld\n",
580 s =
format(s,
"%=30s %=6d %=12ld\n",
597 u64 total_mtrie_memory, total_hash_memory;
598 int verbose, matching, mtrie,
memory;
600 u32 matching_mask = 32;
605 matching = mtrie = memory = 0;
606 total_hash_memory = total_mtrie_memory = 0;
631 else if (
unformat (input,
"table %d", &table_id))
633 else if (
unformat (input,
"index %d", &fib_index))
641 ip4_fib_t *fib = pool_elt_at_index(im4->v4_fibs, fib_table->ft_index);
645 if (table_id >= 0 && table_id != (int)fib->table_id)
647 if (fib_index != ~0 && fib_index != (int)fib->index)
652 uword mtrie_size, hash_size, *old_heap;
655 mtrie_size = ip4_fib_mtrie_memory_usage(&fib->mtrie);
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++)
661 uword * hash = fib->fib_entry_by_dst_address[i];
664 hash_size += hash_bytes(hash);
667 clib_mem_set_heap (old_heap);
670 vlib_cli_output (vm,
"%U mtrie:%d hash:%d",
671 format_fib_table_name, fib->index,
675 total_mtrie_memory += mtrie_size;
676 total_hash_memory += hash_size;
680 s =
format(s,
"%U, fib_index:%d, flow hash:[%U] epoch:%d flags:%U locks:[",
690 if (0 != fib_table->ft_locks[source])
692 s = format(s,
"%U:%d, ",
693 format_fib_source, source,
694 fib_table->ft_locks[source]);
710 for (
i = 0;
i <
ARRAY_LEN (fib->fib_entry_by_dst_address);
i++)
712 uword * hash = fib->fib_entry_by_dst_address[
i];
727 matching_mask, detail);
736 total_mtrie_memory + total_hash_memory);
889 .path =
"show ip fib",
890 .short_help =
"show ip fib [summary] [table <table-id>] [index <fib-id>] [<ip4-addr>[/<mask>]] [mtrie] [detail]",
fib_protocol_t fp_proto
protocol type
u8 * format_fib_entry(u8 *s, va_list *args)
enum fib_source_t_ fib_source_t
The different sources that can create a route.
#define vec_foreach_index(var, v)
Iterate over vector indices.
Continue on to the next entry.
static void ip4_fib_table_show_one(ip4_fib_t *fib, vlib_main_t *vm, ip4_address_t *address, u32 mask_len, int detail)
#define hash_set(h, key, value)
vhost_user_memory_t memory
fib_protocol_t ft_proto
Which protocol this table serves.
void ip4_fib_table_fwding_dpo_remove(ip4_fib_t *fib, const ip4_address_t *addr, u32 len, const dpo_id_t *dpo, u32 cover_index)
#define hash_unset(h, key)
#define FIB_ENTRY_FORMAT_DETAIL
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void ip4_fib_table_destroy(u32 fib_index)
static clib_error_t * ip4_show_fib(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword ip4_destination_matches_route(const ip4_main_t *im, const ip4_address_t *key, const ip4_address_t *dest, uword dest_length)
const fib_prefix_t * fib_entry_get_prefix(fib_node_index_t fib_entry_index)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u32 ip4_fib_table_find_or_create_and_lock(u32 table_id, fib_source_t src)
Get or create an IPv4 fib.
static void ip4_fib_table_show_all(ip4_fib_t *fib, vlib_main_t *vm)
u32 ip4_fib_table_create_and_lock(fib_source_t src)
fib_entry_flag_t ift_flag
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
u32 ft_epoch
Epoch - number of resyncs performed.
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
void ip4_mtrie_free(ip4_fib_mtrie_t *m)
Free an mtrie, It must be emty when free'd.
Aggregate type for a prefix.
void ip4_fib_table_sub_tree_walk(ip4_fib_t *fib, const fib_prefix_t *root, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a sub-tree of the FIB table N.B: This is NOT safe to deletes. ...
static void hash_set_flags(void *v, uword flags)
u16 fp_len
The mask length.
void ip4_fib_table_entry_remove(ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
int fib_entry_cmp_for_sort(void *i1, void *i2)
u32 * ft_locks
per-source number of locks on the table
u8 * format_mheap(u8 *s, va_list *va)
void ip4_mtrie_init(ip4_fib_mtrie_t *m)
Initialise an mtrie.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
u8 * format_fib_table_flags(u8 *s, va_list *args)
#define pool_put(P, E)
Free an object E in pool P.
u32 ft_total_route_counts
Total route counters.
void * mtrie_mheap
The memory heap for the mtries.
void ip4_fib_table_fwding_dpo_update(ip4_fib_t *fib, const ip4_address_t *addr, u32 len, const dpo_id_t *dpo)
ip4_fib_mtrie_t mtrie
Mtrie for fast lookups.
Stop the walk completely.
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
fib_node_index_t ip4_fib_table_lookup(const ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a 'special' entry to the FIB.
void ip4_fib_table_entry_insert(ip4_fib_t *fib, const ip4_address_t *addr, u32 len, fib_node_index_t fib_entry_index)
fib_node_index_t ft_index
Index into FIB vector.
u32 ft_table_id
Table ID (hash key) for this FIB.
u32 ft_flow_hash_config
flow hash configuration
enum fib_table_walk_rc_t_ fib_table_walk_rc_t
return code controlling how a table walk proceeds
#define vec_free(V)
Free vector's memory (no header).
fib_node_index_t * ifsw_indicies
static void * clib_mem_set_heap(void *heap)
fib_table_flags_t ft_flags
Table flags.
u32 fib_node_index_t
A typedef of a node index.
static u32 ip4_fib_index_from_table_id(u32 table_id)
void ip4_fib_table_walk(ip4_fib_t *fib, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
fib_table_walk_rc_t(* fib_table_walk_fn_t)(fib_node_index_t fei, void *ctx)
Call back function when walking entries in a FIB table.
enum fib_entry_flag_t_ fib_entry_flag_t
void fib_table_lock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Release a reference counting lock on the table.
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
static uword hash_elts(void *v)
manual_print typedef address
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
u8 * format_ip4_fib_table_memory(u8 *s, va_list *args)
uword mheap_bytes(void *v)
#define FIB_ENTRY_FORMAT_BRIEF
format_function_t format_ip4_fib_mtrie
Format/display the contents of the mtrie.
index_t dpoi_index
the index of objects of that type
#define FIB_NODE_INDEX_INVALID
struct ip4_fib_t_ * v4_fibs
Vector of MTries.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
void ip4_fib_mtrie_route_add(ip4_fib_mtrie_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index)
Add a route/entry to the mtrie.
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
The default route source.
uword * fib_entry_by_dst_address[33]
u32 * ft_src_route_counts
Per-source route counters.
struct ip4_fib_table_special_prefix_t_ ip4_fib_table_special_prefix_t
DLMALLOC_EXPORT size_t mspace_footprint(mspace msp)
u8 * format_fib_table_name(u8 *s, va_list *ap)
Format the description/name of the table.
ip4_main_t ip4_main
Global ip4 main structure.
struct fib_table_t_ * fibs
Vector of FIBs.
#define FIB_ENTRY_FORMAT_DETAIL2
#define vec_foreach(var, vec)
Vector iterator.
index_t ip4_fib_table_lookup_lb(ip4_fib_t *fib, const ip4_address_t *addr)
void ip4_fib_mtrie_route_del(ip4_fib_mtrie_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index, u32 cover_address_length, u32 cover_adj_index)
remove a route/entry to the mtrie
void fib_table_assert_empty(const fib_table_t *fib_table)
Debug function.
u8 * format_ip_flow_hash_config(u8 *s, va_list *args)
#define CLIB_CACHE_LINE_BYTES
static fib_table_walk_rc_t ip4_fib_show_walk_cb(fib_node_index_t fib_entry_index, void *arg)
#define HASH_FLAG_NO_AUTO_SHRINK
fib_node_index_t ip4_fib_table_lookup_exact_match(const ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
struct ip4_fib_show_walk_ctx_t_ ip4_fib_show_walk_ctx_t
Walk show context.
A protocol Independent FIB table.
static u32 ip4_create_fib_with_table_id(u32 table_id, fib_source_t src)
static uword pool_elts(void *v)
Number of active elements in a pool.