X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Fpunt_node.c;h=de72104605757f313c0bba33bdb2e590dc643a1f;hb=1adc7e78ad3eb7e800d0ce3ace56f53ab7aebffe;hp=c87d2b6fe36ec06de55080158af74966570e16c6;hpb=76b5649d074ab198cbf5737ac76d21649a61bffd;p=vpp.git diff --git a/src/vlib/punt_node.c b/src/vlib/punt_node.c index c87d2b6fe36..de721046057 100644 --- a/src/vlib/punt_node.c +++ b/src/vlib/punt_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Cisco and/or its affiliates. + * Copyright (c) 2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -19,7 +19,7 @@ _(DISPATCHED, "dispatched") \ _(NO_REASON, "No such punt reason") \ _(NO_REG, "No registrations") \ - _(REP_FAIL, "Replication Faliure") + _(REP_FAIL, "Replication Failure") typedef enum punt_error_t_ { @@ -75,7 +75,7 @@ punt_replicate (vlib_main_t * vm, u32 bi0, vlib_punt_reason_t pr0, u32 * next_index, - u32 * n_left_to_next, u32 ** to_next, u32 * pkts_rep_fail) + u32 * n_left_to_next, u32 ** to_next, u32 * n_dispatched) { /* multiple clients => replicate a copy to each */ u16 n_clones0, n_cloned0, clone0; @@ -91,7 +91,6 @@ punt_replicate (vlib_main_t * vm, if (PREDICT_FALSE (n_cloned0 != n_clones0)) { b0->error = node->errors[PUNT_ERROR_REP_FAIL]; - *pkts_rep_fail += 1; } for (clone0 = 1; clone0 < n_cloned0; clone0++) @@ -110,10 +109,6 @@ punt_replicate (vlib_main_t * vm, punt_trace_t *t; c0 = vlib_get_buffer (vm, ci0); - - if (c0 != b0) - vlib_buffer_copy_trace_flag (vm, b0, ci0); - t = vlib_add_trace (vm, node, c0, sizeof (*t)); t->pt_reason = pr0; } @@ -125,10 +120,16 @@ punt_replicate (vlib_main_t * vm, * so there's no need to check if the to_next frame * is full */ } + *n_dispatched = *n_dispatched + n_cloned0; /* The original buffer is the first clone */ next0 = punt_dp_db[pr0][0]; - *to_next[0] = bi0; + /* + * Note: the original buffer is enqueued in punt_dispatch_node. + * Don't do it here. + * + * *to_next[0] = bi0; + */ return next0; } @@ -139,7 +140,7 @@ punt_dispatch_one (vlib_main_t * vm, u32 thread_index, u32 bi0, u32 * next_index, - u32 * n_left_to_next, u32 ** to_next, u32 * pkts_errors) + u32 * n_left_to_next, u32 ** to_next, u32 * n_dispatched) { vlib_punt_reason_t pr0; vlib_buffer_t *b0; @@ -152,7 +153,6 @@ punt_dispatch_one (vlib_main_t * vm, { b0->error = node->errors[PUNT_ERROR_NO_REASON]; next0 = PUNT_NEXT_DROP; - pkts_errors[PUNT_ERROR_NO_REASON] += 1; } else { @@ -166,24 +166,22 @@ punt_dispatch_one (vlib_main_t * vm, * This is the most likely outcome. */ next0 = punt_dp_db[pr0][0]; - pkts_errors[PUNT_ERROR_DISPATCHED] += 1; + *n_dispatched = *n_dispatched + 1; } else if (0 == vec_len (punt_dp_db[pr0])) { /* no registered clients => drop */ next0 = PUNT_NEXT_DROP; - pkts_errors[PUNT_ERROR_NO_REG] += 1; + b0->error = node->errors[PUNT_ERROR_NO_REG]; } else { /* * multiple registered clients => replicate */ - pkts_errors[PUNT_ERROR_DISPATCHED] += 1; - next0 = punt_replicate (vm, node, thread_index, b0, bi0, pr0, next_index, n_left_to_next, to_next, - &pkts_errors[PUNT_ERROR_REP_FAIL]); + n_dispatched); } } @@ -204,13 +202,14 @@ VLIB_NODE_FN (punt_dispatch_node) (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index, thread_index; vlib_combined_counter_main_t *cm; - u32 pkt_errors[PUNT_N_ERRORS] = { 0 }; + u32 n_dispatched; cm = &punt_counters; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; next_index = node->cached_next_index; thread_index = vlib_get_thread_index (); + n_dispatched = 0; while (n_left_from > 0) { @@ -240,10 +239,10 @@ VLIB_NODE_FN (punt_dispatch_node) (vlib_main_t * vm, next0 = punt_dispatch_one (vm, node, cm, thread_index, bi0, &next_index, &n_left_to_next, - &to_next, pkt_errors); + &to_next, &n_dispatched); next1 = punt_dispatch_one (vm, node, cm, thread_index, bi1, &next_index, &n_left_to_next, - &to_next, pkt_errors); + &to_next, &n_dispatched); to_next += 2; n_left_to_next -= 2; @@ -263,7 +262,7 @@ VLIB_NODE_FN (punt_dispatch_node) (vlib_main_t * vm, next0 = punt_dispatch_one (vm, node, cm, thread_index, bi0, &next_index, &n_left_to_next, - &to_next, pkt_errors); + &to_next, &n_dispatched); to_next += 1; n_left_to_next -= 1; @@ -276,17 +275,7 @@ VLIB_NODE_FN (punt_dispatch_node) (vlib_main_t * vm, } vlib_node_increment_counter (vm, node->node_index, - PUNT_ERROR_DISPATCHED, - pkt_errors[PUNT_ERROR_DISPATCHED]); - vlib_node_increment_counter (vm, node->node_index, - PUNT_ERROR_NO_REASON, - pkt_errors[PUNT_ERROR_NO_REASON]); - vlib_node_increment_counter (vm, node->node_index, - PUNT_ERROR_NO_REG, - pkt_errors[PUNT_ERROR_NO_REG]); - vlib_node_increment_counter (vm, node->node_index, - PUNT_ERROR_REP_FAIL, - pkt_errors[PUNT_ERROR_REP_FAIL]); + PUNT_ERROR_DISPATCHED, n_dispatched); return frame->n_vectors; }