diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2013-04-08 18:02:24 +0900 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2013-04-09 17:14:40 +0900 |
commit | 0278627f576832860af2d84e04e383ecaa92d74f (patch) | |
tree | 32e195850b333b077be9f7e998d445feeb4b39ec /translate.c | |
parent | 41e758e33e6c3b43f363591d4113dea54a4330d9 (diff) | |
download | android_external_android-clat-0278627f576832860af2d84e04e383ecaa92d74f.tar.gz android_external_android-clat-0278627f576832860af2d84e04e383ecaa92d74f.tar.bz2 android_external_android-clat-0278627f576832860af2d84e04e383ecaa92d74f.zip |
Pass in the length to pseudo checksum functions
Currently, the pseudo-header checksum calculation functions get
the transport layer length from the IP header. This requires that
the length be known at IP header construction time, which
does not allow transport layer translation functions to change
the length of the packet later. Have the transport functions
pass in the size directly.
Bug: 8276725
Change-Id: I76a93f5e66181bec21d68f779c68c54090a77c33
Diffstat (limited to 'translate.c')
-rw-r--r-- | translate.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/translate.c b/translate.c index cdaca14..89a7e7b 100644 --- a/translate.c +++ b/translate.c @@ -142,7 +142,7 @@ void icmp_to_icmp6(int fd, const struct iphdr *ip, const struct icmphdr *icmp, c icmp6_targ.icmp6_id = icmp->un.echo.id; icmp6_targ.icmp6_seq = icmp->un.echo.sequence; - checksum_temp = ipv6_pseudo_header_checksum(0,&ip6_targ); + checksum_temp = ipv6_pseudo_header_checksum(0, &ip6_targ, sizeof(icmp6_targ) + payload_size); checksum_temp = ip_checksum_add(checksum_temp, &icmp6_targ, sizeof(icmp6_targ)); checksum_temp = ip_checksum_add(checksum_temp, payload, payload_size); icmp6_targ.icmp6_cksum = ip_checksum_finish(checksum_temp); @@ -255,7 +255,7 @@ void udp_to_udp6(int fd, const struct iphdr *ip, const struct udphdr *udp, const fill_ip6_header(&ip6_targ,payload_size + sizeof(struct udphdr),IPPROTO_UDP,ip); - checksum = ipv6_pseudo_header_checksum(0, &ip6_targ); + checksum = ipv6_pseudo_header_checksum(0, &ip6_targ, sizeof(*udp) + payload_size); io_targ[0].iov_base = &tun_header; io_targ[0].iov_len = sizeof(tun_header); @@ -283,7 +283,7 @@ void udp6_to_udp(int fd, const struct ip6_hdr *ip6, const struct udphdr *udp, co fill_ip_header(&ip_targ,payload_size + sizeof(struct udphdr),IPPROTO_UDP,ip6); - checksum = ipv4_pseudo_header_checksum(0, &ip_targ); + checksum = ipv4_pseudo_header_checksum(0, &ip_targ, sizeof(*udp) + payload_size); io_targ[0].iov_base = &tun_header; io_targ[0].iov_len = sizeof(tun_header); @@ -363,7 +363,7 @@ void tcp_to_tcp6(int fd,const struct iphdr *ip, const struct tcphdr *tcp, const fill_ip6_header(&ip6_targ,payload_size+options_size+sizeof(struct tcphdr),IPPROTO_TCP,ip); - checksum = ipv6_pseudo_header_checksum(0, &ip6_targ); + checksum = ipv6_pseudo_header_checksum(0, &ip6_targ, sizeof(*tcp) + options_size + payload_size); io_targ[0].iov_base = &tun_header; io_targ[0].iov_len = sizeof(tun_header); @@ -393,7 +393,7 @@ void tcp6_to_tcp(int fd,const struct ip6_hdr *ip6, const struct tcphdr *tcp, con fill_ip_header(&ip_targ,payload_size+options_size+sizeof(struct tcphdr),IPPROTO_TCP,ip6); - checksum = ipv4_pseudo_header_checksum(0, &ip_targ); + checksum = ipv4_pseudo_header_checksum(0, &ip_targ, sizeof(*tcp) + payload_size + options_size); io_targ[0].iov_base = &tun_header; io_targ[0].iov_len = sizeof(tun_header); |