diff options
Diffstat (limited to 'vnet/vnet/feature/registration.c')
-rw-r--r-- | vnet/vnet/feature/registration.c | 211 |
1 files changed, 4 insertions, 207 deletions
diff --git a/vnet/vnet/feature/registration.c b/vnet/vnet/feature/registration.c index e6b0968e53c..1deeeef904c 100644 --- a/vnet/vnet/feature/registration.c +++ b/vnet/vnet/feature/registration.c @@ -79,7 +79,6 @@ vnet_feature_next. */ -static const char *vnet_cast_names[] = VNET_CAST_NAMES; static int comma_split (u8 * s, u8 ** a, u8 ** b) @@ -196,7 +195,7 @@ vnet_feature_arc_init (vlib_main_t * vm, p = hash_get_mem (index_by_name, a_name); /* - * Note: the next two errors mean that the xxx_FEATURE_INIT macros are + * Note: the next two errors mean that something is * b0rked. As in: if you code "A depends on B," and you forget * to define a FEATURE_INIT macro for B, you lose. * Nonexistent graph nodes are tolerated. @@ -260,9 +259,9 @@ again: p = hash_get (reg_by_index, result[i]); ASSERT (p != 0); this_reg = (vnet_feature_registration_t *) p[0]; - if (this_reg->feature_index) - *this_reg->feature_index = n_features - (i + 1); - this_reg->feature_index_u32 = n_features - (i + 1); + if (this_reg->feature_index_ptr) + *this_reg->feature_index_ptr = n_features - (i + 1); + this_reg->feature_index = n_features - (i + 1); vec_add1 (feature_nodes, this_reg->node_name); } @@ -293,208 +292,6 @@ again: return 0; } -#define foreach_af_cast \ -_(4, VNET_IP_RX_UNICAST_FEAT, "ip4 unicast") \ -_(4, VNET_IP_RX_MULTICAST_FEAT, "ip4 multicast") \ -_(4, VNET_IP_TX_FEAT, "ip4 output") \ -_(6, VNET_IP_RX_UNICAST_FEAT, "ip6 unicast") \ -_(6, VNET_IP_RX_MULTICAST_FEAT, "ip6 multicast") \ -_(6, VNET_IP_TX_FEAT, "ip6 output") - -/** Display the set of available ip features. - Useful for verifying that expected features are present -*/ - -static clib_error_t * -show_ip_features_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - ip4_main_t *im4 = &ip4_main; - ip6_main_t *im6 = &ip6_main; - int i; - char **features; - - vlib_cli_output (vm, "Available IP feature nodes"); - -#define _(a,c,s) \ - do { \ - features = im##a->feature_nodes[c]; \ - vlib_cli_output (vm, "%s:", s); \ - for (i = 0; i < vec_len(features); i++) \ - vlib_cli_output (vm, " %s\n", features[i]); \ - } while(0); - foreach_af_cast; -#undef _ - - return 0; -} - -/*? - * This command is used to display the set of available IP features. - * This can be useful for verifying that expected features are present. - * - * @cliexpar - * Example of how to display the set of available IP features: - * @cliexstart{show ip features} - * Available IP feature nodes - * ip4 unicast: - * ip4-inacl - * ip4-source-check-via-rx - * ip4-source-check-via-any - * ip4-source-and-port-range-check-rx - * ip4-policer-classify - * ipsec-input-ip4 - * vpath-input-ip4 - * snat-in2out - * snat-out2in - * ip4-lookup - * ip4 multicast: - * vpath-input-ip4 - * ip4-lookup-multicast - * ip4 output: - * ip4-source-and-port-range-check-tx - * interface-output - * ip6 unicast: - * ip6-inacl - * ip6-policer-classify - * ipsec-input-ip6 - * l2tp-decap - * vpath-input-ip6 - * sir-to-ila - * ip6-lookup - * ip6 multicast: - * vpath-input-ip6 - * ip6-lookup - * ip6 output: - * interface-output - * @cliexend -?*/ -/* *INDENT-OFF* */ -VLIB_CLI_COMMAND (show_ip_features_command, static) = { - .path = "show ip features", - .short_help = "show ip features", - .function = show_ip_features_command_fn, -}; -/* *INDENT-ON* */ - -/** Display the set of IP features configured on a specific interface - */ - -void -ip_interface_features_show (vlib_main_t * vm, - const char *pname, - vnet_feature_config_main_t * cm, u32 sw_if_index) -{ - u32 node_index, current_config_index; - vnet_cast_t cast; - vnet_config_main_t *vcm; - vnet_config_t *cfg; - u32 cfg_index; - vnet_config_feature_t *feat; - vlib_node_t *n; - int i; - - vlib_cli_output (vm, "%s feature paths configured on %U...", - pname, format_vnet_sw_if_index_name, - vnet_get_main (), sw_if_index); - - for (cast = VNET_IP_RX_UNICAST_FEAT; cast < VNET_N_IP_FEAT; cast++) - { - vcm = &(cm[cast].config_main); - - vlib_cli_output (vm, "\n%s %s:", pname, vnet_cast_names[cast]); - - if (NULL == cm[cast].config_index_by_sw_if_index || - vec_len (cm[cast].config_index_by_sw_if_index) < sw_if_index) - { - vlib_cli_output (vm, "none configured"); - continue; - } - - current_config_index = vec_elt (cm[cast].config_index_by_sw_if_index, - sw_if_index); - - ASSERT (current_config_index - < vec_len (vcm->config_pool_index_by_user_index)); - - cfg_index = vcm->config_pool_index_by_user_index[current_config_index]; - cfg = pool_elt_at_index (vcm->config_pool, cfg_index); - - for (i = 0; i < vec_len (cfg->features); i++) - { - feat = cfg->features + i; - node_index = feat->node_index; - n = vlib_get_node (vm, node_index); - vlib_cli_output (vm, " %v", n->name); - } - } -} - -static clib_error_t * -show_ip_interface_features_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - vnet_main_t *vnm = vnet_get_main (); - ip4_main_t *im4 = &ip4_main; - ip_lookup_main_t *lm4 = &im4->lookup_main; - ip6_main_t *im6 = &ip6_main; - ip_lookup_main_t *lm6 = &im6->lookup_main; - - ip_lookup_main_t *lm; - u32 sw_if_index, af; - - if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) - return clib_error_return (0, "Interface not specified..."); - - vlib_cli_output (vm, "IP feature paths configured on %U...", - format_vnet_sw_if_index_name, vnm, sw_if_index); - - for (af = 0; af < 2; af++) - { - if (af == 0) - lm = lm4; - else - lm = lm6; - - ip_interface_features_show (vm, (af == 0) ? "ip4" : "ip6", - lm->feature_config_mains, sw_if_index); - } - - return 0; -} - -/*? - * This command is used to display the set of IP features configured - * on a specific interface - * - * @cliexpar - * Example of how to display the set of available IP features on an interface: - * @cliexstart{show ip interface features GigabitEthernet2/0/0} - * IP feature paths configured on GigabitEthernet2/0/0... - * ipv4 unicast: - * ip4-lookup - * ipv4 multicast: - * ip4-lookup-multicast - * ipv4 multicast: - * interface-output - * ipv6 unicast: - * ip6-lookup - * ipv6 multicast: - * ip6-lookup - * ipv6 multicast: - * interface-output - * @cliexend -?*/ -/* *INDENT-OFF* */ -VLIB_CLI_COMMAND (show_ip_interface_features_command, static) = { - .path = "show ip interface features", - .short_help = "show ip interface features <interface>", - .function = show_ip_interface_features_command_fn, -}; -/* *INDENT-ON* */ - /* * fd.io coding-style-patch-verification: ON * |