FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
load_balance.c File Reference
+ Include dependency graph for load_balance.c:

Go to the source code of this file.

Data Structures

struct  load_balance_trace_t_
 

Macros

#define LB_DBG(_lb, _fmt, _args...)
 

Typedefs

typedef struct load_balance_trace_t_ load_balance_trace_t
 

Functions

f64 load_balance_get_multipath_tolerance (void)
 
static index_t load_balance_get_index (const load_balance_t *lb)
 
static dpo_id_tload_balance_get_buckets (load_balance_t *lb)
 
static load_balance_tload_balance_alloc_i (void)
 
static u8load_balance_format (index_t lbi, load_balance_format_flags_t flags, u32 indent, u8 *s)
 
u8format_load_balance (u8 *s, va_list *args)
 
static u8format_load_balance_dpo (u8 *s, va_list *args)
 
flow_hash_config_t load_balance_get_default_flow_hash (dpo_proto_t lb_proto)
 
static load_balance_tload_balance_create_i (u32 num_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
 
index_t load_balance_create (u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
 
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_set_bucket (index_t lbi, u32 bucket, const dpo_id_t *next)
 
int load_balance_is_drop (const dpo_id_t *dpo)
 
u16 load_balance_n_buckets (index_t lbi)
 
void load_balance_set_fib_entry_flags (index_t lbi, fib_entry_flag_t flags)
 
void load_balance_set_urpf (index_t lbi, index_t urpf)
 
index_t load_balance_get_urpf (index_t lbi)
 
const dpo_id_tload_balance_get_bucket (index_t lbi, u32 bucket)
 
static int next_hop_sort_by_weight (const load_balance_path_t *n1, const load_balance_path_t *n2)
 
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)
 
static load_balance_path_tload_balance_multipath_next_hop_fixup (const load_balance_path_t *nhs, dpo_proto_t drop_proto)
 
static void load_balance_fill_buckets_norm (load_balance_t *lb, load_balance_path_t *nhs, dpo_id_t *buckets, u32 n_buckets)
 
static void load_balance_fill_buckets_sticky (load_balance_t *lb, load_balance_path_t *nhs, dpo_id_t *buckets, u32 n_buckets)
 
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)
 
static void load_balance_set_n_buckets (load_balance_t *lb, u32 n_buckets)
 
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)
 
static void load_balance_destroy (load_balance_t *lb)
 
static void load_balance_unlock (dpo_id_t *dpo)
 
static void load_balance_mem_show (void)
 
static u16 load_balance_dpo_get_mtu (const dpo_id_t *dpo)
 
void load_balance_module_init (void)
 
static clib_error_tload_balance_show (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static u32 ip_flow_hash (void *data)
 
static u64 mac_to_u64 (u8 *m)
 
static u32 l2_flow_hash (vlib_buffer_t *b0)
 
static uword load_balance_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_l2)
 
