/* Handle multi-buffer segments */
if (n_bytes_to_drop > b->current_length)
{
- if (!(b->flags & VLIB_BUFFER_NEXT_PRESENT))
+ if (!(b->flags & VLIB_BUFFER_NEXT_PRESENT) ||
+ (first + b->total_length_not_including_first_buffer <
+ n_bytes_to_drop))
return -1;
+ b->total_length_not_including_first_buffer -= n_bytes_to_drop - first;
do
{
discard = clib_min (n_bytes_to_drop, b->current_length);
vlib_buffer_advance (b, discard);
b = vlib_get_buffer (vm, b->next_buffer);
n_bytes_to_drop -= discard;
+ if (!b && n_bytes_to_drop)
+ return -1;
}
while (n_bytes_to_drop);
- if (n_bytes_to_drop > first)
- b->total_length_not_including_first_buffer -= n_bytes_to_drop - first;
}
else
vlib_buffer_advance (b, n_bytes_to_drop);