Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7216686
chore(ktls): sort and update deps
cxw620 Aug 28, 2025
197ac8a
PR 62: partial: optimize workspace
cxw620 Aug 27, 2025
fed94a7
PR 62: partial: add rustfmt
cxw620 Aug 27, 2025
f19c87d
PR 62: partial: add lints like rustls
cxw620 Aug 27, 2025
9ea2dce
refactor(setup): setup ULP and TLS params [NOT COMPILED]
cxw620 Aug 28, 2025
91995c9
PR 62: partial: make logging optional [NOT COMPILED]
cxw620 Aug 27, 2025
4545957
PR 62: partial: implement enum KeyUpdateRequest since rustls doesn't …
cxw620 Aug 27, 2025
7742408
refactor(ktls): unified error type [NOT COMPILED]
cxw620 Aug 28, 2025
f95b5da
PR 62: partial: implement KtlsStream [NOT COMPILED]
cxw620 Aug 27, 2025
7e691ed
PR 62: partial: implement Read / Write for KtlsStream
cxw620 Aug 27, 2025
591993d
PR 62: partial: optional implement AsyncRead / AsyncWrite for KtlsStream
cxw620 Aug 27, 2025
02aa230
refactor(probe): probe ktls compatibility
cxw620 Aug 28, 2025
0db74e5
PR 62: partial: export most-frequently-used type
cxw620 Aug 27, 2025
25b5909
PR 62: partial: prepare ktls-util crate
cxw620 Aug 27, 2025
722f28e
PR 62: partial: implement KtlsConnector in ktls-util
cxw620 Aug 27, 2025
0fa74fe
PR 62: partial: implement KtlsAcceptor in ktls-util
cxw620 Aug 27, 2025
677c79d
PR 62: partial: export raw-apis of KtlsStream
cxw620 Aug 27, 2025
e58ecf1
PR 62: partial: tests and examples
cxw620 Aug 27, 2025
4dd5fe7
PR 62: partial: adjust Justfile
cxw620 Aug 27, 2025
b3dfee6
PR 62: partial: adjust CI tests
cxw620 Aug 27, 2025
f21ef5f
PR 62: partial: add CI: kernel compatibility test
cxw620 Aug 27, 2025
2f43fd6
PR 62: partial: fix MSRV and clippy
cxw620 Aug 27, 2025
87ad314
PR 62: partial: cargo docs
cxw620 Aug 27, 2025
5ea6fa1
PR 62: partial: cleanup
cxw620 Aug 27, 2025
9f1fe01
PR 62: partial: adjust README
cxw620 Aug 27, 2025
449bf63
fix(ci): checkout no persist credentials
cxw620 Aug 27, 2025
2c838fa
[skip ci] apply rustfmt
cxw620 Aug 28, 2025
8a44203
refactor: replace pin-project with lite version
cxw620 Aug 28, 2025
d9b529b
refactor: remove thiserror (syn)
cxw620 Aug 28, 2025
9605c84
refactor: adjust default features
cxw620 Aug 28, 2025
54af664
fix: clippy and cargo-doc, and feature flag
cxw620 Aug 28, 2025
1e6fdb5
fix: add Debug impl back for KtlsStream
cxw620 Aug 30, 2025
cd4f967
fix: update debug desc of InvalidCryptoInfo::UnsupportedCipherSuite
cxw620 Sep 3, 2025
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
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the CI changes should go into a separate PR.


on:
push:
branches: ["main"]
pull_request:
merge_group:

permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1

jobs:
test:
name: Test (Rust ${{matrix.toolchain}}, target ${{matrix.target}})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: ["nightly", "beta", "stable"]
target: ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.toolchain}}
components: llvm-tools, clippy, rust-src
- uses: taiki-e/install-action@v2
with:
tool: just,cargo-llvm-cov,cargo-nextest
- name: Enable type layout randomization
if: matrix.toolchain == 'nightly'
run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV
- run: sudo apt-get update && sudo apt-get install -y musl-tools
if: endsWith(matrix.target, 'musl')
- run: rustup target add ${{matrix.target}}
- run: just example client --target ${{matrix.target}}
- run: just build --tests --release --target ${{matrix.target}}
- run: just ci-test --target ${{matrix.target}}

msrv:
name: MSRV
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.77.0
- uses: taiki-e/install-action@v2
with:
tool: just
- run: just build --package ktls
- run: just build --package ktls-sys
- run: just build --package ktls-test
- run: just build --package ktls-util

doc:
name: Documentation
runs-on: ubuntu-latest
timeout-minutes: 45
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/install@cargo-docs-rs
- run: cargo docs-rs --package ktls

clippy:
name: Clippy
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.77.0
components: clippy
- uses: taiki-e/install-action@v2
with:
tool: just
- run: just clippy

coverage:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.77.0
components: llvm-tools, clippy, rust-src
- uses: taiki-e/install-action@v2
with:
tool: just,cargo-llvm-cov,cargo-nextest
- run: just example client
- run: just build --tests --release
- run: just ci-test
- name: Upload coverage information
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov
187 changes: 187 additions & 0 deletions .github/workflows/kernel-compatibility-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Credits: https://github.com/tokio-rs/io-uring/blob/master/.github/workflows/kernel-version-test.yml
#
# Tests kTLS functionality across multiple kernel versions.
# Default matrix: 6.12, 6.6, 6.1, 5.15, 5.10, 5.4
# Manual trigger supports custom space-separated version list.

