From 647f609a11e2afb91a5216ca99d0705a3e1212a7 Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Tue, 23 Jan 2018 19:17:23 +0800 Subject: Add L3DSR feature in LB plugin L3DSR is used to overcome Layer 2 limitations of Direct Server Return Load Balancing. It maps VIP to DSCP bits, and reuse TOS bits to transfer it to server, and then server will get VIP from DSCP-to-VIP mapping. Please refer to https://www.nanog.org/meetings/nanog51/presentations/Monday/NANOG51.Talk45.nanog51-Schaumann.pdf Change-Id: I403ffeadfb04ed0265086eb2dc41f2e17f8f34cb Signed-off-by: Hongjun Ni --- src/plugins/lb/cli.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'src/plugins/lb/cli.c') diff --git a/src/plugins/lb/cli.c b/src/plugins/lb/cli.c index a5a87fccc5f..b29605af984 100644 --- a/src/plugins/lb/cli.c +++ b/src/plugins/lb/cli.c @@ -26,8 +26,9 @@ 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)) @@ -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, }; -- cgit 1.2.3-korg