diff options
author | 2016-11-15 09:19:11 +0100 | |
---|---|---|
committer | 2016-11-17 21:03:25 +0000 | |
commit | 7490a752814187ed03c0deca4d836b0dca09fb4b (patch) | |
tree | 64296629669dba3ba87b580d37bc838c679d546e /vpp | |
parent | 999bbc4a2088c532d75e401703bd9205cf217c84 (diff) |
feature: API/CLI to enable/disable feature per interface
Change-Id: I91d5f5648189143903eb973fdc60de9880fd47c2
Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
Diffstat (limited to 'vpp')
-rw-r--r-- | vpp/vpp-api/api.c | 43 | ||||
-rw-r--r-- | vpp/vpp-api/custom_dump.c | 18 | ||||
-rw-r--r-- | vpp/vpp-api/vpe.api | 24 |
3 files changed, 83 insertions, 2 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index e234df8f..b2b639a7 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -89,6 +89,7 @@ #include <vnet/ipsec-gre/ipsec_gre.h> #include <vnet/flow/flow_report_classify.h> #include <vnet/ip/punt.h> +#include <vnet/feature/feature.h> #undef BIHASH_TYPE #undef __included_bihash_template_h__ @@ -466,7 +467,8 @@ _(IPSEC_SPD_DUMP, ipsec_spd_dump) \ _(IP_FIB_DUMP, ip_fib_dump) \ _(IP_FIB_DETAILS, ip_fib_details) \ _(IP6_FIB_DUMP, ip6_fib_dump) \ -_(IP6_FIB_DETAILS, ip6_fib_details) +_(IP6_FIB_DETAILS, ip6_fib_details) \ +_(FEATURE_ENABLE_DISABLE, feature_enable_disable) #define QUOTE_(x) #x #define QUOTE(x) QUOTE_(x) @@ -9174,6 +9176,45 @@ vl_api_ipsec_spd_dump_t_handler (vl_api_ipsec_spd_dump_t * mp) #endif } +static void +vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp) +{ + vl_api_feature_enable_disable_reply_t *rmp; + int rv = 0; + + u8 *arc_name = format (0, "%s%c", mp->arc_name, 0); + u8 *feature_name = format (0, "%s%c", mp->feature_name, 0); + u32 sw_if_index = ntohl (mp->sw_if_index); + + vnet_feature_registration_t *reg; + reg = + vnet_get_feature_reg ((const char *) arc_name, + (const char *) feature_name); + if (reg == 0) + rv = VNET_API_ERROR_INVALID_VALUE; + else + { + clib_error_t *error = 0; + + if (reg->enable_disable_cb) + error = reg->enable_disable_cb (sw_if_index, mp->enable); + if (!error) + vnet_feature_enable_disable ((const char *) arc_name, + (const char *) feature_name, + sw_if_index, mp->enable, 0, 0); + else + { + clib_error_report (error); + rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE; + } + } + + vec_free (feature_name); + vec_free (arc_name); + + REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY); +} + #define BOUNCE_HANDLER(nn) \ static void vl_api_##nn##_t_handler ( \ vl_api_##nn##_t *mp) \ diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c index 1dc96650..6c181eec 100644 --- a/vpp/vpp-api/custom_dump.c +++ b/vpp/vpp-api/custom_dump.c @@ -2892,6 +2892,21 @@ static void *vl_api_ioam_disable_t_print FINISH; } +static void *vl_api_feature_enable_disable_t_print + (vl_api_feature_enable_disable_t * mp, void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: feature_enable_disable "); + s = format (s, "arc_name %s ", mp->arc_name); + s = format (s, "feature_name %s ", mp->feature_name); + s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + if (!mp->enable) + s = format (s, "disable"); + + FINISH; +} + #define foreach_custom_print_no_arg_function \ _(lisp_eid_table_vni_dump) \ _(lisp_map_resolver_dump) \ @@ -3062,7 +3077,8 @@ _(GET_FIRST_MSG_ID, get_first_msg_id) \ _(IOAM_ENABLE, ioam_enable) \ _(IOAM_DISABLE, ioam_disable) \ _(IP_FIB_DUMP, ip_fib_dump) \ -_(IP6_FIB_DUMP, ip6_fib_dump) +_(IP6_FIB_DUMP, ip6_fib_dump) \ +_(FEATURE_ENABLE_DISABLE, feature_enable_disable) void vl_msg_api_custom_dump_configure (api_main_t * am) { diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api index 8a7fac67..934c4d83 100644 --- a/vpp/vpp-api/vpe.api +++ b/vpp/vpp-api/vpe.api @@ -5495,3 +5495,27 @@ define ipsec_spd_details { u64 packets; }; +/** \brief Feature path enable/disable request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param sw_if_index - the interface + @param enable - 1 = on, 0 = off +*/ +define feature_enable_disable { + u32 client_index; + u32 context; + u32 sw_if_index; + u8 enable; + u8 arc_name[64]; + u8 feature_name[64]; +}; + +/** \brief Reply to the eature path enable/disable request + @param context - sender context which was passed in the request + @param retval - return code for the request +*/ +define feature_enable_disable_reply +{ + u32 context; + i32 retval; +}; |