X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fioam%2Fencap%2Fip6_ioam_trace.c;h=148d566e65e4c51665c023daa21eea48656bf8d5;hb=8c8acc0;hp=e31825614c26aeaab298ab3030fc039170e6c474;hpb=1b563527c143903b6e7e79b5978af5310372f605;p=vpp.git diff --git a/src/plugins/ioam/encap/ip6_ioam_trace.c b/src/plugins/ioam/encap/ip6_ioam_trace.c index e31825614c2..148d566e65e 100644 --- a/src/plugins/ioam/encap/ip6_ioam_trace.c +++ b/src/plugins/ioam/encap/ip6_ioam_trace.c @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include #include @@ -209,7 +211,7 @@ always_inline void ip6_hbh_ioam_loopback_handler (vlib_buffer_t * b, ip6_header_t * ip, ioam_trace_option_t * trace) { - u32 buffers; + u32 buf_index; ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; vlib_buffer_t *b0; vlib_frame_t *nf = 0; @@ -218,7 +220,6 @@ ip6_hbh_ioam_loopback_handler (vlib_buffer_t * b, ip6_header_t * ip, ip6_header_t *ip6; ip6_hop_by_hop_header_t *hbh; ioam_trace_option_t *opt; - u16 ip6_len; udp_ping_t *udp; next_node = vlib_get_node_by_name (hm->vlib_main, (u8 *) "ip6-lookup"); @@ -226,36 +227,22 @@ ip6_hbh_ioam_loopback_handler (vlib_buffer_t * b, ip6_header_t * ip, nf->n_vectors = 0; to_next = vlib_frame_vector_args (nf); - if (vlib_buffer_alloc (hm->vlib_main, &buffers, 1) != 1) - return; - - b0 = vlib_get_buffer (hm->vlib_main, buffers); - ip6_len = clib_net_to_host_u16 (ip->payload_length); - clib_memcpy (b0->data, ip, (ip6_len + sizeof (ip6_header_t))); - b0->current_data = 0; - b0->current_length = ip6_len + sizeof (ip6_header_t); - b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID; + b0 = vlib_buffer_copy (hm->vlib_main, b); + buf_index = vlib_get_buffer_index (hm->vlib_main, b0); vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0; - /* Change destination address */ ip6 = vlib_buffer_get_current (b0); - //ip6->src_address = ip->dst_address; - //ip6->dst_address = ip->src_address; - hbh = (ip6_hop_by_hop_header_t *) (ip6 + 1); opt = (ioam_trace_option_t *) ip6_hbh_get_option (hbh, HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST); udp = (udp_ping_t *) ((u8 *) hbh + ((hbh->length + 1) << 3)); udp_ping_create_reply_from_probe_ip6 (ip6, hbh, udp); - //ip6_hbh_ioam_trace_reset_bit (opt, BIT_LOOPBACK); ip6_hbh_ioam_trace_set_bit (opt, BIT_LOOPBACK_REPLY); - /* No need to trace loopback packet */ - //opt->trace_hdr.data_list_elts_left = 0; - *to_next = buffers; + *to_next = buf_index; nf->n_vectors++; to_next++; @@ -267,13 +254,11 @@ int ip6_hbh_ioam_trace_data_list_handler (vlib_buffer_t * b, ip6_header_t * ip, ip6_hop_by_hop_option_t * opt) { - ip6_main_t *im = &ip6_main; - ip_lookup_main_t *lm = &im->lookup_main; ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; u8 elt_index = 0; ioam_trace_option_t *trace = (ioam_trace_option_t *) opt; u32 adj_index = vnet_buffer (b)->ip.adj_index[VLIB_TX]; - ip_adjacency_t *adj = ip_get_adjacency (lm, adj_index); + ip_adjacency_t *adj = adj_get (adj_index); time_u64_t time_u64; u32 *elt; int rv = 0; @@ -424,6 +409,7 @@ VLIB_CLI_COMMAND (ip6_show_ioam_trace_cmd, static) = { /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, + .description = "Inbound OAM", }; /* *INDENT-ON* */ @@ -444,7 +430,7 @@ ip6_hop_by_hop_ioam_trace_init (vlib_main_t * vm) hm->vlib_main = vm; hm->vnet_main = vnet_get_main (); - memset (hm->counters, 0, sizeof (hm->counters)); + clib_memset (hm->counters, 0, sizeof (hm->counters)); if (ip6_hbh_register_option