FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
lb.h File Reference
+ Include dependency graph for lb.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lb_as_t
 Each VIP is configured with a set of application server. More...
 
struct  lb_new_flow_entry_t
 
struct  lb_vip_encap_args_t
 
struct  vip_port_key_t
 
struct  lb_vip_t
 Load balancing service is provided per VIP+protocol+port. More...
 
struct  lb_snat4_key_t
 
struct  lb_snat6_key_t
 
struct  lb_snat_mapping_t
 
struct  lb_per_cpu_t
 
struct  lb_main_t
 
struct  lb_vip_add_args_t
 

Macros

#define LB_DEFAULT_PER_CPU_STICKY_BUCKETS   1 << 10
 lb-plugin implements a MagLev-like load balancer. More...
 
#define LB_DEFAULT_FLOW_TIMEOUT   40
 
#define LB_MAPPING_BUCKETS   1024
 
#define LB_MAPPING_MEMORY_SIZE   64<<20
 
#define LB_VIP_PER_PORT_BUCKETS   1024
 
#define LB_VIP_PER_PORT_MEMORY_SIZE   64<<20
 
#define foreach_lb_nat_in2out_error
 
#define LB_AS_FLAGS_USED   0x1
 
#define lb_foreach_vip_counter
 
#define LB_VIP_FLAGS_USED   0x1
 
#define lb_vip_is_ip4(type)
 
#define lb_vip_is_ip6(type)
 
#define lb_encap_is_ip4(vip)
 
#define lb_vip_is_gre4(vip)
 
#define lb_vip_is_gre6(vip)
 
#define lb_vip_is_gre4_port(vip)
 
#define lb_vip_is_gre6_port(vip)
 
#define foreach_lb_nat_protocol
 
#define lb_vip_get_by_index(index)   (pool_is_free_index(lb_main.vips, index)?NULL:pool_elt_at_index(lb_main.vips, index))
 

Enumerations

enum  lb_next_t { LB_NEXT_DROP, LB_N_NEXT }
 
enum  LB_nat4_in2out_next_t { LB_NAT4_IN2OUT_NEXT_DROP, LB_NAT4_IN2OUT_NEXT_LOOKUP, LB_NAT4_IN2OUT_N_NEXT }
 
enum  LB_nat6_in2out_next_t { LB_NAT6_IN2OUT_NEXT_DROP, LB_NAT6_IN2OUT_NEXT_LOOKUP, LB_NAT6_IN2OUT_N_NEXT }
 
enum  lb_nat_in2out_error_t { LB_NAT_IN2OUT_N_ERROR }
 
enum  lb_svr_type_t { LB_SRV_TYPE_CLUSTERIP, LB_SRV_TYPE_NODEPORT, LB_SRV_N_TYPES }
 lb for kube-proxy supports three types of service More...
 
enum  lb4_nodeport_next_t { LB4_NODEPORT_NEXT_IP4_NAT4, LB4_NODEPORT_NEXT_DROP, LB4_NODEPORT_N_NEXT }
 
enum  lb6_nodeport_next_t { LB6_NODEPORT_NEXT_IP6_NAT6, LB6_NODEPORT_NEXT_DROP, LB6_NODEPORT_N_NEXT }
 
enum  lb_vip_counter_t { LB_N_VIP_COUNTERS }
 
enum  lb_encap_type_t {
  LB_ENCAP_TYPE_GRE4, LB_ENCAP_TYPE_GRE6, LB_ENCAP_TYPE_L3DSR, LB_ENCAP_TYPE_NAT4,
  LB_ENCAP_TYPE_NAT6, LB_ENCAP_N_TYPES
}
 
enum  lb_lkp_type_t { LB_LKP_SAME_IP_PORT, LB_LKP_DIFF_IP_PORT, LB_LKP_ALL_PORT_IP, LB_LKP_N_TYPES }
 Lookup type. More...
 
enum  lb_vip_type_t {
  LB_VIP_TYPE_IP6_GRE6, LB_VIP_TYPE_IP6_GRE4, LB_VIP_TYPE_IP4_GRE6, LB_VIP_TYPE_IP4_GRE4,
  LB_VIP_TYPE_IP4_L3DSR, LB_VIP_TYPE_IP4_NAT4, LB_VIP_TYPE_IP6_NAT6, LB_VIP_N_TYPES
}
 The load balancer supports IPv4 and IPv6 traffic and GRE4, GRE6, L3DSR and NAT4, NAT6 encap. More...
 
enum  lb_nat_protocol_t { foreach_lb_nat_protocol }
 

Functions

static bool lb_vip_is_l3dsr (const lb_vip_t *vip)
 
