22 #define foreach_kp_error \ 24 _(PROTO_NOT_SUPPORTED, "protocol not supported") 27 #define _(sym,str) KP_ERROR_##sym, 34 #define _(sym,string) string, 62 s =
format(s,
"kp vip[%d]: This VIP was freed since capture\n");
67 s =
format(s,
" kp pod[%d]: This POD was freed since capture");
81 s =
format(s,
"kp nat: rx_sw_if_index = %d, next_index = %d",
179 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
192 while (n_left_from > 0)
195 while (n_left_from > 0 && n_left_to_next > 0)
201 u32 available_index0;
203 u32 hash0 = nexthash0;
224 pi0 = to_next[0] = from[0];
235 kp_time, &available_index0, &podindex0);
240 counter = KP_VIP_COUNTER_NEXT_PACKET;
246 counter = KP_VIP_COUNTER_FIRST_PACKET;
247 counter = (podindex0 == 0)?KP_VIP_COUNTER_NO_SERVER:counter;
260 available_index0, kp_time);
266 counter = KP_VIP_COUNTER_UNTRACKED_PACKET;
277 if ( (is_input_v4==1) && (is_nat_v4==1) )
285 else if ( (is_input_v4==1) && (is_nat_v4==0) )
291 len0 = clib_net_to_host_u16(ip40->
length);
300 else if ( (is_input_v4==0) && (is_nat_v4==0) )
355 s =
format(s,
"kp vip[%d]: This VIP was freed since capture\n");
371 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
378 while (n_left_from > 0)
382 while (n_left_from > 0 && n_left_to_next > 0)
407 pi0 = to_next[0] = from[0];
455 n_left_to_next, pi0, next0);
489 if (clib_bihash_search_8_8 (mapping_hash, &kv, &value))
499 mapping->
port = clib_host_to_net_u16 (m->
port);
519 u32 n_left_from, * from, * to_next;
521 u32 pkts_processed = 0;
523 u32 stats_node_index;
531 while (n_left_from > 0)
536 to_next, n_left_to_next);
538 while (n_left_from > 0 && n_left_to_next > 0)
546 u32 new_addr0, old_addr0;
547 u16 old_port0, new_port0;
589 new_port0 = sm0.
port;
604 old_port0 = tcp0->src_port;
605 tcp0->src_port = new_port0;
607 sum0 = tcp0->checksum;
627 sum0 = tcp0->checksum;
637 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
649 to_next, n_left_to_next,
657 KP_NAT_IN2OUT_ERROR_IN2OUT_PACKETS,
694 .vector_size =
sizeof (
u32),
711 .vector_size =
sizeof (
u32),
728 .vector_size =
sizeof (
u32),
745 .vector_size =
sizeof (
u32),
777 .name =
"kp4-nodeport",
778 .vector_size =
sizeof (
u32),
798 .name =
"kp6-nodeport",
799 .vector_size =
sizeof (
u32),
818 .arc_name =
"ip4-unicast",
819 .node_name =
"kp-nat4-in2out",
826 .name =
"kp-nat4-in2out",
827 .vector_size =
sizeof (
u32),
vlib_node_registration_t kp6_nat6_node
(constructor) VLIB_REGISTER_NODE (kp6_nat6_node)
vlib_refcount_t pod_refcount
Each POD has an associated reference counter.
vlib_node_registration_t kp6_nodeport_node
(constructor) VLIB_REGISTER_NODE (kp6_nodeport_node)
#define kp_hash_nbuckets(h)
vlib_simple_counter_main_t vip_counters[KP_N_VIP_COUNTERS]
Per VIP counter.
vlib_node_registration_t kp4_nodeport_node
(constructor) VLIB_REGISTER_NODE (kp4_nodeport_node)
static uword kp_nat4_in2out_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u32 kp_ip_proto_to_nat_proto(u8 ip_proto)
#define kp_hash_foreach_entry(h, bucket, i)
kp_per_cpu_t * per_cpu
Some global data is per-cpu.
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
static uword kp4_nodeport_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
struct _tcp_header tcp_header_t
vlib_node_registration_t kp_nat4_in2out_node
(constructor) VLIB_REGISTER_NODE (kp_nat4_in2out_node)
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define static_always_inline
static_always_inline u32 kp_node_get_hash(vlib_buffer_t *p, u8 is_input_v4)
u32 kp_hash_time_now(vlib_main_t *vm)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static uword kp4_nat6_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
kp_snat_mapping_t * snat_mappings
format_function_t format_kp_pod
static void * ip4_next_header(ip4_header_t *i)
u8 * format_nodeport_kp_trace(u8 *s, va_list *args)
kp_new_flow_entry_t * new_flow_table
Vector mapping (flow-hash & new_connect_table_mask) to POD index.
u16 target_port
Pod's port corresponding to specific service.
static_always_inline uword kp_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u8 is_input_v4, u8 is_nat_v4)
u8 * format_kp_nat_trace(u8 *s, va_list *args)
vlib_node_registration_t kp4_nat6_node
(constructor) VLIB_REGISTER_NODE (kp4_nat6_node)
static char * kp_error_strings[]
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline void kp_hash_free(kp_hash_t *h)
static_always_inline kp_hash_t * kp_hash_alloc(u32 buckets, u32 timeout)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
VNET_FEATURE_INIT(kp_nat4_in2out_node_fn, static)
static_always_inline void kp_hash_prefetch_bucket(kp_hash_t *ht, u32 hash)
ip46_address_t address
Destination address used to transfer traffic towards to that POD.
#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).
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)
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
static_always_inline void kp_hash_put(kp_hash_t *h, u32 hash, u32 value, u32 vip, u32 available_index, u32 time_now)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
int kp_nat4_mapping_match(kp_main_t *kpm, kp_snat4_key_t match, kp_snat4_key_t *mapping)
Match NAT4 static mapping.
#define clib_warning(format, args...)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
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_always_inline u32 kp_hash_available_value(kp_hash_t *h, u32 hash, u32 available_index)
u8 * format_kp_trace(u8 *s, va_list *args)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
u32 flow_timeout
Flow timeout in seconds.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static uword kp6_nat4_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_node_registration_t kp6_nat4_node
(constructor) VLIB_REGISTER_NODE (kp6_nat4_node)
#define VNET_FEATURES(...)
u32 value[KPHASH_ENTRY_PER_BUCKET]
u32 new_flow_table_mask
New flows table length - 1 (length MUST be a power of 2)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static uword kp6_nat6_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
index_t dpoi_index
the index of objects of that type
static_always_inline void kp_hash_get(kp_hash_t *ht, u32 hash, u32 vip, u32 time_now, u32 *available_index, u32 *found_value)
static uword kp6_nodeport_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
dpo_id_t dpo
The next DPO in the graph to follow.
kp_pod_t * pods
Pool of PODs.
kp_hash_t * kp_get_sticky_table(u32 thread_index)
u64 kp_node_get_other_ports6(ip6_header_t *ip60)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip_csum_update(sum, old, new, type, field)
static uword kp_nodeport_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u8 is_input_v4)
format_function_t format_kp_vip
#define hash_get_mem(h, key)
static_always_inline u32 kp_hash_hash(u64 k0, u64 k1, u64 k2, u64 k3, u64 k4)
kp_vip_t * vips
Pool of all Virtual IPs.
u64 kp_node_get_other_ports4(ip4_header_t *ip40)
u16 flags
Copy of main node flags.
u16 dpoi_next_node
The next VLIB node to follow.
clib_bihash_8_8_t mapping_by_pod
#define VLIB_NODE_FLAG_TRACE
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
vlib_node_registration_t kp4_nat4_node
(constructor) VLIB_REGISTER_NODE (kp4_nat4_node)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword kp4_nat4_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u16 ip4_header_checksum(ip4_header_t *i)
Load balancing service is provided per VIP.
static u16 ip_csum_fold(ip_csum_t c)
kp_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.