Skip to content

Commit 899a5a1

Browse files
committedJan 31, 2017
Fix the TCP MSS calculation.
1 parent 7a7ca32 commit 899a5a1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

Diff for: ‎src/socket/tcp.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ impl<'a> TcpSocket<'a> {
965965
repr.ack_number = Some(ack_number);
966966
self.remote_last_ack = ack_number;
967967

968+
// Remember the header length before enabling the MSS option, since that option
969+
// only affects SYN packets.
970+
let header_len = repr.header_len();
971+
968972
if repr.control == TcpControl::Syn {
969973
// First enable the option, without assigning any value, to get a correct
970974
// result for (ip_repr:Unspecified).payload_len below.
@@ -980,7 +984,7 @@ impl<'a> TcpSocket<'a> {
980984
let ip_repr = try!(ip_repr.lower(&[]));
981985

982986
if repr.control == TcpControl::Syn {
983-
let mtu = mtu - repr.header_len() - ip_repr.buffer_len();
987+
let mtu = mtu - header_len - ip_repr.buffer_len();
984988
repr.max_seg_size = Some(mtu as u16);
985989
}
986990

0 commit comments

Comments
 (0)
Please sign in to comment.