X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Flb%2Fcli.c;h=b29605af984a2b3fb3dd797a80caa0767241034e;hb=647f609;hp=6452a87563e84fb909e495fffb6f38148bf6634c;hpb=a9a20e7f69f4a91a4d5267ab5ce14125bdc7d6c6;p=vpp.git diff --git a/src/plugins/lb/cli.c b/src/plugins/lb/cli.c index 6452a87563e..b29605af984 100644 --- a/src/plugins/lb/cli.c +++ b/src/plugins/lb/cli.c @@ -26,14 +26,15 @@ lb_vip_command_fn (vlib_main_t * vm, u32 new_len = 1024; u8 del = 0; int ret; - u32 gre4 = 0; - lb_vip_type_t type; + u32 encap = 0; + u32 dscp = ~0; + lb_vip_type_t type = 0; clib_error_t *error = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; - if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY, &plen)) { + if (!unformat(line_input, "%U", unformat_ip46_prefix, &prefix, &plen, IP46_TYPE_ANY)) { error = clib_error_return (0, "invalid vip prefix: '%U'", format_unformat_error, line_input); goto done; @@ -46,9 +47,13 @@ lb_vip_command_fn (vlib_main_t * vm, else if (unformat(line_input, "del")) del = 1; else if (unformat(line_input, "encap gre4")) - gre4 = 1; + encap = LB_ENCAP_TYPE_GRE4; else if (unformat(line_input, "encap gre6")) - gre4 = 0; + encap = LB_ENCAP_TYPE_GRE6; + else if (unformat(line_input, "encap l3dsr")) + encap = LB_ENCAP_TYPE_L3DSR; + else if (unformat(line_input, "dscp %d", &dscp)) + ; else { error = clib_error_return (0, "parse error: '%U'", format_unformat_error, line_input); @@ -56,18 +61,39 @@ lb_vip_command_fn (vlib_main_t * vm, } } + if ((encap != LB_ENCAP_TYPE_L3DSR) && (dscp != ~0) ) + { + error = clib_error_return (0, "lb_vip_add error: " + "should not configure dscp for none L3DSR."); + goto done; + } + + if ((encap == LB_ENCAP_TYPE_L3DSR) && (dscp >= 64 ) ) + { + error = clib_error_return (0, "lb_vip_add error: " + "dscp for L3DSR should be less than 64."); + goto done; + } if (ip46_prefix_is_ip4(&prefix, plen)) { - type = (gre4)?LB_VIP_TYPE_IP4_GRE4:LB_VIP_TYPE_IP4_GRE6; + if (encap == LB_ENCAP_TYPE_GRE4) + type = LB_VIP_TYPE_IP4_GRE4; + else if (encap == LB_ENCAP_TYPE_GRE6) + type = LB_VIP_TYPE_IP4_GRE6; + else if (encap == LB_ENCAP_TYPE_L3DSR) + type = LB_VIP_TYPE_IP4_L3DSR; } else { - type = (gre4)?LB_VIP_TYPE_IP6_GRE4:LB_VIP_TYPE_IP6_GRE6; + if (encap == LB_ENCAP_TYPE_GRE4) + type = LB_VIP_TYPE_IP6_GRE4; + else if (encap == LB_ENCAP_TYPE_GRE6) + type = LB_VIP_TYPE_IP6_GRE6; } lb_garbage_collection(); u32 index; if (!del) { - if ((ret = lb_vip_add(&prefix, plen, type, new_len, &index))) { + if ((ret = lb_vip_add(&prefix, plen, type, (u8)(dscp & 0x3F), new_len, &index))) { error = clib_error_return (0, "lb_vip_add error %d", ret); goto done; } else { @@ -92,7 +118,7 @@ done: VLIB_CLI_COMMAND (lb_vip_command, static) = { .path = "lb vip", - .short_help = "lb vip [encap (gre6|gre4)] [new_len ] [del]", + .short_help = "lb vip [encap (gre6|gre4|l3dsr)] [dscp ] [new_len ] [del]", .function = lb_vip_command_fn, }; @@ -273,3 +299,41 @@ VLIB_CLI_COMMAND (lb_show_vips_command, static) = .short_help = "show lb vips [verbose]", .function = lb_show_vips_command_fn, }; + +static clib_error_t * +lb_flowtable_flush_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + u32 thread_index; + vlib_thread_main_t *tm = vlib_get_thread_main(); + lb_main_t *lbm = &lb_main; + + for(thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++ ) { + lb_hash_t *h = lbm->per_cpu[thread_index].sticky_ht; + if (h != NULL) { + u32 i; + lb_hash_bucket_t *b; + + lb_hash_foreach_entry(h, b, i) { + vlib_refcount_add(&lbm->as_refcount, thread_index, b->value[i], -1); + vlib_refcount_add(&lbm->as_refcount, thread_index, 0, 1); + } + + lb_hash_free(h); + lbm->per_cpu[thread_index].sticky_ht = 0; + } + } + + return NULL; +} + +/* + * flush all lb flowtables + * This is indented for debug and unit-tests purposes only + */ +VLIB_CLI_COMMAND (lb_flowtable_flush_command, static) = +{ + .path = "test lb flowtable flush", + .short_help = "test lb flowtable flush", + .function = lb_flowtable_flush_command_fn, +};