X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Flb%2Flb_test.c;h=1edabb51f86306bb6abcd6650394f28891fba960;hb=23b26e71e79ed4f232ac972948a8a91b554ba5f4;hp=00ad673d3547e4bcb961535adbf1d423d5fff1b0;hpb=49ee68443d41ffe1ab72c964104da980a2eb4367;p=vpp.git diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index 00ad673d354..1edabb51f86 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -128,7 +128,9 @@ foreach_standard_reply_retval_handler; #define foreach_vpe_api_reply_msg \ _(LB_CONF_REPLY, lb_conf_reply) \ _(LB_ADD_DEL_VIP_REPLY, lb_add_del_vip_reply) \ - _(LB_ADD_DEL_AS_REPLY, lb_add_del_as_reply) + _(LB_ADD_DEL_AS_REPLY, lb_add_del_as_reply) \ + _(LB_VIP_DETAILS, lb_vip_details) \ + _(LB_AS_DETAILS, lb_as_details) static int api_lb_conf (vat_main_t * vam) { @@ -245,8 +247,8 @@ static int api_lb_add_del_vip (vat_main_t * vam) } M(LB_ADD_DEL_VIP, mp); - clib_memcpy (mp->ip_prefix, &ip_prefix, sizeof (ip_prefix)); - mp->prefix_length = prefix_length; + clib_memcpy (mp->pfx.address.un.ip6, &ip_prefix.ip6, sizeof (ip_prefix.ip6)); + mp->pfx.len = prefix_length; mp->protocol = (u8)protocol; mp->port = htons((u16)port); mp->encap = (u8)encap; @@ -320,11 +322,11 @@ static int api_lb_add_del_as (vat_main_t * vam) } M(LB_ADD_DEL_AS, mp); - clib_memcpy (mp->vip_ip_prefix, &vip_prefix, sizeof (vip_prefix)); - mp->vip_prefix_length = vip_plen; + clib_memcpy (mp->pfx.address.un.ip6, &vip_prefix.ip6, sizeof (vip_prefix.ip6)); + mp->pfx.len = vip_plen; mp->protocol = (u8)protocol; mp->port = htons((u16)port); - clib_memcpy (mp->as_address, &as_addr, sizeof (as_addr)); + clib_memcpy (&mp->as_address, &as_addr, sizeof (as_addr)); mp->is_del = is_del; mp->is_flush = is_flush; @@ -333,6 +335,137 @@ static int api_lb_add_del_as (vat_main_t * vam) return ret; } +static void vl_api_lb_vip_details_t_handler + (vl_api_lb_vip_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%24U%14d%14d%18d", + format_ip46_address, &mp->vip.pfx.address, IP46_TYPE_ANY, + mp->vip.pfx.len, + mp->vip.protocol, + ntohs (mp->vip.port)); +/* + lb_main_t *lbm = &lb_main; + u32 i = 0; + + u32 vip_count = pool_len(lbm->vips); + + print (vam->ofp, "%11d", vip_count); + + for (i=0; iofp, "%24U%14d%14d%18d", + format_ip46_address, &mp->vip.pfx.address, IP46_TYPE_ANY, + mp->vip.pfx.len, + mp->vip.protocol, + ntohs (mp->vip.port)); + } +*/ +} + +static int api_lb_vip_dump (vat_main_t * vam) +{ + vl_api_lb_vip_dump_t *mp; + int ret; + + M(LB_VIP_DUMP, mp); + + S(mp); + W (ret); + return ret; +} + +static void vl_api_lb_as_details_t_handler + (vl_api_lb_as_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%24U%14d%14d%18d%d%d", + format_ip46_address, &mp->vip.pfx.address, IP46_TYPE_ANY, + mp->vip.pfx.len, + mp->vip.protocol, + ntohs (mp->vip.port), + mp->flags, + mp->in_use_since); + + //u32 i = 0; + +/* + lb_main_t *lbm = &lb_main; + print (vam->ofp, "%11d", pool_len(lbm->ass)); + for (i=0; iass); i--) + { + print (vam->ofp, "%24U%14d%14d%18d", + format_ip46_address, &mp->pfx.address, IP46_TYPE_ANY, + mp->pfx.len, + mp->pfx.protocol, + ntohs (mp->pfx.port), + ntohl(mp->app_srv), + mp->flags, + mp->in_use_; + } + */ +} + +static int api_lb_as_dump (vat_main_t * vam) +{ + + unformat_input_t *line_input = vam->input; + vl_api_lb_as_dump_t *mp; + int ret; + ip46_address_t vip_prefix, as_addr; + u8 vip_plen; + ip46_address_t *as_array = 0; + u32 port = 0; + u8 protocol = 0; + + if (!unformat(line_input, "%U", unformat_ip46_prefix, + &vip_prefix, &vip_plen, IP46_TYPE_ANY)) + { + errmsg ("lb_add_del_as: invalid vip prefix\n"); + return -99; + } + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat(line_input, "%U", unformat_ip46_address, + &as_addr, IP46_TYPE_ANY)) + { + vec_add1(as_array, as_addr); + } + else if (unformat(line_input, "protocol tcp")) + { + protocol = IP_PROTOCOL_TCP; + } + else if (unformat(line_input, "protocol udp")) + { + protocol = IP_PROTOCOL_UDP; + } + else if (unformat(line_input, "port %d", &port)) + ; + else { + errmsg ("invalid arguments\n"); + return -99; + } + } + + if (!vec_len(as_array)) { + errmsg ("No AS address provided \n"); + return -99; + } + + M(LB_AS_DUMP, mp); + clib_memcpy (mp->pfx.address.un.ip6, &vip_prefix.ip6, sizeof (vip_prefix.ip6)); + mp->pfx.len = vip_plen; + mp->protocol = (u8)protocol; + mp->port = htons((u16)port); + + S(mp); + W (ret); + return ret; +} + /* * List of messages that the api test plugin sends, * and that the data plane plugin processes @@ -347,10 +480,12 @@ _(lb_add_del_vip, " " \ "[type (nodeport|clusterip) target_port ] " \ "[new_len ] [del]") \ _(lb_add_del_as, " [protocol (tcp|udp) port ] " \ - "[
] [del] [flush]") + "[
] [del] [flush]") \ +_(lb_vip_dump, "") \ +_(lb_as_dump, " [protocol (tcp|udp) port ]") -static void -lb_vat_api_hookup (vat_main_t *vam) +static void +lb_api_hookup (vat_main_t *vam) { lb_test_main_t * lbtm = &lb_test_main; /* Hook up handlers for replies from the data plane plug-in */ @@ -376,22 +511,4 @@ lb_vat_api_hookup (vat_main_t *vam) #undef _ } -clib_error_t * vat_plugin_register (vat_main_t *vam) -{ - lb_test_main_t * lbtm = &lb_test_main; - - u8 * name; - - lbtm->vat_main = vam; - - /* Ask the vpp engine for the first assigned message-id */ - name = format (0, "lb_%08x%c", api_version, 0); - lbtm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); - - if (lbtm->msg_id_base != (u16) ~0) - lb_vat_api_hookup (vam); - - vec_free(name); - - return 0; -} +VAT_PLUGIN_REGISTER(lb);