static uword l2_load_balance (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static u8format_l2_load_balance_trace (u8 *s, va_list *args)
 
static uword nsh_load_balance (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static u8format_nsh_load_balance_trace (u8 *s, va_list *args)
 
static u8format_bier_load_balance_trace (u8 *s, va_list *args)
 
static uword bier_load_balance (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 

Variables

const f64 multipath_next_hop_error_tolerance = 0.1
 
static const char * load_balance_attr_names [] = LOAD_BALANCE_ATTR_NAMES
 
vlib_log_class_t load_balance_logger
 the logger More...
 
load_balance_tload_balance_pool
 Pool of all DPOs. More...
 
load_balance_main_t load_balance_main
 The one instance of load-balance main. More...
 
const static dpo_vft_t lb_vft
 
const static char *const load_balance_ip4_nodes []
 The per-protocol VLIB graph nodes that are assigned to a load-balance object. More...
 
const static char *const load_balance_ip6_nodes []
 
const static char *const load_balance_mpls_nodes []
 
const static char *const load_balance_l2_nodes []
 
const static char *const load_balance_nsh_nodes []
 
const static char *const load_balance_bier_nodes []
 
const static char *const *const load_balance_nodes [DPO_PROTO_NUM]
 
static vlib_cli_command_t load_balance_show_command
 (constructor) VLIB_CLI_COMMAND (load_balance_show_command) More...
 
vlib_node_registration_t l2_load_balance_node
 (constructor) VLIB_REGISTER_NODE (l2_load_balance_node) More...
 
vlib_node_registration_t nsh_load_balance_node
 (constructor) VLIB_REGISTER_NODE (nsh_load_balance_node) More...
 
vlib_node_registration_t bier_load_balance_node
 (constructor) VLIB_REGISTER_NODE (bier_load_balance_node) More...
 

Macro Definition Documentation

◆ LB_DBG

#define LB_DBG (   _lb,
  _fmt,
  _args... 
)
Value:
{ \
vlib_log_debug(load_balance_logger, \
"lb:[%U]:" _fmt, \
##_args); \
}

Definition at line 42 of file load_balance.c.

Typedef Documentation

◆ load_balance_trace_t

Function Documentation

◆ bier_load_balance()

static uword bier_load_balance ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 1329 of file load_balance.c.

+ Here is the call graph for this function:

◆ format_bier_load_balance_trace()

static u8* format_bier_load_balance_trace ( u8 s,
va_list *  args 
)
static

Definition at line 1318 of file load_balance.c.

◆ format_l2_load_balance_trace()

static u8* format_l2_load_balance_trace ( u8 s,
va_list *  args 
)
static

Definition at line 1202 of file load_balance.c.

◆ format_load_balance()

u8* format_load_balance ( u8 s,
va_list *  args 
)

Definition at line 202 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_load_balance_dpo()

static u8* format_load_balance_dpo ( u8 s,
va_list *  args 
)
static

Definition at line 211 of file load_balance.c.

+ Here is the call graph for this function:

◆ format_nsh_load_balance_trace()

static u8* format_nsh_load_balance_trace ( u8 s,
va_list *  args 
)
static

Definition at line 1292 of file load_balance.c.

◆ ip_flow_hash()

static u32 ip_flow_hash ( void *  data)
inlinestatic

Definition at line 1072 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip_multipath_normalize_next_hops()

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 
)

Definition at line 387 of file load_balance.c.

+ Here is the caller graph for this function:

◆ l2_flow_hash()

static u32 l2_flow_hash ( vlib_buffer_t b0)
inlinestatic

Definition at line 1089 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ l2_load_balance()

static uword l2_load_balance ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 1194 of file load_balance.c.

+ Here is the call graph for this function:

◆ load_balance_alloc_i()

static load_balance_t* load_balance_alloc_i ( void  )
static

Definition at line 96 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_create()

index_t load_balance_create ( u32  n_buckets,
dpo_proto_t  lb_proto,
flow_hash_config_t  fhc 
)

Definition at line 266 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_create_i()

static load_balance_t* load_balance_create_i ( u32  num_buckets,
dpo_proto_t  lb_proto,
flow_hash_config_t  fhc 
)
static

Definition at line 241 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_destroy()

static void load_balance_destroy ( load_balance_t lb)
static

Definition at line 874 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_dpo_get_mtu()

static u16 load_balance_dpo_get_mtu ( const dpo_id_t dpo)
static

Definition at line 924 of file load_balance.c.

+ Here is the call graph for this function:

◆ load_balance_fill_buckets()

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 
)
static

Definition at line 604 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_fill_buckets_norm()

static void load_balance_fill_buckets_norm ( load_balance_t lb,
load_balance_path_t nhs,
dpo_id_t buckets,
u32  n_buckets 
)
static

Definition at line 533 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_fill_buckets_sticky()

static void load_balance_fill_buckets_sticky ( load_balance_t lb,
load_balance_path_t nhs,
dpo_id_t buckets,
u32  n_buckets 
)
static

Definition at line 557 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_format()

static u8* load_balance_format ( index_t  lbi,
load_balance_format_flags_t  flags,
u32  indent,
u8 s 
)
static

Definition at line 142 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_get_bucket()

const dpo_id_t* load_balance_get_bucket ( index_t  lbi,
u32  bucket 
)

Definition at line 366 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_get_buckets()

static dpo_id_t* load_balance_get_buckets ( load_balance_t lb)
inlinestatic

Definition at line 83 of file load_balance.c.

+ Here is the caller graph for this function:

◆ load_balance_get_default_flow_hash()

flow_hash_config_t load_balance_get_default_flow_hash ( dpo_proto_t  lb_proto)

Definition at line 220 of file load_balance.c.

+ Here is the caller graph for this function:

◆ load_balance_get_index()

static index_t load_balance_get_index ( const load_balance_t lb)
inlinestatic

Definition at line 77 of file load_balance.c.

+ Here is the caller graph for this function:

◆ load_balance_get_multipath_tolerance()

f64 load_balance_get_multipath_tolerance ( void  )

Definition at line 71 of file load_balance.c.

◆ load_balance_get_urpf()

index_t load_balance_get_urpf ( index_t  lbi)

Definition at line 356 of file load_balance.c.

+ Here is the call graph for this function:

◆ load_balance_inline()

static uword load_balance_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame,
int  is_l2 
)
inlinestatic

