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);
73 vl_api_lb_conf_reply_t * rmp;
137 vl_api_lb_conf_reply_t * rmp;
140 ip46_address_t vip_ip_prefix;
141 ip46_address_t as_address;
166 (vl_api_lb_vip_dump_t * mp)
182 if (vip != lbm->
vips) {
183 msg_size =
sizeof (*rmp);
185 memset (rmp, 0, msg_size);
193 rmp->
vip.port = htons(vip->
port);
221 if (*as_index != 0) {
222 as = &lbm->
ass[*as_index];
223 msg_size =
sizeof (*rmp);
225 memset (rmp, 0, msg_size);
232 rmp->
vip.port = htons(vip->
port);
247 (vl_api_lb_as_dump_t * mp)
259 clib_memcpy(&prefix.ip6, mp->pfx.address.un.ip6,
sizeof(mp->pfx.address.un.ip6));
261 dump_all = (prefix.ip6.as_u64[0] == 0) && (prefix.ip6.as_u64[1] == 0);
267 || ((prefix.as_u64[0] == vip->
prefix.as_u64[0])
268 && (prefix.as_u64[1] == vip->
prefix.as_u64[1])
270 && (mp->port == vip->
port)) )
284 ip46_address_t vip_prefix;
287 vl_api_lb_flush_vip_reply_t * rmp;
294 memcpy (&(vip_prefix.ip6), mp->
pfx.address.un.ip6,
sizeof(vip_prefix.ip6));
296 vip_plen = mp->
pfx.len;
310 vl_api_lb_add_del_intf_nat4_reply_t *rmp;
330 vl_api_lb_add_del_intf_nat6_reply_t *rmp;
346 #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)
Each VIP is configured with a set of application server.
vnet_main_t * vnet_get_main(void)
u32 flow_timeout[default=0xffffffff]
#define pool_foreach(VAR, POOL)
Iterate through pool.
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.
vl_api_lb_srv_type_t srv_type
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
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)
ip46_address_t prefix
A Virtual IP represents a given service delivered by a set of application servers.
u32 new_flows_table_length[default=1024]
static void vl_api_lb_add_del_intf_nat6_t_handler(vl_api_lb_add_del_intf_nat6_t *mp)
void * vl_msg_api_alloc(int nbytes)
#define clib_memcpy(d, s, n)
ip46_address_t address
Destination address used to tunnel traffic towards that application server.
#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.
lb_vip_encap_args_t encap_args
vl_api_lb_encap_type_t encap
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.
u32 last_used
Rotating timestamp of when LB_AS_FLAGS_USED flag was last set.
Enable/disable NAT4 feature on the interface.
vl_api_fib_path_type_t type
u8 plen
The VIP prefix length.
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)
lb_as_t * ass
Pool of ASs.
Reply all configured vip.
lb_vip_type_t type
The type of traffic for this.
Add a virtual address (or prefix)
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)
u32 new_flow_table_mask
New flows table length - 1 (length MUST be a power of 2)
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
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)
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
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)
u8 flags
Some per-AS flags.
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)
vl_api_interface_index_t sw_if_index
#define VALIDATE_SW_IF_INDEX(mp)