Fix pretty-printing in "api trace custom-dump" (VPP-683)
This commit is different from the ones in 1704 and master in that it also adds format_ip6_address which was missing and is needed by the print functions. Change-Id: I45a4c28bc54c6e7e01bf42c6c6e38a96a292a31d Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
This commit is contained in:
Andrew Yourtchenko
committed by
Neale Ranns
parent
a558f61eb9
commit
c6833f804e
@ -29,6 +29,7 @@ acl_plugin_la_SOURCES = \
|
||||
acl/l2sess.c \
|
||||
acl/l2sess_node.c \
|
||||
acl/l2sess.h \
|
||||
acl/manual_fns.h \
|
||||
acl/acl_plugin.api.h
|
||||
|
||||
BUILT_SOURCES = acl/acl.api.h acl/acl.api.json
|
||||
@ -55,9 +56,10 @@ api_DATA = acl/acl.api.json
|
||||
nobase_include_HEADERS = \
|
||||
acl/acl_all_api_h.h \
|
||||
acl/acl_msg_enum.h \
|
||||
acl/manual_fns.h \
|
||||
acl/acl.api.h
|
||||
|
||||
acl_test_plugin_la_SOURCES = acl/acl_test.c acl/acl_plugin.api.h
|
||||
acl_test_plugin_la_SOURCES = acl/acl_test.c acl/acl_plugin.api.h acl/acl_all_api.h
|
||||
|
||||
# Remove *.la files
|
||||
install-data-hook:
|
||||
|
@ -60,7 +60,7 @@ define acl_plugin_get_version_reply
|
||||
@param tcp_flags_value - if proto==6, mask to AND the TCP flags in the packet with
|
||||
*/
|
||||
|
||||
typeonly manual_print manual_endian define acl_rule
|
||||
typeonly manual_print define acl_rule
|
||||
{
|
||||
u8 is_permit;
|
||||
u8 is_ipv6;
|
||||
@ -104,7 +104,7 @@ typeonly manual_print manual_endian define acl_rule
|
||||
@param src_ip_prefix_len - Source prefix length
|
||||
*/
|
||||
|
||||
typeonly manual_print manual_endian define macip_acl_rule
|
||||
typeonly manual_print define macip_acl_rule
|
||||
{
|
||||
u8 is_permit;
|
||||
u8 is_ipv6;
|
||||
@ -161,7 +161,7 @@ define acl_add_replace_reply
|
||||
@param acl_index - ACL index to delete
|
||||
*/
|
||||
|
||||
define acl_del
|
||||
manual_print define acl_del
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
@ -190,7 +190,7 @@ define acl_del_reply
|
||||
@param acl_index - index of ACL for the operation
|
||||
*/
|
||||
|
||||
define acl_interface_add_del
|
||||
manual_print define acl_interface_add_del
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
@ -224,7 +224,7 @@ define acl_interface_add_del_reply
|
||||
@param acls - vector of ACL indices
|
||||
*/
|
||||
|
||||
manual_endian define acl_interface_set_acl_list
|
||||
manual_print define acl_interface_set_acl_list
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
@ -266,7 +266,7 @@ define acl_dump
|
||||
@param r - Array of rules within this ACL
|
||||
*/
|
||||
|
||||
manual_print manual_endian define acl_details
|
||||
manual_endian manual_print define acl_details
|
||||
{
|
||||
u32 context;
|
||||
u32 acl_index;
|
||||
@ -296,7 +296,7 @@ define acl_interface_list_dump
|
||||
@param acls - the vector of ACL indices
|
||||
*/
|
||||
|
||||
manual_endian define acl_interface_list_details
|
||||
define acl_interface_list_details
|
||||
{
|
||||
u32 context;
|
||||
u32 sw_if_index;
|
||||
@ -313,7 +313,7 @@ manual_endian define acl_interface_list_details
|
||||
@param r - vector of MACIP ACL rules
|
||||
*/
|
||||
|
||||
manual_print manual_endian define macip_acl_add
|
||||
manual_endian manual_print define macip_acl_add
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
@ -341,7 +341,7 @@ define macip_acl_add_reply
|
||||
@param acl_index - MACIP ACL index to delete
|
||||
*/
|
||||
|
||||
define macip_acl_del
|
||||
manual_print define macip_acl_del
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
@ -367,7 +367,7 @@ define macip_acl_del_reply
|
||||
@param acl_index - MACIP ACL index
|
||||
*/
|
||||
|
||||
define macip_acl_interface_add_del
|
||||
manual_print define macip_acl_interface_add_del
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
@ -409,7 +409,7 @@ define macip_acl_dump
|
||||
@param r - rules comprising this ACL
|
||||
*/
|
||||
|
||||
manual_print manual_endian define macip_acl_details
|
||||
manual_endian manual_print define macip_acl_details
|
||||
{
|
||||
u32 context;
|
||||
u32 acl_index;
|
||||
|
@ -1832,8 +1832,6 @@ vl_api_macip_acl_interface_get_t_handler (vl_api_macip_acl_interface_get_t *
|
||||
vl_msg_api_send_shmem (q, (u8 *) & rmp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set up the API message handling tables */
|
||||
static clib_error_t *
|
||||
acl_plugin_api_hookup (vlib_main_t * vm)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -161,14 +161,14 @@ vl_api_acl_rule_t_pretty_format (u8 *out, vl_api_acl_rule_t * a)
|
||||
inet_ntop(af, a->src_ip_addr, (void *)src, sizeof(src));
|
||||
inet_ntop(af, a->dst_ip_addr, (void *)dst, sizeof(dst));
|
||||
|
||||
out = format(out, "%s action %d src %s/%d dst %s/%d proto %d sport %d-%d dport %d-%d tcpflags %d %d",
|
||||
out = format(out, "%s action %d src %s/%d dst %s/%d proto %d sport %d-%d dport %d-%d tcpflags %d mask %d",
|
||||
a->is_ipv6 ? "ipv6" : "ipv4", a->is_permit,
|
||||
src, a->src_ip_prefix_len,
|
||||
dst, a->dst_ip_prefix_len,
|
||||
a->proto,
|
||||
a->srcport_or_icmptype_first, a->srcport_or_icmptype_last,
|
||||
a->dstport_or_icmpcode_first, a->dstport_or_icmpcode_last,
|
||||
a->tcp_flags_mask, a->tcp_flags_value);
|
||||
a->tcp_flags_value, a->tcp_flags_mask);
|
||||
return(out);
|
||||
}
|
||||
|
||||
@ -362,6 +362,7 @@ static int api_acl_add_replace (vat_main_t * vam)
|
||||
vl_api_acl_rule_t *rules = 0;
|
||||
int rule_idx = 0;
|
||||
int n_rules = 0;
|
||||
int n_rules_override = -1;
|
||||
u32 proto = 0;
|
||||
u32 port1 = 0;
|
||||
u32 port2 = 0;
|
||||
@ -398,6 +399,10 @@ static int api_acl_add_replace (vat_main_t * vam)
|
||||
vec_validate_acl_rules(rules, rule_idx);
|
||||
rules[rule_idx].is_permit = 1;
|
||||
}
|
||||
else if (unformat (i, "count %d", &n_rules_override))
|
||||
{
|
||||
/* we will use this later */
|
||||
}
|
||||
else if (unformat (i, "action %d", &action))
|
||||
{
|
||||
vec_validate_acl_rules(rules, rule_idx);
|
||||
@ -465,6 +470,12 @@ static int api_acl_add_replace (vat_main_t * vam)
|
||||
rules[rule_idx].tcp_flags_value = tcpflags;
|
||||
rules[rule_idx].tcp_flags_mask = tcpmask;
|
||||
}
|
||||
else if (unformat (i, "tcpflags %d mask %d", &tcpflags, &tcpmask))
|
||||
{
|
||||
vec_validate_acl_rules(rules, rule_idx);
|
||||
rules[rule_idx].tcp_flags_value = tcpflags;
|
||||
rules[rule_idx].tcp_flags_mask = tcpmask;
|
||||
}
|
||||
else if (unformat (i, "proto %d", &proto))
|
||||
{
|
||||
vec_validate_acl_rules(rules, rule_idx);
|
||||
@ -490,6 +501,9 @@ static int api_acl_add_replace (vat_main_t * vam)
|
||||
else
|
||||
n_rules = 0;
|
||||
|
||||
if (n_rules_override >= 0)
|
||||
n_rules = n_rules_override;
|
||||
|
||||
msg_size += n_rules*sizeof(rules[0]);
|
||||
|
||||
mp = vl_msg_api_alloc_as_if_client(msg_size);
|
||||
@ -847,6 +861,7 @@ static int api_macip_acl_add (vat_main_t * vam)
|
||||
vl_api_macip_acl_rule_t *rules = 0;
|
||||
int rule_idx = 0;
|
||||
int n_rules = 0;
|
||||
int n_rules_override = -1;
|
||||
u32 src_prefix_length = 0;
|
||||
u32 action = 0;
|
||||
ip4_address_t src_v4address;
|
||||
@ -877,6 +892,10 @@ static int api_macip_acl_add (vat_main_t * vam)
|
||||
vec_validate_macip_acl_rules(rules, rule_idx);
|
||||
rules[rule_idx].is_permit = 0;
|
||||
}
|
||||
else if (unformat (i, "count %d", &n_rules_override))
|
||||
{
|
||||
/* we will use this later */
|
||||
}
|
||||
else if (unformat (i, "action %d", &action))
|
||||
{
|
||||
vec_validate_macip_acl_rules(rules, rule_idx);
|
||||
@ -890,6 +909,10 @@ static int api_macip_acl_add (vat_main_t * vam)
|
||||
rules[rule_idx].src_ip_prefix_len = src_prefix_length;
|
||||
rules[rule_idx].is_ipv6 = 0;
|
||||
}
|
||||
else if (unformat (i, "src"))
|
||||
{
|
||||
/* Everything in MACIP is "source" but allow this verbosity */
|
||||
}
|
||||
else if (unformat (i, "ip %U/%d",
|
||||
unformat_ip6_address, &src_v6address, &src_prefix_length))
|
||||
{
|
||||
@ -931,6 +954,9 @@ static int api_macip_acl_add (vat_main_t * vam)
|
||||
else
|
||||
n_rules = 0;
|
||||
|
||||
if (n_rules_override >= 0)
|
||||
n_rules = n_rules_override;
|
||||
|
||||
msg_size += n_rules*sizeof(rules[0]);
|
||||
|
||||
mp = vl_msg_api_alloc_as_if_client(msg_size);
|
||||
|
348
plugins/acl-plugin/acl/manual_fns.h
Normal file
348
plugins/acl-plugin/acl/manual_fns.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -193,6 +193,56 @@ format_ip4_address (u8 * s, va_list * args)
|
||||
return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_ip6_address (u8 * s, va_list * args)
|
||||
{
|
||||
ip6_address_t *a = va_arg (*args, ip6_address_t *);
|
||||
u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
|
||||
|
||||
i_max_n_zero = ARRAY_LEN (a->as_u16);
|
||||
max_n_zeros = 0;
|
||||
i_first_zero = i_max_n_zero;
|
||||
n_zeros = 0;
|
||||
for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
|
||||
{
|
||||
u32 is_zero = a->as_u16[i] == 0;
|
||||
if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
|
||||
{
|
||||
i_first_zero = i;
|
||||
n_zeros = 0;
|
||||
}
|
||||
n_zeros += is_zero;
|
||||
if ((!is_zero && n_zeros > max_n_zeros)
|
||||
|| (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
|
||||
{
|
||||
i_max_n_zero = i_first_zero;
|
||||
max_n_zeros = n_zeros;
|
||||
i_first_zero = ARRAY_LEN (a->as_u16);
|
||||
n_zeros = 0;
|
||||
}
|
||||
}
|
||||
|
||||
last_double_colon = 0;
|
||||
for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
|
||||
{
|
||||
if (i == i_max_n_zero && max_n_zeros > 1)
|
||||
{
|
||||
s = format (s, "::");
|
||||
i += max_n_zeros - 1;
|
||||
last_double_colon = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = format (s, "%s%x",
|
||||
(last_double_colon || i == 0) ? "" : ":",
|
||||
clib_net_to_host_u16 (a->as_u16[i]));
|
||||
last_double_colon = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
u8 *
|
||||
format_ethernet_address (u8 * s, va_list * args)
|
||||
{
|
||||
|
Reference in New Issue
Block a user