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

Go to the source code of this file.

Data Structures

struct  lb_pseudorand_t
 

Macros

#define LB_GARBAGE_RUN   60
 
#define LB_CONCURRENCY_TIMEOUT   10
 
#define lb_get_writer_lock()   clib_spinlock_lock (&lb_main.writer_lock)
 
#define lb_put_writer_lock()   clib_spinlock_unlock (&lb_main.writer_lock)
 

Functions

static void lb_as_stack (lb_as_t *as)
 
u32 lb_hash_time_now (vlib_main_t *vm)
 
u8format_lb_main (u8 *s, va_list *args)
 
u8format_lb_vip_type (u8 *s, va_list *args)
 
uword unformat_lb_vip_type (unformat_input_t *input, va_list *args)
 
u8format_lb_vip (u8 *s, va_list *args)
 
u8format_lb_as (u8 *s, va_list *args)
 
u8format_lb_vip_detailed (u8 *s, va_list *args)
 
static int lb_pseudorand_compare (void *a, void *b)
 
static void lb_vip_garbage_collection (lb_vip_t *vip)
 
void lb_garbage_collection ()
 
static void lb_vip_update_new_flow_table (lb_vip_t *vip)
 
int lb_conf (ip4_address_t *ip4_address, ip6_address_t *ip6_address, u32 per_cpu_sticky_buckets, u32 flow_timeout)
 Fix global load-balancer parameters. More...
 
static int lb_vip_port_find_index (ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, lb_lkp_type_t lkp_type, u32 *vip_index)
 
