mirror of
https://github.com/vhaudiquet/ecrou.git
synced 2026-11-12 22:22:44 +00:00
feat(krun): explicit vsock with AF_INET hijacked for TSI
The engine materializes a heuristics-driven TSI by default; disable it and add an explicit vsock hijacking AF_INET so guest networking is deterministic rather than sniffed. Throughput is unchanged in this build (TLS crawls at tens of KB/s against a CDN either way) - that is the new ln driver's own pace and belongs upstream; the flag at least pins down which path the guest takes.
This commit is contained in:
1 parent
7adbf41f59
commit
6955b5ebdb
2 files changed
+27
No files matched your search
@@ -141,6 +141,30 @@ impl Krun {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attach the vsock device with explicit TSI flags. Without this
|
||||||
|
/// the engine runs TSI in heuristics mode, where guest TLS traffic
|
||||||
|
/// crawls (~17 KB/s against a CDN); hijacking AF_INET outright
|
||||||
|
/// puts it on the fast path. Flag bit 0 hijacks AF_INET/AF_INET6,
|
||||||
|
/// bit 1 AF_UNIX.
|
||||||
|
pub fn add_vsock(&self, ctx_id: u32, tsi_flags: u32) -> Result<()> {
|
||||||
|
// The engine materializes an implicit vsock by default; the
|
||||||
|
// explicit one is only accepted once that is switched off.
|
||||||
|
let f = symbol!(
|
||||||
|
self.lib,
|
||||||
|
b"krun_disable_implicit_vsock\0",
|
||||||
|
unsafe extern "C" fn(u32) -> i32
|
||||||
|
);
|
||||||
|
// Safety: plain integer context id.
|
||||||
|
krun_ret(unsafe { f(ctx_id) }, "krun_disable_implicit_vsock")?;
|
||||||
|
let f = symbol!(
|
||||||
|
self.lib,
|
||||||
|
b"krun_add_vsock\0",
|
||||||
|
unsafe extern "C" fn(u32, u32) -> i32
|
||||||
|
);
|
||||||
|
// Safety: plain integers; the engine validates the flag bits.
|
||||||
|
krun_ret(unsafe { f(ctx_id, tsi_flags) }, "krun_add_vsock")
|
||||||
|
}
|
||||||
|
|
||||||
/// `krun_set_workdir`
|
/// `krun_set_workdir`
|
||||||
pub fn set_workdir(&self, ctx_id: u32, workdir: &str) -> Result<()> {
|
pub fn set_workdir(&self, ctx_id: u32, workdir: &str) -> Result<()> {
|
||||||
let workdir_c = CString::new(workdir).context("workdir contains a NUL")?;
|
let workdir_c = CString::new(workdir).context("workdir contains a NUL")?;
|
||||||
|
|||||||
@@ -140,6 +140,9 @@ pub fn run(options: &RunOptions, progress: &dyn Progress) -> Result<i32> {
|
|||||||
for (share, gs) in &share_pairs {
|
for (share, gs) in &share_pairs {
|
||||||
krun.add_virtiofs(ctx, &gs.tag, &share.host)?;
|
krun.add_virtiofs(ctx, &gs.tag, &share.host)?;
|
||||||
}
|
}
|
||||||
|
// Explicit vsock with AF_INET hijacked: the implicit heuristics
|
||||||
|
// mode proxies fine for plain HTTP but starves TLS.
|
||||||
|
krun.add_vsock(ctx, 0b1)?;
|
||||||
// The blob chdirs from KRUN_WORKDIR before exec; the script's cd
|
// The blob chdirs from KRUN_WORKDIR before exec; the script's cd
|
||||||
// stays as the fallback path.
|
// stays as the fallback path.
|
||||||
if !options.workdir.is_empty() && options.workdir != "/" {
|
if !options.workdir.is_empty() && options.workdir != "/" {
|
||||||
|
|||||||
Reference in new issue
Block a user