24 ip46_address_t prefix;
47 if (
unformat(line_input,
"new_len %d", &new_len))
49 else if (
unformat(line_input,
"port %d", &port))
51 else if (
unformat(line_input,
"target_port %d", &target_port))
53 else if (
unformat(line_input,
"node_port %d", &node_port))
55 else if (
unformat(line_input,
"del"))
57 else if (
unformat(line_input,
"nat4"))
59 else if (
unformat(line_input,
"nat6"))
79 if ((ret =
kp_vip_add(&prefix, plen, type, new_len, &index,
80 (
u16)port, (
u16)target_port, (
u16)node_port))) {
104 .path =
"kube-proxy vip",
105 .short_help =
"kube-proxy vip <prefix> port <n> target_port <n>" 106 " node_port <n> [nat4|nat6)] [new_len <n>] [del]",
115 ip46_address_t vip_prefix, pod_addr;
117 ip46_address_t *pod_array = 0;
141 }
else if (
unformat(line_input,
"del")) {
179 .path =
"kube-proxy pod",
181 "kube-proxy pod <vip-prefix> [<address> [<address> [...]]] [del]",
192 u32 per_cpu_sticky_buckets_log2 = 0;
202 if (
unformat(line_input,
"buckets %d", &per_cpu_sticky_buckets))
204 else if (
unformat(line_input,
"buckets-log2 %d", &per_cpu_sticky_buckets_log2)) {
205 if (per_cpu_sticky_buckets_log2 >= 32)
207 per_cpu_sticky_buckets = 1 << per_cpu_sticky_buckets_log2;
208 }
else if (
unformat(line_input,
"timeout %d", &flow_timeout))
219 if ((ret =
kp_conf(per_cpu_sticky_buckets, flow_timeout))) {
232 .path =
"kube-proxy conf",
233 .short_help =
"kube-proxy conf [buckets <n>] [timeout <s>]",
248 .path =
"show kube-proxy",
249 .short_help =
"show kube-proxy",
265 if (
unformat(&line_input,
"verbose"))
269 vlib_cli_output(vm,
"%U\n", verbose?format_kp_vip_detailed:format_kp_vip, vip);
278 .path =
"show kube-proxy vips",
279 .short_help =
"show kube-proxy vips [verbose]",
292 u32 * inside_sw_if_indices = 0;
306 vec_add1 (inside_sw_if_indices, sw_if_index);
307 else if (
unformat (line_input,
"del"))
317 if (
vec_len (inside_sw_if_indices))
319 for (i = 0; i <
vec_len(inside_sw_if_indices); i++)
321 sw_if_index = inside_sw_if_indices[
i];
326 is_del ?
"del" :
"add",
343 .path =
"kube-proxy set interface nat4",
345 .short_help =
"kube-proxy set interface nat4 in <intfc> [del]",
356 for(thread_index = 0; thread_index < tm->
n_vlib_mains; thread_index++ ) {
379 .path =
"test kube-proxy flowtable flush",
380 .short_help =
"test kube-proxy flowtable flush",
sll srl srl sll sra u16x4 i
vlib_refcount_t pod_refcount
Each POD has an associated reference counter.
vnet_main_t * vnet_get_main(void)
format_function_t format_kp_main
static clib_error_t * kp_show_vips_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define kp_hash_foreach_entry(h, bucket, i)
kp_per_cpu_t * per_cpu
Some global data is per-cpu.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
kp_vip_type_t
kube-proxy supports IPv4 and IPv6 traffic and NAT4 and NAT6.
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)
static clib_error_t * kp_set_interface_nat4_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
int kp_vip_del(u32 vip_index)
#define clib_error_return(e, args...)
format_function_t format_vnet_sw_interface_name
int kp_vip_del_pods(u32 vip_index, ip46_address_t *addresses, u32 n)
static_always_inline void kp_hash_free(kp_hash_t *h)
static clib_error_t * kp_pod_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void kp_garbage_collection()
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 clib_error_t * kp_vip_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static clib_error_t * kp_flowtable_flush_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat_ip46_prefix(unformat_input_t *input, va_list *args)
#define VLIB_CLI_COMMAND(x,...)
u32 flow_timeout
Flow timeout in seconds.
u32 value[KPHASH_ENTRY_PER_BUCKET]
int kp_nat4_interface_add_del(u32 sw_if_index, int is_del)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * kp_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int kp_vip_add_pods(u32 vip_index, ip46_address_t *addresses, u32 n)
kp_vip_t * vips
Pool of all Virtual IPs.
static vlib_thread_main_t * vlib_get_thread_main()
int kp_vip_find_index(ip46_address_t *prefix, u8 plen, u32 *vip_index)
#define ip46_prefix_is_ip4(ip46, len)
static clib_error_t * kp_conf_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Load balancing service is provided per VIP.
int kp_conf(u32 per_cpu_sticky_buckets, u32 flow_timeout)
Fix global kube-proxy parameters.
kp_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.