#include <vlib/vlib.h>
#include <vnet/vnet.h>
-#include <vnet/pg/pg.h>
#include <vnet/ethernet/ethernet.h>
#include <vlib/cli.h>
#include <vnet/l2/l2_input.h>
return s;
}
-l2flood_main_t l2flood_main;
+extern l2flood_main_t l2flood_main;
-static vlib_node_registration_t l2flood_node;
+#ifndef CLIB_MARCH_VARIANT
+l2flood_main_t l2flood_main;
+#endif /* CLIB_MARCH_VARIANT */
#define foreach_l2flood_error \
_(L2FLOOD, "L2 flood packets") \
* could be turned into an ICMP reply. If BVI processing is not performed
* last, the modified packet would be replicated to the remaining members.
*/
-static uword
-l2flood_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
l2flood_next_t next_index;
else if (n_clones > 1)
{
vec_validate (msm->clones[thread_index], n_clones);
- vec_reset_length (msm->clones[thread_index]);
/*
* the header offset needs to be large enough to incorporate
n_clones,
VLIB_BUFFER_CLONE_HEAD_SIZE);
+ vec_set_len (msm->clones[thread_index], n_cloned);
+
if (PREDICT_FALSE (n_cloned != n_clones))
{
b0->error = node->errors[L2FLOOD_ERROR_REPL_FAIL];
+ /* Worst-case, no clones, consume the original buf */
+ if (n_cloned == 0)
+ {
+ ci0 = bi0;
+ member = msm->members[thread_index][0];
+ goto use_original_buffer;
+ }
}
/*
ethernet_header_t *h0;
l2flood_trace_t *t;
- if (c0 != b0)
- vlib_buffer_copy_trace_flag (vm, b0, ci0);
-
t = vlib_add_trace (vm, node, c0, sizeof (*t));
h0 = vlib_buffer_get_current (c0);
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (c0)->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
/* Do normal L2 forwarding */
member = msm->members[thread_index][0];
}
+ use_original_buffer:
/*
* the last clone that might go to a BVI
*/
ethernet_header_t *h0;
l2flood_trace_t *t;
- if (c0 != b0)
- vlib_buffer_copy_trace_flag (vm, b0, ci0);
-
t = vlib_add_trace (vm, node, c0, sizeof (*t));
h0 = vlib_buffer_get_current (c0);
t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (c0)->l2.bd_index;
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
+ clib_memcpy_fast (t->src, h0->src_address, 6);
+ clib_memcpy_fast (t->dst, h0->dst_address, 6);
}
-
-
/* Forward packet to the current member */
if (PREDICT_FALSE (member->flags & L2_FLOOD_MEMBER_BVI))
{
/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (l2flood_node,static) = {
- .function = l2flood_node_fn,
+VLIB_REGISTER_NODE (l2flood_node) = {
.name = "l2-flood",
.vector_size = sizeof (u32),
.format_trace = format_l2flood_trace,
[L2FLOOD_NEXT_DROP] = "error-drop",
},
};
-
-VLIB_NODE_FUNCTION_MULTIARCH (l2flood_node, l2flood_node_fn)
/* *INDENT-ON* */
+#ifndef CLIB_MARCH_VARIANT
clib_error_t *
l2flood_init (vlib_main_t * vm)
{
next_by_ethertype_register (&mp->l3_next, type, next_index);
}
+#endif /* CLIB_MARCH_VARIANT */
/**