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;
149 s =
format (0,
"SCRIPT: lb_add_del_vip ");
182 vl_api_lb_conf_reply_t * rmp;
185 ip46_address_t vip_ip_prefix;
186 ip46_address_t as_address;
214 s =
format (0,
"SCRIPT: lb_add_del_as ");
220 (ip6_address_t *) & address.ip6);
223 (ip6_address_t *) & address.ip4);
230 (vl_api_lb_vip_dump_t * mp)
246 if (vip != lbm->vips) {
247 msg_size = sizeof (*rmp);
248 rmp = vl_msg_api_alloc (msg_size);
249 memset (rmp, 0, msg_size);
251 htons (VL_API_LB_VIP_DETAILS + lbm->msg_id_base);
252 rmp->context = mp->context;
254 ip_address_encode(&vip->prefix, IP46_TYPE_ANY, &rmp->vip.pfx.address);
255 rmp->vip.pfx.len = vip->plen;
256 rmp->vip.protocol = htonl (vip->protocol);
257 rmp->vip.port = htons(vip->port);
258 rmp->encap = htonl(vip->type);
259 rmp->dscp = vip->encap_args.dscp;
260 rmp->srv_type = vip->encap_args.srv_type;
261 rmp->target_port = htons(vip->encap_args.target_port);
262 rmp->flow_table_length = htonl(vip->new_flow_table_mask + 1);
264 vl_api_send_msg (reg, (u8 *) rmp);
285 if (*as_index != 0) {
286 as = &lbm->ass[*as_index];
287 msg_size = sizeof (*rmp);
288 rmp = vl_msg_api_alloc (msg_size);
289 memset (rmp, 0, msg_size);
291 htons (VL_API_LB_AS_DETAILS + lbm->msg_id_base);
292 rmp->context = context;
293 ip_address_encode(&vip->prefix, IP46_TYPE_ANY, (vl_api_address_t *)&rmp->vip.pfx.address);
294 rmp->vip.pfx.len = vip->plen;
295 rmp->vip.protocol = htonl (vip->protocol);
296 rmp->vip.port = htons(vip->port);
297 ip_address_encode(&as->address, IP46_TYPE_ANY, &rmp->app_srv);
298 rmp->flags = as->flags;
299 rmp->in_use_since = htonl(as->last_used);
301 vl_api_send_msg (reg, (u8 *) rmp);
311 (vl_api_lb_as_dump_t * mp)
323 clib_memcpy(&prefix.ip6, mp->pfx.address.un.ip6,
sizeof(mp->pfx.address.un.ip6));
325 dump_all = (prefix.ip6.as_u64[0] == 0) && (prefix.ip6.as_u64[1] == 0);
331 || ((prefix.as_u64[0] == vip->prefix.as_u64[0])
332 && (prefix.as_u64[1] == vip->prefix.as_u64[1])
333 && (mp->protocol == vip->protocol)
334 && (mp->port == vip->port)) )
336 send_lb_as_details(reg, mp->context, vip);
348 ip46_address_t vip_prefix;
351 vl_api_lb_flush_vip_reply_t * rmp;
358 memcpy (&(vip_prefix.ip6), mp->
pfx.address.un.ip6,
sizeof(vip_prefix.ip6));
360 vip_plen = mp->
pfx.len;
363 ntohs(mp->
port), &vip_index);
374 vl_api_lb_add_del_intf_nat4_reply_t *rmp;
394 vl_api_lb_add_del_intf_nat6_reply_t *rmp;
414 s =
format (0,
"SCRIPT: lb_add_del_vip ");
416 &mp->
pfx.address, mp->
pfx.len);
423 #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 flow_timeout[default=0xffffffff]
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)
Decode/Encode for struct/union types.
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)
u32 sticky_buckets_per_core[default=0xffffffff]
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
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)