Fix a couple of bugs preventing large packets and fragments from working
This commit is contained in:
@@ -113,6 +113,7 @@ int build_wrapped_ipv4_packet(struct rlocs *reg, struct rloc * s_rloc, struct rl
|
||||
out_len += orig_data_size - bytes_to_encrypt;
|
||||
out->count++;
|
||||
debug( "iovs[2]: %p, %zu", out->iovs[2].iov_base, out->iovs[2].iov_len );
|
||||
debug( "pkt: %p", pkt );
|
||||
}
|
||||
|
||||
wrap_hdr->tot_len = htons( out_len );
|
||||
@@ -214,10 +215,14 @@ int wrap_ipv4_packet( struct rlocs *reg, struct packet *pkt, struct rsp_data *fr
|
||||
|
||||
memcpy( pkt2, pkt, pkt_hdr_len );
|
||||
|
||||
pkt2->hdr.ip.tot_len = htons( pkt_tot_len - frag_off );
|
||||
pkt2->hdr.ip.tot_len = frag2_size;
|
||||
pkt2->hdr.ip.frag_off = htons( frag_off / 8 );
|
||||
memcpy( ((char *)pkt2) + pkt_hdr_len, ((char*)pkt)+pkt_hdr_len, frag2_size );
|
||||
|
||||
// Need to recompute these
|
||||
compute_ip_checksum( &pkt->hdr.ip );
|
||||
compute_ip_checksum( &pkt2->hdr.ip );
|
||||
|
||||
if ( !build_wrapped_ipv4_packet( reg, s_rloc, d_rloc, pkt2, frag2 ) ) {
|
||||
debug( "Couldn't wrap packet 2 of 2 ");
|
||||
return 0;
|
||||
@@ -292,7 +297,7 @@ int unwrap_ipv4_packet(struct rlocs* reg, struct packet *pkt, struct rsp_data *o
|
||||
out->iovs[0].iov_len = decrypted_size;
|
||||
|
||||
// iovec 1: never-encrypted part
|
||||
out->iovs[1].iov_base = (unsigned char*) pkt + hdr_size + 2;
|
||||
out->iovs[1].iov_base = encrypted_data + encrypted_size;
|
||||
out->iovs[1].iov_len = ntohs( pkt->hdr.ip.tot_len ) - hdr_size - encrypted_size;
|
||||
|
||||
if ( out->iovs[0].iov_len + out->iovs[1].iov_len > IP_MAXPACKET ) {
|
||||
|
Reference in New Issue
Block a user