Definition at line 1121 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_is_drop()

int load_balance_is_drop ( const dpo_id_t dpo)

Definition at line 299 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_lock()

static void load_balance_lock ( dpo_id_t dpo)
static

Definition at line 864 of file load_balance.c.

+ Here is the call graph for this function:

◆ load_balance_mem_show()

static void load_balance_mem_show ( void  )
static

Definition at line 914 of file load_balance.c.

+ Here is the call graph for this function:

◆ load_balance_module_init()

void load_balance_module_init ( void  )

Definition at line 1001 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_multipath_next_hop_fixup()

static load_balance_path_t* load_balance_multipath_next_hop_fixup ( const load_balance_path_t nhs,
dpo_proto_t  drop_proto 
)
static

Definition at line 507 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_multipath_update()

void load_balance_multipath_update ( const dpo_id_t dpo,
const load_balance_path_t raw_nhs,
load_balance_flags_t  flags 
)

Definition at line 629 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_n_buckets()

u16 load_balance_n_buckets ( index_t  lbi)

Definition at line 316 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_set_bucket()

void load_balance_set_bucket ( index_t  lbi,
u32  bucket,
const dpo_id_t next 
)

Definition at line 283 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_set_bucket_i()

static void load_balance_set_bucket_i ( load_balance_t lb,
u32  bucket,
dpo_id_t buckets,
const dpo_id_t next 
)
inlinestatic

Definition at line 274 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_set_fib_entry_flags()

void load_balance_set_fib_entry_flags ( index_t  lbi,
fib_entry_flag_t  flags 
)

Definition at line 326 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_set_n_buckets()

static void load_balance_set_n_buckets ( load_balance_t lb,
u32  n_buckets 
)
inlinestatic

Definition at line 621 of file load_balance.c.

+ Here is the caller graph for this function:

◆ load_balance_set_urpf()

void load_balance_set_urpf ( index_t  lbi,
index_t  urpf 
)

Definition at line 337 of file load_balance.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_balance_show()

static clib_error_t* load_balance_show ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 1023 of file load_balance.c.

+ Here is the call graph for this function:

◆ load_balance_unlock()

static void load_balance_unlock ( dpo_id_t dpo)
static

Definition at line 899 of file load_balance.c.

+ Here is the call graph for this function:

◆ mac_to_u64()

static u64 mac_to_u64 ( u8 m)
inlinestatic

Definition at line 1083 of file load_balance.c.

+ Here is the caller graph for this function:

◆ next_hop_sort_by_weight()

