31 #define ADJ_NBR_DEFAULT_HASH_NUM_BUCKETS (64 * 64) 32 #define ADJ_NBR_DEFAULT_HASH_MEMORY_SIZE (32<<20) 35 #define ADJ_NBR_SET_KEY(_key, _lt, _nh) \ 37 _key.key[0] = (_nh)->as_u64[0]; \ 38 _key.key[1] = (_nh)->as_u64[1]; \ 39 _key.key[2] = (_lt); \ 42 #define ADJ_NBR_ITF_OK(_proto, _itf) \ 43 (((_itf) < vec_len(adj_nbr_tables[_proto])) && \ 44 (NULL != adj_nbr_tables[_proto][sw_if_index])) 53 BVT(clib_bihash_kv) kv;
55 if (sw_if_index >=
vec_len(adj_nbr_tables[nh_proto]))
59 if (
NULL == adj_nbr_tables[nh_proto][sw_if_index])
66 sizeof(
BVT(clib_bihash)));
69 "Adjacency Neighbour table",
87 BVT(clib_bihash_kv) kv;
104 BVT(clib_bihash_kv) kv;
111 if (BV(clib_bihash_search)(adj_nbr_tables[nh_proto][sw_if_index],
166 sw_if_index = adj->rewrite_header.sw_if_index;
170 if (feature_count > 0)
187 adj_nbr_insert(nh_proto, link_type, nh_addr,
201 &adj->rewrite_header);
225 adj_index =
adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
233 adj =
adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
245 &adj->rewrite_header);
272 adj_index =
adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
278 adj =
adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
321 adj->rewrite_header.sw_if_index),
330 adj->rewrite_header.sw_if_index),
369 adj->rewrite_header.sw_if_index);
434 old_next != adj_next_index &&
482 sizeof(adj->rewrite_data),
490 sizeof(adj->rewrite_data));
538 return (BIHASH_WALK_CONTINUE);
554 if (
NULL != adj_nbr_tables[proto][sw_if_index])
583 return (BIHASH_WALK_STOP);
584 return (BIHASH_WALK_CONTINUE);
620 ip46_address_t
nh = {
648 ip46_address_t
nh = {
670 const ip46_address_t *
nh,
677 switch (adj_nh_proto)
937 else if (~0 != sw_if_index)
977 .path =
"show adj nbr",
978 .short_help =
"show adj nbr [<adj_index>] [interface]",
991 s =
format (s,
": via %U",
996 vnm, adj->rewrite_header.sw_if_index);
1009 s =
format (s,
" via %U ",
1014 &adj->rewrite_header, sizeof (adj->rewrite_data), 0);
1060 const static char*
const nbr_ip4_nodes[] =
1065 const static char*
const nbr_ip6_nodes[] =
1070 const static char*
const nbr_mpls_nodes[] =
1075 const static char*
const nbr_ethernet_nodes[] =
1088 const static char*
const nbr_incomplete_ip4_nodes[] =
1093 const static char*
const nbr_incomplete_ip6_nodes[] =
1095 "ip6-discover-neighbor",
1098 const static char*
const nbr_incomplete_mpls_nodes[] =
1100 "mpls-adj-incomplete",
1118 &adj_nbr_incompl_dpo_vft,
1119 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.
adj_flags_t ia_flags
Flags on the adjacency 1-bytes.
Context for a walk of the adjacency neighbour DB.
ip_adjacency_t * adj_pool
The global adjacency pool.
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.
void adj_lock(adj_index_t adj_index)
Take a reference counting lock on the adjacency.
An indication that the rewrite is complete, i.e.
vnet_main_t * vnet_get_main(void)
static const char *const nbr_ethernet_nodes[]
static const char *const nbr_incomplete_ip6_nodes[]
void adj_delegate_adj_created(ip_adjacency_t *adj)
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.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
Context for the state change walk of the DB.
This packet is to be rewritten and forwarded to the next processing node.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
ip_lookup_main_t lookup_main
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.
unformat_function_t unformat_vnet_sw_interface
u8 * format_adj_nbr_incomplete(u8 *s, va_list *ap)
Format aa incomplete neigbour (ARP) adjacency.
static const char *const nbr_incomplete_mpls_nodes[]
u32 adj_dpo_get_urpf(const dpo_id_t *dpo)
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.
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
ip_lookup_next_t
An adjacency is a representation of an attached L3 peer.
#define pool_len(p)
Number of elements in pool vector.
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vlib_worker_thread_barrier_sync(X)
vnet_link_t ia_link
link/ether-type 1 bytes
enum walk_rc_t_ walk_rc_t
Walk return code.
u8 output_feature_arc_index
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:
vl_api_interface_index_t sw_if_index
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.
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 walk_rc_t 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.
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.
struct ip_adjacency_t_::@119::@120 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
static const char *const nbr_mpls_nodes[]
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.
union ip_adjacency_t_::@119 sub_type
void vnet_update_adjacency_for_sw_interface(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
static const char *const nbr_ip6_nodes[]
static void adj_nbr_evaluate_feature(adj_index_t ai)
Check and set feature flags if o/p interface has any o/p features.
format_function_t format_vnet_rewrite
u8 output_feature_arc_index
u32 adj_nbr_db_size(void)
Return the size of the adjacency database.
#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.
#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)
void clib_bihash_foreach_key_value_pair(clib_bihash *h, clib_bihash_foreach_key_value_pair_cb *callback, void *arg)
Visit active (key,value) pairs in a bi-hash table.
static adj_index_t adj_get_index(const 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
static int adj_nbr_walk_cb(BVT(clib_bihash_kv) *kvp, void *arg)
u32 ia_node_index
The VLIB node in which this adj is used to forward packets.
#define ADJ_NBR_DEFAULT_HASH_MEMORY_SIZE
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
static u8 ip46_address_is_equal(const ip46_address_t *ip46_1, const ip46_address_t *ip46_2)
format_function_t format_ip46_address
#define ADJ_NBR_SET_KEY(_key, _lt, _nh)
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
void vnet_rewrite_init(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t linkt, u32 this_node, u32 next_node, vnet_rewrite_header_t *rw)
#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.
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.
u32 adj_index_t
An index for adjacencies.
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.
i16 ** feature_count_by_sw_if_index
feature reference counts by interface
#define FOR_EACH_VNET_LINK(_link)
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)
adj_nbr_interface_flags_t flags
Flags on the interface.
ip_lookup_main_t lookup_main
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)
static vlib_main_t * vlib_get_main(void)
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
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
Next hop after ip4-lookup.
void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj, ip_lookup_next_t adj_next_index, u32 this_node, u32 next_node, u8 *rewrite)
adj_nbr_update_rewrite_internal
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. ...
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
ip_adjacency_t * adj_alloc(fib_protocol_t proto)
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)
ip4_main_t ip4_main
Global ip4 main structure.
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.
u8 * format_vnet_link(u8 *s, va_list *ap)
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)
This adjacency/interface has output features configured.
void vnet_rewrite_update_mtu(vnet_main_t *vnm, vnet_link_t linkt, vnet_rewrite_header_t *rw)
vnet_feature_main_t feature_main
void adj_nbr_update_rewrite(adj_index_t adj_index, adj_nbr_rewrite_flag_t flags, u8 *rewrite)
adj_nbr_update_rewrite
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
const ip46_address_t ADJ_BCAST_ADDR
The special broadcast address (to construct a broadcast adjacency.
struct adj_nbr_interface_state_change_ctx_t_ adj_nbr_interface_state_change_ctx_t
Context for the state change walk of the DB.
static int adj_db_count(BVT(clib_bihash_kv) *kvp, void *arg)
static ip46_type_t adj_proto_to_46(fib_protocol_t proto)
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)
Lookup neighbor adjancency.
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.