Skip to content

Commit

Permalink
Merge branch 'main' into test-cargo-fuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert authored Apr 11, 2024
2 parents f7dae6f + b3cf65f commit c9d7d8a
Show file tree
Hide file tree
Showing 30 changed files with 832 additions and 346 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
!**/*.rs
!**/*.h
!**/*.hpp
!neqo-crypto/min_version.txt
!qns
!Cargo.lock
4 changes: 4 additions & 0 deletions .github/actions/pr-comment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
name:
description: 'Artifact name to import comment data from.'
required: true
mode:
description: 'Mode of operation (upsert/recreate/delete).'
default: 'upsert'
token:
description: 'A Github PAT'
required: true
Expand All @@ -29,5 +32,6 @@ runs:
- uses: thollander/actions-comment-pull-request@v2
with:
filePath: contents
mode: ${{ inputs.mode }}
pr_number: ${{ steps.pr-number.outputs.number }}
comment_tag: ${{ inputs.name }}-comment
8 changes: 6 additions & 2 deletions .github/actions/quic-interop-runner/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ runs:
run: |
echo '[**QUIC Interop Runner**](https://github.com/quic-interop/quic-interop-runner)' >> comment
echo '' >> comment
# Ignore all, but table, which starts with "|".
grep -E '^\|' quic-interop-runner/summary >> comment
# Ignore all, but table, which starts with "|". Also reformat it to GitHub Markdown.
grep -E '^\|' quic-interop-runner/summary |\
awk '(!/^\| *:-/ || (d++ && d < 3))' |\
sed -E -e 's/✓/:white_check_mark:/gi' -e 's/✕/:x:/gi' -e 's/\?/:grey_question:/gi' \
>> comment
echo '' >> comment
echo "EXPORT_COMMENT=1" >> "$GITHUB_ENV"
shell: bash

- name: Export PR comment data
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qns-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
if: |
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'failure'
github.event.workflow_run.event == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/pr-comment
with:
name: qns
mode: ${{ github.event.workflow_run.conclusion == 'success' && 'delete' || 'upsert' }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/qns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ jobs:
name: 'neqo-latest'
image: ${{ steps.docker_build_and_push.outputs.imageID }}
url: https://github.com/mozilla/neqo
test: handshake
test: handshake,keyupdate
client: neqo-latest,quic-go,ngtcp2,neqo,msquic
server: neqo-latest,quic-go,ngtcp2,neqo,msquic
21 changes: 11 additions & 10 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '26 8 * * 6'
push:
branches: [ "main" ]
workflow_dispatch:
# # For Branch-Protection check. Only the default branch is supported. See
# # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
# branch_protection_rule:
# # To guarantee Maintained check is occasionally updated. See
# # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
# schedule:
# - cron: '26 8 * * 6'
# push:
# branches: [ "main" ]

# Declare default permissions as read only.
permissions: read-all
Expand Down Expand Up @@ -67,6 +68,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resolver = "2"
homepage = "https://github.com/mozilla/neqo/"
repository = "https://github.com/mozilla/neqo/"
authors = ["The Neqo Authors <necko@mozilla.com>"]
version = "0.7.3"
version = "0.7.4"
# Keep in sync with `.rustfmt.toml` `edition`.
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
14 changes: 4 additions & 10 deletions neqo-bin/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use tokio::runtime::Runtime;
struct Benchmark {
name: String,
requests: Vec<u64>,
/// Download resources in series using separate connections.
download_in_series: bool,
sample_size: Option<usize>,
}

Expand All @@ -27,25 +25,21 @@ fn transfer(c: &mut Criterion) {
for Benchmark {
name,
requests,
download_in_series,
sample_size,
} in [
Benchmark {
name: "1-conn/1-100mb-resp (aka. Download)".to_string(),
requests: vec![100 * 1024 * 1024],
download_in_series: false,
sample_size: Some(10),
},
Benchmark {
name: "1-conn/10_000-1b-seq-resp (aka. RPS)".to_string(),
name: "1-conn/10_000-parallel-1b-resp (aka. RPS)".to_string(),
requests: vec![1; 10_000],
download_in_series: false,
sample_size: None,
},
Benchmark {
name: "100-seq-conn/1-1b-resp (aka. HPS)".to_string(),
requests: vec![1; 100],
download_in_series: true,
name: "1-conn/1-1b-resp (aka. HPS)".to_string(),
requests: vec![1; 1],
sample_size: None,
},
] {
Expand All @@ -61,7 +55,7 @@ fn transfer(c: &mut Criterion) {
}
group.bench_function("client", |b| {
b.to_async(Runtime::new().unwrap()).iter_batched(
|| client::client(client::Args::new(&requests, download_in_series)),
|| client::client(client::Args::new(&requests)),
|client| async move {
client.await.unwrap();
},
Expand Down
53 changes: 33 additions & 20 deletions neqo-bin/src/client/http09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,39 @@ use std::{
use neqo_common::{event::Provider, qdebug, qinfo, qwarn, Datagram};
use neqo_crypto::{AuthenticationStatus, ResumptionToken};
use neqo_transport::{
Connection, ConnectionEvent, EmptyConnectionIdGenerator, Error, Output, State, StreamId,
StreamType,
Connection, ConnectionError, ConnectionEvent, EmptyConnectionIdGenerator, Error, Output, State,
StreamId, StreamType,
};
use url::Url;

use super::{get_output_file, qlog_new, Args, KeyUpdateState, Res};
use super::{get_output_file, qlog_new, Args, Res};

pub struct Handler<'a> {
streams: HashMap<StreamId, Option<BufWriter<File>>>,
url_queue: VecDeque<Url>,
all_paths: Vec<PathBuf>,
args: &'a Args,
token: Option<ResumptionToken>,
key_update: KeyUpdateState,
needs_key_update: bool,
}

impl<'a> super::Handler for Handler<'a> {
type Client = Connection;

fn handle(&mut self, client: &mut Self::Client) -> Res<bool> {
while let Some(event) = client.next_event() {
if self.needs_key_update {
match client.initiate_key_update() {
Ok(()) => {
qdebug!("Keys updated");
self.needs_key_update = false;
self.download_urls(client);
}
Err(neqo_transport::Error::KeyUpdateBlocked) => (),
Err(e) => return Err(e.into()),
}
}

match event {
ConnectionEvent::AuthenticationNeeded => {
client.authenticated(AuthenticationStatus::Ok, Instant::now());
Expand All @@ -66,9 +78,6 @@ impl<'a> super::Handler for Handler<'a> {
qdebug!("{event:?}");
self.download_urls(client);
}
ConnectionEvent::StateChange(State::Confirmed) => {
self.maybe_key_update(client)?;
}
ConnectionEvent::ResumptionToken(token) => {
self.token = Some(token);
}
Expand All @@ -86,12 +95,6 @@ impl<'a> super::Handler for Handler<'a> {
Ok(false)
}

fn maybe_key_update(&mut self, c: &mut Self::Client) -> Res<()> {
self.key_update.maybe_update(|| c.initiate_key_update())?;
self.download_urls(c);
Ok(())
}

fn take_token(&mut self) -> Option<ResumptionToken> {
self.token.take()
}
Expand Down Expand Up @@ -138,8 +141,15 @@ pub(crate) fn create_client(
}

impl super::Client for Connection {
fn process(&mut self, dgram: Option<&Datagram>, now: Instant) -> Output {
self.process(dgram, now)
fn process_output(&mut self, now: Instant) -> Output {
self.process_output(now)
}

fn process_multiple_input<'a, I>(&mut self, dgrams: I, now: Instant)
where
I: IntoIterator<Item = &'a Datagram>,
{
self.process_multiple_input(dgrams, now);
}

fn close<S>(&mut self, now: Instant, app_error: neqo_transport::AppError, msg: S)
Expand All @@ -149,8 +159,11 @@ impl super::Client for Connection {
self.close(now, app_error, msg);
}

fn is_closed(&self) -> bool {
matches!(self.state(), State::Closed(..))
fn is_closed(&self) -> Option<ConnectionError> {
if let State::Closed(err) = self.state() {
return Some(err.clone());
}
None
}

fn stats(&self) -> neqo_transport::Stats {
Expand All @@ -159,14 +172,14 @@ impl super::Client for Connection {
}

impl<'b> Handler<'b> {
pub fn new(url_queue: VecDeque<Url>, args: &'b Args, key_update: KeyUpdateState) -> Self {
pub fn new(url_queue: VecDeque<Url>, args: &'b Args) -> Self {
Self {
streams: HashMap::new(),
url_queue,
all_paths: Vec::new(),
args,
token: None,
key_update,
needs_key_update: args.key_update,
}
}

Expand All @@ -185,7 +198,7 @@ impl<'b> Handler<'b> {
}

fn download_next(&mut self, client: &mut Connection) -> bool {
if self.key_update.needed() {
if self.needs_key_update {
qdebug!("Deferring requests until after first key update");
return false;
}
Expand Down
37 changes: 18 additions & 19 deletions neqo-bin/src/client/http3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ use neqo_common::{event::Provider, hex, qdebug, qinfo, qwarn, Datagram, Header};
use neqo_crypto::{AuthenticationStatus, ResumptionToken};
use neqo_http3::{Error, Http3Client, Http3ClientEvent, Http3Parameters, Http3State, Priority};
use neqo_transport::{
AppError, Connection, EmptyConnectionIdGenerator, Error as TransportError, Output, StreamId,
AppError, Connection, ConnectionError, EmptyConnectionIdGenerator, Error as TransportError,
Output, StreamId,
};
use url::Url;

use super::{get_output_file, qlog_new, Args, KeyUpdateState, Res};
use super::{get_output_file, qlog_new, Args, Res};

pub(crate) struct Handler<'a> {
#[allow(
Expand All @@ -35,17 +36,12 @@ pub(crate) struct Handler<'a> {
clippy::redundant_field_names
)]
url_handler: UrlHandler<'a>,
key_update: KeyUpdateState,
token: Option<ResumptionToken>,
output_read_data: bool,
}

impl<'a> Handler<'a> {
pub(crate) fn new(
url_queue: VecDeque<Url>,
args: &'a Args,
key_update: KeyUpdateState,
) -> Self {
pub(crate) fn new(url_queue: VecDeque<Url>, args: &'a Args) -> Self {
let url_handler = UrlHandler {
url_queue,
stream_handlers: HashMap::new(),
Expand All @@ -60,7 +56,6 @@ impl<'a> Handler<'a> {

Self {
url_handler,
key_update,
token: None,
output_read_data: args.output_read_data,
}
Expand Down Expand Up @@ -111,12 +106,22 @@ pub(crate) fn create_client(
}

impl super::Client for Http3Client {
fn is_closed(&self) -> bool {
matches!(self.state(), Http3State::Closed(..))
fn is_closed(&self) -> Option<ConnectionError> {
if let Http3State::Closed(err) = self.state() {
return Some(err);
}
None
}

fn process(&mut self, dgram: Option<&Datagram>, now: Instant) -> Output {
self.process(dgram, now)
fn process_output(&mut self, now: Instant) -> Output {
self.process_output(now)
}

fn process_multiple_input<'a, I>(&mut self, dgrams: I, now: Instant)
where
I: IntoIterator<Item = &'a Datagram>,
{
self.process_multiple_input(dgrams, now);
}

fn close<S>(&mut self, now: Instant, app_error: AppError, msg: S)
Expand Down Expand Up @@ -214,12 +219,6 @@ impl<'a> super::Handler for Handler<'a> {
Ok(self.url_handler.done())
}

fn maybe_key_update(&mut self, c: &mut Http3Client) -> Res<()> {
self.key_update.maybe_update(|| c.initiate_key_update())?;
self.url_handler.process_urls(c);
Ok(())
}

fn take_token(&mut self) -> Option<ResumptionToken> {
self.token.take()
}
Expand Down
Loading

0 comments on commit c9d7d8a

Please sign in to comment.