Skip to content

Commit 8f17a3b

Browse files
authored
Merge pull request #418 from Tencent/release/v1.4.0
Release/v1.4.0
2 parents db9a23f + 75138e9 commit 8f17a3b

17 files changed

+297
-75
lines changed

.github/workflows/rust.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ jobs:
144144
toolchain: stable
145145
target: 'aarch64-unknown-linux-ohos,armv7-unknown-linux-ohos,x86_64-unknown-linux-ohos'
146146

147-
- name: Run cargo build
148-
run: cargo install ohrs && ohrs build -- --verbose --features ffi --release
147+
- name: Install ohrs
148+
run: cargo install ohrs
149+
150+
- name: Run ohrs build
151+
run: ohrs build -- --verbose --features ffi --release
149152

150153
static_analysis:
151154
name: Static analysis

.github/workflows/tquic-features.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Features
2+
3+
on:
4+
push:
5+
branches: [ "develop" ]
6+
pull_request:
7+
branches: [ "develop" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
features:
14+
name: Build and test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: 'recursive'
20+
- name: Update rust
21+
run: rustup update
22+
- name: Build without default features
23+
run: cargo build --all --no-default-features && cargo test --no-default-features
24+
- name: Build with feature(s) ffi
25+
run: cargo build --all --no-default-features -F ffi && cargo test --no-default-features -F ffi
26+
- name: Build with feature(s) qlog
27+
run: cargo build --all --no-default-features -F qlog && cargo test --no-default-features -F qlog
28+
- name: Build with feature(s) ffi,qlog
29+
run: cargo build --all --no-default-features -F ffi,qlog && cargo test --no-default-features -F ffi,qlog
30+

.github/workflows/tquic-integration.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ jobs:
2626
- name: Run integration tests for disable_1rtt_encryption
2727
run: |
2828
cd tools/tests/
29-
bash ./tquic_tools_test.sh -b ../../target/debug/ -t multipath_roundrobin -c '~~disable-encryption' -s '~~disable-encryption'
30-
29+
bash ./tquic_tools_test.sh -b ../../target/release/ -t multipath_minrtt -c '~~disable-encryption' -s '~~disable-encryption'

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1212

1313

14+
## [v1.4.0] - 2024-10-28
15+
16+
### Added
17+
- Add `qlog` feature flag to reduce the size of complied library
18+
- Optimize pacing for acknowledgement packets
19+
- Minor tweaks for tquic_time_offset.py
20+
21+
### Fixed
22+
- Fix checking packet header under disable_1rtt_encryption mode
23+
- Fix the length of trancated packet number
24+
- Some fixes for tquic_tools_test.sh
25+
26+
1427
## [v1.3.1] - 2024-10-11
1528

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

328341

342+
[v1.4.0]: https://github.com/tencent/tquic/compare/v1.3.1...v1.4.0
329343
[v1.3.1]: https://github.com/tencent/tquic/compare/v1.3.0...v1.3.1
330344
[v1.3.0]: https://github.com/tencent/tquic/compare/v1.2.0...v1.3.0
331345
[v1.2.0]: https://github.com/tencent/tquic/compare/v1.1.0...v1.2.0

Cargo.toml

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tquic"
3-
version = "1.3.1"
3+
version = "1.4.0"
44
edition = "2021"
55
rust-version = "1.70.0"
66
license = "Apache-2.0"
@@ -25,10 +25,19 @@ include = [
2525
"/deps/boringssl/LICENSE",
2626
]
2727

28+
[package.metadata.docs.rs]
29+
no-default-features = true
30+
features = ["qlog"]
31+
2832
[features]
33+
default = ["qlog"]
34+
2935
# build the FFI API
3036
ffi = []
3137

38+
# enable support for the qlog
39+
qlog = ["dep:serde", "dep:serde_json", "dep:serde_derive", "dep:serde_with"]
40+
3241
[dependencies]
3342
bytes = "1"
3443
rustc-hash = "1.1"
@@ -43,10 +52,10 @@ strum_macros = "0.24"
4352
rand = "0.8.5"
4453
smallvec = { version = "1.10", features = ["serde", "union"] }
4554
lru = "0.12"
46-
serde = { version = "1.0.139", features = ["derive"] }
47-
serde_json = { version = "1.0", features = ["preserve_order"] }
48-
serde_derive = "1.0"
49-
serde_with = "3.0.0"
55+
serde = { version = "1.0.139", features = ["derive"], optional=true }
56+
serde_json = { version = "1.0", features = ["preserve_order"], optional=true }
57+
serde_derive = { version = "1.0", optional=true }
58+
serde_with = { version="3.0.0", optional=true }
5059
hex = "0.4"
5160
priority-queue = "1.3.2"
5261
sfv = { version = "0.9" }

src/build.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ fn new_boringssl_cmake_config() -> cmake::Config {
115115
for (name, value) in *params {
116116
boringssl_cmake.define(name, value);
117117
}
118-
// common arguments for ohos help us to ignore some error
119-
boringssl_cmake
120-
.define("CMAKE_C_FLAGS", "-Wno-unused-command-line-argument");
121-
boringssl_cmake
122-
.define("CMAKE_CXX_FLAGS", "-Wno-unused-command-line-argument");
118+
break;
123119
}
124120
}
125121

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

