29 #define ADJ_NBR_DEFAULT_HASH_NUM_BUCKETS (64 * 64) 30 #define ADJ_NBR_DEFAULT_HASH_MEMORY_SIZE (32<<20) 33 #define ADJ_NBR_SET_KEY(_key, _lt, _nh) \ 35 _key.key[0] = (_nh)->as_u64[0]; \ 36 _key.key[1] = (_nh)->as_u64[1]; \ 37 _key.key[2] = (_lt); \ 40 #define ADJ_NBR_ITF_OK(_proto, _itf) \ 41 (((_itf) < vec_len(adj_nbr_tables[_proto])) && \ 42 (NULL != adj_nbr_tables[_proto][sw_if_index])) 47 const ip46_address_t *nh_addr,
51 BVT(clib_bihash_kv) kv;
53 if (sw_if_index >=
vec_len(adj_nbr_tables[nh_proto]))
57 if (
NULL == adj_nbr_tables[nh_proto][sw_if_index])
59 adj_nbr_tables[nh_proto][sw_if_index] =
62 memset(adj_nbr_tables[nh_proto][sw_if_index],
64 sizeof(
BVT(clib_bihash)));
67 "Adjacency Neighbour table",
82 const ip46_address_t *nh_addr,
85 BVT(clib_bihash_kv) kv;
99 const ip46_address_t *nh_addr,
102 BVT(clib_bihash_kv) kv;
138 const ip46_address_t *nh_addr,
145 adj_nbr_insert(nh_proto, link_type, nh_addr,
157 adj->rewrite_header.sw_if_index = sw_if_index;
177 const ip46_address_t *nh_addr,
183 adj_index =
adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
190 adj =
adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
197 &adj->rewrite_header);
217 const ip46_address_t *nh_addr,
224 adj_index =
adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
228 adj =
adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
229 adj->rewrite_header.sw_if_index = sw_if_index;
272 adj->rewrite_header.sw_if_index),
281 adj->rewrite_header.sw_if_index),
320 adj->rewrite_header.sw_if_index);
385 old_next != adj_next_index &&
426 sizeof(adj->rewrite_data),
434 sizeof(adj->rewrite_data));
436 adj->rewrite_header.node_index = this_node;
497 if (
NULL != adj_nbr_tables[proto][sw_if_index])
500 adj_nbr_tables[proto][sw_if_index],
543 adj_nbr_tables[adj_nh_proto][sw_if_index],
584 ip46_address_t nh = {
613 ip46_address_t nh = {
636 const ip46_address_t *nh,
650 adj_nbr_tables[adj_nh_proto][sw_if_index],
867 u32 sw_if_index = ~0;
888 else if (~0 != sw_if_index)
928 .path =
"show adj nbr",
929 .short_help =
"show adj nbr [<adj_index>] [interface]",
957 s =
format (s,
": via %U",
964 adj->rewrite_header.sw_if_index));
978 s =
format (s,
" via %U ",
983 vnm->
vlib_main, &adj->rewrite_header, sizeof (adj->rewrite_data), 0);
1027 const static char*
const nbr_ip4_nodes[] =
1032 const static char*
const nbr_ip6_nodes[] =
1037 const static char*
const nbr_mpls_nodes[] =
1042 const static char*
const nbr_ethernet_nodes[] =
1055 const static char*
const nbr_incomplete_ip4_nodes[] =
1060 const static char*
const nbr_incomplete_ip6_nodes[] =
1062 "ip6-discover-neighbor",
1065 const static char*
const nbr_incomplete_mpls_nodes[] =
1067 "mpls-adj-incomplete",
1085 &adj_nbr_incompl_dpo_vft,
1086 nbr_incomplete_nodes);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
dpo_lock_fn_t dv_lock
A reference counting lock function.
void adj_nbr_walk_nh(u32 sw_if_index, fib_protocol_t adj_nh_proto, const ip46_address_t *nh, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given next-hop.
static clib_error_t * adj_nbr_hw_interface_state_change(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Registered callback for HW interface state changes.
#define vec_foreach_index(var, v)
Iterate over vector indices.
Context for a walk of the adjacency neighbour DB.
ip_adjacency_t * adj_pool
The global adjacnecy pool.
void vnet_rewrite_init(vnet_main_t *vnm, u32 sw_if_index, u32 this_node, u32 next_node, vnet_rewrite_header_t *rw)
A virtual function table regisitered for a DPO type.
enum adj_nbr_interface_flags_t_ adj_nbr_interface_flags_t
Flags associated with the interface state walks.
u8 * format_adj_nbr(u8 *s, va_list *ap)
Format a neigbour (REWRITE) adjacency.
static ip46_type_t adj_proto_to_46(fib_protocol_t proto)
void adj_lock(adj_index_t adj_index)
An adjacency is a representation of an attached L3 peer.
static vlib_main_t * vlib_get_main(void)
An indication that the rewrite is complete, i.e.
static const char *const nbr_ethernet_nodes[]
static const char *const nbr_incomplete_ip6_nodes[]
static adj_walk_rc_t adj_nbr_interface_state_change_one(adj_index_t ai, void *arg)
void vnet_hw_interface_walk_sw(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_sw_interface_walk_t fn, void *ctx)
Walk the SW interfaces on a HW interface - this is the super interface and any sub-interfaces.
u8 * format_vnet_link(u8 *s, va_list ap)
Context for the state change walk of the DB.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
void adj_nbr_walk_nh4(u32 sw_if_index, const ip4_address_t *addr, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given v4 next-hop.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
u8 * format_adj_nbr_incomplete(u8 *s, va_list *ap)
Format aa incomplete neigbour (ARP) adjacency.
#define VNET_HW_INTERFACE_FLAG_LINK_UP
static const char *const nbr_incomplete_mpls_nodes[]
adj_index_t adj_nbr_add_or_lock_w_rewrite(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index, u8 *rewrite)
Add (and lock) a new or lock an existing neighbour adjacency.
#define ip46_address_cmp(ip46_1, ip46_2)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define pool_len(p)
Number of elements in pool vector.
union ip_adjacency_t_::@175 sub_type
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj, u32 adj_next_index, u32 this_node, u32 next_node, u8 *rewrite)
adj_nbr_update_rewrite_internal
vnet_main_t * vnet_get_main(void)
static clib_error_t * adj_nbr_sw_interface_state_change(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Registered function for SW interface state changes.
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
vlib_node_registration_t ip6_discover_neighbor_node
(constructor) VLIB_REGISTER_NODE (ip6_discover_neighbor_node)
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION_PRIO(adj_nbr_sw_interface_state_change, VNET_ITF_FUNC_PRIORITY_HIGH)
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
int clib_bihash_add_del(clib_bihash *h, clib_bihash_kv *add_v, int is_add)
Add or delete a (key,value) pair from a bi-hash table.
void fib_walk_sync(fib_node_type_t parent_type, fib_node_index_t parent_index, fib_node_back_walk_ctx_t *ctx)
Back walk all the children of a FIB node.
ip_adjacency_flags_t ia_flags
Flags on the adjacency.
static void vnet_rewrite_clear_data_internal(vnet_rewrite_header_t *rw, int max_size)
static const char *const nbr_incomplete_ip4_nodes[]
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
static clib_error_t * adj_nbr_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct adj_walk_ctx_t_ adj_walk_ctx_t
Context for a walk of the adjacency neighbour DB.
static const char *const nbr_mpls_nodes[]
static void adj_nbr_walk_cb(BVT(clib_bihash_kv)*kvp, void *arg)
static void adj_dpo_lock(dpo_id_t *dpo)
void fib_show_memory_usage(const char *name, u32 in_use_elts, u32 allocd_elts, size_t size_elt)
Show the memory usage for a type.
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
void vnet_update_adjacency_for_sw_interface(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
static const char *const nbr_ip6_nodes[]
format_function_t format_vnet_rewrite
u32 adj_nbr_db_size(void)
Return the size of the adjacency database.
Context for a walk of the adjacency neighbour DB.
#define ADJ_NBR_DEFAULT_HASH_NUM_BUCKETS
vlib_node_registration_t ip4_arp_node
(constructor) VLIB_REGISTER_NODE (ip4_arp_node)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
fib_node_bw_reason_flag_t fnbw_reason
The reason/trigger for the backwalk.
format_function_t format_vnet_sw_interface_name
static void adj_nbr_hw_sw_interface_state_change(vnet_main_t *vnm, u32 sw_if_index, void *arg)
Invoked on each SW interface of a HW interface when the HW interface state changes.
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
void adj_nbr_remove(adj_index_t ai, fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
static adj_index_t adj_get_index(ip_adjacency_t *adj)
Get a pointer to an adjacency object from its index.
static clib_error_t * adj_nbr_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
adj_nbr_interface_add_del
const ip46_address_t * awc_nh
static void adj_nbr_walk_nh_cb(BVT(clib_bihash_kv)*kvp, void *arg)
#define ADJ_NBR_DEFAULT_HASH_MEMORY_SIZE
Currently a sync walk is active.
void adj_nbr_module_init(void)
Module initialisation.
void clib_bihash_init(clib_bihash *h, char *name, u32 nbuckets, uword memory_size)
initialize a bounded index extensible hash table
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define ADJ_NBR_SET_KEY(_key, _lt, _nh)
void clib_bihash_foreach_key_value_pair(clib_bihash *h, void *callback, void *arg)
Visit active (key,value) pairs in a bi-hash table.
#define vec_free(V)
Free vector's memory (no header).
static adj_walk_rc_t adj_nbr_show_one(adj_index_t ai, void *arg)
Force the walk to be synchronous.
struct ip_adjacency_t_::@175::@176 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
u32 vnet_tx_node_index_for_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static void vnet_rewrite_set_data_internal(vnet_rewrite_header_t *rw, int max_size, void *data, int data_bytes)
adj_walk_rc_t(* adj_walk_cb_t)(adj_index_t ai, void *ctx)
Call back function when walking adjacencies.
void vlib_worker_thread_barrier_sync(vlib_main_t *vm)
u32 adj_index_t
An index for adjacencies.
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
static void adj_mem_show(void)
static ip_adjacency_t * adj_nbr_alloc(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk the neighbour Adjacencies on a given interface.
Context passed between object during a back walk.
#define VLIB_CLI_COMMAND(x,...)
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION_PRIO(adj_nbr_hw_interface_state_change, VNET_ITF_FUNC_PRIORITY_HIGH)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
adj_nbr_interface_flags_t flags
Flags on the interface.
int clib_bihash_search(clib_bihash *h, clib_bihash_kv *search_v, clib_bihash_kv *return_v)
Search a bi-hash table.
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static const char *const nbr_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to an adjacency object.
static u32 adj_get_rewrite_node(vnet_link_t linkt)
static u32 adj_get_nd_node(fib_protocol_t proto)
struct adj_walk_nh_ctx_t_ adj_walk_nh_ctx_t
Context for a walk of the adjacency neighbour DB.
index_t dpoi_index
the index of objects of that type
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip_lookup_next_t lookup_next_index
enum adj_nbr_rewrite_flag_t_ adj_nbr_rewrite_flag_t
When adding a rewrite to an adjacency these are flags that apply to that rewrite. ...
ip_adjacency_t * adj_alloc(fib_protocol_t proto)
static void adj_db_count(BVT(clib_bihash_kv)*kvp, void *arg)
static adj_walk_rc_t adj_nbr_interface_delete_one(adj_index_t ai, void *arg)
#define FIB_PROTOCOL_MAX
Definition outside of enum so it does not need to be included in non-defaulted switch statements...
static void * clib_mem_alloc_aligned(uword size, uword align)
adj_nbr_interface_flags_t_
Flags associated with the interface state walks.
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
This packet is to be rewritten and forwarded to the next processing node.
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
struct adj_db_count_ctx_t_ adj_db_count_ctx_t
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(adj_nbr_interface_add_del)
static void adj_dpo_unlock(dpo_id_t *dpo)
#define CLIB_CACHE_LINE_BYTES
#define ADJ_NBR_ITF_OK(_proto, _itf)
static adj_index_t adj_nbr_find(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
void adj_nbr_update_rewrite(adj_index_t adj_index, adj_nbr_rewrite_flag_t flags, u8 *rewrite)
adj_nbr_update_rewrite
struct adj_nbr_interface_state_change_ctx_t_ adj_nbr_interface_state_change_ctx_t
Context for the state change walk of the DB.
struct ip_adjacency_t_::@175::@177 midchain
IP_LOOKUP_NEXT_MIDCHAIN.
void adj_nbr_walk_nh6(u32 sw_if_index, const ip6_address_t *addr, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given v6 next-hop.
static uword pool_elts(void *v)
Number of active elements in a pool.