51 else if (
unformat(line_input,
"del"))
53 else if (
unformat(line_input,
"encap gre4"))
55 else if (
unformat(line_input,
"encap gre6"))
57 else if (
unformat(line_input,
"encap l3dsr"))
59 else if (
unformat(line_input,
"encap nat4"))
61 else if (
unformat(line_input,
"encap nat6"))
63 else if (
unformat(line_input,
"dscp %d", &dscp))
65 else if (
unformat(line_input,
"type clusterip"))
67 else if (
unformat(line_input,
"type nodeport"))
69 else if (
unformat(line_input,
"port %d", &port))
71 else if (
unformat(line_input,
"target_port %d", &target_port))
73 else if (
unformat(line_input,
"node_port %d", &node_port))
85 "should not configure dscp for none L3DSR.");
92 "dscp for L3DSR should be less than 64.");
168 .short_help =
"lb vip <prefix> [encap (gre6|gre4|l3dsr|nat4|nat6)] " 170 "[type (nodeport|clusterip) port <n> target_port <n> node_port <n>] " 171 "[new_len <n>] [del]",
180 ip46_address_t vip_prefix, as_addr;
182 ip46_address_t *as_array = 0;
206 }
else if (
unformat(line_input,
"del")) {
245 .short_help =
"lb as <vip-prefix> [<address> [<address> [...]]] [del]",
258 u32 per_cpu_sticky_buckets_log2 = 0;
272 else if (
unformat(line_input,
"buckets %d", &per_cpu_sticky_buckets))
274 else if (
unformat(line_input,
"buckets-log2 %d", &per_cpu_sticky_buckets_log2)) {
275 if (per_cpu_sticky_buckets_log2 >= 32)
277 per_cpu_sticky_buckets = 1 << per_cpu_sticky_buckets_log2;
278 }
else if (
unformat(line_input,
"timeout %d", &flow_timeout))
289 if ((ret =
lb_conf(&ip4, &ip6, per_cpu_sticky_buckets, flow_timeout))) {
303 .short_help =
"lb conf [ip4-src-address <addr>] [ip6-src-address <addr>] [buckets <n>] [timeout <s>]",
319 .short_help =
"show lb",
335 if (
unformat(&line_input,
"verbose"))
339 vlib_cli_output(vm,
"%U\n", verbose?format_lb_vip_detailed:format_lb_vip, vip);
348 .path =
"show lb vips",
349 .short_help =
"show lb vips [verbose]",
362 u32 _sw_if_index, *sw_if_index = &_sw_if_index;
363 u32 * inside_sw_if_indices = 0;
374 vec_add1 (inside_sw_if_indices, *sw_if_index);
375 else if (
unformat (line_input,
"del"))
392 0,
"%s %U failed", is_del ?
"del" :
"add",
403 0,
"%s %U failed", is_del ?
"del" :
"add",
427 .path =
"lb set interface nat4",
429 .short_help =
"lb set interface nat4 in <intfc> [del]",
441 .path =
"lb set interface nat6",
443 .short_help =
"lb set interface nat6 in <intfc> [del]",
454 for(thread_index = 0; thread_index < tm->
n_vlib_mains; thread_index++ ) {
479 .path =
"test lb flowtable flush",
480 .short_help =
"test lb flowtable flush",
static clib_error_t * lb_flowtable_flush_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int lb_nat4_interface_add_del(u32 sw_if_index, int is_del)
vnet_main_t * vnet_get_main(void)
static clib_error_t * lb_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address, u32 per_cpu_sticky_buckets, u32 flow_timeout)
Fix global load-balancer parameters.
int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * lb_conf_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
lb_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.
static clib_error_t * lb_show_vips_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * lb_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.
u32 flow_timeout
Flow timeout in seconds.
vlib_refcount_t as_refcount
Each AS has an associated reference counter.
#define clib_error_return(e, args...)
lb_vip_t * vips
Pool of all Virtual IPs.
ip4_address_t ip4_src_address
Source address used for IPv4 encapsulated traffic.
format_function_t format_vnet_sw_interface_name
u32 value[LBHASH_ENTRY_PER_BUCKET]
int lb_vip_del(u32 vip_index)
format_function_t format_lb_main
static_always_inline void vlib_refcount_add(vlib_refcount_t *r, u32 thread_index, u32 counter_index, i32 v)
#define lb_hash_foreach_entry(h, bucket, i)
#define ip46_prefix_is_ip4(ip46, len)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n)
static_always_inline void lb_hash_free(lb_hash_t *h)
#define VLIB_CLI_COMMAND(x,...)
int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u32 *vip_index)
static clib_error_t * lb_set_interface_nat_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd, u8 is_nat6)
lb_vip_encap_args_t encap_args
lb_per_cpu_t * per_cpu
Some global data is per-cpu.
int lb_nat6_interface_add_del(u32 sw_if_index, int is_del)
int lb_vip_add(lb_vip_add_args_t args, u32 *vip_index)
ip6_address_t ip6_src_address
Source address used in IPv6 encapsulated traffic.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
uword unformat_ip46_prefix(unformat_input_t *input, va_list *args)
static clib_error_t * lb_as_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * lb_vip_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void lb_garbage_collection()
static clib_error_t * lb_set_interface_nat6_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_thread_main_t * vlib_get_thread_main()
#define vec_foreach(var, vec)
Vector iterator.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Load balancing service is provided per VIP.