Skip to content

Commit faae5ce

Browse files
committed
add CLI at quiche-client to retire DCIDs
1 parent 2aecdbb commit faae5ce

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

apps/src/args.rs

+38-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
use std::net::SocketAddr;
2828
use std::str::FromStr;
2929

30+
use itertools::Itertools;
31+
use quiche::CIDSeq;
32+
use quiche::PathId;
33+
3034
use super::common::alpns;
3135

3236
pub trait Args {
@@ -300,8 +304,9 @@ Options:
300304
--perform-migration Perform connection migration on another source port.
301305
--initial-max-path-id NUM Enable multipath support up to the number of paths.
302306
-A --address ADDR ... Specify addresses to be used instead of the unspecified address. Non-routable addresses will lead to connectivity issues.
303-
-R --rm-addr TIMEADDR ... Specify addresses to stop using after the provided time (format time,addr).
304-
-S --status TIMEADDRSTAT ... Specify availability status to advertise to the peer after the provided time (format time,addr,available).
307+
-R --rm-addr TIMEADDR ... Specify addresses to stop using after the provided time (format ms time,addr).
308+
-S --status TIMEADDRSTAT ... Specify availability status to advertise to the peer after the provided time (format ms time,addr,available).
309+
-T --retire-dcid TIMEPIDCID ... Specify CIDs to be retired on a specific path ID (format ms time,path id,CID).
305310
-H --header HEADER ... Add a request header.
306311
-n --requests REQUESTS Send the given number of identical requests [default: 1].
307312
--send-priority-update Send HTTP/3 priority updates if the query string params 'u' or 'i' are present in URLs
@@ -334,6 +339,7 @@ pub struct ClientArgs {
334339
pub addrs: Vec<SocketAddr>,
335340
pub rm_addrs: Vec<(std::time::Duration, SocketAddr)>,
336341
pub status: Vec<(std::time::Duration, SocketAddr, bool)>,
342+
pub retire_dcids: Vec<(std::time::Duration, PathId, CIDSeq)>,
337343
}
338344

339345
impl Args for ClientArgs {
@@ -425,15 +431,15 @@ impl Args for ClientArgs {
425431
if s.len() != 2 {
426432
return None;
427433
}
428-
let secs = match s[0].parse::<u64>() {
434+
let millis = match s[0].parse::<u64>() {
429435
Ok(s) => s,
430436
Err(_) => return None,
431437
};
432438
let addr = match SocketAddr::from_str(s[1]) {
433439
Ok(a) => a,
434440
Err(_) => return None,
435441
};
436-
Some((std::time::Duration::from_secs(secs), addr))
442+
Some((std::time::Duration::from_millis(millis), addr))
437443
})
438444
.collect();
439445

@@ -445,7 +451,7 @@ impl Args for ClientArgs {
445451
if s.len() != 3 {
446452
return None;
447453
}
448-
let secs = match s[0].parse::<u64>() {
454+
let millis = match s[0].parse::<u64>() {
449455
Ok(s) => s,
450456
Err(_) => return None,
451457
};
@@ -458,10 +464,34 @@ impl Args for ClientArgs {
458464
Ok(_) => true,
459465
Err(_) => return None,
460466
};
461-
Some((std::time::Duration::from_secs(secs), addr, status))
467+
Some((std::time::Duration::from_millis(millis), addr, status))
462468
})
463469
.collect();
464470

471+
let retire_dcids = args
472+
.get_vec("--retire-dcid")
473+
.into_iter()
474+
.filter_map(|ta| {
475+
let s = ta.split(',').collect_vec();
476+
if s.len() != 3 {
477+
return None;
478+
}
479+
let millis = match s[0].parse::<u64>() {
480+
Ok(s) => s,
481+
Err(_) => return None,
482+
};
483+
let path_id = match s[1].parse::<PathId>() {
484+
Ok(p) => p,
485+
Err(_) => return None,
486+
};
487+
let cid_seq = match s[2].parse::<CIDSeq>() {
488+
Ok(c) => c,
489+
Err(_) => return None,
490+
};
491+
Some((std::time::Duration::from_millis(millis), path_id, cid_seq))
492+
})
493+
.collect_vec();
494+
465495
ClientArgs {
466496
version,
467497
dump_response_path,
@@ -481,6 +511,7 @@ impl Args for ClientArgs {
481511
addrs,
482512
rm_addrs,
483513
status,
514+
retire_dcids,
484515
}
485516
}
486517
}
@@ -506,6 +537,7 @@ impl Default for ClientArgs {
506537
addrs: vec![],
507538
rm_addrs: vec![],
508539
status: vec![],
540+
retire_dcids: vec![],
509541
}
510542
}
511543
}

apps/src/client.rs

+15
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub fn connect(
9797

9898
let mut rm_addrs = args.rm_addrs.clone();
9999
let mut status = args.status.clone();
100+
let mut retire_dcids = args.retire_dcids.clone();
100101

101102
// Create the configuration for the QUIC connection.
102103
let mut config = quiche::Config::new(args.version).unwrap();
@@ -543,6 +544,20 @@ pub fn connect(
543544
});
544545
}
545546

547+
if conn.is_established() {
548+
retire_dcids.retain(|(d, path_id, cid_seq)| {
549+
if conn.available_dcids_on_path(*path_id) > 0 && app_data_start.elapsed() >= *d {
550+
info!("retiring DCID sequence number {cid_seq} with path_id {path_id}");
551+
if let Err(e) = conn.retire_dcid_on_path(*path_id, *cid_seq) {
552+
error!("error when retiring DCID: {e:?}");
553+
}
554+
false
555+
} else {
556+
true
557+
}
558+
});
559+
}
560+
546561
// Determine in which order we are going to iterate over paths.
547562
let scheduled_tuples = lowest_latency_scheduler(&conn);
548563

0 commit comments

Comments
 (0)