Skip to content

Commit

Permalink
fix: Use correct ECN mark when sending datagram
Browse files Browse the repository at this point in the history
EcnInfo::on_packet_sent may update the ECN state and can hence change it.

Also throw in some unrelated fixes to make the ECN log output more
quiet, and to test/test.sh.
  • Loading branch information
larseggert committed May 24, 2024
1 parent ea1b2bb commit f780504
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion neqo-transport/src/ecn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl EcnInfo {
} else if ecn_diff[IpTosEcn::Ect1] > 0 {
qwarn!("ECN validation failed, ACK counted ECT(1) marks that were never sent");
self.state = EcnValidationState::Failed;
} else {
} else if self.state != EcnValidationState::Capable {
qinfo!("ECN validation succeeded, path is capable");
self.state = EcnValidationState::Capable;
}
Expand Down
6 changes: 5 additions & 1 deletion neqo-transport/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,12 @@ impl Path {

/// Make a datagram.
pub fn datagram<V: Into<Vec<u8>>>(&mut self, payload: V) -> Datagram {
// Make sure to use the TOS value from before calling EcnInfo::on_packet_sent, which may
// update the ECN state and can hence change it - this packet should still be sent
// with the current value.
let tos = self.tos();
self.ecn_info.on_packet_sent();
Datagram::new(self.local, self.remote, self.tos(), Some(self.ttl), payload)
Datagram::new(self.local, self.remote, tos, Some(self.ttl), payload)
}

/// Get local address as `SocketAddr`
Expand Down
7 changes: 4 additions & 3 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

set -e
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

cargo build --bin neqo-client --bin neqo-server

Expand All @@ -29,12 +28,14 @@ server="SSLKEYLOGFILE=$tmp/test.tlskey ./target/debug/neqo-server $flags $addr:$

tcpdump -U -i "$iface" -w "$tmp/test.pcap" host $addr and port $port >/dev/null 2>&1 &
tcpdump_pid=$!
trap 'rm -rf "$tmp"; kill -USR2 $tcpdump_pid' EXIT

tmux -CC \
set-option -g default-shell "$(which bash)" \; \
new-session "$client && kill -USR2 $tcpdump_pid && touch $tmp/done" \; \
new-session "$client; kill -USR2 $tcpdump_pid; touch $tmp/done" \; \
split-window -h "$server" \; \
split-window -v -f "\
until [ -e $tmp/done ]; do sleep 1; done && \
until [ -e $tmp/done ]; do sleep 1; done; \
echo $tmp; ls -l $tmp; echo; \
tshark -r $tmp/test.pcap -o tls.keylog_file:$tmp/test.tlskey" \; \
set remain-on-exit on

0 comments on commit f780504

Please sign in to comment.