summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-11-02 21:38:53 +0100
committerDamjan Marion <damarion@cisco.com>2016-11-02 21:54:32 +0100
commit273c26a531bf031b3426588041bad67fe7f0a246 (patch)
tree9772ade89b41e45fb66c125843b7c6a8a398d112
parent8bdc63b6036167e080b6501c17e7691033b64319 (diff)
feature: recover "show ip features" command
Removed by accident. Change-Id: Ifebbe99eb2825cb6ee7d33d55cf3c087a9817f72 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--vnet/vnet/feature/registration.c204
1 files changed, 204 insertions, 0 deletions
diff --git a/vnet/vnet/feature/registration.c b/vnet/vnet/feature/registration.c
index 64a82673b15..5f59eed03a6 100644
--- a/vnet/vnet/feature/registration.c
+++ b/vnet/vnet/feature/registration.c
@@ -87,6 +87,8 @@
vnet_get_config_data.
*/
+static const char *vnet_cast_names[] = VNET_CAST_NAMES;
+
static int
comma_split (u8 * s, u8 ** a, u8 ** b)
{
@@ -299,6 +301,208 @@ 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
*