#include <vnet/devices/af_packet/af_packet.h>
-#define foreach_af_packet_input_error
+#define foreach_af_packet_input_error \
+ _(PARTIAL_PKT, "partial packet")
typedef enum
{
{
ip4_header_t *ip4 =
(vlib_buffer_get_current (b) + sizeof (ethernet_header_t));
- b->flags |= VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
- ip4->checksum = 0;
+ b->flags |= VNET_BUFFER_F_IS_IP4;
if (ip4->protocol == IP_PROTOCOL_TCP)
{
b->flags |= VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
u32 frame_num = apif->rx_req->tp_frame_nr;
u8 *block_start = apif->rx_ring + block * block_size;
uword n_trace = vlib_get_trace_count (vm, node);
- u32 thread_index = vlib_get_thread_index ();
+ u32 thread_index = vm->thread_index;
u32 n_buffer_bytes = vlib_buffer_free_list_buffer_size (vm,
VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
u32 min_bufs = apif->rx_req->tp_frame_size / n_buffer_bytes;
to_next += 1;
n_left_to_next--;
+ /* drop partial packets */
+ if (PREDICT_FALSE (tph->tp_len != tph->tp_snaplen))
+ {
+ next0 = VNET_DEVICE_INPUT_NEXT_DROP;
+ first_b0->error =
+ node->errors[AF_PACKET_INPUT_ERROR_PARTIAL_PKT];
+ }
+ else
+ {
+ next0 = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
+ /* redirect if feature path enabled */
+ vnet_feature_start_device_input_x1 (apif->sw_if_index, &next0,
+ first_b0);
+ }
+
/* trace */
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (first_b0);
if (PREDICT_FALSE (n_trace > 0))
clib_memcpy (&tr->tph, tph, sizeof (struct tpacket2_hdr));
}
- /* redirect if feature path enabled */
- vnet_feature_start_device_input_x1 (apif->sw_if_index, &next0, b0);
-
/* enque and take next packet */
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, first_bi0, next0);