30 #ifndef KP_PLUGIN_KP_KP_H_ 31 #define KP_PLUGIN_KP_KP_H_ 42 #define KP_DEFAULT_PER_CPU_STICKY_BUCKETS 1 << 10 43 #define KP_DEFAULT_FLOW_TIMEOUT 40 44 #define KP_MAPPING_BUCKETS 1024 45 #define KP_MAPPING_MEMORY_SIZE 64<<20 58 #define foreach_kp_nat_in2out_error \ 59 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ 60 _(IN2OUT_PACKETS, "Good in2out packets processed") \ 61 _(NO_TRANSLATION, "No translation") 64 #define _(sym,str) KP_NAT_IN2OUT_ERROR_##sym, 118 #define KP_POD_FLAGS_USED 0x1 154 #define kp_foreach_vip_counter \ 155 _(NEXT_PACKET, "packet from existing sessions", 0) \ 156 _(FIRST_PACKET, "first session packet", 1) \ 157 _(UNTRACKED_PACKET, "untracked packet", 2) \ 158 _(NO_SERVER, "no server configured", 3) 161 #define _(a,b,c) KP_VIP_COUNTER_##a = c, 258 #define KP_VIP_FLAGS_USED 0x1 277 #define kp_vip_is_ip4(vip) ((vip)->type == KP_VIP_TYPE_IP4_NAT44 \ 278 || (vip)->type == KP_VIP_TYPE_IP4_NAT46) 279 #define kp_vip_is_nat4(vip) ((vip)->type == KP_VIP_TYPE_IP6_NAT64 \ 280 || (vip)->type == KP_VIP_TYPE_IP4_NAT44) 284 #define foreach_kp_nat_protocol \ 285 _(UDP, 0, udp, "udp") \ 286 _(TCP, 1, tcp, "tcp") 289 #define _(N, i, n, s) KP_NAT_PROTOCOL_##N = i, 299 nat_proto = (ip_proto == IP_PROTOCOL_UDP) ? KP_NAT_PROTOCOL_UDP : nat_proto;
300 nat_proto = (ip_proto == IP_PROTOCOL_TCP) ? KP_NAT_PROTOCOL_TCP : nat_proto;
431 #define ip46_address_type(ip46) (ip46_address_is_ip4(ip46)?IP46_TYPE_IP4:IP46_TYPE_IP6) 432 #define ip46_prefix_is_ip4(ip46, len) ((len) >= 96 && ip46_address_is_ip4(ip46)) 433 #define ip46_prefix_type(ip46, len) (ip46_prefix_is_ip4(ip46, len)?IP46_TYPE_IP4:IP46_TYPE_IP6) 454 u32 new_length,
u32 *vip_index,
455 u16 port,
u16 target_port,
u16 node_port);
460 #define kp_vip_get_by_index(index) (pool_is_free_index(kp_main.vips, index)?NULL:pool_elt_at_index(kp_main.vips, index))
void ip46_prefix_normalize(ip46_address_t *prefix, u8 plen)
vlib_refcount_t pod_refcount
Each POD has an associated reference counter.
#define foreach_kp_nat_in2out_error
format_function_t format_kp_main
static u32 kp_ip_proto_to_nat_proto(u8 ip_proto)
vlib_node_registration_t kp6_node
kp_per_cpu_t * per_cpu
Some global data is per-cpu.
u32 vip_index
PODs are indexed by address and VIP Index.
fib_node_t fib_node
Registration to FIB event.
kp_vip_type_t
kube-proxy supports IPv4 and IPv6 traffic and NAT4 and NAT6.
int kp_vip_add_pods(u32 vip_index, ip46_address_t *addresses, u32 n)
int kp_conf(u32 sticky_buckets, u32 flow_timeout)
Fix global kube-proxy parameters.
u8 * format_ip46_prefix(u8 *s, va_list *args)
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
u32 last_used
Rotating timestamp of when KP_POD_FLAGS_USED flag was last set.
u8 plen
The VIP prefix length.
vlib_node_registration_t kp6_nodeport_node
(constructor) VLIB_REGISTER_NODE (kp6_nodeport_node)
vlib_node_registration_t kp_nat4_in2out_node
(constructor) VLIB_REGISTER_NODE (kp_nat4_in2out_node)
kp_snat_mapping_t * snat_mappings
format_function_t format_kp_pod
u32 * pod_indexes
Pool of POD indexes used for this VIP.
int kp_vip_del(u32 vip_index)
u32 kp_hash_time_now(vlib_main_t *vm)
A collection of simple counters.
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.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
dpo_type_t dpo_nat4_type
DPO used to send packet from IP4/6 lookup to KP node.
ip46_address_t prefix
A Virtual IP represents a given service delivered by a set of PODs.
volatile u32 * writer_lock
int kp_vip_del_pods(u32 vip_index, ip46_address_t *addresses, u32 n)
ip46_address_t address
Destination address used to transfer traffic towards to that POD.
fib_node_index_t next_hop_fib_entry_index
The FIB entry index for the next-hop.
u32 last_garbage_collection
last time garbage collection was run to free the PODs.
An node in the FIB graph.
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
Each VIP is configured with a set of PODs.
#define foreach_kp_nat_protocol
u32 fib_node_index_t
A typedef of a node index.
void kp_garbage_collection()
int kp_vip_add(ip46_address_t *prefix, u8 plen, kp_vip_type_t type, u32 new_length, u32 *vip_index, u16 port, u16 target_port, u16 node_port)
u32 flow_timeout
Flow timeout in seconds.
kp_vip_type_t type
The type of traffic for this.
format_function_t format_kp_vip_type
unformat_function_t unformat_kp_vip_type
vlib_node_registration_t kp4_nodeport_node
(constructor) VLIB_REGISTER_NODE (kp4_nodeport_node)
u32 next_hop_child_index
The child index on the FIB entry.
u32 new_flow_table_mask
New flows table length - 1 (length MUST be a power of 2)
struct _vlib_node_registration vlib_node_registration_t
u16 msg_id_base
API dynamically registered base ID.
kp_svr_type_t
kube-proxy supports three types of service
u8 flags
Flags related to this VIP.
dpo_id_t dpo
The next DPO in the graph to follow.
int kp_nat4_interface_add_del(u32 sw_if_index, int is_del)
#define kp_foreach_vip_counter
kp_pod_t * pods
Pool of PODs.
vlib_node_registration_t kp4_node
format_function_t format_kp_vip
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
kp_vip_t * vips
Pool of all Virtual IPs.
uword unformat_ip46_prefix(unformat_input_t *input, va_list *args)
fib_node_type_t fib_node_type
Node type for registering to fib changes.
u8 flags
Some per-POD flags.
clib_bihash_8_8_t mapping_by_pod
int kp_vip_find_index(ip46_address_t *prefix, u8 plen, u32 *vip_index)
format_function_t format_kp_vip_detailed
Load balancing service is provided per VIP.
u16 node_port
Node's port, can access service via NodeIP:node_port.
kp_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.