summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schultz <andreas.schultz@travelping.com>2018-07-17 11:43:23 +0200
committerFlorin Coras <florin.coras@gmail.com>2018-07-19 14:02:19 +0000
commite73b6b7bacb635814b6e47c63e49c60cc5a13bf1 (patch)
treec2a85ff75139388532591a1a85d0e899006dc51a /src
parent43f02bb8a77337e2f56016529c9e46c8b8dc455a (diff)
Fix IPv6 csum calculation in GTP-U encapsulation
The length field is included in the checksum. Therefor, we need to update it before calculating the checksum. Change-Id: Id23234efb80ea3747a0f8a5c7bf8621748d27635 Signed-off-by: Andreas Schultz <andreas.schultz@travelping.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/gtpu/gtpu_encap.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/plugins/gtpu/gtpu_encap.c b/src/plugins/gtpu/gtpu_encap.c
index 4442c42ad66..5f52d5a1543 100644
--- a/src/plugins/gtpu/gtpu_encap.c
+++ b/src/plugins/gtpu/gtpu_encap.c
@@ -380,24 +380,6 @@ gtpu_encap_inline (vlib_main_t * vm,
udp3->length = new_l3;
udp3->src_port = flow_hash3;
- /* IPv6 UDP checksum is mandatory */
- udp0->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b0,
- ip6_0, &bogus);
- if (udp0->checksum == 0)
- udp0->checksum = 0xffff;
- udp1->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b1,
- ip6_1, &bogus);
- if (udp1->checksum == 0)
- udp1->checksum = 0xffff;
- udp2->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b2,
- ip6_2, &bogus);
- if (udp2->checksum == 0)
- udp2->checksum = 0xffff;
- udp3->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b3,
- ip6_3, &bogus);
- if (udp3->checksum == 0)
- udp3->checksum = 0xffff;
-
/* Fix GTPU length */
gtpu0 = (gtpu_header_t *)(udp0+1);
new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain(vm, b0)
@@ -419,6 +401,25 @@ gtpu_encap_inline (vlib_main_t * vm,
- sizeof (*ip6_3) - sizeof(*udp3)
- GTPU_V1_HDR_LEN);
gtpu3->length = new_l3;
+
+ /* IPv6 UDP checksum is mandatory */
+ udp0->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b0,
+ ip6_0, &bogus);
+ if (udp0->checksum == 0)
+ udp0->checksum = 0xffff;
+ udp1->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b1,
+ ip6_1, &bogus);
+ if (udp1->checksum == 0)
+ udp1->checksum = 0xffff;
+ udp2->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b2,
+ ip6_2, &bogus);
+ if (udp2->checksum == 0)
+ udp2->checksum = 0xffff;
+ udp3->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b3,
+ ip6_3, &bogus);
+ if (udp3->checksum == 0)
+ udp3->checksum = 0xffff;
+
}
pkts_encapsulated += 4;
@@ -592,18 +593,18 @@ gtpu_encap_inline (vlib_main_t * vm,
udp0->length = new_l0;
udp0->src_port = flow_hash0;
- /* IPv6 UDP checksum is mandatory */
- udp0->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b0,
- ip6_0, &bogus);
- if (udp0->checksum == 0)
- udp0->checksum = 0xffff;
-
/* Fix GTPU length */
gtpu0 = (gtpu_header_t *)(udp0+1);
new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain(vm, b0)
- sizeof (*ip4_0) - sizeof(*udp0)
- GTPU_V1_HDR_LEN);
gtpu0->length = new_l0;
+
+ /* IPv6 UDP checksum is mandatory */
+ udp0->checksum = ip6_tcp_udp_icmp_compute_checksum(vm, b0,
+ ip6_0, &bogus);
+ if (udp0->checksum == 0)
+ udp0->checksum = 0xffff;
}
pkts_encapsulated ++;