static bool lb_vip_is_l3dsr_port (const lb_vip_t *vip)
 
static bool lb_vip_is_nat4_port (const lb_vip_t *vip)
 
static bool lb_vip_is_nat6_port (const lb_vip_t *vip)
 
static u32 lb_ip_proto_to_nat_proto (u8 ip_proto)
 
int lb_conf (ip4_address_t *ip4_address, ip6_address_t *ip6_address, u32 sticky_buckets, u32 flow_timeout)
 Fix global load-balancer parameters. More...
 
int lb_vip_add (lb_vip_add_args_t args, u32 *vip_index)
 
int lb_vip_del (u32 vip_index)
 
int lb_vip_find_index (ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
 
int lb_vip_add_ass (u32 vip_index, ip46_address_t *addresses, u32 n)
 
int lb_vip_del_ass (u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush)
 
int lb_flush_vip_as (u32 vip_index, u32 as_index)
 
u32 lb_hash_time_now (vlib_main_t *vm)
 
void lb_garbage_collection ()
 
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)
 

Variables

format_function_t format_lb_as
 
format_function_t format_lb_vip_type
 
unformat_function_t unformat_lb_vip_type
 
format_function_t format_lb_vip
 
format_function_t format_lb_vip_detailed
 
lb_main_t lb_main
 
vlib_node_registration_t lb4_node
 
vlib_node_registration_t lb6_node
 
vlib_node_registration_t lb4_nodeport_node
 (constructor) VLIB_REGISTER_NODE (lb4_nodeport_node) More...
 
vlib_node_registration_t lb6_nodeport_node
 (constructor) VLIB_REGISTER_NODE (lb6_nodeport_node) More...
 
vlib_node_registration_t lb_nat4_in2out_node
 (constructor) VLIB_REGISTER_NODE (lb_nat4_in2out_node) More...
 
vlib_node_registration_t lb_nat6_in2out_node
 (constructor) VLIB_REGISTER_NODE (lb_nat6_in2out_node) More...
 
format_function_t format_lb_main
 

Macro Definition Documentation

◆ foreach_lb_nat_in2out_error

