25 #include <vpp/app/version.h> 30 #include <lb/lb.api_enum.h> 31 #include <lb/lb.api_types.h> 33 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 35 #define REPLY_MSG_ID_BASE lbm->msg_id_base 41 vl_print (handle, (char *)s); \ 50 vl_api_lb_conf_reply_t * rmp;
51 u32 sticky_buckets_per_core, flow_timeout;
63 sticky_buckets_per_core, flow_timeout);
72 s =
format (0,
"SCRIPT: lb_conf ");
86 vl_api_lb_conf_reply_t * rmp;
96 memcpy (&(args.
prefix.ip6), &mp->
pfx.address.un.ip6,
sizeof(args.
prefix.ip6));
149 s =
format (0,
"SCRIPT: lb_add_del_vip ");
182 vl_api_lb_conf_reply_t * rmp;
185 ip46_address_t vip_ip_prefix;
193 memcpy(&vip_ip_prefix.ip6, &mp->
pfx.address.un.ip6,
194 sizeof(vip_ip_prefix.ip6));
196 ip46_address_t as_address;
198 memcpy(&as_address.ip6, &mp->
as_address.un.ip6,
199 sizeof(as_address.ip6));
219 s =
format (0,
"SCRIPT: lb_add_del_as ");
235 (vl_api_lb_vip_dump_t * mp)
251 if (vip != lbm->vips) {
252 msg_size = sizeof (*rmp);
253 rmp = vl_msg_api_alloc (msg_size);
254 memset (rmp, 0, msg_size);
256 htons (VL_API_LB_VIP_DETAILS + lbm->msg_id_base);
257 rmp->context = mp->context;
259 ip_address_encode(&vip->prefix, IP46_TYPE_ANY, &rmp->vip.pfx.address);
260 rmp->vip.pfx.len = vip->plen;
261 rmp->vip.protocol = htonl (vip->protocol);
262 rmp->vip.port = htons(vip->port);
263 rmp->encap = htonl(vip->type);
264 rmp->dscp = vip->encap_args.dscp;
265 rmp->srv_type = vip->encap_args.srv_type;
266 rmp->target_port = htons(vip->encap_args.target_port);
267 rmp->flow_table_length = htonl(vip->new_flow_table_mask + 1);
269 vl_api_send_msg (reg, (u8 *) rmp);
290 if (*as_index != 0) {
291 as = &lbm->ass[*as_index];
292 msg_size = sizeof (*rmp);
293 rmp = vl_msg_api_alloc (msg_size);
294 memset (rmp, 0, msg_size);
296 htons (VL_API_LB_AS_DETAILS + lbm->msg_id_base);
297 rmp->context = context;
298 ip_address_encode(&vip->prefix, IP46_TYPE_ANY, (vl_api_address_t *)&rmp->vip.pfx.address);
299 rmp->vip.pfx.len = vip->plen;
300 rmp->vip.protocol = htonl (vip->protocol);
301 rmp->vip.port = htons(vip->port);
302 ip_address_encode(&as->address, IP46_TYPE_ANY, &rmp->app_srv);
303 rmp->flags = as->flags;
304 rmp->in_use_since = htonl(as->last_used);
306 vl_api_send_msg (reg, (u8 *) rmp);
316 (vl_api_lb_as_dump_t * mp)
328 clib_memcpy(&prefix.ip6, mp->pfx.address.un.ip6,
sizeof(mp->pfx.address.un.ip6));
330 dump_all = (prefix.ip6.as_u64[0] == 0) && (prefix.ip6.as_u64[1] == 0);
336 || ((prefix.as_u64[0] == vip->prefix.as_u64[0])
337 && (prefix.as_u64[1] == vip->prefix.as_u64[1])
338 && (mp->protocol == vip->protocol)
339 && (mp->port == vip->port)) )
341 send_lb_as_details(reg, mp->context, vip);
353 ip46_address_t vip_prefix;
356 vl_api_lb_flush_vip_reply_t * rmp;
363 memcpy (&(vip_prefix.ip6), mp->
pfx.address.un.ip6,
sizeof(vip_prefix.ip6));
365 vip_plen = mp->
pfx.len;
368 ntohs(mp->
port), &vip_index);
379 vl_api_lb_add_del_intf_nat4_reply_t *rmp;
399 vl_api_lb_add_del_intf_nat6_reply_t *rmp;
419 s =
format (0,
"SCRIPT: lb_add_del_vip ");
421 &mp->
pfx.address, mp->
pfx.len);
428 #include <lb/lb.api.c>
int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush)
vl_api_address_t as_address
static void vl_api_lb_conf_t_handler(vl_api_lb_conf_t *mp)
int lb_nat4_interface_add_del(u32 sw_if_index, int is_del)
static void * vl_api_lb_add_del_vip_t_print(vl_api_lb_add_del_vip_t *mp, void *handle)
Each VIP is configured with a set of application server.
vnet_main_t * vnet_get_main(void)
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
Optimized string handling code, including c11-compliant "safe C library" variants.
u16 msg_id_base
API dynamically registered base ID.
Enable/disable NAT6 feature on the interface.
u8 * format_vl_api_address(u8 *s, va_list *args)
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)
u32 new_flows_table_length[default=1024]
static void * vl_api_lb_conf_t_print(vl_api_lb_conf_t *mp, void *handle)
static void vl_api_lb_add_del_intf_nat6_t_handler(vl_api_lb_add_del_intf_nat6_t *mp)
static void * vl_api_lb_add_del_as_t_print(vl_api_lb_add_del_as_t *mp, void *handle)
#define clib_memcpy(d, s, n)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
vl_api_address_with_prefix_t pfx
static void vl_api_lb_vip_dump_t_handler(vl_api_lb_vip_dump_t *mp)
u32 flow_timeout
Flow timeout in seconds.
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
lb_vip_t * vips
Pool of all Virtual IPs.
Enable/disable NAT4 feature on the interface.
vl_api_fib_path_type_t type
u8 * format_vl_api_prefix(u8 *s, va_list *args)
vl_api_ip6_address_t ip6_src_address
int lb_vip_del(u32 vip_index)
vl_api_lb_srv_type_t type
int lb_flush_vip_as(u32 vip_index, u32 as_index)
Add an application server for a given VIP.
#define ip46_prefix_is_ip4(ip46, len)
An API client registration, only in vpp/vlib.
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_lb_add_del_intf_nat4_t_handler(vl_api_lb_add_del_intf_nat4_t *mp)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
u32 sticky_buckets_per_core
Reply all configured vip.
Add a virtual address (or prefix)
manual_print typedef address
lb_vip_type_t
The load balancer supports IPv4 and IPv6 traffic and GRE4, GRE6, L3DSR and NAT4, NAT6 encap...
vl_api_address_with_prefix_t pfx
static void setup_message_id_table(api_main_t *am)
int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
lb_vip_encap_args_t encap_args
static void send_lb_as_details(vl_api_registration_t *reg, u32 context, lb_vip_t *vip)
vl_api_interface_index_t sw_if_index
int lb_nat6_interface_add_del(u32 sw_if_index, int is_del)
Configure Load-Balancer global parameters (unlike the CLI, both ip4_src_address and ip6_src_address n...
int lb_vip_add(lb_vip_add_args_t args, u32 *vip_index)
vl_api_address_with_prefix_t pfx
static void * vl_api_lb_flush_vip_t_print(vl_api_lb_flush_vip_t *mp, void *handle)
vl_api_ip4_address_t ip4_src_address
vl_api_interface_index_t sw_if_index
static void vl_api_lb_as_dump_t_handler(vl_api_lb_as_dump_t *mp)
static void vl_api_lb_add_del_vip_t_handler(vl_api_lb_add_del_vip_t *mp)
static void vl_api_lb_flush_vip_t_handler(vl_api_lb_flush_vip_t *mp)
vl_api_lb_encap_type_t encap
static void vl_api_lb_add_del_as_t_handler(vl_api_lb_add_del_as_t *mp)
Load balancing service is provided per VIP+protocol+port.
u32 * as_indexes
Pool of AS indexes used for this VIP.
static clib_error_t * lb_api_init(vlib_main_t *vm)
#define VALIDATE_SW_IF_INDEX(mp)