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;
109 if (BV(clib_bihash_search)(adj_nbr_tables[nh_proto][sw_if_index],
164 sw_if_index = adj->rewrite_header.sw_if_index;
168 if (feature_count > 0)
178 const ip46_address_t *nh_addr,
185 adj_nbr_insert(nh_proto, link_type, nh_addr,
197 adj->rewrite_header.sw_if_index = sw_if_index;
216 const ip46_address_t *nh_addr,
222 adj_index =
adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
229 adj =
adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
236 &adj->rewrite_header);
256 const ip46_address_t *nh_addr,
263 adj_index =
adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
267 adj =
adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
268 adj->rewrite_header.sw_if_index = sw_if_index;
311 adj->rewrite_header.sw_if_index),
320 adj->rewrite_header.sw_if_index),
359 adj->rewrite_header.sw_if_index);
424 old_next != adj_next_index &&
465 sizeof(adj->rewrite_data),
473 sizeof(adj->rewrite_data));
535 if (
NULL != adj_nbr_tables[proto][sw_if_index])
538 adj_nbr_tables[proto][sw_if_index],
581 adj_nbr_tables[adj_nh_proto][sw_if_index],
599 ip46_address_t nh = {
627 ip46_address_t nh = {
649 const ip46_address_t *nh,
890 u32 sw_if_index = ~0;
911 else if (~0 != sw_if_index)
951 .path =
"show adj nbr",
952 .short_help =
"show adj nbr [<adj_index>] [interface]",
965 s =
format (s,
": via %U",
970 vnm, adj->rewrite_header.sw_if_index);
983 s =
format (s,
" via %U ",
988 &adj->rewrite_header, sizeof (adj->rewrite_data), 0);
1034 const static char*
const nbr_ip4_nodes[] =
1039 const static char*
const nbr_ip6_nodes[] =
1044 const static char*
const nbr_mpls_nodes[] =
1049 const static char*
const nbr_ethernet_nodes[] =
1062 const static char*
const nbr_incomplete_ip4_nodes[] =
1067 const static char*
const nbr_incomplete_ip6_nodes[] =
1069 "ip6-discover-neighbor",
1072 const static char*
const nbr_incomplete_mpls_nodes[] =
1074 "mpls-adj-incomplete",
1092 &adj_nbr_incompl_dpo_vft,
1093 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 adjacnecy 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[]
struct ip_adjacency_t_::@45::@46 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
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.
union ip_adjacency_t_::@45 sub_type
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.
#define VNET_HW_INTERFACE_FLAG_LINK_UP
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:
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.
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[]
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)
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
#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
#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.
Currently a sync walk is active.
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)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
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 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)
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.
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,...)
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 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.