33 #define PROFILE_ID_MASK 0xF 34 u8 reserved_profile_id;
39 #define foreach_ip6_hop_by_hop_ioam_pot_stats \ 40 _(PROCESSED, "Pkts with ip6 hop-by-hop pot options") \ 41 _(PROFILE_MISS, "Pkts with ip6 hop-by-hop pot options but no profile set") \ 42 _(PASSED, "Pkts with POT in Policy") \ 43 _(FAILED, "Pkts with POT out of Policy") 45 static char * ip6_hop_by_hop_ioam_pot_stats_strings[] = {
46 #define _(sym,string) string, 52 #define _(sym,str) IP6_IOAM_POT_##sym, 80 ioam_pot_option_t * pot0 = va_arg (*args, ioam_pot_option_t *);
81 u64 random, cumulative;
82 random = cumulative = 0;
85 random = clib_net_to_host_u64 (pot0->random);
86 cumulative = clib_net_to_host_u64 (pot0->cumulative);
89 s =
format (s,
"random = 0x%Lx, Cumulative = 0x%Lx, Index = 0x%x",
90 random, cumulative, pot0 ? pot0->reserved_profile_id : ~0);
97 ioam_pot_option_t *pot;
99 s =
format (s,
" POT opt present\n");
100 pot = (ioam_pot_option_t *) opt;
110 ioam_pot_option_t * pot0;
111 u64 random = 0, cumulative = 0;
113 u8 pot_profile_index;
117 pot0 = (ioam_pot_option_t *) opt0;
118 pot_encap = (pot0->random == 0);
128 pot0->reserved_profile_id =
135 pot_profile_index || pot_profile == 0))
141 new_profile->valid == 0))
148 pot_profile_index = pot0->reserved_profile_id;
149 pot_profile = new_profile;
157 if (pot0->random == 0)
160 pot0->cumulative = 0;
162 random = clib_net_to_host_u64(pot0->random);
163 cumulative = clib_net_to_host_u64(pot0->cumulative);
164 pot0->cumulative = clib_host_to_net_u64(
177 ioam_pot_option_t * pot0;
184 pot0 = (ioam_pot_option_t *) opt0;
185 random = clib_net_to_host_u64(pot0->random);
186 cumulative = clib_net_to_host_u64(pot0->cumulative);
204 ioam_pot_option_t * pot_option;
205 if (rewrite_string && *rewrite_size ==
sizeof(ioam_pot_option_t))
207 pot_option = (ioam_pot_option_t *)rewrite_string;
210 pot_option->hdr.length =
sizeof (ioam_pot_option_t) -
228 s =
format(s,
" %s - %lu\n", ip6_hop_by_hop_ioam_pot_stats_strings[i],
239 .path =
"show ioam pot",
240 .short_help =
"iOAM pot statistics",
260 return (
clib_error_create(
"registration of HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT failed"));
263 sizeof(ioam_pot_option_t),
265 return (
clib_error_create(
"registration of HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT for rewrite failed"));
269 return (
clib_error_create(
"registration of HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT POP failed"));
static pot_profile * pot_profile_get_active(void)
sll srl srl sll sra u16x4 i
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)
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)
#define foreach_ip6_hop_by_hop_ioam_pot_stats
static int pot_profile_set_active(u8 id)
vnet_main_t * vnet_get_main(void)
#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 vlib_call_init_function(vm, x)
typedef CLIB_PACKED(struct{ip6_hop_by_hop_option_t hdr;u8 pot_type;#define PROFILE_ID_MASK u8 reserved_profile_id;u64 random;u64 cumulative;})
ip6_hop_by_hop_ioam_pot_main_t ip6_hop_by_hop_ioam_pot_main
#define clib_error_create(args...)
u8 pot_validate(pot_profile *profile, u64 cumulative, u64 random)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u8 * ip6_hbh_ioam_proof_of_transit_trace_handler(u8 *s, ip6_hop_by_hop_option_t *opt)
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))
u64 counters[ARRAY_LEN(ip6_hop_by_hop_ioam_pot_stats_strings)]