Skip to content

Commit

Permalink
Merge pull request #418 from Tencent/release/v1.4.0
Browse files Browse the repository at this point in the history
Release/v1.4.0
  • Loading branch information
iyangsj authored Oct 28, 2024
2 parents db9a23f + 75138e9 commit 8f17a3b
Show file tree
Hide file tree
Showing 17 changed files with 297 additions and 75 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ jobs:
toolchain: stable
target: 'aarch64-unknown-linux-ohos,armv7-unknown-linux-ohos,x86_64-unknown-linux-ohos'

- name: Run cargo build
run: cargo install ohrs && ohrs build -- --verbose --features ffi --release
- name: Install ohrs
run: cargo install ohrs

- name: Run ohrs build
run: ohrs build -- --verbose --features ffi --release

static_analysis:
name: Static analysis
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/tquic-features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Features

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

env:
CARGO_TERM_COLOR: always

jobs:
features:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Update rust
run: rustup update
- name: Build without default features
run: cargo build --all --no-default-features && cargo test --no-default-features
- name: Build with feature(s) ffi
run: cargo build --all --no-default-features -F ffi && cargo test --no-default-features -F ffi
- name: Build with feature(s) qlog
run: cargo build --all --no-default-features -F qlog && cargo test --no-default-features -F qlog
- name: Build with feature(s) ffi,qlog
run: cargo build --all --no-default-features -F ffi,qlog && cargo test --no-default-features -F ffi,qlog

3 changes: 1 addition & 2 deletions .github/workflows/tquic-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ jobs:
- name: Run integration tests for disable_1rtt_encryption
run: |
cd tools/tests/
bash ./tquic_tools_test.sh -b ../../target/debug/ -t multipath_roundrobin -c '~~disable-encryption' -s '~~disable-encryption'
bash ./tquic_tools_test.sh -b ../../target/release/ -t multipath_minrtt -c '~~disable-encryption' -s '~~disable-encryption'
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [v1.4.0] - 2024-10-28

### Added
- Add `qlog` feature flag to reduce the size of complied library
- Optimize pacing for acknowledgement packets
- Minor tweaks for tquic_time_offset.py

### Fixed
- Fix checking packet header under disable_1rtt_encryption mode
- Fix the length of trancated packet number
- Some fixes for tquic_tools_test.sh


## [v1.3.1] - 2024-10-11

### Added
Expand Down Expand Up @@ -326,6 +339,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Provide example clients and servers.


[v1.4.0]: https://github.com/tencent/tquic/compare/v1.3.1...v1.4.0
[v1.3.1]: https://github.com/tencent/tquic/compare/v1.3.0...v1.3.1
[v1.3.0]: https://github.com/tencent/tquic/compare/v1.2.0...v1.3.0
[v1.2.0]: https://github.com/tencent/tquic/compare/v1.1.0...v1.2.0
Expand Down
19 changes: 14 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tquic"
version = "1.3.1"
version = "1.4.0"
edition = "2021"
rust-version = "1.70.0"
license = "Apache-2.0"
Expand All @@ -25,10 +25,19 @@ include = [
"/deps/boringssl/LICENSE",
]

[package.metadata.docs.rs]
no-default-features = true
features = ["qlog"]

[features]
default = ["qlog"]

# build the FFI API
ffi = []

# enable support for the qlog
qlog = ["dep:serde", "dep:serde_json", "dep:serde_derive", "dep:serde_with"]

[dependencies]
bytes = "1"
rustc-hash = "1.1"
Expand All @@ -43,10 +52,10 @@ strum_macros = "0.24"
rand = "0.8.5"
smallvec = { version = "1.10", features = ["serde", "union"] }
lru = "0.12"
serde = { version = "1.0.139", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_derive = "1.0"
serde_with = "3.0.0"
serde = { version = "1.0.139", features = ["derive"], optional=true }
serde_json = { version = "1.0", features = ["preserve_order"], optional=true }
serde_derive = { version = "1.0", optional=true }
serde_with = { version="3.0.0", optional=true }
hex = "0.4"
priority-queue = "1.3.2"
sfv = { version = "0.9" }
Expand Down
9 changes: 4 additions & 5 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ fn new_boringssl_cmake_config() -> cmake::Config {
for (name, value) in *params {
boringssl_cmake.define(name, value);
}
// common arguments for ohos help us to ignore some error
boringssl_cmake
.define("CMAKE_C_FLAGS", "-Wno-unused-command-line-argument");
boringssl_cmake
.define("CMAKE_CXX_FLAGS", "-Wno-unused-command-line-argument");
break;
}
}

