22 #define foreach_lb_error \ 24 _(PROTO_NOT_SUPPORTED, "protocol not supported") 28 #define _(sym,str) LB_ERROR_##sym, 36 #define _(sym,string) string, 73 s =
format (s,
"lb vip[%d]: This VIP was freed since capture\n");
82 s =
format (s,
"lb as[%d]: This AS was freed since capture\n");
104 s =
format (s,
"lb vip[%d]: This VIP was freed since capture\n");
113 s =
format (s,
"lb as[%d]: This AS was freed since capture\n");
120 s =
format (s,
"lb nat: rx_sw_if_index = %d, next_index = %d",
187 || ip40->
protocol == IP_PROTOCOL_UDP))
202 || ip60->
protocol == IP_PROTOCOL_UDP))
222 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
235 while (n_left_from > 0)
238 while (n_left_from > 0 && n_left_to_next > 0)
245 u32 available_index0;
247 u32 hash0 = nexthash0;
268 pi0 = to_next[0] = from[0];
282 len0 = clib_net_to_host_u16 (ip40->
length);
294 &available_index0, &asindex0);
299 counter = LB_VIP_COUNTER_NEXT_PACKET;
306 counter = LB_VIP_COUNTER_FIRST_PACKET;
307 counter = (asindex0 == 0) ? LB_VIP_COUNTER_NO_SERVER : counter;
324 available_index0, lb_time);
331 counter = LB_VIP_COUNTER_UNTRACKED_PACKET;
357 ip40->
length = clib_host_to_net_u16 (
373 clib_host_to_net_u32 (0x6 << 28);
382 clib_host_to_net_u16 (0x0800) :
383 clib_host_to_net_u16 (0x86DD);
390 u32 old_dst, new_dst;
395 new_dst = lbm->
ass[asindex0].
address.ip4.as_u32;
439 if ((ip40->
protocol == IP_PROTOCOL_UDP)
477 csum, lbm->
ass[asindex0].
address.ip6.as_u64[0]);
479 csum, lbm->
ass[asindex0].
address.ip6.as_u64[1]);
501 vm, node, next_index, to_next, n_left_to_next, pi0,
521 s =
format (s,
"lb vip[%d]: This VIP was freed since capture\n");
539 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
545 while (n_left_from > 0)
549 while (n_left_from > 0 && n_left_to_next > 0)
572 pi0 = to_next[0] = from[0];
639 if (clib_bihash_search_8_8 (mapping_hash, &kv4, &value))
644 *index = value.
value;
674 if (clib_bihash_search_24_8 (mapping_hash, &kv6, &value))
679 *index = value.
value;
687 u32 n_left_from, *from, *to_next;
689 u32 pkts_processed = 0;
691 u32 stats_node_index;
700 while (n_left_from > 0)
706 while (n_left_from > 0 && n_left_to_next > 0)
713 u16 old_port0, new_port0;
737 u32 old_addr0, new_addr0;
759 new_addr0 = sm40->
src_ip.ip4.as_u32;
772 old_port0 = tcp0->src_port;
773 tcp0->src_port = new_port0;
775 csum = tcp0->checksum;
834 old_port0 = tcp0->src_port;
835 tcp0->src_port = new_port0;
837 csum = tcp0->checksum;
874 n_left_to_next, bi0, next0);
881 LB_NAT_IN2OUT_ERROR_IN2OUT_PACKETS,
953 .vector_size =
sizeof(
u32),
965 .vector_size =
sizeof(
u32),
978 .vector_size =
sizeof(
u32),
991 .vector_size =
sizeof(
u32),
1003 .name =
"lb4-l3dsr",
1004 .vector_size =
sizeof(
u32),
1017 .vector_size =
sizeof(
u32),
1030 .vector_size =
sizeof(
u32),
1056 .name =
"lb4-nodeport",
1057 .vector_size =
sizeof(
u32),
1072 .name =
"lb6-nodeport",
1073 .vector_size =
sizeof(
u32),
1087 .arc_name =
"ip4-unicast",
1088 .node_name =
"lb-nat4-in2out",
1095 .name =
"lb-nat4-in2out",
1096 .vector_size =
sizeof(
u32),
1110 .arc_name =
"ip6-unicast",
1111 .node_name =
"lb-nat6-in2out",
1118 .name =
"lb-nat6-in2out",
1119 .vector_size =
sizeof(
u32),
u8 * format_lb_trace(u8 *s, va_list *args)
format_function_t format_lb_vip
u32 lb_hash_time_now(vlib_main_t *vm)
static u32 lb_ip_proto_to_nat_proto(u8 ip_proto)
static uword lb6_gre4_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword lb4_l3dsr_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_node_registration_t lb6_gre6_node
(constructor) VLIB_REGISTER_NODE (lb6_gre6_node)
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
static uword lb_nat6_in2out_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static_always_inline lb_hash_t * lb_hash_alloc(u32 buckets, u32 timeout)
vlib_node_registration_t lb_nat4_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat4_in2out_node)
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
static_always_inline u32 lb_hash_available_value(lb_hash_t *h, u32 hash, u32 available_index)
struct _tcp_header tcp_header_t
lb_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.
static uword lb4_nat4_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword lb4_nodeport_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
ip46_address_t address
Destination address used to tunnel traffic towards that application server.
static uword lb4_gre6_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u8 * format_nodeport_lb_trace(u8 *s, va_list *args)
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define lb_hash_nbuckets(h)
#define static_always_inline
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
u32 flow_timeout
Flow timeout in seconds.
static uword lb6_nat6_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_refcount_t as_refcount
Each AS has an associated reference counter.
lb_vip_encap_args_t encap_args
static void * ip4_next_header(ip4_header_t *i)
format_function_t format_lb_as
lb_vip_t * vips
Pool of all Virtual IPs.
vlib_node_registration_t lb4_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb4_nodeport_node)
ip4_address_t ip4_src_address
Source address used for IPv4 encapsulated traffic.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u32 value[LBHASH_ENTRY_PER_BUCKET]
vlib_node_registration_t lb4_nat4_node
(constructor) VLIB_REGISTER_NODE (lb4_nat4_node)
vlib_node_registration_t lb4_gre4_node
(constructor) VLIB_REGISTER_NODE (lb4_gre4_node)
u16 src_port
Network byte order for vip + port case, src_port = port; for node ip + node_port, src_port = node_por...
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static_always_inline void lb_hash_prefetch_bucket(lb_hash_t *ht, u32 hash)
clib_bihash_8_8_t mapping_by_as4
lb_hash_t * lb_get_sticky_table(u32 thread_index)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vlib_node_registration_t lb6_gre4_node
(constructor) VLIB_REGISTER_NODE (lb6_gre4_node)
static uword lb_nodeport_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u8 is_input_v4)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static_always_inline void vlib_refcount_add(vlib_refcount_t *r, u32 thread_index, u32 counter_index, i32 v)
static_always_inline u32 lb_node_get_hash(vlib_buffer_t *p, u8 is_input_v4)
u8 * format_lb_nat_trace(u8 *s, va_list *args)
ip46_address_t src_ip
for vip + port case, src_ip = vip; for node ip + node_port, src_ip = node_ip
#define lb_hash_foreach_entry(h, bucket, i)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
u64 lb_node_get_other_ports6(ip6_header_t *ip60)
static_always_inline uword lb_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u8 is_input_v4, lb_encap_type_t encap_type)
#define clib_warning(format, args...)
int lb_nat66_mapping_match(lb_main_t *lbm, lb_snat6_key_t *match, u32 *index)
Match NAT66 static mapping.
vlib_node_registration_t lb4_l3dsr_node
(constructor) VLIB_REGISTER_NODE (lb4_l3dsr_node)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
VNET_FEATURE_INIT(bond_input, static)
8 octet key, 8 octet key value pair
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
static uword lb_nat4_in2out_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * ip6_next_header(ip6_header_t *i)
static_always_inline void lb_hash_free(lb_hash_t *h)
lb_as_t * ass
Pool of ASs.
uword * vip_index_by_nodeport
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
vlib_node_registration_t lb_nat6_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat6_in2out_node)
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
u32 new_flow_table_mask
New flows table length - 1 (length MUST be a power of 2)
static char * lb_error_strings[]
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
lb_per_cpu_t * per_cpu
Some global data is per-cpu.
#define VNET_FEATURES(...)
vlib_simple_counter_main_t vip_counters[LB_N_VIP_COUNTERS]
Per VIP counter.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vlib_node_registration_t lb6_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb6_nodeport_node)
ip6_address_t ip6_src_address
Source address used in IPv6 encapsulated traffic.
index_t dpoi_index
the index of objects of that type
int lb_nat44_mapping_match(lb_main_t *lbm, lb_snat4_key_t *match, u32 *index)
Match NAT44 static mapping.
u64 lb_node_get_other_ports4(ip4_header_t *ip40)
static uword lb6_nodeport_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
lb_snat_mapping_t * snat_mappings
#define ip_csum_update(sum, old, new, type, field)
static uword lb6_gre6_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define hash_get_mem(h, key)
vlib_node_registration_t lb6_nat6_node
(constructor) VLIB_REGISTER_NODE (lb6_nat6_node)
static_always_inline u32 lb_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
dpo_id_t dpo
The next DPO in the graph to follow.
u16 flags
Copy of main node flags.
u16 dpoi_next_node
The next VLIB node to follow.
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.
static uword lb_nat_in2out_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 is_nat4)
#define VLIB_NODE_FLAG_TRACE
static uword lb4_gre4_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Load balancing service is provided per VIP.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static_always_inline void lb_hash_get(lb_hash_t *ht, u32 hash, u32 vip, u32 time_now, u32 *available_index, u32 *found_value)
static u16 ip4_header_checksum(ip4_header_t *i)
static u16 ip_csum_fold(ip_csum_t c)
static ip_csum_t ip_csum_add_even(ip_csum_t c, ip_csum_t x)
vlib_node_registration_t lb4_gre6_node
(constructor) VLIB_REGISTER_NODE (lb4_gre6_node)
static_always_inline void lb_hash_put(lb_hash_t *h, u32 hash, u32 value, u32 vip, u32 available_index, u32 time_now)