Skip to content

Commit e93b039

Browse files
committed
Start sending path abandon
This changes the open_path function to no longer return the PATH_ABANDON frame, but instead put it on the pending data. And adds functionality to send it in poll_transmit.
1 parent 52432e2 commit e93b039

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ use crate::{
2424
config::{ServerConfig, TransportConfig},
2525
congestion::Controller,
2626
crypto::{self, KeyPair, Keys, PacketKey},
27-
frame::{
28-
self, Close, Datagram, FrameStruct, NewToken, ObservedAddr, PathAbandon, PathAvailable,
29-
},
27+
frame::{self, Close, Datagram, FrameStruct, NewToken, ObservedAddr, PathAvailable},
3028
packet::{
3129
FixedLengthConnectionIdParser, Header, InitialHeader, InitialPacket, LongType, Packet,
3230
PacketNumber, PartialDecode, SpaceId,
@@ -581,14 +579,11 @@ impl Connection {
581579
// This allows us to safely consume the path_id due to the failed attempt, otherwise
582580
// we would need to keep track of holes in the range and revert the
583581
// max_path_id_in_use
584-
585-
return Some((
586-
None,
587-
vec![Frame::PathAbandon(PathAbandon {
588-
path_id,
589-
error_code: TransportErrorCode::NO_CID_AVAILABLE,
590-
})],
591-
));
582+
self.spaces[SpaceId::Data]
583+
.pending
584+
.path_abandon
585+
.push((path_id, TransportErrorCode::NO_CID_AVAILABLE));
586+
return None;
592587
};
593588

594589
let mut path = PathData::new(remote, self.allow_mtud, None, now, &self.config);
@@ -4087,6 +4082,23 @@ impl Connection {
40874082
}
40884083
}
40894084

4085+
// PATH_ABANDON
4086+
while !path_exclusive_only
4087+
&& space_id == SpaceId::Data
4088+
&& frame::PathAbandon::SIZE_BOUND <= buf.remaining_mut()
4089+
{
4090+
let Some((path_id, error_code)) = space.pending.path_abandon.pop() else {
4091+
break;
4092+
};
4093+
frame::PathAbandon {
4094+
path_id,
4095+
error_code,
4096+
}
4097+
.encode(buf);
4098+
// TODO(flub): frame stats?
4099+
}
4100+
4101+
// RESET_STREAM, STOP_SENDING, MAX_DATA, MAX_STREAM_DATA, MAX_STREAMS
40904102
if space_id == SpaceId::Data {
40914103
self.streams.write_control_frames(
40924104
buf,

quinn-proto/src/connection/spaces.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ use tracing::{error, trace};
1111

1212
use super::{PathId, assembler::Assembler};
1313
use crate::{
14-
Dir, Duration, Instant, SocketAddr, StreamId, TransportError, VarInt, connection::StreamsState,
15-
crypto::Keys, frame, packet::SpaceId, range_set::ArrayRangeSet, shared::IssuedCid,
14+
Dir, Duration, Instant, SocketAddr, StreamId, TransportError, TransportErrorCode, VarInt,
15+
connection::StreamsState, crypto::Keys, frame, packet::SpaceId, range_set::ArrayRangeSet,
16+
shared::IssuedCid,
1617
};
1718

1819
pub(super) struct PacketSpace {
@@ -517,6 +518,8 @@ pub struct Retransmits {
517518
/// something. However, due to the architecture of Quinn, it is considerably simpler to not do
518519
/// that; consider what such a change would mean for implementing `BitOrAssign` on Self.
519520
pub(super) new_tokens: Vec<SocketAddr>,
521+
/// Paths which need to be abandoned
522+
pub(super) path_abandon: Vec<(PathId, TransportErrorCode)>,
520523
}
521524

522525
impl Retransmits {
@@ -536,6 +539,7 @@ impl Retransmits {
536539
&& !self.handshake_done
537540
&& !self.observed_addr
538541
&& self.new_tokens.is_empty()
542+
&& self.path_abandon.is_empty()
539543
}
540544
}
541545

@@ -559,6 +563,7 @@ impl ::std::ops::BitOrAssign for Retransmits {
559563
self.handshake_done |= rhs.handshake_done;
560564
self.observed_addr |= rhs.observed_addr;
561565
self.new_tokens.extend_from_slice(&rhs.new_tokens);
566+
self.path_abandon.extend_from_slice(&rhs.path_abandon)
562567
}
563568
}
564569

quinn-proto/src/frame.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,8 +1288,9 @@ pub(crate) struct PathAbandon {
12881288
pub(crate) error_code: TransportErrorCode,
12891289
}
12901290

1291-
#[allow(dead_code)] // TODO(flub)
12921291
impl PathAbandon {
1292+
pub(crate) const SIZE_BOUND: usize = VarInt(FrameType::PATH_ABANDON.0).size() + 8 + 8;
1293+
12931294
// TODO(@divma): docs
12941295
pub(crate) fn encode<W: BufMut>(&self, buf: &mut W) {
12951296
buf.write(FrameType::PATH_ABANDON);

0 commit comments

Comments
 (0)