#include <lb/lb.h>
#include <vppinfra/byte_order.h>
+#include <vppinfra/string.h>
#include <vlibapi/api.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
vl_api_lb_conf_reply_t * rmp;
int rv = 0;
+ if (mp->sticky_buckets_per_core == ~0) {
+ mp->sticky_buckets_per_core = lbm->per_cpu_sticky_buckets;
+ }
+ if (mp->flow_timeout == ~0) {
+ mp->flow_timeout = lbm->flow_timeout;
+ }
+
rv = lb_conf((ip4_address_t *)&mp->ip4_src_address,
- (ip6_address_t *)mp->ip6_src_address,
+ (ip6_address_t *)&mp->ip6_src_address,
mp->sticky_buckets_per_core,
mp->flow_timeout);
u8 * s;
s = format (0, "SCRIPT: lb_conf ");
s = format (s, "%U ", format_ip4_address, (ip4_address_t *)&mp->ip4_src_address);
- s = format (s, "%U ", format_ip6_address, (ip6_address_t *)mp->ip6_src_address);
+ s = format (s, "%U ", format_ip6_address, (ip6_address_t *)&mp->ip6_src_address);
s = format (s, "%u ", mp->sticky_buckets_per_core);
s = format (s, "%u ", mp->flow_timeout);
FINISH;
int rv = 0;
lb_vip_add_args_t args;
- if((mp->protocol != IP_PROTOCOL_TCP)
- && (mp->protocol != IP_PROTOCOL_UDP))
+ /* if port == 0, it means all-port VIP */
+ if (mp->port == 0)
{
mp->protocol = ~0;
- mp->port = 0;
}
memcpy (&(args.prefix.ip6), mp->ip_prefix, sizeof(args.prefix.ip6));
if (mp->is_del) {
u32 vip_index;
if (!(rv = lb_vip_find_index(&(args.prefix), mp->prefix_length,
- mp->protocol, mp->port, &vip_index)))
+ mp->protocol, ntohs(mp->port), &vip_index)))
rv = lb_vip_del(vip_index);
} else {
u32 vip_index;
}
args.plen = mp->prefix_length;
+ args.protocol = mp->protocol;
+ args.port = ntohs(mp->port);
args.type = type;
args.new_length = ntohl(mp->new_flows_table_length);
sizeof(as_address.ip6));
if ((rv = lb_vip_find_index(&vip_ip_prefix, mp->vip_prefix_length,
- mp->protocol, mp->port, &vip_index)))
+ mp->protocol, ntohs(mp->port), &vip_index)))
goto done;
if (mp->is_del)
FINISH;
}
+static void
+vl_api_lb_flush_vip_t_handler
+(vl_api_lb_flush_vip_t * mp)
+{
+ lb_main_t *lbm = &lb_main;
+ int rv = 0;
+ ip46_address_t vip_prefix;
+ u8 vip_plen;
+ u32 vip_index;
+ vl_api_lb_flush_vip_reply_t * rmp;
+
+ if (mp->port == 0)
+ {
+ mp->protocol = ~0;
+ }
+
+ memcpy (&(vip_prefix.ip6), mp->ip_prefix, sizeof(vip_prefix.ip6));
+
+ vip_plen = mp->prefix_length;
+
+ rv = lb_vip_find_index(&vip_prefix, vip_plen, mp->protocol,
+ ntohs(mp->port), &vip_index);
+
+ rv = lb_flush_vip_as(vip_index, ~0);
+
+ REPLY_MACRO (VL_API_LB_FLUSH_VIP_REPLY);
+}
+
+static void *vl_api_lb_flush_vip_t_print
+(vl_api_lb_flush_vip_t *mp, void * handle)
+{
+ u8 * s;
+ s = format (0, "SCRIPT: lb_add_del_vip ");
+ s = format (s, "%U ", format_ip46_prefix,
+ (ip46_address_t *)mp->ip_prefix, mp->prefix_length, IP46_TYPE_ANY);
+
+ s = format (s, "protocol %u ", mp->protocol);
+ s = format (s, "port %u ", mp->port);
+
+ FINISH;
+}
+
/* List of message types that this plugin understands */
#define foreach_lb_plugin_api_msg \
_(LB_CONF, lb_conf) \
_(LB_ADD_DEL_VIP, lb_add_del_vip) \
-_(LB_ADD_DEL_AS, lb_add_del_as)
+_(LB_ADD_DEL_AS, lb_add_del_as) \
+_(LB_FLUSH_VIP, lb_flush_vip)
static clib_error_t * lb_api_init (vlib_main_t * vm)
{