npt66: add show command and rx/tx counters
Add show npt66 bindings. Add RX/TX and translation error counters. Type: improvement Change-Id: I4513b111f815a15d5a7537ce503f0c084b523aa1 Signed-off-by: Ole Troan <otroan@employees.org>
This commit is contained in:
committed by
Andrew Yourtchenko
parent
054aa8c2f2
commit
bdeee2194b
@@ -16,3 +16,25 @@ autoendian autoreply define npt66_binding_add_del
|
||||
vl_api_ip6_prefix_t internal;
|
||||
vl_api_ip6_prefix_t external;
|
||||
};
|
||||
|
||||
counters npt66 {
|
||||
rx {
|
||||
severity info;
|
||||
type counter64;
|
||||
units "packets";
|
||||
description "packets translated from external to internal";
|
||||
};
|
||||
tx {
|
||||
severity info;
|
||||
type counter64;
|
||||
units "packets";
|
||||
description "packets translated from internal to external";
|
||||
};
|
||||
translation {
|
||||
severity error;
|
||||
type counter64;
|
||||
units "packets";
|
||||
description "packet translation failed";
|
||||
};
|
||||
|
||||
};
|
||||
@@ -86,3 +86,36 @@ VLIB_CLI_COMMAND (set_npt66_binding_command, static) = {
|
||||
"external <pfx> [del]",
|
||||
.function = set_npt66_binding_command_fn,
|
||||
};
|
||||
|
||||
static u8 *
|
||||
format_npt66_binding (u8 *s, va_list *args)
|
||||
{
|
||||
u32 index = va_arg (*args, u32);
|
||||
npt66_binding_t *b = va_arg (*args, npt66_binding_t *);
|
||||
s = format (s, "[%d] internal: %U/%d external: %U/%d", index,
|
||||
format_ip6_address, &b->internal, b->internal_plen,
|
||||
format_ip6_address, &b->external, b->external_plen);
|
||||
return s;
|
||||
}
|
||||
|
||||
static clib_error_t *
|
||||
show_npt66_bindings_command_fn (vlib_main_t *vm, unformat_input_t *input,
|
||||
vlib_cli_command_t *cmd)
|
||||
{
|
||||
npt66_main_t *nm = &npt66_main;
|
||||
npt66_binding_t *b;
|
||||
clib_error_t *error = 0;
|
||||
|
||||
/* Get a line of input. */
|
||||
pool_foreach (b, nm->bindings)
|
||||
{
|
||||
vlib_cli_output (vm, "%U", format_npt66_binding, b - nm->bindings, b);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
VLIB_CLI_COMMAND (show_npt66_bindings_command, static) = {
|
||||
.path = "show npt66 bindings",
|
||||
.short_help = "show npt66 bindings",
|
||||
.function = show_npt66_bindings_command_fn,
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <vnet/ip/ip6_packet.h>
|
||||
|
||||
#include <npt66/npt66.h>
|
||||
#include <npt66/npt66.api_enum.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -197,11 +198,17 @@ npt66_node_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
|
||||
int rv = npt66_translate (ip, binding, dir);
|
||||
if (rv < 0)
|
||||
{
|
||||
clib_warning ("npt66_translate failed");
|
||||
vlib_node_increment_counter (vm, node->node_index,
|
||||
NPT66_ERROR_TRANSLATION, 1);
|
||||
*next = NPT66_NEXT_DROP;
|
||||
goto next;
|
||||
}
|
||||
else if (dir == VLIB_TX)
|
||||
vlib_node_increment_counter (vm, node->node_index, NPT66_ERROR_TX, 1);
|
||||
else
|
||||
vlib_node_increment_counter (vm, node->node_index, NPT66_ERROR_RX, 1);
|
||||
|
||||
/*next: */
|
||||
next:
|
||||
next += 1;
|
||||
n_left_from -= 1;
|
||||
b += 1;
|
||||
@@ -260,8 +267,8 @@ VLIB_REGISTER_NODE(npt66_input_node) = {
|
||||
.vector_size = sizeof(u32),
|
||||
.format_trace = format_npt66_trace,
|
||||
.type = VLIB_NODE_TYPE_INTERNAL,
|
||||
// .n_errors = NPT66_N_ERROR,
|
||||
// .error_counters = npt66_error_counters,
|
||||
.n_errors = NPT66_N_ERROR,
|
||||
.error_counters = npt66_error_counters,
|
||||
.n_next_nodes = NPT66_N_NEXT,
|
||||
.next_nodes =
|
||||
{
|
||||
@@ -274,8 +281,8 @@ VLIB_REGISTER_NODE (npt66_output_node) = {
|
||||
.vector_size = sizeof (u32),
|
||||
.format_trace = format_npt66_trace,
|
||||
.type = VLIB_NODE_TYPE_INTERNAL,
|
||||
// .n_errors = npt66_N_ERROR,
|
||||
// .error_counters = npt66_error_counters,
|
||||
.n_errors = NPT66_N_ERROR,
|
||||
.error_counters = npt66_error_counters,
|
||||
.sibling_of = "npt66-input",
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user