#define foreach_lb_nat_in2out_error
Value:
_(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \
_(IN2OUT_PACKETS, "Good in2out packets processed") \
_(NO_TRANSLATION, "No translation")

Definition at line 70 of file lb.h.

◆ foreach_lb_nat_protocol

#define foreach_lb_nat_protocol
Value:
_(UDP, 0, udp, "udp") \
_(TCP, 1, tcp, "tcp")

Definition at line 390 of file lb.h.

◆ LB_AS_FLAGS_USED

#define LB_AS_FLAGS_USED   0x1

Definition at line 134 of file lb.h.

◆ LB_DEFAULT_FLOW_TIMEOUT

#define LB_DEFAULT_FLOW_TIMEOUT   40

Definition at line 46 of file lb.h.

◆ LB_DEFAULT_PER_CPU_STICKY_BUCKETS

#define LB_DEFAULT_PER_CPU_STICKY_BUCKETS   1 << 10

lb-plugin implements a MagLev-like load balancer.

http://research.google.com/pubs/pub44824.html

It hasn't been tested for interoperability with the original MagLev but intends to provide similar functionality. The load-balancer receives traffic destined to VIP (Virtual IP) addresses from one or multiple(ECMP) routers. The load-balancer tunnels the traffic toward many application servers ensuring session stickyness (i.e. that a single sessions is tunneled towards a single application server).

Definition at line 45 of file lb.h.

◆ lb_encap_is_ip4

#define lb_encap_is_ip4 (   vip)
Value:
((vip)->type == LB_VIP_TYPE_IP6_GRE4 \
|| (vip)->type == LB_VIP_TYPE_IP4_GRE4 \
|| (vip)->type == LB_VIP_TYPE_IP4_L3DSR \
|| (vip)->type == LB_VIP_TYPE_IP4_NAT4 )

Definition at line 343 of file lb.h.

◆ lb_foreach_vip_counter

#define lb_foreach_vip_counter
Value:
_(NEXT_PACKET, "packet from existing sessions", 0) \
_(FIRST_PACKET, "first session packet", 1) \
_(UNTRACKED_PACKET, "untracked packet", 2) \
_(NO_SERVER, "no server configured", 3)

Definition at line 170 of file lb.h.

◆ LB_MAPPING_BUCKETS

#define LB_MAPPING_BUCKETS   1024

Definition at line 47 of file lb.h.

◆ LB_MAPPING_MEMORY_SIZE

#define LB_MAPPING_MEMORY_SIZE   64<<20

Definition at line 48 of file lb.h.

◆ LB_VIP_FLAGS_USED

#define LB_VIP_FLAGS_USED   0x1

Definition at line 325 of file lb.h.

◆ lb_vip_get_by_index

#define lb_vip_get_by_index (   index)    (pool_is_free_index(lb_main.vips, index)?NULL:pool_elt_at_index(lb_main.vips, index))

Definition at line 606 of file lb.h.

◆ lb_vip_is_gre4

#define lb_vip_is_gre4 (   vip)
Value:
(((vip)->type == LB_VIP_TYPE_IP6_GRE4 \
|| (vip)->type == LB_VIP_TYPE_IP4_GRE4) \
&& ((vip)->port == 0))

Definition at line 348 of file lb.h.

◆ lb_vip_is_gre4_port

#define lb_vip_is_gre4_port (   vip)
Value:
(((vip)->type == LB_VIP_TYPE_IP6_GRE4 \
|| (vip)->type == LB_VIP_TYPE_IP4_GRE4) \
&& ((vip)->port != 0))

Definition at line 357 of file lb.h.

◆ lb_vip_is_gre6

#define lb_vip_is_gre6 (   vip)
Value:
(((vip)->type == LB_VIP_TYPE_IP6_GRE6 \
|| (vip)->type == LB_VIP_TYPE_IP4_GRE6) \
&& ((vip)->port == 0))

Definition at line 353 of file lb.h.

◆ lb_vip_is_gre6_port

#define lb_vip_is_gre6_port (   vip)
Value:
(((vip)->type == LB_VIP_TYPE_IP6_GRE6 \
|| (vip)->type == LB_VIP_TYPE_IP4_GRE6) \
&& ((vip)->port != 0))

Definition at line 361 of file lb.h.

◆ lb_vip_is_ip4

#define lb_vip_is_ip4 (   type)
Value:

Definition at line 334 of file lb.h.

◆ lb_vip_is_ip6

#define lb_vip_is_ip6 (   type)
Value:

Definition at line 339 of file lb.h.

◆ LB_VIP_PER_PORT_BUCKETS

#define LB_VIP_PER_PORT_BUCKETS   1024

Definition at line 50 of file lb.h.

◆ LB_VIP_PER_PORT_MEMORY_SIZE

#define LB_VIP_PER_PORT_MEMORY_SIZE   64<<20

Definition at line 51 of file lb.h.

Enumeration Type Documentation

◆ lb4_nodeport_next_t

Enumerator
LB4_NODEPORT_NEXT_IP4_NAT4 
LB4_NODEPORT_NEXT_DROP 
LB4_NODEPORT_N_NEXT 

Definition at line 91 of file lb.h.

◆ lb6_nodeport_next_t

Enumerator
LB6_NODEPORT_NEXT_IP6_NAT6 
LB6_NODEPORT_NEXT_DROP 
LB6_NODEPORT_N_NEXT 

Definition at line 97 of file lb.h.

◆ lb_encap_type_t

Enumerator
LB_ENCAP_TYPE_GRE4 
LB_ENCAP_TYPE_GRE6 
LB_ENCAP_TYPE_L3DSR 
LB_ENCAP_TYPE_NAT4 
LB_ENCAP_TYPE_NAT6 
LB_ENCAP_N_TYPES 

Definition at line 183 of file lb.h.

◆ lb_lkp_type_t

Lookup type.

Enumerator
LB_LKP_SAME_IP_PORT 
LB_LKP_DIFF_IP_PORT 
LB_LKP_ALL_PORT_IP 
LB_LKP_N_TYPES 

Definition at line 196 of file lb.h.

◆ LB_nat4_in2out_next_t

Enumerator
LB_NAT4_IN2OUT_NEXT_DROP 
LB_NAT4_IN2OUT_NEXT_LOOKUP 
LB_NAT4_IN2OUT_N_NEXT 

Definition at line 58 of file lb.h.

◆ LB_nat6_in2out_next_t

Enumerator
LB_NAT6_IN2OUT_NEXT_DROP 
LB_NAT6_IN2OUT_NEXT_LOOKUP 
LB_NAT6_IN2OUT_N_NEXT 

Definition at line 64 of file lb.h.

◆ lb_nat_in2out_error_t

Enumerator
LB_NAT_IN2OUT_N_ERROR 

Definition at line 75 of file lb.h.

◆ lb_nat_protocol_t

Enumerator
foreach_lb_nat_protocol 

Definition at line 394 of file lb.h.

◆ lb_next_t

enum lb_next_t
Enumerator
LB_NEXT_DROP 
LB_N_NEXT 

Definition at line 53 of file lb.h.

◆ lb_svr_type_t

lb for kube-proxy supports three types of service

Enumerator
LB_SRV_TYPE_CLUSTERIP 
LB_SRV_TYPE_NODEPORT 
LB_SRV_N_TYPES 

Definition at line 85 of file lb.h.

◆ lb_vip_counter_t

Enumerator
LB_N_VIP_COUNTERS 

Definition at line 176 of file lb.h.

◆ lb_vip_type_t

The load balancer supports IPv4 and IPv6 traffic and GRE4, GRE6, L3DSR and NAT4, NAT6 encap.

Enumerator
LB_VIP_TYPE_IP6_GRE6 
LB_VIP_TYPE_IP6_GRE4 
LB_VIP_TYPE_IP4_GRE6 
LB_VIP_TYPE_IP4_GRE4 
LB_VIP_TYPE_IP4_L3DSR 
LB_VIP_TYPE_IP4_NAT4 
LB_VIP_TYPE_IP6_NAT6 
LB_VIP_N_TYPES 

Definition at line 207 of file lb.h.

Function Documentation

◆ 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
Returns
0 on success. VNET_LB_ERR_XXX on error

Definition at line 472 of file lb.c.

+ Here is the call graph for this function:
+ 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 756 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 353 of file lb.c.

+ Here is the caller graph for this function:

◆ lb_hash_time_now()

u32 lb_hash_time_now ( vlib_main_t vm)

Definition at line 92 of file lb.c.

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

◆ lb_ip_proto_to_nat_proto()

static u32 lb_ip_proto_to_nat_proto ( u8  ip_proto)
inlinestatic

Definition at line 401 of file lb.h.

+ Here is the caller 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 1316 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 1332 of file lb.c.

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

◆ lb_vip_add()

int lb_vip_add ( lb_vip_add_args_t  args,
u32 vip_index 
)

Definition at line 1035 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 579 of file lb.c.

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

◆ lb_vip_del()

int lb_vip_del ( u32  vip_index)

Definition at line 1189 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 847 of file lb.c.

+ Here is the call graph for this function:
+ 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 549 of file lb.c.

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

◆ lb_vip_is_l3dsr()

static bool lb_vip_is_l3dsr ( const lb_vip_t vip)
inlinestatic

Definition at line 366 of file lb.h.

+ Here is the caller graph for this function:

◆ lb_vip_is_l3dsr_port()

static bool lb_vip_is_l3dsr_port ( const lb_vip_t vip)
inlinestatic

Definition at line 372 of file lb.h.

+ Here is the caller graph for this function:

◆ lb_vip_is_nat4_port()

static bool lb_vip_is_nat4_port ( const lb_vip_t vip)
inlinestatic

Definition at line 377 of file lb.h.

+ Here is the caller graph for this function:

◆ lb_vip_is_nat6_port()

static bool lb_vip_is_nat6_port ( const lb_vip_t vip)
inlinestatic

Definition at line 382 of file lb.h.

+ Here is the caller graph for this function:

Variable Documentation

◆ format_lb_as

format_function_t format_lb_as

Definition at line 164 of file lb.h.

◆ format_lb_main

format_function_t format_lb_main

Definition at line 619 of file lb.h.

◆ format_lb_vip

format_function_t format_lb_vip

Definition at line 387 of file lb.h.

◆ format_lb_vip_detailed

format_function_t format_lb_vip_detailed

Definition at line 388 of file lb.h.

◆ format_lb_vip_type

format_function_t format_lb_vip_type

Definition at line 218 of file lb.h.

◆ lb4_node

◆ lb4_nodeport_node

vlib_node_registration_t lb4_nodeport_node

(constructor) VLIB_REGISTER_NODE (lb4_nodeport_node)

Definition at line 1204 of file node.c.

◆ lb6_node

◆ lb6_nodeport_node

vlib_node_registration_t lb6_nodeport_node

(constructor) VLIB_REGISTER_NODE (lb6_nodeport_node)

Definition at line 1220 of file node.c.

◆ lb_main

lb_main_t lb_main

Definition at line 28 of file lb.c.

◆ lb_nat4_in2out_node

vlib_node_registration_t lb_nat4_in2out_node

(constructor) VLIB_REGISTER_NODE (lb_nat4_in2out_node)

Definition at line 1243 of file node.c.

◆ lb_nat6_in2out_node

vlib_node_registration_t lb_nat6_in2out_node

(constructor) VLIB_REGISTER_NODE (lb_nat6_in2out_node)

Definition at line 1266 of file node.c.

◆ unformat_lb_vip_type

unformat_function_t unformat_lb_vip_type

Definition at line 219 of file lb.h.