36 #define LOOKUP_SUB_TYPE_NUM (LOOKUP_SUB_TYPE_DST_TABLE_FROM_INTERFACE+1) 38 #define FOR_EACH_LOOKUP_SUB_TYPE(_st) \ 39 for (_st = LOOKUP_SUB_TYPE_IP4_SRC; _st < LOOKUP_SUB_TYPE_NUM; _st++) 64 return (lkd - lookup_dpo_pool);
159 s =
format(s,
"%s lookup in interface's %U table",
165 s =
format(s,
"%s lookup in %U",
206 u32 * src_adj_index0)
229 u32 * src_adj_index0,
230 u32 * src_adj_index1)
278 int table_from_interface)
280 u32 n_left_from, next_index, * from, * to_next;
289 while (n_left_from > 0)
295 while (n_left_from >= 4 && n_left_to_next > 2)
297 u32 bi0, lkdi0, lbi0, fib_index0, next0, hash_c0;
305 u32 bi1, lkdi1, lbi1, fib_index1, next1, hash_c1;
352 if (table_from_interface)
383 input_addr0, input_addr1,
422 (cm, cpu_index, lbi0, 1,
425 (cm, cpu_index, lbi1, 1,
434 tr->
addr.ip4 = *input_addr0;
442 tr->
addr.ip4 = *input_addr1;
446 to_next, n_left_to_next,
447 bi0, bi1, next0, next1);
450 while (n_left_from > 0 && n_left_to_next > 0)
452 u32 bi0, lkdi0, lbi0, fib_index0, next0, hash_c0;
479 if (table_from_interface)
526 (cm, cpu_index, lbi0, 1,
535 tr->
addr.ip4 = *input_addr;
539 n_left_to_next, bi0, next0);
553 s =
format (s,
"%U fib-index:%d addr:%U load-balance:%d",
571 .name =
"lookup-ip4-dst",
572 .vector_size =
sizeof (
u32),
573 .sibling_of =
"ip4-lookup",
588 .name =
"lookup-ip4-dst-itf",
589 .vector_size =
sizeof (
u32),
590 .sibling_of =
"ip4-lookup",
605 .name =
"lookup-ip4-src",
606 .vector_size =
sizeof (
u32),
608 .sibling_of =
"ip4-lookup",
617 int table_from_interface)
620 u32 n_left_from, next_index, * from, * to_next;
628 while (n_left_from > 0)
634 while (n_left_from >= 4 && n_left_to_next > 2)
636 u32 bi0, lkdi0, lbi0, fib_index0, next0, hash_c0;
644 u32 bi1, lkdi1, lbi1, fib_index1, next1, hash_c1;
691 if (table_from_interface)
764 (cm, cpu_index, lbi0, 1,
767 (cm, cpu_index, lbi1, 1,
776 tr->
addr.ip6 = *input_addr0;
784 tr->
addr.ip6 = *input_addr1;
787 n_left_to_next, bi0, bi1,
790 while (n_left_from > 0 && n_left_to_next > 0)
792 u32 bi0, lkdi0, lbi0, fib_index0, next0, hash_c0;
819 if (table_from_interface)
868 (cm, cpu_index, lbi0, 1,
877 tr->
addr.ip6 = *input_addr0;
880 n_left_to_next, bi0, next0);
897 .name =
"lookup-ip6-dst",
898 .vector_size =
sizeof (
u32),
900 .sibling_of =
"ip6-lookup",
914 .name =
"lookup-ip6-dst-itf",
915 .vector_size =
sizeof (
u32),
917 .sibling_of =
"ip6-lookup",
931 .name =
"lookup-ip6-src",
932 .vector_size =
sizeof (
u32),
934 .sibling_of =
"ip6-lookup",
942 int table_from_interface)
944 u32 n_left_from, next_index, * from, * to_next;
953 while (n_left_from > 0)
962 while (n_left_from > 0 && n_left_to_next > 0)
964 u32 bi0, lkdi0, lbi0, fib_index0, next0, hash0;
989 if (table_from_interface)
1021 (cm, cpu_index, lbi0, 1,
1025 vnet_buffer (b0)->mpls.exp = (((
char*)hdr0)[2] & 0xe) >> 1;
1039 n_left_to_next, bi0, next0);
1057 s =
format (s,
"%U fib-index:%d hdr:%U load-balance:%d",
1075 .name =
"lookup-mpls-dst",
1076 .vector_size =
sizeof (
u32),
1077 .sibling_of =
"mpls-lookup",
1093 .name =
"lookup-mpls-dst-itf",
1094 .vector_size =
sizeof (
u32),
1095 .sibling_of =
"mpls-lookup",
1163 "lookup-ip4-dst-itf",
1168 "lookup-ip6-dst-itf",
1173 "lookup-mpls-dst-itf",
static uword lookup_ip6_dst_itf(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
u16 lb_n_buckets
number of buckets in the load-balance.
dpo_lock_fn_t dv_lock
A reference counting lock function.
lookup_input_t lkd_input
Switch to use src or dst address.
lookup_dpo_t * lookup_dpo_pool
pool of all MPLS Label DPOs
vlib_combined_counter_main_t lbm_to_counters
A representation of an MPLS label for imposition in the data-path.
static uword lookup_ip4_src(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
A virtual function table regisitered for a DPO type.
struct lookup_trace_t_ lookup_trace_t
Lookup trace data.
static uword lookup_dpo_mpls_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int table_from_interface)
enum lookup_sub_type_t_ lookup_sub_type_t
Enumeration of the lookup subtypes.
fib_node_index_t fib_index
format_function_t format_mpls_header
lookup_sub_type_t_
Enumeration of the lookup subtypes.
void fib_table_lock(u32 fib_index, fib_protocol_t proto)
Release a reference counting lock on the table.
void lookup_dpo_add_or_lock_w_table_id(u32 table_id, dpo_proto_t proto, lookup_input_t input, lookup_table_t table_config, dpo_id_t *dpo)
static const char *const *const lookup_dst_nodes[DPO_PROTO_NUM]
static dpo_type_t lookup_dpo_sub_types[LOOKUP_SUB_TYPE_NUM]
An array of registered DPO type values for the sub-types.
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
static uword lookup_mpls_dst(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
static uword lookup_dpo_ip6_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int input_src_addr, int table_from_interface)
void lookup_dpo_add_or_lock_w_fib_index(fib_node_index_t fib_index, dpo_proto_t proto, lookup_input_t input, lookup_table_t table_config, dpo_id_t *dpo)
#define LOOKUP_SUB_TYPE_NUM
vlib_node_registration_t lookup_mpls_dst_itf_node
(constructor) VLIB_REGISTER_NODE (lookup_mpls_dst_itf_node)
u8 * format_lookup_dpo(u8 *s, va_list *args)
u16 lkd_locks
Number of locks.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_len(p)
Number of elements in pool vector.
#define IP4_FIB_MTRIE_LEAF_EMPTY
static ip4_fib_mtrie_leaf_t ip4_fib_mtrie_lookup_step(ip4_fib_mtrie_t *m, ip4_fib_mtrie_leaf_t current_leaf, const ip4_address_t *dst_address, u32 dst_address_byte_index)
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
static const char *const lookup_dst_from_interface_ip6_nodes[]
static lookup_dpo_t * lookup_dpo_alloc(void)
u16 lb_n_buckets_minus_1
number of buckets in the load-balance - 1.
static uword lookup_ip6_src(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static const char *const *const lookup_src_nodes[DPO_PROTO_NUM]
dpo_proto_t lkd_proto
The protocol of the FIB for the lookup, and hence the protocol of the packet.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static void lookup_dpo_unlock(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.
static uword lookup_ip4_dst_itf(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
static u32 ip4_fib_mtrie_leaf_get_adj_index(ip4_fib_mtrie_leaf_t n)
vlib_node_registration_t lookup_ip4_dst_node
(constructor) VLIB_REGISTER_NODE (lookup_ip4_dst_node)
static u32 mpls_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
vlib_node_registration_t lookup_ip6_src_node
(constructor) VLIB_REGISTER_NODE (lookup_ip6_src_node)
static void lookup_dpo_lock(dpo_id_t *dpo)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
void fib_table_unlock(u32 fib_index, fib_protocol_t proto)
Take a reference counting lock on the table.
static lookup_dpo_t * lookup_dpo_get(index_t index)
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
static u32 mpls_compute_flow_hash(const mpls_unicast_header_t *hdr, flow_hash_config_t flow_hash_config)
uword os_get_cpu_number(void)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u32 ip6_compute_flow_hash(const ip6_header_t *ip, flow_hash_config_t flow_hash_config)
mpls_unicast_header_t hdr
#define pool_put(P, E)
Free an object E in pool P.
load_balance_main_t load_balance_main
The one instance of load-balance main.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
void lookup_dpo_module_init(void)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static const char *const lookup_src_ip6_nodes[]
static const char *const lookup_dst_mpls_nodes[]
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
vlib_node_registration_t lookup_ip6_dst_itf_node
(constructor) VLIB_REGISTER_NODE (lookup_ip6_dst_itf_node)
u32 ip6_fib_table_fwding_lookup(ip6_main_t *im, u32 fib_index, const ip6_address_t *dst)
static void ip4_src_fib_lookup_two(u32 src_fib_index0, u32 src_fib_index1, const ip4_address_t *addr0, const ip4_address_t *addr1, u32 *src_adj_index0, u32 *src_adj_index1)
static const char *const lookup_dst_from_interface_mpls_nodes[]
#define CLIB_PREFETCH(addr, size, type)
static uword lookup_mpls_dst_itf(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
enum lookup_table_t_ lookup_table_t
Switch to use the packet's source or destination address for lookup.
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
#define VLIB_BUFFER_IS_TRACED
static const char *const lookup_input_names[]
u32 fib_node_index_t
A typedef of a node index.
static const char *const lookup_dst_ip6_nodes[]
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
vlib_node_registration_t lookup_mpls_dst_node
(constructor) VLIB_REGISTER_NODE (lookup_mpls_dst_node)
enum lookup_input_t_ lookup_input_t
Switch to use the packet's source or destination address for lookup.
static const char *const lookup_dst_from_interface_ip4_nodes[]
static uword lookup_ip6_dst(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
vlib_node_registration_t lookup_ip6_dst_node
(constructor) VLIB_REGISTER_NODE (lookup_ip6_dst_node)
#define IP4_FIB_MTRIE_LEAF_ROOT
static void lookup_dpo_mem_show(void)
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
static const char *const lookup_src_ip4_nodes[]
static load_balance_t * load_balance_get(index_t lbi)
static const char *const lookup_dst_ip4_nodes[]
static uword lookup_dpo_ip4_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int input_src_addr, int table_from_interface)
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
static const char *const *const lookup_dst_from_interface_nodes[DPO_PROTO_NUM]
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void lookup_dpo_add_or_lock_i(fib_node_index_t fib_index, dpo_proto_t proto, lookup_input_t input, lookup_table_t table_config, dpo_id_t *dpo)
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
lookup_table_t lkd_table
Switch to use the table index passed, or the table of the input interface.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
u8 * format_fib_table_name(u8 *s, va_list ap)
Format the description/name of the table.
index_t dpoi_index
the index of objects of that type
#define FIB_NODE_INDEX_INVALID
static u8 * format_lookup_mpls_trace(u8 *s, va_list *args)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
A collection of combined counters.
static index_t mpls_fib_table_forwarding_lookup(u32 mpls_fib_index, const mpls_unicast_header_t *hdr)
Lookup a label and EOS bit in the MPLS_FIB table to retrieve the load-balance index to be used for pa...
u8 * format_dpo_proto(u8 *s, va_list *args)
format a DPO protocol
vlib_node_registration_t lookup_ip4_dst_itf_node
(constructor) VLIB_REGISTER_NODE (lookup_ip4_dst_itf_node)
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
static void ip4_src_fib_lookup_one(u32 src_fib_index0, const ip4_address_t *addr0, u32 *src_adj_index0)
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
vlib_node_registration_t lookup_ip4_src_node
(constructor) VLIB_REGISTER_NODE (lookup_ip4_src_node)
static index_t lookup_dpo_get_index(lookup_dpo_t *lkd)
static uword lookup_ip4_dst(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
u16 dpoi_next_node
The next VLIB node to follow.
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
fib_node_index_t lkd_fib_index
The FIB, or interface from which to get a FIB, in which to perform the next lookup;.
static u8 * format_lookup_trace(u8 *s, va_list *args)
ip4_fib_mtrie_leaf_t default_leaf
static uword pool_elts(void *v)
Number of active elements in a pool.