summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2020-04-23 17:59:49 +0200
committerNeale Ranns <nranns@cisco.com>2020-05-05 07:44:12 +0000
commit84f91fa9c54f82c54b58ea3bf6e9ba22ff735d3a (patch)
tree63a762ea0e66b1a0074378f25984eb6450ac9ceb
parent5ec6a4ea4440211e468a813ffe0f3173421c9b29 (diff)
gso: add support for IP-IP
Type: feature Change-Id: I37752af8496e0042a1da91124f3d94216b39ff11 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
-rw-r--r--src/vnet/devices/virtio/device.c22
-rw-r--r--src/vnet/devices/virtio/vhost_user_output.c10
-rw-r--r--src/vnet/gso/FEATURE.yaml4
-rw-r--r--src/vnet/gso/gso.c24
-rw-r--r--src/vnet/gso/hdr_offset_parser.h132
-rw-r--r--src/vnet/gso/node.c209
-rw-r--r--src/vnet/interface_output.h3
-rw-r--r--test/test_gso.py205
8 files changed, 465 insertions, 144 deletions
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index d110946dede..9a35bb8162f 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -168,13 +168,15 @@ virtio_free_used_device_desc (vlib_main_t * vm, virtio_vring_t * vring,
}
static_always_inline void
-set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
+set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr,
+ int is_l2)
{
if (b->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 1 /* ip4 */ ,
+ 0 /* ip6 */ );
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset; // 0x22;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
@@ -198,7 +200,8 @@ set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
else if (b->flags & VNET_BUFFER_F_IS_IP6)
{
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 0 /* ip4 */ ,
+ 1 /* ip6 */ );
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset; // 0x36;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
@@ -213,13 +216,14 @@ set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
}
static_always_inline void
-set_gso_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
+set_gso_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr, int is_l2)
{
if (b->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 1 /* ip4 */ ,
+ 0 /* ip6 */ );
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->hdr_len = gho.hdr_sz;
@@ -238,7 +242,8 @@ set_gso_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
else if (b->flags & VNET_BUFFER_F_IS_IP6)
{
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 0 /* ip4 */ ,
+ 1 /* ip6 */ );
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->hdr_len = gho.hdr_sz;
@@ -260,13 +265,14 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_if_t * vif,
d = &vring->desc[next];
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
struct virtio_net_hdr_v1 *hdr = vlib_buffer_get_current (b) - hdr_sz;
+ int is_l2 = (vif->type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI));
clib_memset (hdr, 0, hdr_sz);
if (b->flags & VNET_BUFFER_F_GSO)
{
if (do_gso)
- set_gso_offsets (b, hdr);
+ set_gso_offsets (b, hdr, is_l2);
else
{
virtio_interface_drop_inline (vm, node_index, &bi, 1,
@@ -278,7 +284,7 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_if_t * vif,
VNET_BUFFER_F_OFFLOAD_UDP_CKSUM))
{
if (csum_offload)
- set_checksum_offsets (b, hdr);
+ set_checksum_offsets (b, hdr, is_l2);
else
{
virtio_interface_drop_inline (vm, node_index, &bi, 1,
diff --git a/src/vnet/devices/virtio/vhost_user_output.c b/src/vnet/devices/virtio/vhost_user_output.c
index 4f5eb3c1d76..d48e43738a9 100644
--- a/src/vnet/devices/virtio/vhost_user_output.c
+++ b/src/vnet/devices/virtio/vhost_user_output.c
@@ -237,7 +237,11 @@ vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
virtio_net_hdr_t * hdr)
{
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
+ int is_ip6 = b->flags & VNET_BUFFER_F_IS_IP6;
+
+ ASSERT (!(is_ip4 && is_ip6));
+ vnet_generic_header_offset_parser (b, &gho, 1 /* l2 */ , is_ip4, is_ip6);
if (b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM)
{
ip4_header_t *ip4;
@@ -272,13 +276,13 @@ vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
{
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
{
- if ((b->flags & VNET_BUFFER_F_IS_IP4) &&
+ if (is_ip4 &&
(vui->features & (1ULL << FEAT_VIRTIO_NET_F_GUEST_TSO4)))
{
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
}
- else if ((b->flags & VNET_BUFFER_F_IS_IP6) &&
+ else if (is_ip6 &&
(vui->features & (1ULL << FEAT_VIRTIO_NET_F_GUEST_TSO6)))
{
hdr->gso_size = vnet_buffer2 (b)->gso_size;
diff --git a/src/vnet/gso/FEATURE.yaml b/src/vnet/gso/FEATURE.yaml
index b3296d6efa6..79b506df69c 100644
--- a/src/vnet/gso/FEATURE.yaml
+++ b/src/vnet/gso/FEATURE.yaml
@@ -5,9 +5,11 @@ features:
- Basic GSO support
- GSO for VLAN tagged packets
- GSO for VXLAN tunnel
+ - GSO for IP-IP tunnel
+ - GSO for IPSec tunnel
- Provide inline function to get header offsets
description: "Generic Segmentation Offload"
missing:
- - Thorough Testing, IPIP, GRE, Geneve, IPSec
+ - Thorough Testing, GRE, Geneve
state: experimental
properties: [API, CLI]
diff --git a/src/vnet/gso/gso.c b/src/vnet/gso/gso.c
index c741b17bdd4..854bffb39e3 100644
--- a/src/vnet/gso/gso.c
+++ b/src/vnet/gso/gso.c
@@ -26,30 +26,6 @@ gso_main_t gso_main;
int
vnet_sw_interface_gso_enable_disable (u32 sw_if_index, u8 enable)
{
- ethernet_interface_t *eif;
- vnet_sw_interface_t *si;
- ethernet_main_t *em;
- vnet_main_t *vnm;
-
- vnm = vnet_get_main ();
- em = &ethernet_main;
- si = vnet_get_sw_interface (vnm, sw_if_index);
-
- /*
- * only ethernet HW interfaces are supported at this time
- */
- if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
- {
- return (VNET_API_ERROR_INVALID_VALUE);
- }
-
- eif = ethernet_get_interface (em, si->hw_if_index);
-
- if (!eif)
- {
- return (VNET_API_ERROR_FEATURE_DISABLED);
- }
-
vnet_feature_enable_disable ("ip4-output", "gso-ip4", sw_if_index, enable,
0, 0);
vnet_feature_enable_disable ("ip6-output", "gso-ip6", sw_if_index, enable,
diff --git a/src/vnet/gso/hdr_offset_parser.h b/src/vnet/gso/hdr_offset_parser.h
index 8f9e0cda984..b194333e780 100644
--- a/src/vnet/gso/hdr_offset_parser.h
+++ b/src/vnet/gso/hdr_offset_parser.h
@@ -36,7 +36,8 @@
_( 8, VXLAN_TUNNEL) \
_( 9, GRE_TUNNEL) \
_( 10, IPIP_TUNNEL) \
- _( 11, GENEVE_TUNNEL)
+ _( 11, IPIP6_TUNNEL) \
+ _( 12, GENEVE_TUNNEL)
typedef enum gho_flag_t_
{
@@ -45,9 +46,10 @@ typedef enum gho_flag_t_
#undef _
} gho_flag_t;
-#define GHO_F_TUNNEL (GHO_F_VXLAN_TUNNEL | \
- GHO_F_GENEVE_TUNNEL | \
- GHO_F_IPIP_TUNNEL | \
+#define GHO_F_TUNNEL (GHO_F_VXLAN_TUNNEL | \
+ GHO_F_GENEVE_TUNNEL | \
+ GHO_F_IPIP_TUNNEL | \
+ GHO_F_IPIP6_TUNNEL | \
GHO_F_GRE_TUNNEL)
#define GHO_F_OUTER_HDR (GHO_F_OUTER_IP4 | \
@@ -173,11 +175,77 @@ static_always_inline void
vnet_ipip_inner_header_parser_inline (vlib_buffer_t * b0,
generic_header_offset_t * gho)
{
- /* not supported yet */
- if ((gho->gho_flags & GHO_F_IPIP_TUNNEL) == 0)
+ if ((gho->gho_flags & (GHO_F_IPIP_TUNNEL | GHO_F_IPIP6_TUNNEL)) == 0)
return;
- ASSERT (0);
+ u8 l4_proto = 0;
+ u8 l4_hdr_sz = 0;
+
+ gho->outer_l2_hdr_offset = gho->l2_hdr_offset;
+ gho->outer_l3_hdr_offset = gho->l3_hdr_offset;
+ gho->outer_l4_hdr_offset = gho->l4_hdr_offset;
+ gho->outer_l4_hdr_sz = gho->l4_hdr_sz;
+ gho->outer_hdr_sz = gho->hdr_sz;
+
+ gho->l2_hdr_offset = 0;
+ gho->l3_hdr_offset = 0;
+ gho->l4_hdr_offset = 0;
+ gho->l4_hdr_sz = 0;
+ gho->hdr_sz = 0;
+
+ if (gho->gho_flags & GHO_F_IP4)
+ {
+ gho->gho_flags |= GHO_F_OUTER_IP4;
+ }
+ else if (gho->gho_flags & GHO_F_IP6)
+ {
+ gho->gho_flags |= GHO_F_OUTER_IP6;
+ }
+
+ gho->gho_flags &= ~GHO_F_INNER_HDR;
+
+ vnet_get_inner_header (b0, gho);
+
+ gho->l2_hdr_offset = b0->current_data;
+ gho->l3_hdr_offset = 0;
+
+ if (PREDICT_TRUE (gho->gho_flags & GHO_F_IPIP_TUNNEL))
+ {
+ ip4_header_t *ip4 = (ip4_header_t *) vlib_buffer_get_current (b0);
+ gho->l4_hdr_offset = ip4_header_bytes (ip4);
+ l4_proto = ip4->protocol;
+ gho->gho_flags |= GHO_F_IP4;
+ }
+ else if (PREDICT_TRUE (gho->gho_flags & GHO_F_IPIP6_TUNNEL))
+ {
+ ip6_header_t *ip6 = (ip6_header_t *) vlib_buffer_get_current (b0);
+ /* FIXME IPv6 EH traversal */
+ gho->l4_hdr_offset = sizeof (ip6_header_t);
+ l4_proto = ip6->protocol;
+ gho->gho_flags |= GHO_F_IP6;
+ }
+ if (l4_proto == IP_PROTOCOL_TCP)
+ {
+ tcp_header_t *tcp = (tcp_header_t *) (vlib_buffer_get_current (b0) +
+ gho->l4_hdr_offset);
+ l4_hdr_sz = tcp_header_bytes (tcp);
+
+ gho->gho_flags |= GHO_F_TCP;
+
+ }
+ else if (l4_proto == IP_PROTOCOL_UDP)
+ {
+ udp_header_t *udp = (udp_header_t *) (vlib_buffer_get_current (b0) +
+ gho->l4_hdr_offset);
+ l4_hdr_sz = sizeof (*udp);
+
+ gho->gho_flags |= GHO_F_UDP;
+ }
+
+ gho->l4_hdr_sz = l4_hdr_sz;
+ gho->hdr_sz += gho->l4_hdr_offset + l4_hdr_sz;
+
+ vnet_get_outer_header (b0, gho);
}
static_always_inline void
@@ -290,7 +358,7 @@ vnet_generic_inner_header_parser_inline (vlib_buffer_t * b0,
if (gho->gho_flags & GHO_F_VXLAN_TUNNEL)
vnet_vxlan_inner_header_parser_inline (b0, gho);
- else if (gho->gho_flags & GHO_F_IPIP_TUNNEL)
+ else if (gho->gho_flags & (GHO_F_IPIP_TUNNEL | GHO_F_IPIP6_TUNNEL))
vnet_ipip_inner_header_parser_inline (b0, gho);
else if (gho->gho_flags & GHO_F_GRE_TUNNEL)
vnet_gre_inner_header_parser_inline (b0, gho);
@@ -300,33 +368,44 @@ vnet_generic_inner_header_parser_inline (vlib_buffer_t * b0,
static_always_inline void
vnet_generic_outer_header_parser_inline (vlib_buffer_t * b0,
- generic_header_offset_t * gho)
+ generic_header_offset_t * gho,
+ int is_l2, int is_ip4, int is_ip6)
{
u8 l4_proto = 0;
u8 l4_hdr_sz = 0;
+ u16 ethertype = 0;
+ u16 l2hdr_sz = 0;
- ethernet_header_t *eh = (ethernet_header_t *) vlib_buffer_get_current (b0);
- u16 ethertype = clib_net_to_host_u16 (eh->type);
- u16 l2hdr_sz = sizeof (ethernet_header_t);
+ ASSERT (is_ip4 ^ is_ip6);
- if (ethernet_frame_is_tagged (ethertype))
+ if (is_l2)
{
- ethernet_vlan_header_t *vlan = (ethernet_vlan_header_t *) (eh + 1);
+ ethernet_header_t *eh =
+ (ethernet_header_t *) vlib_buffer_get_current (b0);
+ ethertype = clib_net_to_host_u16 (eh->type);
+ l2hdr_sz = sizeof (ethernet_header_t);
- ethertype = clib_net_to_host_u16 (vlan->type);
- l2hdr_sz += sizeof (*vlan);
- if (ethertype == ETHERNET_TYPE_VLAN)
+ if (ethernet_frame_is_tagged (ethertype))
{
- vlan++;
+ ethernet_vlan_header_t *vlan = (ethernet_vlan_header_t *) (eh + 1);
+
ethertype = clib_net_to_host_u16 (vlan->type);
l2hdr_sz += sizeof (*vlan);
+ if (ethertype == ETHERNET_TYPE_VLAN)
+ {
+ vlan++;
+ ethertype = clib_net_to_host_u16 (vlan->type);
+ l2hdr_sz += sizeof (*vlan);
+ }
}
}
+ else
+ l2hdr_sz = vnet_buffer (b0)->ip.save_rewrite_length;
gho->l2_hdr_offset = b0->current_data;
gho->l3_hdr_offset = l2hdr_sz;
- if (PREDICT_TRUE (ethertype == ETHERNET_TYPE_IP4))
+ if (PREDICT_TRUE (is_ip4))
{
ip4_header_t *ip4 =
(ip4_header_t *) (vlib_buffer_get_current (b0) + l2hdr_sz);
@@ -334,7 +413,7 @@ vnet_generic_outer_header_parser_inline (vlib_buffer_t * b0,
l4_proto = ip4->protocol;
gho->gho_flags |= GHO_F_IP4;
}
- else if (PREDICT_TRUE (ethertype == ETHERNET_TYPE_IP6))
+ else if (PREDICT_TRUE (is_ip6))
{
ip6_header_t *ip6 =
(ip6_header_t *) (vlib_buffer_get_current (b0) + l2hdr_sz);
@@ -369,12 +448,16 @@ vnet_generic_outer_header_parser_inline (vlib_buffer_t * b0,
gho->gho_flags |= GHO_F_GENEVE_TUNNEL;
}
}
- else if ((l4_proto == IP_PROTOCOL_IP_IN_IP)
- || (l4_proto == IP_PROTOCOL_IPV6))
+ else if (l4_proto == IP_PROTOCOL_IP_IN_IP)
{
l4_hdr_sz = 0;
gho->gho_flags |= GHO_F_IPIP_TUNNEL;
}
+ else if (l4_proto == IP_PROTOCOL_IPV6)
+ {
+ l4_hdr_sz = 0;
+ gho->gho_flags |= GHO_F_IPIP6_TUNNEL;
+ }
else if (l4_proto == IP_PROTOCOL_GRE)
{
l4_hdr_sz = 0;
@@ -387,9 +470,10 @@ vnet_generic_outer_header_parser_inline (vlib_buffer_t * b0,
static_always_inline void
vnet_generic_header_offset_parser (vlib_buffer_t * b0,
- generic_header_offset_t * gho)
+ generic_header_offset_t * gho, int is_l2,
+ int is_ip4, int is_ip6)
{
- vnet_generic_outer_header_parser_inline (b0, gho);
+ vnet_generic_outer_header_parser_inline (b0, gho, is_l2, is_ip4, is_ip6);
if (gho->gho_flags & GHO_F_TUNNEL)
{
diff --git a/src/vnet/gso/node.c b/src/vnet/gso/node.c
index 663f9cc602d..b57830f1ac5 100644
--- a/src/vnet/gso/node.c
+++ b/src/vnet/gso/node.c
@@ -56,6 +56,50 @@ format_gso_trace (u8 * s, va_list * args)
return s;
}
+static_always_inline u16
+tso_segment_ipip_tunnel_fixup (vlib_main_t * vm,
+ vnet_interface_per_thread_data_t * ptd,
+ vlib_buffer_t * sb0,
+ generic_header_offset_t * gho)
+{
+ u16 n_tx_bufs = vec_len (ptd->split_buffers);
+ u16 i = 0, n_tx_bytes = 0;
+
+ while (i < n_tx_bufs)
+ {
+ vlib_buffer_t *b0 = vlib_get_buffer (vm, ptd->split_buffers[i]);
+ vnet_get_outer_header (b0, gho);
+ clib_memcpy_fast (vlib_buffer_get_current (b0),
+ vlib_buffer_get_current (sb0), gho->outer_hdr_sz);
+
+ ip4_header_t *ip4 =
+ (ip4_header_t *) (vlib_buffer_get_current (b0) +
+ gho->outer_l3_hdr_offset);
+ ip6_header_t *ip6 =
+ (ip6_header_t *) (vlib_buffer_get_current (b0) +
+ gho->outer_l3_hdr_offset);
+
+ if (gho->gho_flags & GHO_F_OUTER_IP4)
+ {
+ ip4->length =
+ clib_host_to_net_u16 (b0->current_length -
+ gho->outer_l3_hdr_offset);
+ ip4->checksum = ip4_header_checksum (ip4);
+ }
+ else if (gho->gho_flags & GHO_F_OUTER_IP6)
+ {
+ ip6->payload_length =
+ clib_host_to_net_u16 (b0->current_length -
+ gho->outer_l4_hdr_offset);
+ }
+
+ n_tx_bytes += gho->outer_hdr_sz;
+ i++;
+ }
+ return n_tx_bytes;
+
+}
+
static_always_inline void
tso_segment_vxlan_tunnel_headers_fixup (vlib_main_t * vm, vlib_buffer_t * b,
generic_header_offset_t * gho)
@@ -177,14 +221,22 @@ static_always_inline void
tso_init_buf_from_template_base (vlib_buffer_t * nb0, vlib_buffer_t * b0,
u32 flags, u16 length)
{
+ /* copying objects from cacheline 0 */
nb0->current_data = b0->current_data;
- nb0->total_length_not_including_first_buffer = 0;
+ nb0->current_length = length;
nb0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID | flags;
- nb0->trace_handle = b0->trace_handle;
+ nb0->flow_id = b0->flow_id;
+ nb0->error = b0->error;
+ nb0->current_config_index = b0->current_config_index;
clib_memcpy_fast (&nb0->opaque, &b0->opaque, sizeof (nb0->opaque));
+
+ /* copying objects from cacheline 1 */
+ nb0->trace_handle = b0->trace_handle;
+ nb0->total_length_not_including_first_buffer = 0;
+
+ /* copying data */
clib_memcpy_fast (vlib_buffer_get_current (nb0),
vlib_buffer_get_current (b0), length);
- nb0->current_length = length;
}
static_always_inline void
@@ -209,8 +261,7 @@ tso_init_buf_from_template (vlib_main_t * vm, vlib_buffer_t * nb0,
static_always_inline void
tso_fixup_segmented_buf (vlib_main_t * vm, vlib_buffer_t * b0, u8 tcp_flags,
- int is_ip6, generic_header_offset_t * gho,
- u32 do_csums)
+ int is_ip6, generic_header_offset_t * gho)
{
ip4_header_t *ip4 =
(ip4_header_t *) (vlib_buffer_get_current (b0) + gho->l3_hdr_offset);
@@ -224,9 +275,8 @@ tso_fixup_segmented_buf (vlib_main_t * vm, vlib_buffer_t * b0, u8 tcp_flags,
if (is_ip6)
{
ip6->payload_length =
- clib_host_to_net_u16 (b0->current_length -
- (gho->l4_hdr_offset - gho->l2_hdr_offset));
- if (do_csums && (b0->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM))
+ clib_host_to_net_u16 (b0->current_length - gho->l4_hdr_offset);
+ if (gho->gho_flags & GHO_F_TCP)
{
int bogus = 0;
tcp->checksum = 0;
@@ -238,20 +288,29 @@ tso_fixup_segmented_buf (vlib_main_t * vm, vlib_buffer_t * b0, u8 tcp_flags,
else
{
ip4->length =
- clib_host_to_net_u16 (b0->current_length -
- (gho->l3_hdr_offset - gho->l2_hdr_offset));
- if (do_csums)
+ clib_host_to_net_u16 (b0->current_length - gho->l3_hdr_offset);
+ if (gho->gho_flags & GHO_F_IP4)
+ ip4->checksum = ip4_header_checksum (ip4);
+ if (gho->gho_flags & GHO_F_TCP)
{
- if (b0->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM)
- ip4->checksum = ip4_header_checksum (ip4);
- if (b0->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
- {
- tcp->checksum = 0;
- tcp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip4);
- }
- b0->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
- b0->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
+ tcp->checksum = 0;
+ tcp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip4);
}
+ b0->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
+ b0->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
+ }
+
+ if ((gho->gho_flags & GHO_F_TUNNEL) == 0)
+ {
+ u32 adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
+
+ ip_adjacency_t *adj0 = adj_get (adj_index0);
+
+ if (adj0->lookup_next_index == IP_LOOKUP_NEXT_MIDCHAIN &&
+ adj0->sub_type.midchain.fixup_func)
+ /* calls e.g. ipip44_fixup */
+ adj0->sub_type.midchain.fixup_func
+ (vm, adj0, b0, adj0->sub_type.midchain.fixup_data);
}
}
@@ -267,8 +326,7 @@ tso_fixup_segmented_buf (vlib_main_t * vm, vlib_buffer_t * b0, u8 tcp_flags,
static_always_inline u32
tso_segment_buffer (vlib_main_t * vm, vnet_interface_per_thread_data_t * ptd,
u32 sbi0, vlib_buffer_t * sb0,
- generic_header_offset_t * gho, u32 n_bytes_b0, int is_ip6,
- u32 do_csums)
+ generic_header_offset_t * gho, u32 n_bytes_b0, int is_ip6)
{
u32 n_tx_bytes = 0;
u16 gso_size = vnet_buffer2 (sb0)->gso_size;
@@ -316,8 +374,7 @@ tso_segment_buffer (vlib_main_t * vm, vnet_interface_per_thread_data_t * ptd,
src_ptr = vlib_buffer_get_current (sb0) + l234_sz + first_data_size;
src_left = sb0->current_length - l234_sz - first_data_size;
- tso_fixup_segmented_buf (vm, b0, tcp_flags_no_fin_psh, is_ip6, gho,
- do_csums);
+ tso_fixup_segmented_buf (vm, b0, tcp_flags_no_fin_psh, is_ip6, gho);
/* grab a second buffer and prepare the loop */
ASSERT (dbi < vec_len (ptd->split_buffers));
@@ -367,7 +424,7 @@ tso_segment_buffer (vlib_main_t * vm, vnet_interface_per_thread_data_t * ptd,
{
n_tx_bytes += cdb0->current_length;
tso_fixup_segmented_buf (vm, cdb0, tcp_flags_no_fin_psh, is_ip6,
- gho, do_csums);
+ gho);
ASSERT (dbi < vec_len (ptd->split_buffers));
cdb0 = vlib_get_buffer (vm, ptd->split_buffers[dbi++]);
tso_init_buf_from_template (vm, cdb0, b0, l234_sz,
@@ -376,8 +433,7 @@ tso_segment_buffer (vlib_main_t * vm, vnet_interface_per_thread_data_t * ptd,
}
}
- tso_fixup_segmented_buf (vm, cdb0, save_tcp_flags, is_ip6, gho,
- do_csums);
+ tso_fixup_segmented_buf (vm, cdb0, save_tcp_flags, is_ip6, gho);
n_tx_bytes += cdb0->current_length;
}
@@ -411,7 +467,7 @@ vnet_gso_node_inline (vlib_main_t * vm,
vlib_frame_t * frame,
vnet_main_t * vnm,
vnet_hw_interface_t * hi,
- int is_ip6, int do_segmentation)
+ int is_l2, int is_ip4, int is_ip6, int do_segmentation)
{
u32 *to_next;
u32 next_index = node->cached_next_index;
@@ -496,7 +552,8 @@ vnet_gso_node_inline (vlib_main_t * vm,
t0->flags = b[0]->flags & VNET_BUFFER_F_GSO;
t0->gso_size = vnet_buffer2 (b[0])->gso_size;
t0->gso_l4_hdr_sz = vnet_buffer2 (b[0])->gso_l4_hdr_sz;
- vnet_generic_header_offset_parser (b[0], &t0->gho);
+ vnet_generic_header_offset_parser (b[0], &t0->gho, is_l2,
+ is_ip4, is_ip6);
}
if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -504,7 +561,8 @@ vnet_gso_node_inline (vlib_main_t * vm,
t1->flags = b[1]->flags & VNET_BUFFER_F_GSO;
t1->gso_size = vnet_buffer2 (b[1])->gso_size;
t1->gso_l4_hdr_sz = vnet_buffer2 (b[1])->gso_l4_hdr_sz;
- vnet_generic_header_offset_parser (b[1], &t1->gho);
+ vnet_generic_header_offset_parser (b[1], &t1->gho, is_l2,
+ is_ip4, is_ip6);
}
if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -512,7 +570,8 @@ vnet_gso_node_inline (vlib_main_t * vm,
t2->flags = b[2]->flags & VNET_BUFFER_F_GSO;
t2->gso_size = vnet_buffer2 (b[2])->gso_size;
t2->gso_l4_hdr_sz = vnet_buffer2 (b[2])->gso_l4_hdr_sz;
- vnet_generic_header_offset_parser (b[2], &t2->gho);
+ vnet_generic_header_offset_parser (b[2], &t2->gho, is_l2,
+ is_ip4, is_ip6);
}
if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
{
@@ -520,7 +579,8 @@ vnet_gso_node_inline (vlib_main_t * vm,
t3->flags = b[3]->flags & VNET_BUFFER_F_GSO;
t3->gso_size = vnet_buffer2 (b[3])->gso_size;
t3->gso_l4_hdr_sz = vnet_buffer2 (b[3])->gso_l4_hdr_sz;
- vnet_generic_header_offset_parser (b[3], &t3->gho);
+ vnet_generic_header_offset_parser (b[3], &t3->gho, is_l2,
+ is_ip4, is_ip6);
}
from += 4;
@@ -547,7 +607,6 @@ vnet_gso_node_inline (vlib_main_t * vm,
vnet_hw_interface_t *hi0;
u32 next0 = 0;
u32 do_segmentation0 = 0;
- u32 do_csums = 0;
swif0 = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
if (PREDICT_FALSE (hi->sw_if_index != swif0))
@@ -573,7 +632,8 @@ vnet_gso_node_inline (vlib_main_t * vm,
t0->flags = b[0]->flags & VNET_BUFFER_F_GSO;
t0->gso_size = vnet_buffer2 (b[0])->gso_size;
t0->gso_l4_hdr_sz = vnet_buffer2 (b[0])->gso_l4_hdr_sz;
- vnet_generic_header_offset_parser (b[0], &t0->gho);
+ vnet_generic_header_offset_parser (b[0], &t0->gho, is_l2,
+ is_ip4, is_ip6);
}
if (do_segmentation0)
@@ -592,12 +652,14 @@ vnet_gso_node_inline (vlib_main_t * vm,
u32 n_bytes_b0 = vlib_buffer_length_in_chain (vm, b[0]);
u32 n_tx_bytes = 0;
- vnet_generic_header_offset_parser (b[0], &gho);
+ vnet_generic_header_offset_parser (b[0], &gho, is_l2,
+ is_ip4, is_ip6);
if (PREDICT_FALSE (gho.gho_flags & GHO_F_TUNNEL))
{
if (PREDICT_FALSE
- ((gho.gho_flags & GHO_F_VXLAN_TUNNEL) == 0))
+ (gho.gho_flags & (GHO_F_GRE_TUNNEL |
+ GHO_F_GENEVE_TUNNEL)))
{
/* not supported yet */
drop_one_buffer_and_count (vm, vnm, node, from - 1,
@@ -610,17 +672,12 @@ vnet_gso_node_inline (vlib_main_t * vm,
vnet_get_inner_header (b[0], &gho);
n_bytes_b0 -= gho.outer_hdr_sz;
- /*
- * In case of tunnel encapsulated packet, we will
- * calculate the checksums for segmented inner packets.
- */
- do_csums = 1;
is_ip6 = (gho.gho_flags & GHO_F_IP6) != 0;
}
n_tx_bytes =
tso_segment_buffer (vm, ptd, bi0, b[0], &gho, n_bytes_b0,
- is_ip6, do_csums);
+ is_ip6);
if (PREDICT_FALSE (n_tx_bytes == 0))
{
@@ -631,12 +688,22 @@ vnet_gso_node_inline (vlib_main_t * vm,
continue;
}
+
if (PREDICT_FALSE (gho.gho_flags & GHO_F_VXLAN_TUNNEL))
{
vnet_get_outer_header (b[0], &gho);
n_tx_bytes +=
tso_segment_vxlan_tunnel_fixup (vm, ptd, b[0], &gho);
}
+ else
+ if (PREDICT_FALSE
+ (gho.gho_flags & (GHO_F_IPIP_TUNNEL |
+ GHO_F_IPIP6_TUNNEL)))
+ {
+ vnet_get_outer_header (b[0], &gho);
+ n_tx_bytes +=
+ tso_segment_ipip_tunnel_fixup (vm, ptd, b[0], &gho);
+ }
u16 n_tx_bufs = vec_len (ptd->split_buffers);
u32 *from_seg = ptd->split_buffers;
@@ -645,30 +712,7 @@ vnet_gso_node_inline (vlib_main_t * vm,
{
u32 sbi0;
vlib_buffer_t *sb0;
- if (n_tx_bufs >= n_left_to_next)
- {
- while (n_left_to_next > 0)
- {
- sbi0 = to_next[0] = from_seg[0];
- sb0 = vlib_get_buffer (vm, sbi0);
- ASSERT (sb0->current_length > 0);
- to_next += 1;
- from_seg += 1;
- n_left_to_next -= 1;
- n_tx_bufs -= 1;
- vnet_feature_next (&next0, sb0);
- vlib_validate_buffer_enqueue_x1 (vm, node,
- next_index,
- to_next,
- n_left_to_next,
- sbi0, next0);
- }
- vlib_put_next_frame (vm, node, next_index,
- n_left_to_next);
- vlib_get_new_next_frame (vm, node, next_index,
- to_next, n_left_to_next);
- }
- while (n_tx_bufs > 0)
+ while (n_tx_bufs > 0 && n_left_to_next > 0)
{
sbi0 = to_next[0] = from_seg[0];
sb0 = vlib_get_buffer (vm, sbi0);
@@ -677,6 +721,7 @@ vnet_gso_node_inline (vlib_main_t * vm,
from_seg += 1;
n_left_to_next -= 1;
n_tx_bufs -= 1;
+ next0 = 0;
vnet_feature_next (&next0, sb0);
vlib_validate_buffer_enqueue_x1 (vm, node,
next_index,
@@ -684,6 +729,11 @@ vnet_gso_node_inline (vlib_main_t * vm,
n_left_to_next,
sbi0, next0);
}
+ vlib_put_next_frame (vm, node, next_index,
+ n_left_to_next);
+ if (n_tx_bufs > 0)
+ vlib_get_next_frame (vm, node, next_index,
+ to_next, n_left_to_next);
}
/* The buffers were enqueued. Reset the length */
_vec_len (ptd->split_buffers) = 0;
@@ -707,7 +757,8 @@ vnet_gso_node_inline (vlib_main_t * vm,
static_always_inline uword
vnet_gso_inline (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame, int is_ip6)
+ vlib_node_runtime_t * node, vlib_frame_t * frame, int is_l2,
+ int is_ip4, int is_ip6)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hi;
@@ -721,10 +772,12 @@ vnet_gso_inline (vlib_main_t * vm,
if (hi->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO)
return vnet_gso_node_inline (vm, node, frame, vnm, hi,
- is_ip6, /* do_segmentation */ 0);
+ is_l2, is_ip4, is_ip6,
+ /* do_segmentation */ 0);
else
return vnet_gso_node_inline (vm, node, frame, vnm, hi,
- is_ip6, /* do_segmentation */ 1);
+ is_l2, is_ip4, is_ip6,
+ /* do_segmentation */ 1);
}
return 0;
}
@@ -732,25 +785,29 @@ vnet_gso_inline (vlib_main_t * vm,
VLIB_NODE_FN (gso_l2_ip4_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- return vnet_gso_inline (vm, node, frame, 0 /* ip6 */ );
+ return vnet_gso_inline (vm, node, frame, 1 /* l2 */ , 1 /* ip4 */ ,
+ 0 /* ip6 */ );
}
VLIB_NODE_FN (gso_l2_ip6_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- return vnet_gso_inline (vm, node, frame, 1 /* ip6 */ );
+ return vnet_gso_inline (vm, node, frame, 1 /* l2 */ , 0 /* ip4 */ ,
+ 1 /* ip6 */ );
}
VLIB_NODE_FN (gso_ip4_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- return vnet_gso_inline (vm, node, frame, 0 /* ip6 */ );
+ return vnet_gso_inline (vm, node, frame, 0 /* l2 */ , 1 /* ip4 */ ,
+ 0 /* ip6 */ );
}
VLIB_NODE_FN (gso_ip6_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- return vnet_gso_inline (vm, node, frame, 1 /* ip6 */ );
+ return vnet_gso_inline (vm, node, frame, 0 /* l2 */ , 0 /* ip4 */ ,
+ 1 /* ip6 */ );
}
/* *INDENT-OFF* */
@@ -806,15 +863,13 @@ VNET_FEATURE_INIT (gso_l2_ip6_node, static) = {
VNET_FEATURE_INIT (gso_ip4_node, static) = {
.arc_name = "ip4-output",
.node_name = "gso-ip4",
- .runs_after = VNET_FEATURES ("ipsec4-output-feature"),
- .runs_before = VNET_FEATURES ("interface-output"),
+ .runs_before = VNET_FEATURES ("esp4-encrypt-tun","ipsec4-output-feature"),
};
VNET_FEATURE_INIT (gso_ip6_node, static) = {
.arc_name = "ip6-output",
.node_name = "gso-ip6",
- .runs_after = VNET_FEATURES ("ipsec6-output-feature"),
- .runs_before = VNET_FEATURES ("interface-output"),
+ .runs_before = VNET_FEATURES ("esp6-encrypt-tun","ipsec6-output-feature"),
};
/*
diff --git a/src/vnet/interface_output.h b/src/vnet/interface_output.h
index ef7aaa8999e..c408fca9ca9 100644
--- a/src/vnet/interface_output.h
+++ b/src/vnet/interface_output.h
@@ -92,7 +92,8 @@ vnet_calc_checksums_inline (vlib_main_t * vm, vlib_buffer_t * b,
if (with_gso)
{
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, 1 /* l2 */ , is_ip4,
+ is_ip6);
ASSERT (gho.gho_flags ^ (GHO_F_IP4 | GHO_F_IP6));
diff --git a/test/test_gso.py b/test/test_gso.py
index c5e537c91bd..71766b6d8ba 100644
--- a/test/test_gso.py
+++ b/test/test_gso.py
@@ -22,6 +22,7 @@ from vpp_object import VppObject
from vpp_interface import VppInterface
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath, FibPathProto
+from vpp_ipip_tun_interface import VppIpIpTunInterface
from vpp_vxlan_tunnel import VppVxlanTunnel
from socket import AF_INET, AF_INET6, inet_pton
from util import reassemble4
@@ -67,12 +68,15 @@ class TestGSO(VppTestCase):
self.vxlan = VppVxlanTunnel(self, src=self.pg0.local_ip4,
dst=self.pg0.remote_ip4,
vni=self.single_tunnel_bd)
- self.vxlan.add_vpp_config()
self.vxlan2 = VppVxlanTunnel(self, src=self.pg0.local_ip6,
dst=self.pg0.remote_ip6,
vni=self.single_tunnel_bd)
- self.vxlan2.add_vpp_config()
+
+ self.ipip4 = VppIpIpTunInterface(self, self.pg0, self.pg0.local_ip4,
+ self.pg0.remote_ip4)
+ self.ipip6 = VppIpIpTunInterface(self, self.pg0, self.pg0.local_ip6,
+ self.pg0.remote_ip6)
def tearDown(self):
super(TestGSO, self).tearDown()
@@ -286,6 +290,11 @@ class TestGSO(VppTestCase):
# create VXLAN VTEP on VPP pg0, and put vxlan_tunnel0 and pg2
# into BD.
#
+
+ #
+ # enable ipv4/vxlan
+ #
+ self.vxlan.add_vpp_config()
self.vapi.sw_interface_set_l2_bridge(
rx_sw_if_index=self.vxlan.sw_if_index, bd_id=self.single_tunnel_bd)
self.vapi.sw_interface_set_l2_bridge(
@@ -300,7 +309,6 @@ class TestGSO(VppTestCase):
TCP(sport=1234, dport=1234) /
Raw(b'\xa5' * 65200))
- self.pg0.enable_capture()
rxs = self.send_and_expect(self.pg2, [p45], self.pg0, 45)
size = 0
for rx in rxs:
@@ -325,7 +333,6 @@ class TestGSO(VppTestCase):
TCP(sport=1234, dport=1234) /
Raw(b'\xa5' * 65200))
- self.pg0.enable_capture()
rxs = self.send_and_expect(self.pg2, [p65], self.pg0, 45)
size = 0
for rx in rxs:
@@ -350,6 +357,7 @@ class TestGSO(VppTestCase):
#
# enable ipv6/vxlan
#
+ self.vxlan2.add_vpp_config()
self.vapi.sw_interface_set_l2_bridge(
rx_sw_if_index=self.vxlan2.sw_if_index,
bd_id=self.single_tunnel_bd)
@@ -362,7 +370,6 @@ class TestGSO(VppTestCase):
TCP(sport=1234, dport=1234) /
Raw(b'\xa5' * 65200))
- self.pg0.enable_capture()
rxs = self.send_and_expect(self.pg2, [p46], self.pg0, 45)
size = 0
for rx in rxs:
@@ -387,7 +394,6 @@ class TestGSO(VppTestCase):
TCP(sport=1234, dport=1234) /
Raw(b'\xa5' * 65200))
- self.pg0.enable_capture()
rxs = self.send_and_expect(self.pg2, [p66], self.pg0, 45)
size = 0
for rx in rxs:
@@ -404,5 +410,192 @@ class TestGSO(VppTestCase):
size += inner[IPv6].plen - 20
self.assertEqual(size, 65200)
+ #
+ # disable ipv4/vxlan
+ #
+ self.vxlan2.remove_vpp_config()
+
+ def test_gso_ipip(self):
+ """ GSO IPIP test """
+ self.logger.info(self.vapi.cli("sh int addr"))
+ #
+ # Send jumbo frame with gso enabled only on input interface and
+ # create IPIP tunnel on VPP pg0.
+ #
+ self.vapi.feature_gso_enable_disable(self.pg0.sw_if_index)
+
+ #
+ # enable ipip4
+ #
+ self.ipip4.add_vpp_config()
+
+ # Set interface up and enable IP on it
+ self.ipip4.admin_up()
+ self.ipip4.set_unnumbered(self.pg0.sw_if_index)
+
+ # Add IPv4 routes via tunnel interface
+ self.ip4_via_ip4_tunnel = VppIpRoute(
+ self, "172.16.10.0", 24,
+ [VppRoutePath("0.0.0.0",
+ self.ipip4.sw_if_index,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP4)])
+ self.ip4_via_ip4_tunnel.add_vpp_config()
+
+ #
+ # IPv4/IPv4 - IPIP
+ #
+ p47 = (Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") /
+ IP(src=self.pg2.remote_ip4, dst="172.16.10.3", flags='DF') /
+ TCP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 65200))
+
+ rxs = self.send_and_expect(self.pg2, [p47], self.pg0, 45)
+ size = 0
+ for rx in rxs:
+ self.assertEqual(rx[Ether].src, self.pg0.local_mac)
+ self.assertEqual(rx[Ether].dst, self.pg0.remote_mac)
+ self.assertEqual(rx[IP].src, self.pg0.local_ip4)
+ self.assertEqual(rx[IP].dst, self.pg0.remote_ip4)
+ self.assertEqual(rx[IP].proto, 4) # ipencap
+ inner = rx[IP].payload
+ self.assertEqual(inner[IP].src, self.pg2.remote_ip4)
+ self.assertEqual(inner[IP].dst, "172.16.10.3")
+ size += inner[IP].len - 20 - 20
+ self.assertEqual(size, 65200)
+
+ self.ip6_via_ip4_tunnel = VppIpRoute(
+ self, "fd01:10::", 64,
+ [VppRoutePath("::",
+ self.ipip4.sw_if_index,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
+ self.ip6_via_ip4_tunnel.add_vpp_config()
+ #
+ # IPv4/IPv6 - IPIP
+ #
+ p67 = (Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") /
+ IPv6(src=self.pg2.remote_ip6, dst="fd01:10::3") /
+ TCP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 65200))
+
+ rxs = self.send_and_expect(self.pg2, [p67], self.pg0, 45)
+ size = 0
+ for rx in rxs:
+ self.assertEqual(rx[Ether].src, self.pg0.local_mac)
+ self.assertEqual(rx[Ether].dst, self.pg0.remote_mac)
+ self.assertEqual(rx[IP].src, self.pg0.local_ip4)
+ self.assertEqual(rx[IP].dst, self.pg0.remote_ip4)
+ self.assertEqual(rx[IP].proto, 41) # ipv6
+ inner = rx[IP].payload
+ self.assertEqual(inner[IPv6].src, self.pg2.remote_ip6)
+ self.assertEqual(inner[IPv6].dst, "fd01:10::3")
+ size += inner[IPv6].plen - 20
+ self.assertEqual(size, 65200)
+
+ #
+ # Send jumbo frame with gso enabled only on input interface and
+ # create IPIP tunnel on VPP pg0. Enable gso feature node on ipip
+ # tunnel - IPSec use case
+ #
+ self.vapi.feature_gso_enable_disable(self.pg0.sw_if_index, 0)
+ self.vapi.feature_gso_enable_disable(self.ipip4.sw_if_index)
+
+ rxs = self.send_and_expect(self.pg2, [p47], self.pg0, 45)
+ size = 0
+ for rx in rxs:
+ self.assertEqual(rx[Ether].src, self.pg0.local_mac)
+ self.assertEqual(rx[Ether].dst, self.pg0.remote_mac)
+ self.assertEqual(rx[IP].src, self.pg0.local_ip4)
+ self.assertEqual(rx[IP].dst, self.pg0.remote_ip4)
+ self.assertEqual(rx[IP].proto, 4) # ipencap
+ inner = rx[IP].payload
+ self.assertEqual(inner[IP].src, self.pg2.remote_ip4)
+ self.assertEqual(inner[IP].dst, "172.16.10.3")
+ size += inner[IP].len - 20 - 20
+ self.assertEqual(size, 65200)
+
+ #
+ # disable ipip4
+ #
+ self.vapi.feature_gso_enable_disable(self.ipip4.sw_if_index, 0)
+ self.ip4_via_ip4_tunnel.remove_vpp_config()
+ self.ip6_via_ip4_tunnel.remove_vpp_config()
+ self.ipip4.remove_vpp_config()
+
+ #
+ # enable ipip6
+ #
+ self.vapi.feature_gso_enable_disable(self.pg0.sw_if_index)
+ self.ipip6.add_vpp_config()
+
+ # Set interface up and enable IP on it
+ self.ipip6.admin_up()
+ self.ipip6.set_unnumbered(self.pg0.sw_if_index)
+
+ # Add IPv4 routes via tunnel interface
+ self.ip4_via_ip6_tunnel = VppIpRoute(
+ self, "172.16.10.0", 24,
+ [VppRoutePath("0.0.0.0",
+ self.ipip6.sw_if_index,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP4)])
+ self.ip4_via_ip6_tunnel.add_vpp_config()
+
+ #
+ # IPv6/IPv4 - IPIP
+ #
+ p48 = (Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") /
+ IP(src=self.pg2.remote_ip4, dst="172.16.10.3", flags='DF') /
+ TCP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 65200))
+
+ rxs = self.send_and_expect(self.pg2, [p48], self.pg0, 45)
+ size = 0
+ for rx in rxs:
+ self.assertEqual(rx[Ether].src, self.pg0.local_mac)
+ self.assertEqual(rx[Ether].dst, self.pg0.remote_mac)
+ self.assertEqual(rx[IPv6].src, self.pg0.local_ip6)
+ self.assertEqual(rx[IPv6].dst, self.pg0.remote_ip6)
+ self.assertEqual(ipv6nh[rx[IPv6].nh], "IP")
+ inner = rx[IPv6].payload
+ self.assertEqual(inner[IP].src, self.pg2.remote_ip4)
+ self.assertEqual(inner[IP].dst, "172.16.10.3")
+ size += inner[IP].len - 20 - 20
+ self.assertEqual(size, 65200)
+
+ self.ip6_via_ip6_tunnel = VppIpRoute(
+ self, "fd01:10::", 64,
+ [VppRoutePath("::",
+ self.ipip6.sw_if_index,
+ proto=FibPathProto.FIB_PATH_NH_PROTO_IP6)])
+ self.ip6_via_ip6_tunnel.add_vpp_config()
+
+ #
+ # IPv6/IPv6 - IPIP
+ #
+ p68 = (Ether(src=self.pg2.remote_mac, dst="02:fe:60:1e:a2:79") /
+ IPv6(src=self.pg2.remote_ip6, dst="fd01:10::3") /
+ TCP(sport=1234, dport=1234) /
+ Raw(b'\xa5' * 65200))
+
+ rxs = self.send_and_expect(self.pg2, [p68], self.pg0, 45)
+ size = 0
+ for rx in rxs:
+ self.assertEqual(rx[Ether].src, self.pg0.local_mac)
+ self.assertEqual(rx[Ether].dst, self.pg0.remote_mac)
+ self.assertEqual(rx[IPv6].src, self.pg0.local_ip6)
+ self.assertEqual(rx[IPv6].dst, self.pg0.remote_ip6)
+ self.assertEqual(ipv6nh[rx[IPv6].nh], "IPv6")
+ inner = rx[IPv6].payload
+ self.assertEqual(inner[IPv6].src, self.pg2.remote_ip6)
+ self.assertEqual(inner[IPv6].dst, "fd01:10::3")
+ size += inner[IPv6].plen - 20
+ self.assertEqual(size, 65200)
+
+ #
+ # disable ipip6
+ #
+ self.ip4_via_ip6_tunnel.remove_vpp_config()
+ self.ip6_via_ip6_tunnel.remove_vpp_config()
+ self.ipip6.remove_vpp_config()
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)