diff options
author | Benoît Ganne <bganne@cisco.com> | 2019-07-04 16:43:26 +0200 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2019-07-05 08:48:39 +0000 |
commit | 3918bdbcbb6459fe61eb5ab8bd1c30bf287e39ce (patch) | |
tree | b44e38eacab075c4a90049241e8fa5f81e2a00c3 /src/plugins/gbp/gbp_ext_itf.c | |
parent | 73c8d1d644c1b1606848579c7d539f739d63487a (diff) |
gbp: update gbp-ext-itf API
Change gbp-ext-itf API to create anonymous ext-itf through the same API
as non-anonymous instead of a new API
Type: refactor
Change-Id: I381ff2a5bcd55276793df78ca891334c28946cd0
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/plugins/gbp/gbp_ext_itf.c')
-rw-r--r-- | src/plugins/gbp/gbp_ext_itf.c | 66 |
1 files changed, 25 insertions, 41 deletions
diff --git a/src/plugins/gbp/gbp_ext_itf.c b/src/plugins/gbp/gbp_ext_itf.c index 89bcb3da49e..6462eca9eaf 100644 --- a/src/plugins/gbp/gbp_ext_itf.c +++ b/src/plugins/gbp/gbp_ext_itf.c @@ -43,13 +43,14 @@ format_gbp_ext_itf (u8 * s, va_list * args) { gbp_ext_itf_t *gx = va_arg (*args, gbp_ext_itf_t *); - return (format (s, "%U in %U", + return (format (s, "%U%s in %U", format_gbp_itf, gx->gx_itf, + (gx->gx_flags & GBP_EXT_ITF_F_ANON) ? " [anon]" : "", format_gbp_bridge_domain, gx->gx_bd)); } int -gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id) +gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id, u32 flags) { gbp_ext_itf_t *gx; index_t gxi; @@ -92,6 +93,20 @@ gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id) gr->grd_fib_index[fib_proto_to_dpo (fproto)]; } + if (flags & GBP_EXT_ITF_F_ANON) + { + /* add interface to the BD */ + index_t itf = gbp_itf_add_and_lock (sw_if_index, bd_id); + /* setup GBP L2 features on this interface */ + gbp_itf_set_l2_input_feature (itf, 0, + L2INPUT_FEAT_GBP_LPM_ANON_CLASSIFY | + L2INPUT_FEAT_LEARN); + gbp_itf_set_l2_output_feature (itf, 0, + L2OUTPUT_FEAT_GBP_POLICY_LPM); + } + + gx->gx_flags = flags; + gbp_ext_itf_db[sw_if_index] = gxi; GBP_EXT_ITF_DBG ("add: %U", format_gbp_ext_itf, gx); @@ -119,6 +134,9 @@ gbp_ext_itf_delete (u32 sw_if_index) GBP_EXT_ITF_DBG ("del: %U", format_gbp_ext_itf, gx); + if (gx->gx_flags & GBP_EXT_ITF_F_ANON) + gbp_itf_unlock (gx->gx_itf); + gbp_route_domain_unlock (gx->gx_rd); gbp_bridge_domain_unlock (gx->gx_bd); @@ -130,39 +148,13 @@ gbp_ext_itf_delete (u32 sw_if_index) return (VNET_API_ERROR_NO_SUCH_ENTRY); } -int -gbp_ext_itf_anon_add (u32 sw_if_index, u32 bd_id, u32 rd_id) -{ - int rv = gbp_ext_itf_add (sw_if_index, bd_id, rd_id); - if (rv) - return rv; - /* add interface to the BD */ - index_t itf = gbp_itf_add_and_lock (sw_if_index, bd_id); - /* setup GBP L2 features on this interface */ - gbp_itf_set_l2_input_feature (itf, 0, - L2INPUT_FEAT_GBP_LPM_ANON_CLASSIFY | - L2INPUT_FEAT_LEARN); - gbp_itf_set_l2_output_feature (itf, 0, L2OUTPUT_FEAT_GBP_POLICY_LPM); - return 0; -} - -int -gbp_ext_itf_anon_delete (u32 sw_if_index) -{ - int rv = gbp_ext_itf_delete (sw_if_index); - if (rv) - return rv; - gbp_itf_unlock (sw_if_index); - return 0; -} - static clib_error_t * gbp_ext_itf_add_del_cli (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { unformat_input_t _line_input, *line_input = &_line_input; - u32 sw_if_index = ~0, bd_id = ~0, rd_id = ~0; - int add = 1, anon = 0; + u32 sw_if_index = ~0, bd_id = ~0, rd_id = ~0, flags = 0; + int add = 1; int rv; /* Get a line of input. */ @@ -183,7 +175,7 @@ gbp_ext_itf_add_del_cli (vlib_main_t * vm, else if (unformat (line_input, "rd %d", &rd_id)) ; else if (unformat (line_input, "anon-l3-out")) - anon = 1; + flags |= GBP_EXT_ITF_F_ANON; else return clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); @@ -199,18 +191,10 @@ gbp_ext_itf_add_del_cli (vlib_main_t * vm, return clib_error_return (0, "BD-ID must be specified"); if (~0 == rd_id) return clib_error_return (0, "RD-ID must be specified"); - if (anon) - rv = gbp_ext_itf_anon_add (sw_if_index, bd_id, rd_id); - else - rv = gbp_ext_itf_add (sw_if_index, bd_id, rd_id); + rv = gbp_ext_itf_add (sw_if_index, bd_id, rd_id, flags); } else - { - if (anon) - rv = gbp_ext_itf_anon_delete (sw_if_index); - else - rv = gbp_ext_itf_delete (sw_if_index); - } + rv = gbp_ext_itf_delete (sw_if_index); switch (rv) { |