IGMP: improve CLI debug output
Change-Id: If88fc3acdba1f73b3e8be94d8014556c5239596c Signed-off-by: Neale Ranns <nranns@cisco.com>
This commit is contained in:
@ -353,26 +353,12 @@ igmp_show_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
{
|
||||
clib_error_t *error = NULL;
|
||||
igmp_main_t *im = &igmp_main;
|
||||
vnet_main_t *vnm = vnet_get_main ();
|
||||
igmp_config_t *config;
|
||||
igmp_group_t *group;
|
||||
igmp_src_t *src;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
pool_foreach (config, im->configs,
|
||||
({
|
||||
vlib_cli_output (vm, "interface: %U mode: %U %U",
|
||||
format_vnet_sw_if_index_name, vnm, config->sw_if_index,
|
||||
format_igmp_mode, config->mode, format_igmp_proxy_device_id, config->proxy_device_id);
|
||||
|
||||
FOR_EACH_GROUP (group, config,
|
||||
({
|
||||
vlib_cli_output (vm, "\t%U", format_igmp_key, group->key);
|
||||
FOR_EACH_SRC (src, group, IGMP_FILTER_MODE_INCLUDE,
|
||||
({
|
||||
vlib_cli_output (vm, "\t\t%U", format_igmp_key, src->key);
|
||||
}));
|
||||
}));
|
||||
vlib_cli_output (vm, "%U", format_igmp_config, config);
|
||||
}));
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
@ -87,6 +87,54 @@ igmp_group_lookup (igmp_config_t * config, const igmp_key_t * key)
|
||||
return group;
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_igmp_config_timer_type (u8 * s, va_list * args)
|
||||
{
|
||||
igmp_config_timer_type_t type = va_arg (*args, igmp_config_timer_type_t);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
#define _(v,t) case IGMP_CONFIG_TIMER_##v: return (format (s, "%s", t));
|
||||
foreach_igmp_config_timer_type
|
||||
#undef _
|
||||
}
|
||||
return (s);
|
||||
}
|
||||
|
||||
|
||||
u8 *
|
||||
format_igmp_config (u8 * s, va_list * args)
|
||||
{
|
||||
igmp_config_t *config;
|
||||
igmp_group_t *group;
|
||||
vnet_main_t *vnm;
|
||||
u32 ii;
|
||||
|
||||
config = va_arg (*args, igmp_config_t *);
|
||||
vnm = vnet_get_main ();
|
||||
|
||||
s = format (s, "interface: %U mode: %U %U",
|
||||
format_vnet_sw_if_index_name, vnm, config->sw_if_index,
|
||||
format_igmp_mode, config->mode,
|
||||
format_igmp_proxy_device_id, config->proxy_device_id);
|
||||
|
||||
for (ii = 0; ii < IGMP_CONFIG_N_TIMERS; ii++)
|
||||
{
|
||||
s = format (s, "\n %U:%U",
|
||||
format_igmp_config_timer_type, ii,
|
||||
format_igmp_timer_id, config->timers[ii]);
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
FOR_EACH_GROUP (group, config,
|
||||
({
|
||||
s = format (s, "\n%U", format_igmp_group, group, 4);
|
||||
}));
|
||||
/* *INDENT-ON* */
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
|
@ -22,21 +22,25 @@
|
||||
#include <igmp/igmp_timer.h>
|
||||
#include <igmp/igmp_group.h>
|
||||
|
||||
/**
|
||||
* GENERAL_REPORT = On expiry send a general report
|
||||
* GENERAL_QUERY = On expiry send a general query
|
||||
*/
|
||||
#define foreach_igmp_config_timer_type \
|
||||
_(GENERAL_REPORT, "general-report") \
|
||||
_(GENERAL_QUERY, "general-query")
|
||||
|
||||
typedef enum igmp_config_timer_type_t_
|
||||
{
|
||||
/**
|
||||
* On expiry send a general report
|
||||
*/
|
||||
IGMP_CONFIG_TIMER_GENERAL_REPORT,
|
||||
|
||||
/**
|
||||
* On expiry send a general query
|
||||
*/
|
||||
IGMP_CONFIG_TIMER_GENERAL_QUERY,
|
||||
#define _(v,s) IGMP_CONFIG_TIMER_##v,
|
||||
foreach_igmp_config_timer_type
|
||||
#undef _
|
||||
} igmp_config_timer_type_t;
|
||||
|
||||
#define IGMP_CONFIG_N_TIMERS (IGMP_CONFIG_TIMER_GENERAL_QUERY + 1)
|
||||
|
||||
extern u8 *format_igmp_config_timer_type (u8 * s, va_list * args);
|
||||
|
||||
/**
|
||||
* @brief IGMP interface configuration
|
||||
*/
|
||||
@ -122,6 +126,8 @@ extern igmp_config_t *igmp_config_get (u32 index);
|
||||
extern igmp_group_t *igmp_group_lookup (igmp_config_t * config,
|
||||
const igmp_key_t * key);
|
||||
|
||||
extern u8 *format_igmp_config (u8 * s, va_list * args);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -280,6 +280,46 @@ igmp_group_get (u32 index)
|
||||
return (pool_elt_at_index (igmp_main.groups, index));
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_igmp_group_timer_type (u8 * s, va_list * args)
|
||||
{
|
||||
igmp_group_timer_type_t type = va_arg (*args, igmp_group_timer_type_t);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
#define _(v,t) case IGMP_GROUP_TIMER_##v: return (format (s, "%s", t));
|
||||
foreach_igmp_group_timer
|
||||
#undef _
|
||||
}
|
||||
return (s);
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_igmp_group (u8 * s, va_list * args)
|
||||
{
|
||||
igmp_group_t *group = va_arg (*args, igmp_group_t *);
|
||||
u32 indent = va_arg (*args, u32);
|
||||
igmp_src_t *src;
|
||||
u32 ii;
|
||||
|
||||
s = format (s, "%U%U",
|
||||
format_white_space, indent, format_igmp_key, group->key);
|
||||
|
||||
for (ii = 0; ii < IGMP_GROUP_N_TIMERS; ii++)
|
||||
s = format (s, "\n%U %U:%U", format_white_space, indent,
|
||||
format_igmp_group_timer_type, ii,
|
||||
format_igmp_timer_id, group->timers[ii]);
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
FOR_EACH_SRC (src, group, IGMP_FILTER_MODE_INCLUDE,
|
||||
({
|
||||
s = format (s, "\n%U", format_igmp_src, src, indent+4);
|
||||
}));
|
||||
/* *INDENT-ON* */
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
|
@ -21,33 +21,34 @@
|
||||
#include <igmp/igmp_types.h>
|
||||
#include <igmp/igmp_src.h>
|
||||
|
||||
/**
|
||||
* QUERY_REPLY = Timer running to reply to a G/SG specific query
|
||||
* QUERY_SENT = wait for response from a sent G/SG specific query.
|
||||
* Sent when a host leaves a group
|
||||
* RESEND_REPORT = Timer running to resend report
|
||||
* FILTER_MODE_CHANGE = to check if the group can swap to
|
||||
* INCLUDE mode (section 6.2.2)
|
||||
*/
|
||||
#define foreach_igmp_group_timer \
|
||||
_(QUERY_REPLY, "query-reply") \
|
||||
_(QUERY_SENT, "query-sent") \
|
||||
_(RESEND_REPORT, "resend-report") \
|
||||
_(FILTER_MODE_CHANGE, "filter-mode-change")
|
||||
|
||||
/**
|
||||
* Types of timers maintained for each group
|
||||
*/
|
||||
typedef enum igmp_group_timer_type_t_
|
||||
{
|
||||
/**
|
||||
* Timer running to reply to a G/SG specific query
|
||||
*/
|
||||
IGMP_GROUP_TIMER_QUERY_REPLY,
|
||||
/**
|
||||
* wait for response from a sent G/SG specific query.
|
||||
* Sent when a host leaves a group
|
||||
*/
|
||||
IGMP_GROUP_TIMER_QUERY_SENT,
|
||||
/**
|
||||
* Timer running to resend report
|
||||
*/
|
||||
IGMP_GROUP_TIMER_RESEND_REPORT,
|
||||
/**
|
||||
* filter-mode change timer, to check if the group can swap to
|
||||
* INCLUDE mode (section 6.2.2)
|
||||
*/
|
||||
IGMP_GROUP_TIMER_FILTER_MODE_CHANGE,
|
||||
#define _(v,s) IGMP_GROUP_TIMER_##v,
|
||||
foreach_igmp_group_timer
|
||||
#undef _
|
||||
} igmp_group_timer_type_t;
|
||||
|
||||
#define IGMP_GROUP_N_TIMERS (IGMP_GROUP_TIMER_FILTER_MODE_CHANGE + 1)
|
||||
|
||||
extern u8 *format_igmp_group_timer_type (u8 * s, va_list * args);
|
||||
|
||||
/**
|
||||
* @brief IGMP group
|
||||
* A multicast group address for which reception has been requested.
|
||||
@ -114,6 +115,8 @@ extern igmp_src_t *igmp_group_src_update (igmp_group_t * group,
|
||||
igmp_mode_t mode);
|
||||
|
||||
extern void igmp_group_src_remove (igmp_group_t * group, igmp_src_t * src);
|
||||
extern u8 *format_igmp_group (u8 * s, va_list * args);
|
||||
|
||||
|
||||
extern ip46_address_t *igmp_group_present_minus_new (igmp_group_t * group,
|
||||
igmp_filter_mode_t mode,
|
||||
|
@ -143,6 +143,19 @@ igmp_src_index (igmp_src_t * src)
|
||||
return (src - igmp_main.srcs);
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_igmp_src (u8 * s, va_list * args)
|
||||
{
|
||||
igmp_src_t *src = va_arg (*args, igmp_src_t *);
|
||||
u32 indent = va_arg (*args, u32);
|
||||
|
||||
s = format (s, "%U%U %U",
|
||||
format_white_space, indent,
|
||||
format_igmp_key, src->key,
|
||||
format_igmp_timer_id, src->timers[IGMP_SRC_TIMER_EXP]);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
|
@ -82,6 +82,7 @@ extern u32 igmp_src_index (igmp_src_t * src);
|
||||
|
||||
extern void igmp_src_refresh (igmp_src_t * src);
|
||||
extern void igmp_src_blocked (igmp_src_t * src);
|
||||
extern u8 *format_igmp_src (u8 * s, va_list * args);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -232,6 +232,28 @@ igmp_timer_retire (igmp_timer_id_t * tid)
|
||||
IGMP_PROCESS_EVENT_UPDATE_TIMER, 0);
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_igmp_timer_id (u8 * s, va_list * args)
|
||||
{
|
||||
igmp_timer_id_t tid = va_arg (*args, igmp_timer_id_t);
|
||||
igmp_timer_t *timer;
|
||||
|
||||
if (IGMP_TIMER_ID_INVALID == tid)
|
||||
{
|
||||
s = format (s, "not-running");
|
||||
}
|
||||
else
|
||||
{
|
||||
timer = pool_elt_at_index (timer_pool, tid);
|
||||
|
||||
s =
|
||||
format (s, "[expires-in:%f]",
|
||||
timer->exp_time - vlib_time_now (vlib_get_main ()));
|
||||
}
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
|
@ -51,6 +51,8 @@ extern f64 igmp_timer_get_expiry_time (igmp_timer_id_t t);
|
||||
extern void *igmp_timer_get_data (igmp_timer_id_t t);
|
||||
extern void igmp_timer_set_data (igmp_timer_id_t t, void *data);
|
||||
|
||||
extern u8 *format_igmp_timer_id (u8 * s, va_list * args);
|
||||
|
||||
/**
|
||||
* IGMP timer types and their values
|
||||
* QUERY - the general query timer
|
||||
|
Reference in New Issue
Block a user