Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send a challenge ACK in response to an unacceptable TCP ACK.
Browse files Browse the repository at this point in the history
whitequark committed Sep 8, 2017

Verified

This commit was signed with the committer’s verified signature.
makenowjust Hiroya Fujinami
1 parent ef6f658 commit 9f41659
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -734,19 +734,20 @@ impl<'a> TcpSocket<'a> {
// Every acknowledgement must be for transmitted but unacknowledged data.
(_, &TcpRepr { ack_number: Some(ack_number), .. }) => {
let unacknowledged = self.tx_buffer.len() + control_len;

if ack_number < self.local_seq_no {
net_debug!("[{}]{}:{}: duplicate ACK ({} not in {}...{})",
self.debug_id, self.local_endpoint, self.remote_endpoint,
ack_number, self.local_seq_no, self.local_seq_no + unacknowledged);
// FIXME: instead of waiting for the retransmit timer to kick in,
// reset it here.
// FIXME: implement fast retransmit
return Err(Error::Dropped)
}

if ack_number > self.local_seq_no + unacknowledged {
net_debug!("[{}]{}:{}: unacceptable ACK ({} not in {}...{})",
self.debug_id, self.local_endpoint, self.remote_endpoint,
ack_number, self.local_seq_no, self.local_seq_no + unacknowledged);
return Err(Error::Dropped)
return Ok(Some(self.ack_reply(ip_repr, &repr)))
}
}
}
@@ -2903,6 +2904,20 @@ mod test {
}));
}

#[test]
fn test_unacceptable_ack_challenge_ack() {
let mut s = socket_established();
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1 + 1),
..SEND_TEMPL
}, Ok(Some(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
..RECV_TEMPL
})));
}

#[test]
fn test_fill_peer_window() {
let mut s = socket_established();

0 comments on commit 9f41659

Please sign in to comment.