37 u8 mpls_hdr_length =
vnet_buffer (from_b)->mpls.mpls_hdr_length;
38 u8 *org_from_mpls_packet =
60 s =
format (s,
"IPv%s mtu: %u fragments: %u next: %d",
88 to->
flags |= VNET_BUFFER_F_QOS_DATA_VALID;
126 u16 mtu,
len, max, rem, ip_frag_id, ip_frag_offset;
127 u8 *org_from_packet, more;
142 *error = IP_FRAG_ERROR_MALFORMED;
148 *error = IP_FRAG_ERROR_CANT_FRAGMENT_HEADER;
155 *error = IP_FRAG_ERROR_DONT_FRAGMENT_SET;
174 u8 *from_data = (
void *) (ip4 + 1);
188 len = (rem > max ? max : rem);
193 *error = IP_FRAG_ERROR_MEMORY;
202 to_data = (
void *) (to_ip4 + 1);
205 u16 left_in_to_buffer =
len, to_ptr = 0;
211 bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ?
212 left_in_to_buffer : left_in_from_buffer;
214 left_in_to_buffer -= bytes_to_copy;
215 ptr += bytes_to_copy;
216 left_in_from_buffer -= bytes_to_copy;
217 if (left_in_to_buffer == 0)
220 ASSERT (left_in_from_buffer <= 0);
222 if (!(from_b->
flags & VLIB_BUFFER_NEXT_PRESENT))
224 *error = IP_FRAG_ERROR_MALFORMED;
231 to_ptr += bytes_to_copy;
238 clib_host_to_net_u16 ((fo >> 3) + ip_frag_offset);
240 clib_host_to_net_u16 (((len != rem) || more) << 13);
260 sizeof (*encap_header6));
284 u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
289 u32 frag_sent = 0, small_packets = 0;
292 while (n_left_from > 0)
296 while (n_left_from > 0 && n_left_to_next > 0)
298 u32 pi0, *frag_from, frag_left;
310 error0 = IP_FRAG_ERROR_NONE;
323 tr->
ipv6 = is_ip6 ? 1 : 0;
328 if (!is_ip6 && error0 == IP_FRAG_ERROR_DONT_FRAGMENT_SET)
331 ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set,
349 if (error0 == IP_FRAG_ERROR_NONE)
353 small_packets += (
vec_len (buffer) == 1);
366 while (frag_left > 0)
368 while (frag_left > 0 && n_left_to_next > 0)
371 i = to_next[0] = frag_from[0];
379 to_next, n_left_to_next, i,
393 IP_FRAG_ERROR_FRAGMENT_SENT, frag_sent);
395 IP_FRAG_ERROR_SMALL_PACKET, small_packets);
426 u16 mtu,
len, max, rem, ip_frag_id;
433 max = (mtu -
sizeof (
ip6_header_t) -
sizeof (ip6_frag_hdr_t)) & ~0x7;
438 *error = IP_FRAG_ERROR_MALFORMED;
443 if (ip6->
protocol == IP_PROTOCOL_IPV6_FRAGMENTATION)
445 *error = IP_FRAG_ERROR_MALFORMED;
449 u8 *from_data = (
void *) (ip6 + 1);
463 ip6_frag_hdr_t *to_frag_hdr;
468 (mtu -
sizeof (
ip6_header_t) -
sizeof (ip6_frag_hdr_t)) ? max : rem);
473 *error = IP_FRAG_ERROR_MEMORY;
482 to_frag_hdr = (ip6_frag_hdr_t *) (to_ip6 + 1);
483 to_data = (
void *) (to_frag_hdr + 1);
486 u16 left_in_to_buffer =
len, to_ptr = 0;
492 bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ?
493 left_in_to_buffer : left_in_from_buffer;
495 left_in_to_buffer -= bytes_to_copy;
496 ptr += bytes_to_copy;
497 left_in_from_buffer -= bytes_to_copy;
498 if (left_in_to_buffer == 0)
501 ASSERT (left_in_from_buffer <= 0);
503 if (!(from_b->
flags & VLIB_BUFFER_NEXT_PRESENT))
505 *error = IP_FRAG_ERROR_MALFORMED;
512 to_ptr += bytes_to_copy;
518 clib_host_to_net_u16 (len +
sizeof (ip6_frag_hdr_t));
519 to_ip6->
protocol = IP_PROTOCOL_IPV6_FRAGMENTATION;
520 to_frag_hdr->fragment_offset_and_more =
522 to_frag_hdr->identification = ip_frag_id;
523 to_frag_hdr->next_hdr = ip6->
protocol;
524 to_frag_hdr->rsv = 0;
535 #define _(sym,string) string, 544 .vector_size =
sizeof (
u32),
567 .vector_size =
sizeof (
u32),
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static uword frag_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 node_index, bool is_ip6)
#define foreach_ip_frag_error
void ip_frag_set_vnet_buffer(vlib_buffer_t *b, u16 mtu, u8 next_index, u8 flags)
#define IP6_FRAG_NODE_NAME
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
#define clib_memcpy_fast(a, b, c)
#define IP_FRAG_FLAG_MPLS_HEADER
u16 current_length
Nbytes between current data and the end of this buffer.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void frag_set_sw_if_index(vlib_buffer_t *to, vlib_buffer_t *from)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static u8 * format_ip_frag_trace(u8 *s, va_list *args)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static int ip4_is_fragment(const ip4_header_t *i)
static u32 running_fragment_id
void ip4_frag_do_fragment(vlib_main_t *vm, u32 from_bi, u32 **buffer, ip_frag_error_t *error)
static uword ip4_frag(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void ip6_frag_do_fragment(vlib_main_t *vm, u32 from_bi, u32 **buffer, ip_frag_error_t *error)
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define IP4_FRAG_NODE_NAME
static int ip4_get_fragment_offset(const ip4_header_t *i)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vlib_node_registration_t ip6_frag_node
(constructor) VLIB_REGISTER_NODE (ip6_frag_node)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
#define VLIB_REGISTER_NODE(x,...)
static void vlib_buffer_copy_trace_flag(vlib_main_t *vm, vlib_buffer_t *b, u32 bi_target)
#define vec_free(V)
Free vector's memory (no header).
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
#define IP_FRAG_FLAG_IP6_HEADER
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define IP_FRAG_FLAG_IP4_HEADER
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static vlib_main_t * vlib_get_main(void)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
vlib_node_registration_t ip4_frag_node
(constructor) VLIB_REGISTER_NODE (ip4_frag_node)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 next_buffer
Next buffer for this linked-list of buffers.
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
VLIB buffer representation.
static char * ip4_frag_error_strings[]
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static uword ip6_frag(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static void copy_mpls_hdr(vlib_buffer_t *to_b, vlib_buffer_t *from_b)
#define ip6_frag_hdr_offset_and_more(offset, more)
static void vlib_buffer_free_one(vlib_main_t *vm, u32 buffer_index)
Free one buffer Shorthand to free a single buffer chain.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static vlib_buffer_t * frag_buffer_alloc(vlib_buffer_t *org_b, u32 *bi)