name: Kernel Compatibility Test

on:
push:
branches: ["main"]
pull_request:
merge_group:
workflow_dispatch:
inputs:
kernel_versions:
description: "Space-separated list of Linux kernel versions to test (e.g., '6.12 6.6 6.1.148 5.15.189 5.10.240 5.4.296')"
required: true

permissions:
contents: read

jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
if [ -n "${GITHUB_EVENT_INPUTS_KERNEL_VERSIONS}" ]; then
# Manual trigger with custom versions
versions="${GITHUB_EVENT_INPUTS_KERNEL_VERSIONS}"
echo "Using manual input versions: $versions"
else
# Default versions for push events
versions="6.12 6.6 6.1.148 5.15.189 5.10.240 5.4.296"
echo "Using default versions: $versions"
fi

# Convert space-separated list to JSON array
json_array=$(echo "$versions" | tr ' ' '\n' | jq -R . | jq -s -c .)
echo "matrix={\"kernel_version\":$json_array}" >> $GITHUB_OUTPUT
echo "Generated matrix: {\"kernel_version\":$json_array}"
env:
GITHUB_EVENT_INPUTS_KERNEL_VERSIONS: ${{ github.event.inputs.kernel_versions }}

build:
needs: prepare-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
fail-fast: false
env:
KERNEL_VERSION: ${{ matrix.kernel_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
bison flex libelf-dev \
qemu-system-x86 busybox-static cpio xz-utils wget e2fsprogs \
musl-tools

- name: Install Rust 1.77.0
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.77.0
targets: x86_64-unknown-linux-musl

- name: Generate the test binary
run: |
cargo build --package ktls-test --example client --release --target x86_64-unknown-linux-musl

- name: Cache Linux source
id: cache-kernel
uses: actions/cache@v4
with:
path: linux-${{ env.KERNEL_VERSION }}
key: kernel-${{ env.KERNEL_VERSION }}

- name: Download & build Linux kernel
if: steps.cache-kernel.outputs.cache-hit != 'true'
run: |
MAJOR=${KERNEL_VERSION%%.*}
wget https://cdn.kernel.org/pub/linux/kernel/v${MAJOR}.x/linux-${KERNEL_VERSION}.tar.xz
tar xf linux-${KERNEL_VERSION}.tar.xz
cd linux-${KERNEL_VERSION}

# Generate the default config
make defconfig

# Enable essentials as built-ins
scripts/config --enable CONFIG_DEVTMPFS
scripts/config --enable CONFIG_DEVTMPFS_MOUNT

# Enable virtio drivers
scripts/config --enable CONFIG_VIRTIO
scripts/config --enable CONFIG_VIRTIO_PCI
scripts/config --enable CONFIG_VIRTIO_BLK

# Enable kTLS support
scripts/config --enable CONFIG_TLS
scripts/config --enable CONFIG_TLS_DEVICE

# Generate the updated config
make olddefconfig

make -j$(nproc)

- name: Prepare initramfs + tests binaries
run: |
rm -rf initramfs && mkdir -p initramfs/{bin,sbin,proc,sys,tmp}

# Copy the test binary
cp target/x86_64-unknown-linux-musl/release/examples/client initramfs/bin/ktls-test

# Add necessary binaries from busybox
cp /usr/bin/busybox initramfs/bin/
for cmd in sh mount ip ifconfig cat; do ln -sf busybox initramfs/bin/$cmd; done
ln -sf ../bin/busybox initramfs/sbin/poweroff

# Generate init script
cat > initramfs/init << 'EOF'
#!/bin/sh
set -e

# Activating the loopback interface (it's required for some network tests)
ip link set lo up

mkdir -p /dev

# Enable necessary devices
# https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
mknod /dev/port c 1 4
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/tty c 5 0

mkdir -p /tmp && mount -t tmpfs -o mode=1777 tmpfs /tmp

# Bring up ext4 test volume at /mnt
mount -t devtmpfs devtmpfs /dev

exit_code=0

# Run the test binary
RUST_BACKTRACE=1 /bin/ktls-test || exit_code=1

# If the test binary exited with a non-zero code, write it to /dev/port.
# This lets QEMU exit with non-zero exit-code, triggering a CI error.
[ $exit_code -eq 0 ] || printf '\x01' \
| dd of=/dev/port bs=1 seek=244 count=1 2>/dev/null

/sbin/poweroff -f

EOF

chmod +x initramfs/init

# Pack into a CPIO archive
(cd initramfs && find . -print0 \
| cpio --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz)

- name: Run tests in QEMU
run: |
qemu-system-x86_64 \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-kernel linux-${KERNEL_VERSION}/arch/x86/boot/bzImage \
-initrd initramfs.cpio.gz \
-netdev user,id=net0 \
-device e1000,netdev=net0 \
-append "console=ttyS0 rootfstype=ramfs panic=1" \
-nographic -no-reboot -m 1024 -action panic=exit-failure

if [ $? -ne 0 ]; then
echo "tests failed (QEMU exited abnormally)"
exit 1
else
echo "all tests passed"
fi
58 changes: 0 additions & 58 deletions .github/workflows/test.yml

This file was deleted.

Loading