|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
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))
clib_bihash_8_8_t vip_index_per_port
u16 msg_id_base
API dynamically registered base ID.
ip46_address_t prefix
A Virtual IP represents a given service delivered by a set of application servers.
Each VIP is configured with a set of application server.
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
fib_node_index_t next_hop_fib_entry_index
The FIB entry index for the next-hop.
u16 src_port
Network byte order for vip + port case, src_port = port; for node ip + node_port, src_port = node_por...
@ LB6_NODEPORT_NEXT_IP6_NAT6
uword * vip_index_by_nodeport
lb_vip_t * vips
Pool of all Virtual IPs.
int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
ip46_address_t address
Destination address used to tunnel traffic towards that application server.
#define foreach_lb_nat_in2out_error
@ LB_NAT6_IN2OUT_NEXT_DROP
ip4_address_t ip4_src_address
Source address used for IPv4 encapsulated traffic.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
u32 last_used
Rotating timestamp of when LB_AS_FLAGS_USED flag was last set.
u8 plen
The VIP prefix length.
@ LB_NAT6_IN2OUT_NEXT_LOOKUP
lb_per_cpu_t * per_cpu
Some global data is per-cpu.
uword * vip_prefix_indexes
bitmap for vip prefix to support per-port vip
vlib_refcount_t as_refcount
Each AS has an associated reference counter.
@ LB_NAT4_IN2OUT_NEXT_LOOKUP
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
vlib_node_registration_t lb4_node
dpo_type_t dpo_nat4_port_type
u32 vip_index
ASs are indexed by address and VIP Index.
dpo_type_t dpo_l3dsr_port_type
dpo_type_t dpo_gre4_port_type
dpo_type_t dpo_l3dsr_type
dpo_type_t dpo_gre6_port_type
u32 lb_hash_time_now(vlib_main_t *vm)
unformat_function_t unformat_lb_vip_type
lb_lkp_type_t
Lookup type.
int lb_nat6_interface_add_del(u32 sw_if_index, int is_del)
int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush)
dpo_type_t dpo_nat6_port_type
dpo_type_t dpo_gre4_type
DPO used to send packet from IP4/6 lookup to LB node.
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.
format_function_t format_lb_as
int lb_nat4_interface_add_del(u32 sw_if_index, int is_del)
static bool lb_vip_is_nat6_port(const lb_vip_t *vip)
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type()
int lb_vip_del(u32 vip_index)
lb_vip_type_t type
The type of traffic for this.
lb_vip_encap_args_t encap_args
ip6_address_t ip6_src_address
Source address used in IPv6 encapsulated traffic.
vlib_node_registration_t lb_nat6_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat6_in2out_node)
vlib_node_registration_t lb_nat4_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat4_in2out_node)
void lb_garbage_collection()
Load balancing service is provided per VIP+protocol+port.
struct _vlib_node_registration vlib_node_registration_t
lb_vip_encap_args_t encap_args
int lb_flush_vip_as(u32 vip_index, u32 as_index)
fib_node_t fib_node
Registration to FIB event.
clib_spinlock_t writer_lock
format_function_t format_lb_vip_type
format_function_t format_lb_vip
@ LB_NAT4_IN2OUT_NEXT_DROP
lb_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.
int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address, u32 sticky_buckets, u32 flow_timeout)
Fix global load-balancer parameters.
vlib_node_registration_t lb4_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb4_nodeport_node)
vlib_node_registration_t lb6_node
vl_api_ip_proto_t protocol
manual_print typedef u8 ip4_address[4]
dpo_id_t dpo
The next DPO in the graph to follow.
manual_print typedef u8 ip6_address[16]
format_function_t format_lb_main
clib_bihash_8_8_t mapping_by_as4
clib_bihash_24_8_t mapping_by_as6
An node in the FIB graph.
lb_vip_type_t
The load balancer supports IPv4 and IPv6 traffic and GRE4, GRE6, L3DSR and NAT4, NAT6 encap.
u8 flags
Flags related to this VIP.
lb_new_flow_entry_t * new_flow_table
Vector mapping (flow-hash & new_connect_table_mask) to AS index.
vlib_node_registration_t lb6_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb6_nodeport_node)
static bool lb_vip_is_l3dsr_port(const lb_vip_t *vip)
A collection of simple counters.
static u32 lb_ip_proto_to_nat_proto(u8 ip_proto)
static bool lb_vip_is_l3dsr(const lb_vip_t *vip)
lb_as_t * ass
Pool of ASs.
int lb_vip_add(lb_vip_add_args_t args, u32 *vip_index)
#define foreach_lb_nat_protocol
u8 flags
Some per-AS flags.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
u32 flow_timeout
Flow timeout in seconds.
ip46_address_t src_ip
for vip + port case, src_ip = vip; for node ip + node_port, src_ip = node_ip
fib_node_type_t fib_node_type
Node type for registering to fib changes.
u32 new_flow_table_mask
New flows table length - 1 (length MUST be a power of 2)
lb_svr_type_t
lb for kube-proxy supports three types of service
u32 * as_indexes
Pool of AS indexes used for this VIP.
static bool lb_vip_is_nat4_port(const lb_vip_t *vip)
#define lb_foreach_vip_counter
u32 next_hop_child_index
The child index on the FIB entry.
int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n)
vl_api_interface_index_t sw_if_index
format_function_t format_lb_vip_detailed
lb_snat_mapping_t * snat_mappings
@ LB4_NODEPORT_NEXT_IP4_NAT4