30 #ifndef LB_PLUGIN_LB_LB_H_ 31 #define LB_PLUGIN_LB_LB_H_ 46 #define LB_DEFAULT_PER_CPU_STICKY_BUCKETS 1 << 10 47 #define LB_DEFAULT_FLOW_TIMEOUT 40 48 #define LB_MAPPING_BUCKETS 1024 49 #define LB_MAPPING_MEMORY_SIZE 64<<20 51 #define LB_VIP_PER_PORT_BUCKETS 1024 52 #define LB_VIP_PER_PORT_MEMORY_SIZE 64<<20 71 #define foreach_lb_nat_in2out_error \ 72 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ 73 _(IN2OUT_PACKETS, "Good in2out packets processed") \ 74 _(NO_TRANSLATION, "No translation") 77 #define _(sym,str) LB_NAT_IN2OUT_ERROR_##sym, 135 #define LB_AS_FLAGS_USED 0x1 171 #define lb_foreach_vip_counter \ 172 _(NEXT_PACKET, "packet from existing sessions", 0) \ 173 _(FIRST_PACKET, "first session packet", 1) \ 174 _(UNTRACKED_PACKET, "untracked packet", 2) \ 175 _(NO_SERVER, "no server configured", 3) 178 #define _(a,b,c) LB_VIP_COUNTER_##a = c, 326 #define LB_VIP_FLAGS_USED 0x1 335 #define lb_vip_is_ip4(type) (type == LB_VIP_TYPE_IP4_GRE6 \ 336 || type == LB_VIP_TYPE_IP4_GRE4 \ 337 || type == LB_VIP_TYPE_IP4_L3DSR \ 338 || type == LB_VIP_TYPE_IP4_NAT4 ) 340 #define lb_vip_is_ip6(type) (type == LB_VIP_TYPE_IP6_GRE6 \ 341 || type == LB_VIP_TYPE_IP6_GRE4 \ 342 || type == LB_VIP_TYPE_IP6_NAT6 ) 344 #define lb_encap_is_ip4(vip) ((vip)->type == LB_VIP_TYPE_IP6_GRE4 \ 345 || (vip)->type == LB_VIP_TYPE_IP4_GRE4 \ 346 || (vip)->type == LB_VIP_TYPE_IP4_L3DSR \ 347 || (vip)->type == LB_VIP_TYPE_IP4_NAT4 ) 349 #define lb_vip_is_gre4(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE4 \ 350 || (vip)->type == LB_VIP_TYPE_IP4_GRE4) \ 351 && ((vip)->port == 0)) 354 #define lb_vip_is_gre6(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE6 \ 355 || (vip)->type == LB_VIP_TYPE_IP4_GRE6) \ 356 && ((vip)->port == 0)) 358 #define lb_vip_is_gre4_port(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE4 \ 359 || (vip)->type == LB_VIP_TYPE_IP4_GRE4) \ 360 && ((vip)->port != 0)) 362 #define lb_vip_is_gre6_port(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE6 \ 363 || (vip)->type == LB_VIP_TYPE_IP4_GRE6) \ 364 && ((vip)->port != 0)) 391 #define foreach_lb_nat_protocol \ 392 _(UDP, 0, udp, "udp") \ 393 _(TCP, 1, tcp, "tcp") 396 #define _(N, i, n, s) LB_NAT_PROTOCOL_##N = i, 406 nat_proto = (ip_proto == IP_PROTOCOL_UDP) ? LB_NAT_PROTOCOL_UDP : nat_proto;
407 nat_proto = (ip_proto == IP_PROTOCOL_TCP) ? LB_NAT_PROTOCOL_TCP : nat_proto;
600 u32 sticky_buckets,
u32 flow_timeout);
609 #define lb_vip_get_by_index(index) (pool_is_free_index(lb_main.vips, index)?NULL:pool_elt_at_index(lb_main.vips, index)) format_function_t format_lb_vip
int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n)
static u32 lb_ip_proto_to_nat_proto(u8 ip_proto)
Each VIP is configured with a set of application server.
static bool lb_vip_is_l3dsr(const lb_vip_t *vip)
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
u16 msg_id_base
API dynamically registered base ID.
manual_print typedef u8 ip4_address[4]
ip46_address_t prefix
A Virtual IP represents a given service delivered by a set of application servers.
format_function_t format_lb_vip_type
u32 vip_index
ASs are indexed by address and VIP Index.
int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush)
lb_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.
ip46_address_t address
Destination address used to tunnel traffic towards that application server.
int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address, u32 sticky_buckets, u32 flow_timeout)
Fix global load-balancer parameters.
vl_api_ip_proto_t protocol
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
unformat_function_t unformat_lb_vip_type
lb_lkp_type_t
Lookup type.
u32 flow_timeout
Flow timeout in seconds.
fib_node_type_t fib_node_type
Node type for registering to fib changes.
dpo_type_t dpo_gre4_type
DPO used to send packet from IP4/6 lookup to LB node.
vlib_refcount_t as_refcount
Each AS has an associated reference counter.
lb_vip_encap_args_t encap_args
#define foreach_lb_nat_protocol
uword * vip_prefix_indexes
bitmap for vip prefix to support per-port vip
format_function_t format_lb_as
A collection of simple counters.
vlib_node_registration_t lb6_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb6_nodeport_node)
lb_vip_t * vips
Pool of all Virtual IPs.
u32 last_used
Rotating timestamp of when LB_AS_FLAGS_USED flag was last set.
ip4_address_t ip4_src_address
Source address used for IPv4 encapsulated traffic.
vlib_node_registration_t lb_nat6_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat6_in2out_node)
u8 plen
The VIP prefix length.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
u16 src_port
Network byte order for vip + port case, src_port = port; for node ip + node_port, src_port = node_por...
vlib_node_registration_t lb4_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb4_nodeport_node)
format_function_t format_lb_main
clib_bihash_8_8_t mapping_by_as4
An node in the FIB graph.
fib_node_t fib_node
Registration to FIB event.
int lb_flush_vip_as(u32 vip_index, u32 as_index)
ip46_address_t src_ip
for vip + port case, src_ip = vip; for node ip + node_port, src_ip = node_ip
static bool lb_vip_is_nat4_port(const lb_vip_t *vip)
vlib_node_registration_t lb6_node
dpo_type_t dpo_l3dsr_port_type
dpo_type_t dpo_nat4_port_type
dpo_type_t dpo_gre4_port_type
static bool lb_vip_is_nat6_port(const lb_vip_t *vip)
#define lb_foreach_vip_counter
u32 fib_node_index_t
A typedef of a node index.
u32 last_garbage_collection
Last time garbage collection was run to free the ASs.
lb_as_t * ass
Pool of ASs.
uword * vip_index_by_nodeport
vlib_node_registration_t lb4_node
lb_vip_type_t type
The type of traffic for this.
int lb_vip_del(u32 vip_index)
lb_svr_type_t
lb for kube-proxy supports three types of service
lb_vip_type_t
The load balancer supports IPv4 and IPv6 traffic and GRE4, GRE6, L3DSR and NAT4, NAT6 encap...
manual_print typedef u8 ip6_address[16]
void lb_garbage_collection()
#define foreach_lb_nat_in2out_error
u32 new_flow_table_mask
New flows table length - 1 (length MUST be a power of 2)
format_function_t format_lb_vip_detailed
dpo_type_t dpo_gre6_port_type
int lb_vip_add(lb_vip_add_args_t args, u32 *vip_index)
lb_vip_encap_args_t encap_args
vlib_node_registration_t lb_nat4_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat4_in2out_node)
lb_per_cpu_t * per_cpu
Some global data is per-cpu.
struct _vlib_node_registration vlib_node_registration_t
ip6_address_t ip6_src_address
Source address used in IPv6 encapsulated traffic.
clib_spinlock_t writer_lock
lb_snat_mapping_t * snat_mappings
static bool lb_vip_is_l3dsr_port(const lb_vip_t *vip)
u32 next_hop_child_index
The child index on the FIB entry.
dpo_type_t dpo_l3dsr_type
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
u32 lb_hash_time_now(vlib_main_t *vm)
clib_bihash_8_8_t vip_index_per_port
dpo_id_t dpo
The next DPO in the graph to follow.
u8 flags
Some per-AS flags.
clib_bihash_24_8_t mapping_by_as6
lb_new_flow_entry_t * new_flow_table
Vector mapping (flow-hash & new_connect_table_mask) to AS index.
dpo_type_t dpo_nat6_port_type
u8 flags
Flags related to this VIP.
Load balancing service is provided per VIP+protocol+port.
u32 * as_indexes
Pool of AS indexes used for this VIP.
vl_api_interface_index_t sw_if_index
int lb_nat4_interface_add_del(u32 sw_if_index, int is_del)
fib_node_index_t next_hop_fib_entry_index
The FIB entry index for the next-hop.
int lb_nat6_interface_add_del(u32 sw_if_index, int is_del)