@@ -9,10 +9,10 @@ use crate::{
9
9
path:: { challenge, Path } ,
10
10
transmission,
11
11
} ;
12
- use core:: time:: Duration ;
13
12
use s2n_quic_core:: {
14
13
ack,
15
- connection:: { self , PeerId } ,
14
+ connection:: { self , Limits , PeerId } ,
15
+ ensure,
16
16
event:: {
17
17
self ,
18
18
builder:: { DatagramDropReason , MtuUpdatedCause } ,
@@ -245,7 +245,7 @@ impl<Config: endpoint::Config> Manager<Config> {
245
245
congestion_controller_endpoint : & mut Config :: CongestionControllerEndpoint ,
246
246
migration_validator : & mut Config :: PathMigrationValidator ,
247
247
mtu_config : mtu:: Config ,
248
- initial_rtt : Duration ,
248
+ limits : & Limits ,
249
249
publisher : & mut Pub ,
250
250
) -> Result < ( Id , AmplificationOutcome ) , DatagramDropReason > {
251
251
let valid_initial_received = self . valid_initial_received ( ) ;
@@ -308,7 +308,7 @@ impl<Config: endpoint::Config> Manager<Config> {
308
308
congestion_controller_endpoint,
309
309
migration_validator,
310
310
mtu_config,
311
- initial_rtt ,
311
+ limits ,
312
312
publisher,
313
313
)
314
314
}
@@ -321,7 +321,7 @@ impl<Config: endpoint::Config> Manager<Config> {
321
321
congestion_controller_endpoint : & mut Config :: CongestionControllerEndpoint ,
322
322
migration_validator : & mut Config :: PathMigrationValidator ,
323
323
mtu_config : mtu:: Config ,
324
- initial_rtt : Duration ,
324
+ limits : & Limits ,
325
325
publisher : & mut Pub ,
326
326
) -> Result < ( Id , AmplificationOutcome ) , DatagramDropReason > {
327
327
//= https://www.rfc-editor.org/rfc/rfc9000#section-9
@@ -332,6 +332,17 @@ impl<Config: endpoint::Config> Manager<Config> {
332
332
let local_address = path_handle. local_address ( ) ;
333
333
let active_local_addr = self . active_path ( ) . local_address ( ) ;
334
334
let active_remote_addr = self . active_path ( ) . remote_address ( ) ;
335
+ // The peer has intentionally tried to migrate to a new path because they changed
336
+ // their destination_connection_id. This is considered an "active" migration.
337
+ let active_migration =
338
+ self . active_path ( ) . local_connection_id != datagram. destination_connection_id ;
339
+
340
+ if active_migration {
341
+ ensure ! (
342
+ limits. active_migration_enabled( ) ,
343
+ Err ( DatagramDropReason :: RejectedConnectionMigration )
344
+ )
345
+ }
335
346
336
347
// TODO set alpn if available
337
348
let attempt: migration:: Attempt = migration:: AttemptBuilder {
@@ -403,19 +414,21 @@ impl<Config: endpoint::Config> Manager<Config> {
403
414
// estimator for the new path, and they are initialized with initial values,
404
415
// we do not need to reset congestion controller and round-trip time estimator
405
416
// again on confirming the peer's ownership of its new address.
406
- let rtt = self . active_path ( ) . rtt_estimator . for_new_path ( initial_rtt) ;
417
+ let rtt = self
418
+ . active_path ( )
419
+ . rtt_estimator
420
+ . for_new_path ( limits. initial_round_trip_time ( ) ) ;
407
421
let path_info =
408
422
congestion_controller:: PathInfo :: new ( mtu_config. initial_mtu , & remote_address) ;
409
423
let cc = congestion_controller_endpoint. new_congestion_controller ( path_info) ;
410
424
411
425
let peer_connection_id = {
412
- if self . active_path ( ) . local_connection_id != datagram . destination_connection_id {
426
+ if active_migration {
413
427
//= https://www.rfc-editor.org/rfc/rfc9000#section-9.5
414
428
//# Similarly, an endpoint MUST NOT reuse a connection ID when sending to
415
429
//# more than one destination address.
416
430
417
- // Peer has intentionally tried to migrate to this new path because they changed
418
- // their destination_connection_id, so we will change our destination_connection_id as well.
431
+ // Active connection migrations must use a new connection ID
419
432
self . peer_id_registry
420
433
. consume_new_id_for_new_path ( )
421
434
. ok_or ( DatagramDropReason :: InsufficientConnectionIds ) ?
0 commit comments