static int lb_vip_port_find_index_with_lock (ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
 
static int lb_vip_port_find_all_port_vip (ip46_address_t *prefix, u8 plen, u32 *vip_index)
 
static int lb_vip_port_find_diff_port (ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
 
int lb_vip_find_index (ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
 
static int lb_as_find_index_vip (lb_vip_t *vip, ip46_address_t *address, u32 *as_index)
 
int lb_vip_add_ass (u32 vip_index, ip46_address_t *addresses, u32 n)
 
int lb_flush_vip_as (u32 vip_index, u32 as_index)
 
int lb_vip_del_ass_withlock (u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush)
 
int lb_vip_del_ass (u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush)
 
static int lb_vip_prefix_index_alloc (lb_main_t *lbm)
 
static int lb_vip_prefix_index_free (lb_main_t *lbm, u32 instance)
 
static void lb_vip_add_adjacency (lb_main_t *lbm, lb_vip_t *vip, u32 *vip_prefix_index)
 Add the VIP adjacency to the ip4 or ip6 fib. More...
 
static int lb_vip_add_port_filter (lb_main_t *lbm, lb_vip_t *vip, u32 vip_prefix_index, u32 vip_idx)
 Add the VIP filter entry. More...
 
static int lb_vip_del_port_filter (lb_main_t *lbm, lb_vip_t *vip)
 Del the VIP filter entry. More...
 
static void lb_vip_del_adjacency (lb_main_t *lbm, lb_vip_t *vip)
 Deletes the adjacency associated with the VIP. More...
 
int lb_vip_add (lb_vip_add_args_t args, u32 *vip_index)
 
int lb_vip_del (u32 vip_index)
 
 VLIB_PLUGIN_REGISTER ()
 
u8format_lb_dpo (u8 *s, va_list *va)
 
static void lb_dpo_lock (dpo_id_t *dpo)
 
static void lb_dpo_unlock (dpo_id_t *dpo)
 
static fib_node_tlb_fib_node_get_node (fib_node_index_t index)
 
static void lb_fib_node_last_lock_gone (fib_node_t *node)
 
static lb_as_tlb_as_from_fib_node (fib_node_t *node)
 
static fib_node_back_walk_rc_t lb_fib_node_back_walk_notify (fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
 
int lb_nat4_interface_add_del (u32 sw_if_index, int is_del)
 
int lb_nat6_interface_add_del (u32 sw_if_index, int is_del)
 
clib_error_tlb_init (vlib_main_t *vm)
 

Variables

static fib_source_t lb_fib_src
 
lb_main_t lb_main
 
const static char *const lb_dpo_gre4_ip4 [] = { "lb4-gre4" , NULL }
 
const static char *const lb_dpo_gre4_ip6 [] = { "lb6-gre4" , NULL }
 
const static char *const *const lb_dpo_gre4_nodes [DPO_PROTO_NUM]
 
const static char *const lb_dpo_gre6_ip4 [] = { "lb4-gre6" , NULL }
 
const static char *const lb_dpo_gre6_ip6 [] = { "lb6-gre6" , NULL }
 
const static char *const *const lb_dpo_gre6_nodes [DPO_PROTO_NUM]
 
const static char *const lb_dpo_gre4_ip4_port [] = { "lb4-gre4-port" , NULL }
 
const static char *const lb_dpo_gre4_ip6_port [] = { "lb6-gre4-port" , NULL }
 
const static char *const *const lb_dpo_gre4_port_nodes [DPO_PROTO_NUM]
 
const static char *const lb_dpo_gre6_ip4_port [] = { "lb4-gre6-port" , NULL }
 
const static char *const lb_dpo_gre6_ip6_port [] = { "lb6-gre6-port" , NULL }
 
const static char *const *const lb_dpo_gre6_port_nodes [DPO_PROTO_NUM]
 
const static char *const lb_dpo_l3dsr_ip4 [] = {"lb4-l3dsr" , NULL}
 
const static char *const *const lb_dpo_l3dsr_nodes [DPO_PROTO_NUM]
 
const static char *const lb_dpo_l3dsr_ip4_port [] = {"lb4-l3dsr-port" , NULL}
 
const static char *const *const lb_dpo_l3dsr_port_nodes [DPO_PROTO_NUM]
 
const static char *const lb_dpo_nat4_ip4_port [] = { "lb4-nat4-port" , NULL }
 
const static char *const *const lb_dpo_nat4_port_nodes [DPO_PROTO_NUM]
 
const static char *const lb_dpo_nat6_ip6_port [] = { "lb6-nat6-port" , NULL }
 
const static char *const *const lb_dpo_nat6_port_nodes [DPO_PROTO_NUM]
 
static char * lb_vip_type_strings []
 

Macro Definition Documentation

◆ LB_CONCURRENCY_TIMEOUT

#define LB_CONCURRENCY_TIMEOUT   10

Definition at line 27 of file lb.c.

◆ LB_GARBAGE_RUN

#define LB_GARBAGE_RUN   60

Definition at line 24 of file lb.c.

◆ lb_get_writer_lock

#define lb_get_writer_lock ( )    clib_spinlock_lock (&lb_main.writer_lock)

Definition at line 34 of file lb.c.

◆ lb_put_writer_lock

#define lb_put_writer_lock ( )    clib_spinlock_unlock (&lb_main.writer_lock)

Definition at line 35 of file lb.c.

Function Documentation

◆ format_lb_as()

u8* format_lb_as ( u8 s,
va_list *  args 
)

Definition at line 187 of file lb.c.

◆ format_lb_dpo()

u8* format_lb_dpo ( u8 s,
va_list *  va 
)

Definition at line 1259 of file lb.c.

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

◆ format_lb_main()

u8* format_lb_main ( u8 s,
va_list *  args 
)

Definition at line 101 of file lb.c.

+ Here is the call graph for this function:

◆ format_lb_vip()

u8* format_lb_vip ( u8 s,
va_list *  args 
)

Definition at line 156 of file lb.c.

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

◆ format_lb_vip_detailed()

u8* format_lb_vip_detailed ( u8 s,
va_list *  args 
)

Definition at line 195 of file lb.c.

+ Here is the call graph for this function:

◆ format_lb_vip_type()

u8* format_lb_vip_type ( u8 s,
va_list *  args 
)

Definition at line 134 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_as_find_index_vip()

static int lb_as_find_index_vip ( lb_vip_t vip,
ip46_address_t *  address,
u32 as_index 
)
static

Definition at line 565 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_as_from_fib_node()

static lb_as_t* lb_as_from_fib_node ( fib_node_t node)
static

Definition at line 1285 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_as_stack()

static void lb_as_stack ( lb_as_t as)
static

Definition at line 1292 of file lb.c.

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

◆ lb_conf()

int lb_conf ( ip4_address_t ip4_address,
ip6_address_t *  ip6_address,
u32  sticky_buckets,
u32  flow_timeout 
)

Fix global load-balancer parameters.

Parameters
ip4_addressIPv4 source address used for encapsulated traffic
ip6_addressIPv6 source address used for encapsulated traffic
sticky_bucketsFIXME
flow_timeoutFIXME
Returns
0 on success. VNET_LB_ERR_XXX on error

Definition at line 476 of file lb.c.

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

◆ lb_dpo_lock()

static void lb_dpo_lock ( dpo_id_t dpo)
static

Definition at line 1268 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_dpo_unlock()

static void lb_dpo_unlock ( dpo_id_t dpo)
static

Definition at line 1269 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_fib_node_back_walk_notify()

static fib_node_back_walk_rc_t lb_fib_node_back_walk_notify ( fib_node_t node,
fib_node_back_walk_ctx_t ctx 
)
static

Definition at line 1323 of file lb.c.

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

◆ lb_fib_node_get_node()

static fib_node_t* lb_fib_node_get_node ( fib_node_index_t  index)
static

Definition at line 1272 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_fib_node_last_lock_gone()

static void lb_fib_node_last_lock_gone ( fib_node_t node)
static

Definition at line 1280 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_flush_vip_as()

int lb_flush_vip_as ( u32  vip_index,
u32  as_index 
)

Definition at line 762 of file lb.c.

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

◆ lb_garbage_collection()

void lb_garbage_collection ( )

Definition at line 357 of file lb.c.

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

◆ lb_hash_time_now()

u32 lb_hash_time_now ( vlib_main_t vm)

Definition at line 96 of file lb.c.

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

◆ lb_init()

clib_error_t* lb_init ( vlib_main_t vm)

Definition at line 1363 of file lb.c.

+ Here is the call graph for this function:

◆ lb_nat4_interface_add_del()

int lb_nat4_interface_add_del ( u32  sw_if_index,
int  is_del 
)

Definition at line 1330 of file lb.c.

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

◆ lb_nat6_interface_add_del()

int lb_nat6_interface_add_del ( u32  sw_if_index,
int  is_del 
)

Definition at line 1346 of file lb.c.

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

◆ lb_pseudorand_compare()

static int lb_pseudorand_compare ( void *  a,
void *  b 
)
static

Definition at line 279 of file lb.c.

◆ lb_vip_add()

int lb_vip_add ( lb_vip_add_args_t  args,
u32 vip_index 
)

Definition at line 1048 of file lb.c.

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

◆ lb_vip_add_adjacency()

static void lb_vip_add_adjacency ( lb_main_t lbm,
lb_vip_t vip,
u32 vip_prefix_index 
)
static

Add the VIP adjacency to the ip4 or ip6 fib.

Definition at line 895 of file lb.c.

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

◆ lb_vip_add_ass()

int lb_vip_add_ass ( u32  vip_index,
ip46_address_t *  addresses,
u32  n 
)

Definition at line 585 of file lb.c.

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

◆ lb_vip_add_port_filter()

static int lb_vip_add_port_filter ( lb_main_t lbm,
lb_vip_t vip,
u32  vip_prefix_index,
u32  vip_idx 
)
static

Add the VIP filter entry.

Definition at line 965 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_vip_del()

int lb_vip_del ( u32  vip_index)

Definition at line 1202 of file lb.c.

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

◆ lb_vip_del_adjacency()

static void lb_vip_del_adjacency ( lb_main_t lbm,
lb_vip_t vip 
)
static

Deletes the adjacency associated with the VIP.

Definition at line 1015 of file lb.c.

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

◆ lb_vip_del_ass()

int lb_vip_del_ass ( u32  vip_index,
ip46_address_t *  addresses,
u32  n,
u8  flush 
)

Definition at line 853 of file lb.c.

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

◆ lb_vip_del_ass_withlock()

int lb_vip_del_ass_withlock ( u32  vip_index,
ip46_address_t *  addresses,
u32  n,
u8  flush 
)

Definition at line 796 of file lb.c.

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

◆ lb_vip_del_port_filter()

static int lb_vip_del_port_filter ( lb_main_t lbm,
lb_vip_t vip 
)
static

Del the VIP filter entry.

Definition at line 986 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_vip_find_index()

int lb_vip_find_index ( ip46_address_t *  prefix,
u8  plen,
u8  protocol,
u16  port,
u32 vip_index 
)

Definition at line 554 of file lb.c.

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

◆ lb_vip_garbage_collection()

static void lb_vip_garbage_collection ( lb_vip_t vip)
static

Definition at line 288 of file lb.c.

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

◆ lb_vip_port_find_all_port_vip()

static int lb_vip_port_find_all_port_vip ( ip46_address_t *  prefix,
u8  plen,
u32 vip_index 
)
static

Definition at line 538 of file lb.c.

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

◆ lb_vip_port_find_diff_port()

static int lb_vip_port_find_diff_port ( ip46_address_t *  prefix,
u8  plen,
u8  protocol,
u16  port,
u32 vip_index 
)
static

Definition at line 547 of file lb.c.

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

◆ lb_vip_port_find_index()

static int lb_vip_port_find_index ( ip46_address_t *  prefix,
u8  plen,
u8  protocol,
u16  port,
lb_lkp_type_t  lkp_type,
u32 vip_index 
)
static

Definition at line 496 of file lb.c.

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

◆ lb_vip_port_find_index_with_lock()

static int lb_vip_port_find_index_with_lock ( ip46_address_t *  prefix,
u8  plen,
u8  protocol,
u16  port,
u32 vip_index 
)
static

Definition at line 530 of file lb.c.

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

◆ lb_vip_prefix_index_alloc()

static int lb_vip_prefix_index_alloc ( lb_main_t lbm)
static

Definition at line 863 of file lb.c.

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

◆ lb_vip_prefix_index_free()

static int lb_vip_prefix_index_free ( lb_main_t lbm,
u32  instance 
)
static

Definition at line 878 of file lb.c.

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

◆ lb_vip_update_new_flow_table()

static void lb_vip_update_new_flow_table ( lb_vip_t vip)
static

Definition at line 382 of file lb.c.

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

◆ unformat_lb_vip_type()

uword unformat_lb_vip_type ( unformat_input_t input,
va_list *  args 
)

Definition at line 144 of file lb.c.

+ Here is the call graph for this function:

◆ VLIB_PLUGIN_REGISTER()

VLIB_PLUGIN_REGISTER ( )

Variable Documentation

◆ lb_dpo_gre4_ip4

const static char* const lb_dpo_gre4_ip4[] = { "lb4-gre4" , NULL }
static

Definition at line 40 of file lb.c.

◆ lb_dpo_gre4_ip4_port

const static char* const lb_dpo_gre4_ip4_port[] = { "lb4-gre4-port" , NULL }
static

Definition at line 56 of file lb.c.

◆ lb_dpo_gre4_ip6

const static char* const lb_dpo_gre4_ip6[] = { "lb6-gre4" , NULL }
static

Definition at line 41 of file lb.c.

◆ lb_dpo_gre4_ip6_port

const static char* const lb_dpo_gre4_ip6_port[] = { "lb6-gre4-port" , NULL }
static

Definition at line 57 of file lb.c.

◆ lb_dpo_gre4_nodes

const static char* const * const lb_dpo_gre4_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 42 of file lb.c.

◆ lb_dpo_gre4_port_nodes

const static char* const * const lb_dpo_gre4_port_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 58 of file lb.c.

◆ lb_dpo_gre6_ip4

const static char* const lb_dpo_gre6_ip4[] = { "lb4-gre6" , NULL }
static

Definition at line 48 of file lb.c.

◆ lb_dpo_gre6_ip4_port

const static char* const lb_dpo_gre6_ip4_port[] = { "lb4-gre6-port" , NULL }
static

Definition at line 64 of file lb.c.

◆ lb_dpo_gre6_ip6

const static char* const lb_dpo_gre6_ip6[] = { "lb6-gre6" , NULL }
static

Definition at line 49 of file lb.c.

◆ lb_dpo_gre6_ip6_port

const static char* const lb_dpo_gre6_ip6_port[] = { "lb6-gre6-port" , NULL }
static

Definition at line 65 of file lb.c.

◆ lb_dpo_gre6_nodes

const static char* const * const lb_dpo_gre6_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 50 of file lb.c.

◆ lb_dpo_gre6_port_nodes

const static char* const * const lb_dpo_gre6_port_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 66 of file lb.c.

◆ lb_dpo_l3dsr_ip4

const static char* const lb_dpo_l3dsr_ip4[] = {"lb4-l3dsr" , NULL}
static

Definition at line 72 of file lb.c.

◆ lb_dpo_l3dsr_ip4_port

const static char* const lb_dpo_l3dsr_ip4_port[] = {"lb4-l3dsr-port" , NULL}
static

Definition at line 78 of file lb.c.

◆ lb_dpo_l3dsr_nodes

const static char* const * const lb_dpo_l3dsr_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 73 of file lb.c.

◆ lb_dpo_l3dsr_port_nodes

const static char* const * const lb_dpo_l3dsr_port_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 79 of file lb.c.

◆ lb_dpo_nat4_ip4_port

const static char* const lb_dpo_nat4_ip4_port[] = { "lb4-nat4-port" , NULL }
static

Definition at line 84 of file lb.c.

◆ lb_dpo_nat4_port_nodes

const static char* const * const lb_dpo_nat4_port_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 85 of file lb.c.

◆ lb_dpo_nat6_ip6_port

const static char* const lb_dpo_nat6_ip6_port[] = { "lb6-nat6-port" , NULL }
static

Definition at line 90 of file lb.c.

◆ lb_dpo_nat6_port_nodes

const static char* const * const lb_dpo_nat6_port_nodes[DPO_PROTO_NUM]
static
Initial value:

Definition at line 91 of file lb.c.

◆ lb_fib_src

fib_source_t lb_fib_src
static

Definition at line 30 of file lb.c.

◆ lb_main

lb_main_t lb_main

Definition at line 32 of file lb.c.

◆ lb_vip_type_strings

char* lb_vip_type_strings[]
static
Initial value:
= {
[LB_VIP_TYPE_IP6_GRE6] = "ip6-gre6",
[LB_VIP_TYPE_IP6_GRE4] = "ip6-gre4",
[LB_VIP_TYPE_IP4_GRE6] = "ip4-gre6",
[LB_VIP_TYPE_IP4_GRE4] = "ip4-gre4",
[LB_VIP_TYPE_IP4_L3DSR] = "ip4-l3dsr",
[LB_VIP_TYPE_IP4_NAT4] = "ip4-nat4",
[LB_VIP_TYPE_IP6_NAT6] = "ip6-nat6",
}

Definition at line 124 of file lb.c.

lb_dpo_gre4_ip4
const static char *const lb_dpo_gre4_ip4[]
Definition: lb.c:40
lb_dpo_gre6_ip4
const static char *const lb_dpo_gre6_ip4[]
Definition: lb.c:48
lb_dpo_gre6_ip6
const static char *const lb_dpo_gre6_ip6[]
Definition: lb.c:49
LB_VIP_TYPE_IP6_GRE4
@ LB_VIP_TYPE_IP6_GRE4
Definition: lb.h:210
lb_dpo_l3dsr_ip4
const static char *const lb_dpo_l3dsr_ip4[]
Definition: lb.c:72
lb_dpo_nat6_ip6_port
const static char *const lb_dpo_nat6_ip6_port[]
Definition: lb.c:90
LB_VIP_TYPE_IP4_L3DSR
@ LB_VIP_TYPE_IP4_L3DSR
Definition: lb.h:213
lb_dpo_nat4_ip4_port
const static char *const lb_dpo_nat4_ip4_port[]
Definition: lb.c:84
LB_VIP_TYPE_IP4_GRE4
@ LB_VIP_TYPE_IP4_GRE4
Definition: lb.h:212
LB_VIP_TYPE_IP4_NAT4
@ LB_VIP_TYPE_IP4_NAT4
Definition: lb.h:214
LB_VIP_TYPE_IP6_NAT6
@ LB_VIP_TYPE_IP6_NAT6
Definition: lb.h:215
LB_VIP_TYPE_IP4_GRE6
@ LB_VIP_TYPE_IP4_GRE6
Definition: lb.h:211
lb_dpo_gre6_ip6_port
const static char *const lb_dpo_gre6_ip6_port[]
Definition: lb.c:65
lb_dpo_gre4_ip6
const static char *const lb_dpo_gre4_ip6[]
Definition: lb.c:41
lb_dpo_gre4_ip6_port
const static char *const lb_dpo_gre4_ip6_port[]
Definition: lb.c:57
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
LB_VIP_TYPE_IP6_GRE6
@ LB_VIP_TYPE_IP6_GRE6
Definition: lb.h:209
lb_dpo_gre4_ip4_port
const static char *const lb_dpo_gre4_ip4_port[]
Definition: lb.c:56
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
lb_dpo_l3dsr_ip4_port
const static char *const lb_dpo_l3dsr_ip4_port[]
Definition: lb.c:78
lb_dpo_gre6_ip4_port
const static char *const lb_dpo_gre6_ip4_port[]
Definition: lb.c:64