static int next_hop_sort_by_weight ( const load_balance_path_t n1,
const load_balance_path_t n2 
)
static

Definition at line 377 of file load_balance.c.

◆ nsh_load_balance()

static uword nsh_load_balance ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 1228 of file load_balance.c.

+ Here is the call graph for this function:

Variable Documentation

◆ bier_load_balance_node

vlib_node_registration_t bier_load_balance_node
Initial value:
= {
.function = bier_load_balance,
.name = "bier-load-balance",
.vector_size = sizeof (u32),
.sibling_of = "mpls-load-balance",
}

(constructor) VLIB_REGISTER_NODE (bier_load_balance_node)

Definition at line 1339 of file load_balance.c.

◆ l2_load_balance_node

vlib_node_registration_t l2_load_balance_node
Initial value:
= {
.function = l2_load_balance,
.name = "l2-load-balance",
.vector_size = sizeof (u32),
.n_next_nodes = 1,
.next_nodes = {
[0] = "error-drop",
},
}

(constructor) VLIB_REGISTER_NODE (l2_load_balance_node)

Definition at line 1215 of file load_balance.c.

◆ lb_vft

const static dpo_vft_t lb_vft
static
Initial value:
= {
.dv_lock = load_balance_lock,
.dv_unlock = load_balance_unlock,
.dv_mem_show = load_balance_mem_show,
.dv_get_mtu = load_balance_dpo_get_mtu,
}

Definition at line 941 of file load_balance.c.

◆ load_balance_attr_names

const char* load_balance_attr_names[] = LOAD_BALANCE_ATTR_NAMES
static

Definition at line 35 of file load_balance.c.

◆ load_balance_bier_nodes

const static char* const load_balance_bier_nodes[]
static
Initial value:
=
{
"bier-load-balance",
NULL,
}

Definition at line 985 of file load_balance.c.

◆ load_balance_ip4_nodes

const static char* const load_balance_ip4_nodes[]
static
Initial value:
=
{
"ip4-load-balance",
NULL,
}

The per-protocol VLIB graph nodes that are assigned to a load-balance object.

this means that these graph nodes are ones from which a load-balance is the parent object in the DPO-graph.

We do not list all the load-balance nodes, such as the *-lookup. instead we are relying on the correct use of the .sibling_of field when setting up these sibling nodes.

Definition at line 960 of file load_balance.c.

◆ load_balance_ip6_nodes

const static char* const load_balance_ip6_nodes[]
static
Initial value:
=
{
"ip6-load-balance",
NULL,
}

Definition at line 965 of file load_balance.c.

◆ load_balance_l2_nodes

const static char* const load_balance_l2_nodes[]
static
Initial value:
=
{
"l2-load-balance",
NULL,
}

Definition at line 975 of file load_balance.c.

◆ load_balance_logger

vlib_log_class_t load_balance_logger

the logger

Definition at line 40 of file load_balance.c.

◆ load_balance_main

load_balance_main_t load_balance_main
Initial value:
= {
.lbm_to_counters = {
.name = "route-to",
.stat_segment_name = "/net/route/to",
},
.lbm_via_counters = {
.name = "route-via",
.stat_segment_name = "/net/route/via",
}
}

The one instance of load-balance main.

Definition at line 59 of file load_balance.c.

◆ load_balance_mpls_nodes

const static char* const load_balance_mpls_nodes[]
static
Initial value:
=
{
"mpls-load-balance",
NULL,
}

Definition at line 970 of file load_balance.c.

◆ load_balance_nodes

◆ load_balance_nsh_nodes

const static char* const load_balance_nsh_nodes[]
static
Initial value:
=
{
"nsh-load-balance",
NULL
}

Definition at line 980 of file load_balance.c.

◆ load_balance_pool

load_balance_t* load_balance_pool

Pool of all DPOs.

The encapsulation breakages are for fast DP access.

It's not static so the DP can have fast access

Definition at line 54 of file load_balance.c.

