pi1 = pm->policer_index_by_sw_if_index[sw_if_index1];
act0 = vnet_policer_police (vm, b0, pi0, time_in_policer_periods,
- POLICE_CONFORM /* no chaining */, false);
+ POLICE_CONFORM /* no chaining */, true);
act1 = vnet_policer_police (vm, b1, pi1, time_in_policer_periods,
- POLICE_CONFORM /* no chaining */, false);
+ POLICE_CONFORM /* no chaining */, true);
- if (PREDICT_FALSE (act0 == QOS_ACTION_DROP)) /* drop action */
+ if (PREDICT_FALSE (act0 == QOS_ACTION_HANDOFF))
+ {
+ next0 = VNET_POLICER_NEXT_HANDOFF;
+ vnet_buffer (b0)->policer.index = pi0;
+ }
+ else if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
{
next0 = VNET_POLICER_NEXT_DROP;
b0->error = node->errors[VNET_POLICER_ERROR_DROP];
}
- else /* transmit or mark-and-transmit action */
+ else /* transmit or mark-and-transmit action */
{
transmitted++;
vnet_feature_next (&next0, b0);
}
- if (PREDICT_FALSE (act1 == QOS_ACTION_DROP)) /* drop action */
+ if (PREDICT_FALSE (act1 == QOS_ACTION_HANDOFF))
+ {
+ next1 = VNET_POLICER_NEXT_HANDOFF;
+ vnet_buffer (b1)->policer.index = pi1;
+ }
+ else if (PREDICT_FALSE (act1 == QOS_ACTION_DROP)) /* drop action */
{
next1 = VNET_POLICER_NEXT_DROP;
b1->error = node->errors[VNET_POLICER_ERROR_DROP];
}
- else /* transmit or mark-and-transmit action */
+ else /* transmit or mark-and-transmit action */
{
transmitted++;
vnet_feature_next (&next1, b1);
pi0 = pm->policer_index_by_sw_if_index[sw_if_index0];
act0 = vnet_policer_police (vm, b0, pi0, time_in_policer_periods,
- POLICE_CONFORM /* no chaining */, false);
+ POLICE_CONFORM /* no chaining */, true);
- if (PREDICT_FALSE (act0 == QOS_ACTION_DROP)) /* drop action */
+ if (PREDICT_FALSE (act0 == QOS_ACTION_HANDOFF))
+ {
+ next0 = VNET_POLICER_NEXT_HANDOFF;
+ vnet_buffer (b0)->policer.index = pi0;
+ }
+ else if (PREDICT_FALSE (act0 == QOS_ACTION_DROP))
{
next0 = VNET_POLICER_NEXT_DROP;
b0->error = node->errors[VNET_POLICER_ERROR_DROP];
}
- else /* transmit or mark-and-transmit action */
+ else /* transmit or mark-and-transmit action */
{
transmitted++;
vnet_feature_next (&next0, b0);
.n_next_nodes = VNET_POLICER_N_NEXT,
.next_nodes = {
[VNET_POLICER_NEXT_DROP] = "error-drop",
+ [VNET_POLICER_NEXT_HANDOFF] = "policer-input-handoff",
},
};
.runs_before = VNET_FEATURES ("ethernet-input"),
};
+static char *policer_input_handoff_error_strings[] = { "congestion drop" };
+
+VLIB_NODE_FN (policer_input_handoff_node)
+(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
+{
+ return policer_handoff (vm, node, frame, vnet_policer_main.fq_index, ~0);
+}
+
+VLIB_REGISTER_NODE (policer_input_handoff_node) = {
+ .name = "policer-input-handoff",
+ .vector_size = sizeof (u32),
+ .format_trace = format_policer_handoff_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(policer_input_handoff_error_strings),
+ .error_strings = policer_input_handoff_error_strings,
+
+ .n_next_nodes = 1,
+ .next_nodes = {
+ [0] = "error-drop",
+ },
+};
+
typedef struct
{
u32 sw_if_index;
vnet_policer_main_t *pm;
policer_t *policer;
u32 this_thread, policer_thread;
+ bool single_policer_node = (policer_index != ~0);
pm = &vnet_policer_main;
- policer = &pm->policers[policer_index];
- policer_thread = policer->thread_index;
+ if (single_policer_node)
+ {
+ policer = &pm->policers[policer_index];
+ policer_thread = policer->thread_index;
+ }
this_thread = vm->thread_index;
from = vlib_frame_vector_args (frame);
while (n_left_from > 0)
{
- ti[0] = policer_thread;
+ if (!single_policer_node)
+ {
+ policer_index = vnet_buffer (b[0])->policer.index;
+ policer = &pm->policers[policer_index];
+ ti[0] = policer->thread_index;
+ }
+ else
+ {
+ ti[0] = policer_thread;
+ }
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
b[0]->flags & VLIB_BUFFER_IS_TRACED))
policer_handoff_trace_t *t =
vlib_add_trace (vm, node, b[0], sizeof (*t));
t->current_worker_index = this_thread;
- t->next_worker_index = policer_thread;
+ t->next_worker_index = ti[0];
t->policer_index = policer_index;
}