#include <vnet/ip/ip.h>
+/*
+ * Copy the mpls header if present.
+ * The current is pointing to the ip header.
+ * Adjust the buffer and point to the mpls headers on these fragments
+ * before sending the packet back to mpls-output node.
+ */
+static inline void
+copy_mpls_hdr (vlib_buffer_t * to_b, vlib_buffer_t * from_b)
+{
+ if ((vnet_buffer (from_b)->ip_frag.flags) & IP_FRAG_FLAG_MPLS_HEADER)
+ {
+ u8 mpls_hdr_length = vnet_buffer (from_b)->mpls.mpls_hdr_length;
+ u8 *org_from_mpls_packet =
+ from_b->data + (from_b->current_data - mpls_hdr_length);
+ clib_memcpy_fast ((to_b->data - mpls_hdr_length), org_from_mpls_packet,
+ mpls_hdr_length);
+ vlib_buffer_advance (to_b, -vnet_buffer (to_b)->mpls.mpls_hdr_length);
+ }
+}
typedef struct
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
ip_frag_trace_t *t = va_arg (*args, ip_frag_trace_t *);
- s = format (s, "IPv%s mtu: %u fragments: %u",
- t->ipv6 ? "6" : "4", t->mtu, t->n_fragments);
+ s = format (s, "IPv%s mtu: %u fragments: %u next: %d",
+ t->ipv6 ? "6" : "4", t->mtu, t->n_fragments, t->next);
return s;
}
vnet_buffer2 (to)->qos = vnet_buffer2 (from)->qos;
to->flags |= VNET_BUFFER_F_QOS_DATA_VALID;
}
+
+ /* Copy mpls opaque data */
+ if ((vnet_buffer (from)->ip_frag.flags) & IP_FRAG_FLAG_MPLS_HEADER)
+ {
+ vnet_buffer (to)->mpls.pyld_proto = vnet_buffer (from)->mpls.pyld_proto;
+ vnet_buffer (to)->mpls.mpls_hdr_length =
+ vnet_buffer (from)->mpls.mpls_hdr_length;
+ }
}
static vlib_buffer_t *
rem = clib_net_to_host_u16 (ip4->length) - sizeof (ip4_header_t);
max =
- (clib_min (mtu, vlib_bufer_get_default_size (vm)) -
+ (clib_min (mtu, vlib_buffer_get_default_data_size (vm)) -
sizeof (ip4_header_t)) & ~0x7;
if (rem >
clib_memcpy_fast (to_b->data, org_from_packet, sizeof (ip4_header_t));
to_ip4 = vlib_buffer_get_current (to_b);
to_data = (void *) (to_ip4 + 1);
+ vnet_buffer (to_b)->l3_hdr_offset = to_b->current_data;
+ to_b->flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
+
+ if (from_b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID)
+ {
+ vnet_buffer (to_b)->l4_hdr_offset =
+ (vnet_buffer (to_b)->l3_hdr_offset +
+ (vnet_buffer (from_b)->l4_hdr_offset -
+ vnet_buffer (from_b)->l3_hdr_offset));
+ to_b->flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
+ }
/* Spin through from buffers filling up the to buffer */
u16 left_in_to_buffer = len, to_ptr = 0;
}
to_b->current_length = len + sizeof (ip4_header_t);
+ to_b->flags |= VNET_BUFFER_F_IS_IP4;
to_ip4->fragment_id = ip_frag_id;
to_ip4->flags_and_fragment_offset =
to_ip4->length = clib_host_to_net_u16 (len + sizeof (ip4_header_t));
to_ip4->checksum = ip4_header_checksum (to_ip4);
+ /* we've just done the IP checksum .. */
+ to_b->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
+
if (vnet_buffer (org_from_b)->ip_frag.flags & IP_FRAG_FLAG_IP4_HEADER)
{
/* Encapsulating ipv4 header */
clib_host_to_net_u16 (to_b->current_length -
sizeof (*encap_header6));
}
+
+ /* Copy mpls header if present */
+ copy_mpls_hdr (to_b, org_from_b);
+
rem -= len;
fo += len;
}
to_frag_hdr = (ip6_frag_hdr_t *) (to_ip6 + 1);
to_data = (void *) (to_frag_hdr + 1);
+ vnet_buffer (to_b)->l3_hdr_offset = to_b->current_data;
+ to_b->flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
+
+ if (from_b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID)
+ {
+ vnet_buffer (to_b)->l4_hdr_offset =
+ (vnet_buffer (to_b)->l3_hdr_offset +
+ (vnet_buffer (from_b)->l4_hdr_offset -
+ vnet_buffer (from_b)->l3_hdr_offset));
+ to_b->flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
+ }
+ to_b->flags |= VNET_BUFFER_F_IS_IP6;
+
/* Spin through from buffers filling up the to buffer */
u16 left_in_to_buffer = len, to_ptr = 0;
while (1)
to_frag_hdr->next_hdr = ip6->protocol;
to_frag_hdr->rsv = 0;
+ /* Copy mpls header if present */
+ copy_mpls_hdr (to_b, org_from_b);
+
rem -= len;
fo += len;
}
.n_next_nodes = IP4_FRAG_N_NEXT,
.next_nodes = {
[IP4_FRAG_NEXT_IP4_REWRITE] = "ip4-rewrite",
+ [IP4_FRAG_NEXT_IP4_REWRITE_MIDCHAIN] = "ip4-midchain",
[IP4_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup",
[IP4_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup",
+ [IP4_FRAG_NEXT_MPLS_OUTPUT] = "mpls-output",
[IP4_FRAG_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[IP4_FRAG_NEXT_DROP] = "ip4-drop"
},
.n_next_nodes = IP6_FRAG_N_NEXT,
.next_nodes = {
[IP6_FRAG_NEXT_IP6_REWRITE] = "ip6-rewrite",
+ [IP6_FRAG_NEXT_IP6_REWRITE_MIDCHAIN] = "ip6-midchain",
[IP6_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup",
[IP6_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup",
+ [IP6_FRAG_NEXT_MPLS_OUTPUT] = "mpls-output",
[IP6_FRAG_NEXT_DROP] = "ip6-drop"
},
};