src/connection/connection.rs

+36-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ use crate::multipath_scheduler::*;
5252
use crate::packet;
5353
use crate::packet::PacketHeader;
5454
use crate::packet::PacketType;
55+
#[cfg(feature = "qlog")]
5556
use crate::qlog;
57+
#[cfg(feature = "qlog")]
5658
use crate::qlog::events;
5759
use crate::tls;
5860
use crate::tls::Keys;
@@ -160,6 +162,7 @@ pub struct Connection {
160162
context: Option<Box<dyn Any + Send + Sync>>,
161163

162164
/// Qlog writer
165+
#[cfg(feature = "qlog")]
163166
qlog: Option<qlog::QlogWriter>,
164167

165168
/// Unique trace id for deubg logging
@@ -272,6 +275,7 @@ impl Connection {
272275
events: EventQueue::default(),
273276
queues: None,
274277
context: None,
278+
#[cfg(feature = "qlog")]
275279
qlog: None,
276280
trace_id,
277281
};
@@ -357,6 +361,7 @@ impl Connection {
357361
/// Set qlog output to the given [`writer`]
358362
///
359363
/// [`Writer`]: https://doc.rust-lang.org/std/io/trait.Write.html
364+
#[cfg(feature = "qlog")]
360365
pub fn set_qlog(
361366
&mut self,
362367
writer: Box<dyn std::io::Write + Send + Sync>,
@@ -603,6 +608,7 @@ impl Connection {
603608
// Process each QUIC frame in the QUIC packet
604609
let mut ack_eliciting_pkt = false;
605610
let mut probing_pkt = true;
611+
#[cfg(feature = "qlog")]
606612
let mut qframes = vec![];
607613

608614
while !payload.is_empty() {
@@ -613,6 +619,7 @@ impl Connection {
613619
if !frame.probing() {
614620
probing_pkt = false;
615621
}
622+
#[cfg(feature = "qlog")]
616623
if self.qlog.is_some() {
617624
qframes.push(frame.to_qlog());
618625
}
@@ -622,6 +629,7 @@ impl Connection {
622629
}
623630

624631
// Write events to qlog.
632+
#[cfg(feature = "qlog")]
625633
if let Some(qlog) = &mut self.qlog {
626634
// Write TransportPacketReceived event to qlog.
627635
Self::qlog_quic_packet_received(qlog, &hdr, pkt_num, read, payload_len, qframes);
@@ -750,6 +758,7 @@ impl Connection {
750758
space_id,
751759
&mut self.spaces,
752760
handshake_status,
761+
#[cfg(feature = "qlog")]
753762
self.qlog.as_mut(),
754763
now,
755764
)?;
@@ -1205,6 +1214,7 @@ impl Connection {
12051214
self.flags.insert(AppliedPeerTransportParams);
12061215

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

14291439
// Write QuicStreamDataMoved event to qlog
1440+
#[cfg(feature = "qlog")]
14301441
if let Some(qlog) = &mut self.qlog {
14311442
Self::qlog_quic_data_acked(qlog, stream_id, offset, length);
14321443
}
@@ -1680,7 +1691,11 @@ impl Connection {
16801691
.tls_session
16811692
.get_overhead(level)
16821693
.ok_or(Error::InternalError)?;
1683-
let total_overhead = pkt_num_offset + pkt_num_len + crypto_overhead;
1694+
let total_overhead = if !self.is_encryption_disabled(hdr.pkt_type) {
1695+
pkt_num_offset + pkt_num_len + crypto_overhead
1696+
} else {
1697+
pkt_num_offset + pkt_num_len
1698+
};
16841699

16851700
match left.checked_sub(total_overhead) {
16861701
Some(val) => left = val,
@@ -1727,6 +1742,8 @@ impl Connection {
17271742
// fields) in bytes
17281743
let payload_len = write_status.written;
17291744
if pkt_type != PacketType::OneRTT {
1745+
// Note: This type of packet is always encrypted, even if the disable_1rtt_encryption
1746+
// transport parameter is successfully negotiated.
17301747
let len = pkt_num_len + payload_len + crypto_overhead;
17311748
let mut out = &mut out[hdr_offset..];
17321749
out.write_varint_with_len(len as u64, crate::LENGTH_FIELD_LEN)?;
@@ -1769,6 +1786,7 @@ impl Connection {
17691786
in_flight: write_status.in_flight,
17701787
has_data: write_status.has_data,
17711788
pmtu_probe: write_status.is_pmtu_probe,
1789+
pacing: write_status.pacing,
17721790
frames: write_status.frames,
17731791
rate_sample_state: Default::default(),
17741792
buffer_flags: write_status.buffer_flags,
@@ -1782,6 +1800,7 @@ impl Connection {
17821800
);
17831801

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

19161936
// Write PMTU probe frames
19171937
// Note: To probe the path MTU, the write size will exceed `left` but
@@ -3225,13 +3245,15 @@ impl Connection {
32253245
path.space_id,
32263246
&mut self.spaces,
32273247
handshake_status,
3248+
#[cfg(feature = "qlog")]
32283249
self.qlog.as_mut(),
32293250
now,
32303251
);
32313252
self.stats.lost_count += lost_pkts;
32323253
self.stats.lost_bytes += lost_bytes;
32333254

32343255
// Write RecoveryMetricsUpdate event to qlog.
3256+
#[cfg(feature = "qlog")]
32353257
if let Some(qlog) = &mut self.qlog {
32363258
path.recovery.qlog_recovery_metrics_updated(qlog);
32373259
}
@@ -3826,6 +3848,7 @@ impl Connection {
38263848
match self.streams.stream_read(stream_id, out) {
38273849
Ok((read, fin)) => {
38283850
// Write QuicStreamDataMoved event to qlog
3851+
#[cfg(feature = "qlog")]
38293852
if let Some(qlog) = &mut self.qlog {
38303853
Self::qlog_transport_data_read(qlog, stream_id, read_off.unwrap_or(0), read);
38313854
}
@@ -3844,6 +3867,7 @@ impl Connection {
38443867
match self.streams.stream_write(stream_id, buf, fin) {
38453868
Ok(written) => {
38463869
// Write QuicStreamDataMoved event to qlog
3870+
#[cfg(feature = "qlog")]
38473871
if let Some(qlog) = &mut self.qlog {
38483872
Self::qlog_transport_data_write(
38493873
qlog,
@@ -4066,6 +4090,7 @@ impl Connection {
40664090
}
40674091

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

40794104
/// Write a QuicPacketReceived event to the qlog.
4105+
#[cfg(feature = "qlog")]
40804106
fn qlog_quic_packet_received(
40814107
qlog: &mut qlog::QlogWriter,
40824108
hdr: &PacketHeader,
@@ -4112,6 +4138,7 @@ impl Connection {
41124138
}
41134139

41144140
/// Write a QuicPacketSent event to the qlog.
4141+
#[cfg(feature = "qlog")]
41154142
fn qlog_quic_packet_sent(
41164143
qlog: &mut qlog::QlogWriter,
41174144
hdr: &PacketHeader,
@@ -4150,6 +4177,7 @@ impl Connection {
41504177
}
41514178

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

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

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

4488+
/// Whether it consumes the pacer's tokens
4489+
pacing: bool,
4490+
44584491
/// Packet overhead (i.e. packet header and crypto overhead) in bytes
44594492
overhead: usize,
44604493

@@ -6271,6 +6304,7 @@ pub(crate) mod tests {
62716304
}
62726305

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

76347668
#[test]
7669+
#[cfg(feature = "qlog")]
76357670
fn conn_write_qlog() -> Result<()> {
76367671
let clog = NamedTempFile::new().unwrap();
76377672
let mut cfile = clog.reopen().unwrap();

0 commit comments

Comments
 (0)