28 #define foreach_ip6_hop_by_hop_ioam_pot_stats \ 29 _(PROCESSED, "Pkts with ip6 hop-by-hop pot options") \ 30 _(PROFILE_MISS, "Pkts with ip6 hop-by-hop pot options but no profile set") \ 31 _(PASSED, "Pkts with POT in Policy") \ 32 _(FAILED, "Pkts with POT out of Policy") 35 #define _(sym,string) string, 41 #define _(sym,str) IP6_IOAM_POT_##sym, 69 ioam_pot_option_t * pot0 = va_arg (*args, ioam_pot_option_t *);
70 u64 random, cumulative;
71 random = cumulative = 0;
74 random = clib_net_to_host_u64 (pot0->random);
75 cumulative = clib_net_to_host_u64 (pot0->cumulative);
78 s =
format (s,
"random = 0x%Lx, Cumulative = 0x%Lx, Index = 0x%x",
79 random, cumulative, pot0 ? pot0->reserved_profile_id : ~0);
86 ioam_pot_option_t *pot;
88 s =
format (s,
" POT opt present\n");
89 pot = (ioam_pot_option_t *) opt;
99 ioam_pot_option_t * pot0;
100 u64 random = 0, cumulative = 0;
102 u8 pot_profile_index;
106 pot0 = (ioam_pot_option_t *) opt0;
107 pot_encap = (pot0->random == 0);
117 pot0->reserved_profile_id =
124 pot_profile_index || pot_profile == 0))
130 new_profile->valid == 0))
137 pot_profile_index = pot0->reserved_profile_id;
138 pot_profile = new_profile;
146 if (pot0->random == 0)
149 pot0->cumulative = 0;
151 random = clib_net_to_host_u64(pot0->random);
152 cumulative = clib_net_to_host_u64(pot0->cumulative);
153 pot0->cumulative = clib_host_to_net_u64(
166 ioam_pot_option_t * pot0;
173 pot0 = (ioam_pot_option_t *) opt0;
174 random = clib_net_to_host_u64(pot0->random);
175 cumulative = clib_net_to_host_u64(pot0->cumulative);
193 ioam_pot_option_t * pot_option;
194 if (rewrite_string && *rewrite_size ==
sizeof(ioam_pot_option_t))
196 pot_option = (ioam_pot_option_t *)rewrite_string;
199 pot_option->hdr.length =
sizeof (ioam_pot_option_t) -
228 .path =
"show ioam pot",
229 .short_help =
"iOAM pot statistics",
249 return (
clib_error_create(
"registration of HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT failed"));
252 sizeof(ioam_pot_option_t),
254 return (
clib_error_create(
"registration of HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT for rewrite failed"));
258 return (
clib_error_create(
"registration of HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT POP failed"));
static pot_profile * pot_profile_get_active(void)
static u8 pot_profile_get_active_id(void)
static void ip6_ioam_stats_increment_counter(u32 counter_index, u64 increment)
pot_profile * pot_profile_find(u8 id)
vnet_main_t * vnet_get_main(void)
static clib_error_t * ip6_hop_by_hop_ioam_pot_init(vlib_main_t *vm)
int ip6_hbh_register_option(u8 option, int options(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt), u8 *trace(u8 *s, ip6_hop_by_hop_option_t *opt))
int ip6_hbh_ioam_proof_of_transit_handler(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt0)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define foreach_ip6_hop_by_hop_ioam_pot_stats
static int pot_profile_set_active(u8 id)
#define HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT
#define VLIB_INIT_FUNCTION(x)
int ip6_hbh_pop_register_option(u8 option, int options(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt))
int ip6_hbh_ioam_proof_of_transit_pop_handler(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt0)
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
#define clib_error_create(args...)
#define vlib_call_init_function(vm, x)
static char * ip6_hop_by_hop_ioam_pot_stats_strings[]
ip6_hop_by_hop_ioam_pot_main_t ip6_hop_by_hop_ioam_pot_main
u8 pot_validate(pot_profile *profile, u64 cumulative, u64 random)
u8 * ip6_hbh_ioam_proof_of_transit_trace_handler(u8 *s, ip6_hop_by_hop_option_t *opt)
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
static u8 * format_ioam_pot(u8 *s, va_list *args)
static void pot_profile_reset_usage_stats(pot_profile *pow)
#define vec_free(V)
Free vector's memory (no header).
u64 pot_generate_random(pot_profile *profile)
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * ip6_show_ioam_pot_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void pot_profile_incr_usage_stats(pot_profile *pow)
static clib_error_t * ip6_hop_by_hop_ioam_init(vlib_main_t *vm)
u64 pot_update_cumulative(pot_profile *profile, u64 cumulative, u64 random)
#define HBH_OPTION_TYPE_DATA_CHANGE_ENROUTE
int ip6_hop_by_hop_ioam_pot_rewrite_handler(u8 *rewrite_string, u8 *rewrite_size)
int ip6_hbh_add_register_option(u8 option, u8 size, int rewrite_options(u8 *rewrite_string, u8 *rewrite_size))
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u64 counters[ARRAY_LEN(ip6_hop_by_hop_ioam_pot_stats_strings)]