|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
42 #define LB_DBG(_lb, _fmt, _args...) \
44 vlib_log_debug(load_balance_logger, \
46 format_load_balance, load_balance_get_index(_lb), \
47 LOAD_BALANCE_FORMAT_NONE, \
62 .stat_segment_name =
"/net/route/to",
66 .stat_segment_name =
"/net/route/via",
99 u8 need_barrier_sync = 0;
105 if (need_barrier_sync)
114 if (need_barrier_sync == 0)
122 if (need_barrier_sync)
135 if (need_barrier_sync)
176 s =
format(s,
"to:[%Ld:%Ld]",
to.packets,
to.bytes);
179 s =
format(s,
" via:[%Ld:%Ld]",
192 s =
format(s,
"\n%U[%d] %U",
196 &buckets[
i], indent+6);
214 u32 indent = va_arg(*args,
u32);
293 ASSERT(bucket < lb->lb_n_buckets);
402 nhs = *normalized_next_hops;
409 nhs[0] = raw_next_hops[0];
410 nhs[0].path_weight = 1;
421 nhs[0] = raw_next_hops[cmp];
422 nhs[1] = raw_next_hops[cmp ^ 1];
425 if (
nhs[0].path_weight ==
nhs[1].path_weight)
427 nhs[0].path_weight =
nhs[1].path_weight = 1;
442 sum_weight +=
nhs[
i].path_weight;
448 nhs[
i].path_weight = 1;
462 norm = n_adj / ((
f64) sum_weight);
469 n = n > n_adj_left ? n_adj_left : n;
472 nhs[
i].path_weight = n;
474 if (0 ==
nhs[
i].path_weight)
488 nhs[0].path_weight += n_adj_left;
501 *normalized_next_hops =
nhs;
502 *sum_weight_in = sum_weight;
549 for (ii = 0; ii <
nh->path_weight; ii++)
551 ASSERT(bucket < n_buckets);
563 u16 ii, bucket, fpath;
575 if (
vec_len(fwding_paths) == 0)
584 for (ii = 0; ii <
nh->path_weight; ii++)
586 ASSERT(bucket < n_buckets);
595 fpath = (fpath + 1) %
vec_len(fwding_paths);
634 u32 sum_of_weights, n_buckets, ii;
760 dpo_id_t *new_buckets, *old_buckets, *tmp_dpo;
845 for (ii = n_buckets; ii < old_n_buckets; ii++)
1065 .path =
"show load-balance",
1066 .short_help =
"show load-balance [<index>]",
1085 return (*((
u64 *) m) & 0xffffffffffff);
1093 uword is_ip, eh_size;
1097 eh_type = clib_net_to_host_u16 (eh->
type);
1100 is_ip = (eh_type == ETHERNET_TYPE_IP4 || eh_type == ETHERNET_TYPE_IP6);
1142 u32 bi0, lbi0, next0;
1151 n_left_to_next -= 1;
1184 n_left_to_next, bi0, next0);
1190 return frame->n_vectors;
1217 .name =
"l2-load-balance",
1218 .vector_size =
sizeof (
u32),
1248 u32 bi0, lbi0, next0, *nsh0;
1257 n_left_to_next -= 1;
1282 n_left_to_next, bi0, next0);
1288 return frame->n_vectors;
1307 .name =
"nsh-load-balance",
1308 .vector_size =
sizeof (
u32),
1341 .name =
"bier-load-balance",
1342 .vector_size =
sizeof (
u32),
1345 .sibling_of =
"mpls-load-balance",
static const char * load_balance_attr_names[]
struct load_balance_trace_t_ load_balance_trace_t
int dpo_is_drop(const dpo_id_t *dpo)
The Drop DPO will drop all packets, no questions asked.
u16 dpoi_next_node
The next VLIB node to follow.
u16 lb_n_buckets
number of buckets in the load-balance.
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
index_t dpoi_index
the index of objects of that type
u32 ip_multipath_normalize_next_hops(const load_balance_path_t *raw_next_hops, load_balance_path_t **normalized_next_hops, u32 *sum_weight_in, f64 multipath_next_hop_error_tolerance)
void load_balance_map_unlock(index_t lbmi)
static u16 load_balance_dpo_get_mtu(const dpo_id_t *dpo)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
nat44_ei_hairpin_src_next_t next_index
u32 path_weight
weight for the path.
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static vlib_cli_command_t load_balance_show_command
(constructor) VLIB_CLI_COMMAND (load_balance_show_command)
dpo_type_t dpoi_type
the type
load_balance_t * load_balance_pool
Pool of all DPOs.
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
#define LOAD_BALANCE_ATTR_NAMES
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
vlib_main_t vlib_node_runtime_t * node
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
static u8 * format_l2_load_balance_trace(u8 *s, va_list *args)
static void load_balance_mem_show(void)
index_t load_balance_create(u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
enum load_balance_format_flags_t_ load_balance_format_flags_t
Flags controlling load-balance formatting/display.
static load_balance_t * load_balance_alloc_i(void)
void load_balance_set_urpf(index_t lbi, index_t urpf)
index_t lb_map
index of the load-balance map, INVALID if this LB does not use one
u16 load_balance_n_buckets(index_t lbi)
vlib_combined_counter_main_t lbm_via_counters
u8 * format_dpo_type(u8 *s, va_list *args)
format a DPO type
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
#define pool_put(P, E)
Free an object E in pool P.
const static char *const load_balance_bier_nodes[]
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
void fib_urpf_list_lock(index_t ui)
char * name
The counter collection's name.
static void load_balance_set_n_buckets(load_balance_t *lb, u32 n_buckets)
vl_api_gbp_next_hop_t nhs[8]
static u8 * format_load_balance_dpo(u8 *s, va_list *args)
u8 * format_load_balance(u8 *s, va_list *args)
static uword bier_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static load_balance_path_t * load_balance_multipath_next_hop_fixup(const load_balance_path_t *nhs, dpo_proto_t drop_proto)
int vlib_validate_combined_counter_will_expand(vlib_combined_counter_main_t *cm, u32 index)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static u32 ip_flow_hash(void *data)
flow_hash_config_t load_balance_get_default_flow_hash(dpo_proto_t lb_proto)
static int next_hop_sort_by_weight(const load_balance_path_t *n1, const load_balance_path_t *n2)
void load_balance_set_fib_entry_flags(index_t lbi, fib_entry_flag_t flags)
#define pool_get_aligned_will_expand(P, YESNO, A)
See if pool_get will expand the pool or not.
int load_balance_is_drop(const dpo_id_t *dpo)
void load_balance_multipath_update(const dpo_id_t *dpo, const load_balance_path_t *raw_nhs, load_balance_flags_t flags)
static void load_balance_lock(dpo_id_t *dpo)
#define MPLS_FLOW_HASH_DEFAULT
There are no options for controlling the MPLS flow hash, but since it mostly entails using IP data to...
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
@ LOAD_BALANCE_FORMAT_DETAIL
static void load_balance_unlock(dpo_id_t *dpo)
#define pool_foreach(VAR, POOL)
Iterate through pool.
load_balance_main_t load_balance_main
The one instance of load-balance main.
static dpo_id_t * load_balance_get_buckets(load_balance_t *lb)
const dpo_id_t * load_balance_get_bucket(index_t lbi, u32 bucket)
#define FOR_EACH_LOAD_BALANCE_ATTR(_attr)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
enum fib_entry_flag_t_ fib_entry_flag_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
const static char *const *const load_balance_nodes[DPO_PROTO_NUM]
index_t load_balance_get_urpf(index_t lbi)
static u8 * load_balance_format(index_t lbi, load_balance_format_flags_t flags, u32 indent, u8 *s)
static u32 ip6_compute_flow_hash(const ip6_header_t *ip, flow_hash_config_t flow_hash_config)
static void load_balance_fill_buckets_norm(load_balance_t *lb, load_balance_path_t *nhs, dpo_id_t *buckets, u32 n_buckets)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
static void load_balance_fill_buckets(load_balance_t *lb, load_balance_path_t *nhs, dpo_id_t *buckets, u32 n_buckets, load_balance_flags_t flags)
enum load_balance_flags_t_ load_balance_flags_t
Combined counter to hold both packets and byte differences.
#define vlib_worker_thread_barrier_sync(X)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
enum flow_hash_config_t_ flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define ethernet_buffer_header_size(b)
Determine the size of the Ethernet headers of the current frame in the buffer.
fib_entry_flag_t lb_fib_entry_flags
Flags from the load-balance's associated fib_entry_t.
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple + flowlabel without the "reverse" bit.
void load_balance_module_init(void)
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.
const static char *const load_balance_ip6_nodes[]
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
u16 dpo_get_mtu(const dpo_id_t *dpo)
Get the MTU DPO.
@ LOAD_BALANCE_FLAG_USES_MAP
@ LOAD_BALANCE_FORMAT_NONE
static load_balance_t * load_balance_create_i(u32 num_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
index_t load_balance_map_add_or_lock(u32 n_buckets, u32 sum_of_weights, const load_balance_path_t *paths)
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
dpo_lock_fn_t dv_lock
A reference counting lock function.
f64 load_balance_get_multipath_tolerance(void)
#define CLIB_MEMORY_BARRIER()
void load_balance_map_show_mem(void)
counter_t packets
packet counter
#define CLIB_CACHE_LINE_BYTES
vlib_node_registration_t l2_load_balance_node
(constructor) VLIB_REGISTER_NODE (l2_load_balance_node)
struct _vlib_node_registration vlib_node_registration_t
#define LB_DBG(_lb, _fmt, _args...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject.
#define LB_HAS_INLINE_BUCKETS(_lb)
#define LB_NUM_INLINE_BUCKETS
The number of buckets that a load-balance object can have and still fit in one cache-line.
vlib_node_registration_t bier_load_balance_node
(constructor) VLIB_REGISTER_NODE (bier_load_balance_node)
@ LOAD_BALANCE_FLAG_STICKY
static uword nsh_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
enum load_balance_attr_t_ load_balance_attr_t
Flags controlling load-balance creation and modification.
void load_balance_set_bucket(index_t lbi, u32 bucket, const dpo_id_t *next)
@ DPO_LOAD_BALANCE
load-balancing over a choice of [un]equal cost paths
static uword l2_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
load_balance_flags_t lb_flags
Flags concenring the LB's creation and modification.
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
static u8 * format_bier_load_balance_trace(u8 *s, va_list *args)
#define vec_free(V)
Free vector's memory (no header).
static_always_inline u32 bier_compute_flow_hash(const bier_hdr_t *hdr)
#define pool_len(p)
Number of elements in pool vector.
#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.
vlib_combined_counter_main_t lbm_to_counters
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
static clib_error_t * load_balance_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
const static char *const load_balance_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to a load-balance object.
description fragment has unexpected format
vlib_put_next_frame(vm, node, next_index, 0)
static void load_balance_fill_buckets_sticky(load_balance_t *lb, load_balance_path_t *nhs, dpo_id_t *buckets, u32 n_buckets)
static u32 l2_flow_hash(vlib_buffer_t *b0)
counter_t bytes
byte counter
const f64 multipath_next_hop_error_tolerance
u8 * format_load_balance_map(u8 *s, va_list *ap)
#define vec_foreach(var, vec)
Vector iterator.
static load_balance_t * load_balance_get(index_t lbi)
static word flt_round_nearest(f64 x)
static uword pool_elts(void *v)
Number of active elements in a pool.
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
static u64 mac_to_u64(u8 *m)
const static char *const load_balance_l2_nodes[]
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static u8 * format_nsh_load_balance_trace(u8 *s, va_list *args)
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
A virtual function table regisitered for a DPO type.
u8 * format_dpo_proto(u8 *s, va_list *args)
format a DPO protocol
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static vlib_main_t * vlib_get_main(void)
dpo_id_t * lb_buckets
Vector of buckets containing the next DPOs, sized as lbo_num.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
const static char *const load_balance_mpls_nodes[]
vlib_node_registration_t nsh_load_balance_node
(constructor) VLIB_REGISTER_NODE (nsh_load_balance_node)
dpo_proto_t lb_proto
The protocol of packets that traverse this LB.
static void load_balance_destroy(load_balance_t *lb)
vlib_log_class_t load_balance_logger
the logger
dpo_id_t lb_buckets_inline[LB_NUM_INLINE_BUCKETS]
The rest of the cache line is used for buckets.
A BIER header of variable length The encoding follows: https://tools.ietf.org/html/draft-ietf-bier-mp...
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
u16 lb_n_buckets_minus_1
number of buckets in the load-balance - 1.
static uword max_pow2(uword x)
void qsort(void *base, uword n, uword size, int(*compar)(const void *, const void *))
static uword load_balance_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_l2)
index_t lb_urpf
This is the index of the uRPF list for this LB.
The load-balance object represents an ECMP choice.
static index_t load_balance_get_index(const load_balance_t *lb)
#define hash_mix64(a0, b0, c0)
u32 lb_locks
The number of locks, which is approximately the number of users, of this load-balance.
const static dpo_vft_t lb_vft
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
const static char *const load_balance_nsh_nodes[]
#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).
One path from an [EU]CMP set that the client wants to add to a load-balance object.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
static void load_balance_set_bucket_i(load_balance_t *lb, u32 bucket, dpo_id_t *buckets, const dpo_id_t *next)
void load_balance_map_module_init(void)
Make/add a new or lock an existing Load-balance map.
void fib_urpf_list_unlock(index_t ui)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
vl_api_wireguard_peer_flags_t flags