X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Flb%2Fapi.c;h=e2ab2ac25df704337cba6d2845d529c825260eb0;hb=10bbfce0264249354f14243fbc166ee0beb41366;hp=86e2ce08ed7fbc790ff134f07f80d20f69a3ee69;hpb=3efcd0d7c3e73b812dece730396cf8816951d8ad;p=vpp.git diff --git a/src/plugins/lb/api.c b/src/plugins/lb/api.c index 86e2ce08ed7..e2ab2ac25df 100644 --- a/src/plugins/lb/api.c +++ b/src/plugins/lb/api.c @@ -60,6 +60,8 @@ _(LB_ADD_DEL_AS, lb_add_del_as) \ _(LB_VIP_DUMP, lb_vip_dump) \ _(LB_AS_DUMP, lb_as_dump) \ _(LB_FLUSH_VIP, lb_flush_vip) \ +_(LB_ADD_DEL_INTF_NAT4, lb_add_del_intf_nat4) \ +_(LB_ADD_DEL_INTF_NAT6, lb_add_del_intf_nat6) \ /* Macro to finish up custom dump fns */ @@ -78,16 +80,16 @@ vl_api_lb_conf_t_handler int rv = 0; if (mp->sticky_buckets_per_core == ~0) { - mp->sticky_buckets_per_core = lbm->per_cpu_sticky_buckets; + mp->sticky_buckets_per_core = htonl(lbm->per_cpu_sticky_buckets); } if (mp->flow_timeout == ~0) { - mp->flow_timeout = lbm->flow_timeout; + mp->flow_timeout = htonl(lbm->flow_timeout); } rv = lb_conf((ip4_address_t *)&mp->ip4_src_address, (ip6_address_t *)&mp->ip6_src_address, - mp->sticky_buckets_per_core, - mp->flow_timeout); + ntohl(mp->sticky_buckets_per_core), + ntohl(mp->flow_timeout)); REPLY_MACRO (VL_API_LB_CONF_REPLY); } @@ -120,7 +122,7 @@ vl_api_lb_add_del_vip_t_handler mp->protocol = ~0; } - memcpy (&(args.prefix), &mp->pfx, sizeof(args.prefix)); + ip_address_decode (&mp->pfx.address, &(args.prefix)); if (mp->is_del) { u32 vip_index; @@ -210,14 +212,10 @@ vl_api_lb_add_del_as_t_handler int rv = 0; u32 vip_index; ip46_address_t vip_ip_prefix; - - memcpy(&vip_ip_prefix, &mp->pfx, - sizeof(vip_ip_prefix)); - ip46_address_t as_address; - memcpy(&as_address, &mp->as_address, - sizeof(as_address)); + ip_address_decode (&mp->pfx.address, &vip_ip_prefix); + ip_address_decode (&mp->as_address, &as_address); if ((rv = lb_vip_find_index(&vip_ip_prefix, mp->pfx.len, mp->protocol, ntohs(mp->port), &vip_index))) @@ -393,6 +391,46 @@ vl_api_lb_flush_vip_t_handler REPLY_MACRO (VL_API_LB_FLUSH_VIP_REPLY); } +static void vl_api_lb_add_del_intf_nat4_t_handler + (vl_api_lb_add_del_intf_nat4_t * mp) +{ + lb_main_t *lbm = &lb_main; + vl_api_lb_add_del_intf_nat4_reply_t *rmp; + u32 sw_if_index = ntohl (mp->sw_if_index); + u8 is_del; + int rv = 0; + + is_del = !mp->is_add; + + VALIDATE_SW_IF_INDEX (mp); + + rv = lb_nat4_interface_add_del(sw_if_index, is_del); + + BAD_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_LB_ADD_DEL_INTF_NAT4_REPLY); +} + +static void vl_api_lb_add_del_intf_nat6_t_handler + (vl_api_lb_add_del_intf_nat6_t * mp) +{ + lb_main_t *lbm = &lb_main; + vl_api_lb_add_del_intf_nat6_reply_t *rmp; + u32 sw_if_index = ntohl (mp->sw_if_index); + u8 is_del; + int rv = 0; + + is_del = !mp->is_add; + + VALIDATE_SW_IF_INDEX (mp); + + rv = lb_nat6_interface_add_del(sw_if_index, is_del); + + BAD_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_LB_ADD_DEL_INTF_NAT6_REPLY); +} + static void *vl_api_lb_flush_vip_t_print (vl_api_lb_flush_vip_t *mp, void * handle) {