aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip4_to_ip6.h
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-11-08 00:18:15 -0800
committerOle Trøan <otroan@employees.org>2017-11-08 11:23:28 +0000
commitc8e294b0108c0888b824395b814e2ee1dab6cdb6 (patch)
tree49d2e50fbb39155c099b264aa179a83d53ea4d39 /src/vnet/ip/ip4_to_ip6.h
parent0938dcf192d203dcbe89d2819d3819d2f93408bf (diff)
NAT64: fixed csum crash (VPP-1055)
Change-Id: I28c8abe49c9858966a66530d3dc41c074c6901f3 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/vnet/ip/ip4_to_ip6.h')
-rw-r--r--src/vnet/ip/ip4_to_ip6.h18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/vnet/ip/ip4_to_ip6.h b/src/vnet/ip/ip4_to_ip6.h
index 6ffc562c842..f2ed13dc381 100644
--- a/src/vnet/ip/ip4_to_ip6.h
+++ b/src/vnet/ip/ip4_to_ip6.h
@@ -507,6 +507,7 @@ ip4_to_ip6_tcp_udp (vlib_buffer_t * p, ip4_to_ip6_set_fn_t fn, void *ctx)
ip6_frag_hdr_t *frag;
u32 frag_id;
int rv;
+ ip4_address_t old_src, old_dst;
ip4 = vlib_buffer_get_current (p);
@@ -534,9 +535,8 @@ ip4_to_ip6_tcp_udp (vlib_buffer_t * p, ip4_to_ip6_set_fn_t fn, void *ctx)
checksum = &tcp->checksum;
}
- csum = ip_csum_sub_even (*checksum, ip4->src_address.as_u32);
- csum = ip_csum_sub_even (csum, ip4->dst_address.as_u32);
- *checksum = ip_csum_fold (csum);
+ old_src.as_u32 = ip4->src_address.as_u32;
+ old_dst.as_u32 = ip4->dst_address.as_u32;
// Deal with fragmented packets
if (PREDICT_FALSE (ip4->flags_and_fragment_offset &
@@ -577,7 +577,9 @@ ip4_to_ip6_tcp_udp (vlib_buffer_t * p, ip4_to_ip6_set_fn_t fn, void *ctx)
if ((rv = fn (ip4, ip6, ctx)) != 0)
return rv;
- csum = ip_csum_add_even (*checksum, ip6->src_address.as_u64[0]);
+ csum = ip_csum_sub_even (*checksum, old_src.as_u32);
+ csum = ip_csum_sub_even (csum, old_dst.as_u32);
+ csum = ip_csum_add_even (csum, ip6->src_address.as_u64[0]);
csum = ip_csum_add_even (csum, ip6->src_address.as_u64[1]);
csum = ip_csum_add_even (csum, ip6->dst_address.as_u64[0]);
csum = ip_csum_add_even (csum, ip6->dst_address.as_u64[1]);
@@ -649,11 +651,3 @@ ip4_to_ip6 (vlib_buffer_t * p, ip4_to_ip6_set_fn_t fn, void *ctx)
}
#endif /* __included_ip4_to_ip6_h__ */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */