Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve rtr client version negotiation. #282

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/rtr/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@

const IO_TIMEOUT: Duration = Duration::from_secs(10);

/// The protocol version we initially propose.
///
/// While the client technically supports version 2 as well, the format of the
/// ASPA PDU has not yet been agreed upon. Rather than possibly deploying
/// broken servers, we only start with version 1 for now.
const INITIAL_VERSION: u8 = 1;


//------------ PayloadTarget -------------------------------------------------

Expand Down Expand Up @@ -191,7 +198,7 @@

/// Returns the protocol version to use.
fn version(&self) -> u8 {
self.version.unwrap_or(1)
self.version.unwrap_or(INITIAL_VERSION)
}
}

Expand Down Expand Up @@ -426,6 +433,15 @@
Ok(())
}
}
else if version > INITIAL_VERSION {
Err(io::Error::new(
io::ErrorKind::InvalidData,
format!(
"server requested unsupported protocol version {}",
version
)
))
}
else {
self.version = Some(version);
Ok(())
Expand All @@ -442,7 +458,7 @@
Response(pdu::CacheResponse),

/// A reset response. We need to retry with a reset query.
Reset(pdu::CacheReset),

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (macOS-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (macOS-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (macOS-latest, nightly)

field `0` is never read

Check warning on line 461 in src/rtr/client.rs

View workflow job for this annotation

GitHub Actions / test (macOS-latest, nightly)

field `0` is never read
}

impl FirstReply {
Expand Down
6 changes: 5 additions & 1 deletion src/rtr/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ use super::state::State;
/// The maximum protocol version we support.
///
/// We support all protocol versions from 0 up to and including this value.
const MAX_VERSION: u8 = 2;
///
/// While the server technically supports version 2 as well, the format of the
/// ASPA PDU has not yet been agreed upon. Rather than possibly deploying
/// broken servers, we only announce support for version 0 or 1 for now.
const MAX_VERSION: u8 = 1;

//============ Traits ========================================================

Expand Down