Expand All @@ -129,6 +125,9 @@ fn new_boringssl_cmake_config() -> cmake::Config {
let toolchain_file = ohos_ndk_home.join("native/build/cmake/ohos.toolchain.cmake");
let toolchain_file = toolchain_file.to_str().unwrap();
boringssl_cmake.define("CMAKE_TOOLCHAIN_FILE", toolchain_file);
// common arguments for ohos help us to ignore some error
boringssl_cmake.define("CMAKE_C_FLAGS", "-Wno-unused-command-line-argument");
boringssl_cmake.define("CMAKE_CXX_FLAGS", "-Wno-unused-command-line-argument");
}
}

Expand Down
37 changes: 36 additions & 1 deletion src/connection/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ use crate::multipath_scheduler::*;
use crate::packet;
use crate::packet::PacketHeader;
use crate::packet::PacketType;
#[cfg(feature = "qlog")]
use crate::qlog;
#[cfg(feature = "qlog")]
use crate::qlog::events;
use crate::tls;
use crate::tls::Keys;
Expand Down Expand Up @@ -160,6 +162,7 @@ pub struct Connection {
context: Option<Box<dyn Any + Send + Sync>>,

/// Qlog writer
#[cfg(feature = "qlog")]
qlog: Option<qlog::QlogWriter>,

/// Unique trace id for deubg logging
Expand Down Expand Up @@ -272,6 +275,7 @@ impl Connection {
events: EventQueue::default(),
queues: None,
context: None,
#[cfg(feature = "qlog")]
qlog: None,
trace_id,
};
Expand Down Expand Up @@ -357,6 +361,7 @@ impl Connection {
/// Set qlog output to the given [`writer`]
///
/// [`Writer`]: https://doc.rust-lang.org/std/io/trait.Write.html
#[cfg(feature = "qlog")]
pub fn set_qlog(
&mut self,
writer: Box<dyn std::io::Write + Send + Sync>,
Expand Down Expand Up @@ -603,6 +608,7 @@ impl Connection {
// Process each QUIC frame in the QUIC packet
let mut ack_eliciting_pkt = false;
let mut probing_pkt = true;
#[cfg(feature = "qlog")]
let mut qframes = vec![];

while !payload.is_empty() {
Expand All @@ -613,6 +619,7 @@ impl Connection {
if !frame.probing() {
probing_pkt = false;
}
#[cfg(feature = "qlog")]
if self.qlog.is_some() {
qframes.push(frame.to_qlog());
}
Expand All @@ -622,6 +629,7 @@ impl Connection {
}

// Write events to qlog.
#[cfg(feature = "qlog")]
if let Some(qlog) = &mut self.qlog {
// Write TransportPacketReceived event to qlog.
Self::qlog_quic_packet_received(qlog, &hdr, pkt_num, read, payload_len, qframes);
Expand Down Expand Up @@ -750,6 +758,7 @@ impl Connection {
space_id,
&mut self.spaces,
handshake_status,
#[cfg(feature = "qlog")]
self.qlog.as_mut(),
now,
)?;
Expand Down Expand Up @@ -1205,6 +1214,7 @@ impl Connection {
self.flags.insert(AppliedPeerTransportParams);

// Write TransportParametersSet event to qlog.
#[cfg(feature = "qlog")]
if let Some(qlog) = &mut self.qlog {
Self::qlog_quic_params_set(
qlog,
Expand Down Expand Up @@ -1427,6 +1437,7 @@ impl Connection {
.on_stream_frame_acked(stream_id, offset, length);

// Write QuicStreamDataMoved event to qlog
#[cfg(feature = "qlog")]
if let Some(qlog) = &mut self.qlog {
Self::qlog_quic_data_acked(qlog, stream_id, offset, length);
}
Expand Down Expand Up @@ -1680,7 +1691,11 @@ impl Connection {
.tls_session
.get_overhead(level)
.ok_or(Error::InternalError)?;
let total_overhead = pkt_num_offset + pkt_num_len + crypto_overhead;
let total_overhead = if !self.is_encryption_disabled(hdr.pkt_type) {
pkt_num_offset + pkt_num_len + crypto_overhead
} else {
pkt_num_offset + pkt_num_len
};

match left.checked_sub(total_overhead) {
Some(val) => left = val,
Expand Down Expand Up @@ -1727,6 +1742,8 @@ impl Connection {
// fields) in bytes
let payload_len = write_status.written;
if pkt_type != PacketType::OneRTT {
// Note: This type of packet is always encrypted, even if the disable_1rtt_encryption
// transport parameter is successfully negotiated.
let len = pkt_num_len + payload_len + crypto_overhead;
let mut out = &mut out[hdr_offset..];
out.write_varint_with_len(len as u64, crate::LENGTH_FIELD_LEN)?;
Expand Down Expand Up @@ -1769,6 +1786,7 @@ impl Connection {
in_flight: write_status.in_flight,
has_data: write_status.has_data,
pmtu_probe: write_status.is_pmtu_probe,
pacing: write_status.pacing,
frames: write_status.frames,
rate_sample_state: Default::default(),
buffer_flags: write_status.buffer_flags,
Expand All @@ -1782,6 +1800,7 @@ impl Connection {
);

// Write events to qlog.
#[cfg(feature = "qlog")]
if let Some(qlog) = &mut self.qlog {
// Write TransportPacketSent event to qlog.
let mut qframes = Vec::with_capacity(sent_pkt.frames.len());
Expand Down Expand Up @@ -1912,6 +1931,7 @@ impl Connection {
if !st.is_probe && !r.can_send() {
return Err(Error::Done);
}
st.pacing = true;

// Write PMTU probe frames
// Note: To probe the path MTU, the write size will exceed `left` but
Expand Down Expand Up @@ -3225,13 +3245,15 @@ impl Connection {
path.space_id,
&mut self.spaces,
handshake_status,
#[cfg(feature = "qlog")]
self.qlog.as_mut(),
now,
);
self.stats.lost_count += lost_pkts;
self.stats.lost_bytes += lost_bytes;

// Write RecoveryMetricsUpdate event to qlog.
#[cfg(feature = "qlog")]
if let Some(qlog) = &mut self.qlog {
path.recovery.qlog_recovery_metrics_updated(qlog);
}
Expand Down Expand Up @@ -3826,6 +3848,7 @@ impl Connection {
match self.streams.stream_read(stream_id, out) {
Ok((read, fin)) => {
// Write QuicStreamDataMoved event to qlog
#[cfg(feature = "qlog")]
if let Some(qlog) = &mut self.qlog {
Self::qlog_transport_data_read(qlog, stream_id, read_off.unwrap_or(0), read);
}
Expand All @@ -3844,6 +3867,7 @@ impl Connection {
match self.streams.stream_write(stream_id, buf, fin) {
Ok(written) => {
// Write QuicStreamDataMoved event to qlog
#[cfg(feature = "qlog")]
if let Some(qlog) = &mut self.qlog {
Self::qlog_transport_data_write(
qlog,
Expand Down Expand Up @@ -4066,6 +4090,7 @@ impl Connection {
}

/// Write a QuicParametersSet event to the qlog.
#[cfg(feature = "qlog")]
fn qlog_quic_params_set(
qlog: &mut qlog::QlogWriter,
params: &TransportParams,
Expand All @@ -4077,6 +4102,7 @@ impl Connection {
}

/// Write a QuicPacketReceived event to the qlog.
#[cfg(feature = "qlog")]
fn qlog_quic_packet_received(
qlog: &mut qlog::QlogWriter,
hdr: &PacketHeader,
Expand Down Expand Up @@ -4112,6 +4138,7 @@ impl Connection {
}

/// Write a QuicPacketSent event to the qlog.
#[cfg(feature = "qlog")]
fn qlog_quic_packet_sent(
qlog: &mut qlog::QlogWriter,
hdr: &PacketHeader,
Expand Down Expand Up @@ -4150,6 +4177,7 @@ impl Connection {
}

/// Write a QuicStreamDataMoved event to the qlog.
#[cfg(feature = "qlog")]
fn qlog_quic_data_acked(
qlog: &mut qlog::QlogWriter,
stream_id: u64,
Expand All @@ -4168,6 +4196,7 @@ impl Connection {
}

/// Write a QuicStreamDataMoved event to the qlog.
#[cfg(feature = "qlog")]
fn qlog_transport_data_read(
qlog: &mut qlog::QlogWriter,
stream_id: u64,
Expand All @@ -4186,6 +4215,7 @@ impl Connection {
}

/// Write a QuicStreamDataMoved event to the qlog.
#[cfg(feature = "qlog")]
fn qlog_transport_data_write(
qlog: &mut qlog::QlogWriter,
stream_id: u64,
Expand Down Expand Up @@ -4455,6 +4485,9 @@ struct FrameWriteStatus {
/// Whether it is a PMTU probe packet
is_pmtu_probe: bool,

/// Whether it consumes the pacer's tokens
pacing: bool,

/// Packet overhead (i.e. packet header and crypto overhead) in bytes
overhead: usize,

Expand Down Expand Up @@ -6271,6 +6304,7 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "qlog")]
fn ping() -> Result<()> {
let mut client_config = TestPair::new_test_config(false)?;
client_config.enable_dplpmtud(false);
Expand Down Expand Up @@ -7632,6 +7666,7 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "qlog")]
fn conn_write_qlog() -> Result<()> {
let clog = NamedTempFile::new().unwrap();
let mut cfile = clog.reopen().unwrap();
Expand Down
Loading

0 comments on commit 8f17a3b

Please sign in to comment.