@@ -14,7 +14,7 @@ use crate::{
1414use core:: time:: Duration ;
1515use s2n_quic_core:: {
1616 connection:: limits:: ANTI_AMPLIFICATION_MULTIPLIER ,
17- event:: { builder :: MigrationDenyReason , testing:: Publisher } ,
17+ event:: testing:: Publisher ,
1818 inet:: { DatagramInfo , ExplicitCongestionNotification , SocketAddress } ,
1919 path:: { migration, RemoteAddress } ,
2020 random:: { self , Generator } ,
@@ -982,6 +982,9 @@ fn limit_number_of_connection_migrations() {
982982 assert_eq ! ( total_paths, MAX_ALLOWED_PATHS ) ;
983983}
984984
985+ // Connection migration is still allowed to proceed even if the `disable_active_migration`
986+ // transport parameter is sent, as there is no way to definitely distinguish an active
987+ // migration from a NAT rebind.
985988#[ test]
986989fn active_connection_migration_disabled ( ) {
987990 // Setup:
@@ -1015,13 +1018,14 @@ fn active_connection_migration_disabled() {
10151018 let new_addr: SocketAddr = "127.0.0.2:1" . parse ( ) . unwrap ( ) ;
10161019 let new_addr = SocketAddress :: from ( new_addr) ;
10171020 let new_addr = RemoteAddress :: from ( new_addr) ;
1018- let new_cid = connection:: LocalId :: try_from_bytes ( b"id02" ) . unwrap ( ) ;
1021+ let new_cid_1 = connection:: LocalId :: try_from_bytes ( b"id02" ) . unwrap ( ) ;
1022+ let new_cid_2 = connection:: LocalId :: try_from_bytes ( b"id03" ) . unwrap ( ) ;
10191023 let now = NoopClock { } . get_time ( ) ;
10201024 let mut datagram = DatagramInfo {
10211025 timestamp : now,
10221026 payload_len : 0 ,
10231027 ecn : ExplicitCongestionNotification :: default ( ) ,
1024- destination_connection_id : new_cid ,
1028+ destination_connection_id : new_cid_1 ,
10251029 destination_connection_id_classification : connection:: id:: Classification :: Local ,
10261030 source_connection_id : None ,
10271031 } ;
@@ -1040,16 +1044,21 @@ fn active_connection_migration_disabled() {
10401044 & mut publisher,
10411045 ) ;
10421046
1043- // The active migration is rejected
1044- assert ! ( matches!(
1045- res,
1046- Err ( DatagramDropReason :: RejectedConnectionMigration {
1047- reason: MigrationDenyReason :: ConnectionMigrationDisabled { .. }
1048- } )
1049- ) ) ;
1050- assert_eq ! ( 1 , manager. paths. len( ) ) ;
1047+ // The migration succeeds
1048+ assert ! ( res. is_ok( ) ) ;
1049+ assert_eq ! ( 2 , manager. paths. len( ) ) ;
1050+ // The new path uses a new CID since there were enough supplied
1051+ assert_eq ! (
1052+ manager. paths[ res. unwrap( ) . 0 . as_u8( ) as usize ] . peer_connection_id,
1053+ id_3
1054+ ) ;
1055+
1056+ // Clear the pending packet authentication to allow another migration to proceed
1057+ manager. pending_packet_authentication = None ;
10511058
10521059 // Try an active connection migration with active migration enabled (default)
1060+ datagram. destination_connection_id = new_cid_2;
1061+
10531062 let res = manager. handle_connection_migration (
10541063 & new_addr,
10551064 & datagram,
@@ -1062,7 +1071,12 @@ fn active_connection_migration_disabled() {
10621071
10631072 // The migration succeeds
10641073 assert ! ( res. is_ok( ) ) ;
1065- assert_eq ! ( 2 , manager. paths. len( ) ) ;
1074+ assert_eq ! ( 3 , manager. paths. len( ) ) ;
1075+ // The new path uses the existing id since there wasn't a new one available
1076+ assert_eq ! (
1077+ manager. paths[ res. unwrap( ) . 0 . as_u8( ) as usize ] . peer_connection_id,
1078+ id_2
1079+ ) ;
10661080
10671081 // Now try a non-active (passive) migration, with active migration disabled
10681082 // the same CID is used, so it's not an active migration
@@ -1088,7 +1102,12 @@ fn active_connection_migration_disabled() {
10881102
10891103 // The passive migration succeeds
10901104 assert ! ( res. is_ok( ) ) ;
1091- assert_eq ! ( 3 , manager. paths. len( ) ) ;
1105+ assert_eq ! ( 4 , manager. paths. len( ) ) ;
1106+ // The new path uses the existing id since the peer did not change their destination CID
1107+ assert_eq ! (
1108+ manager. paths[ res. unwrap( ) . 0 . as_u8( ) as usize ] . peer_connection_id,
1109+ id_2
1110+ ) ;
10921111}
10931112
10941113#[ test]
0 commit comments