◆ load_balance_show_command

vlib_cli_command_t load_balance_show_command
static
Initial value:
= {
.path = "show load-balance",
.short_help = "show load-balance [<index>]",
.function = load_balance_show,
}

(constructor) VLIB_CLI_COMMAND (load_balance_show_command)

Definition at line 1064 of file load_balance.c.

◆ multipath_next_hop_error_tolerance

const f64 multipath_next_hop_error_tolerance = 0.1

Definition at line 33 of file load_balance.c.

◆ nsh_load_balance_node

vlib_node_registration_t nsh_load_balance_node
Initial value:
= {
.function = nsh_load_balance,
.name = "nsh-load-balance",
.vector_size = sizeof (u32),
.n_next_nodes = 1,
.next_nodes = {
[0] = "error-drop",
},
}

(constructor) VLIB_REGISTER_NODE (nsh_load_balance_node)

Definition at line 1305 of file load_balance.c.

load_balance_dpo_get_mtu
static u16 load_balance_dpo_get_mtu(const dpo_id_t *dpo)
Definition: load_balance.c:924
format_l2_load_balance_trace
static u8 * format_l2_load_balance_trace(u8 *s, va_list *args)
Definition: load_balance.c:1202
load_balance_mem_show
static void load_balance_mem_show(void)
Definition: load_balance.c:914
load_balance_bier_nodes
const static char *const load_balance_bier_nodes[]
Definition: load_balance.c:985
DPO_PROTO_BIER
@ DPO_PROTO_BIER
Definition: dpo.h:68
format_load_balance_dpo
static u8 * format_load_balance_dpo(u8 *s, va_list *args)
Definition: load_balance.c:211
format_load_balance
u8 * format_load_balance(u8 *s, va_list *args)
Definition: load_balance.c:202
bier_load_balance
static uword bier_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: load_balance.c:1329
load_balance_lock
static void load_balance_lock(dpo_id_t *dpo)
Definition: load_balance.c:864
load_balance_unlock
static void load_balance_unlock(dpo_id_t *dpo)
Definition: load_balance.c:899
load_balance_ip6_nodes
const static char *const load_balance_ip6_nodes[]
Definition: load_balance.c:965
LOAD_BALANCE_FORMAT_NONE
@ LOAD_BALANCE_FORMAT_NONE
Definition: load_balance.h:184
nsh_load_balance
static uword nsh_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: load_balance.c:1228
l2_load_balance
static uword l2_load_balance(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: load_balance.c:1194
format_bier_load_balance_trace
static u8 * format_bier_load_balance_trace(u8 *s, va_list *args)
Definition: load_balance.c:1318
load_balance_show
static clib_error_t * load_balance_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: load_balance.c:1023
load_balance_ip4_nodes
const static char *const load_balance_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to a load-balance object.
Definition: load_balance.c:960
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
DPO_PROTO_MPLS
@ DPO_PROTO_MPLS
Definition: dpo.h:66
u32
unsigned int u32
Definition: types.h:88
load_balance_l2_nodes
const static char *const load_balance_l2_nodes[]
Definition: load_balance.c:975
format_nsh_load_balance_trace
static u8 * format_nsh_load_balance_trace(u8 *s, va_list *args)
Definition: load_balance.c:1292
load_balance_mpls_nodes
const static char *const load_balance_mpls_nodes[]
Definition: load_balance.c:970
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
load_balance_logger
vlib_log_class_t load_balance_logger
the logger
Definition: load_balance.c:40
DPO_PROTO_NSH
@ DPO_PROTO_NSH
Definition: dpo.h:69
DPO_PROTO_ETHERNET
@ DPO_PROTO_ETHERNET
Definition: dpo.h:67
load_balance_get_index
static index_t load_balance_get_index(const load_balance_t *lb)
Definition: load_balance.c:77
load_balance_nsh_nodes
const static char *const load_balance_nsh_nodes[]
Definition: load_balance.c:980