Skip to content

build(rust): depend on our boringtun fork - #7120

Merged
thomaseizinger merged 2 commits into
mainfrom
chore/depend-on-boringtun-fork
Nov 12, 2024
Merged

build(rust): depend on our boringtun fork#7120
thomaseizinger merged 2 commits into
mainfrom
chore/depend-on-boringtun-fork

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Oct 22, 2024

Copy link
Copy Markdown
Member

This switches our dependency on boringtun over to our fork at https://github.com/firezone/boringtun. The idea of the fork is to carefully only patch selective parts such that upstream things later is still possible. The complete diff can be seen here: cloudflare/boringtun@master...firezone:boringtun:master

So far, the only patches in the fork are dependency bumps, linter fixes, adjustments to log levels and the removal of panics when the destination buffer is too small.

@vercel

vercel Bot commented Oct 22, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 2:56am

@thomaseizinger thomaseizinger self-assigned this Oct 22, 2024
Comment thread rust/connlib/snownet/src/node.rs Outdated

@jamilbk jamilbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't really have anything to add here

@thomaseizinger

Copy link
Copy Markdown
Member Author

We should have done this much sooner. Modelling time correctly in boringtun is revealing a bunch of issues ...

@conectado conectado left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@thomaseizinger

Copy link
Copy Markdown
Member Author

Need to deep-dive on these test failures and how boringtun manages these sessions. Something is not right there.

@thomaseizinger
thomaseizinger force-pushed the chore/depend-on-boringtun-fork branch from 341afb2 to fe3f4b6 Compare October 25, 2024 03:27
@thomaseizinger

Copy link
Copy Markdown
Member Author

@jamilbk I ended up adjusting our fork to - for now - only change log levels and remove the panic paths. I'll deal with the time-impurity later once I changed our test suite to be less sensitive to individual packet drops.

Comment on lines -442 to -453
let packet_len = packet.packet().len();
let max_len = if self.mode.is_client() {
ip_packet::PACKET_SIZE
} else {
ip_packet::PACKET_SIZE + ip_packet::NAT46_OVERHEAD
};

// TODO: This is a it of a hack, we should compile-time enforce this.
if packet_len > max_len {
tracing::warn!("Packet is too large; max={max_len}, actual={packet_len}");
return Ok(None);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is no longer needed because our fork now has firezone/boringtun#26.

@jamilbk jamilbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚀

@thomaseizinger
thomaseizinger added this pull request to the merge queue Nov 12, 2024
github-merge-queue Bot pushed a commit that referenced this pull request Nov 12, 2024
Within our test suite, we "spin" for several (simulated) seconds after
each state transition to allow for packets being sent between the
different nodes. The test suite simulates different latencies by
delaying the delivery of some of these packets.

`connlib` has several timers for sending packets, i.e. STUN bindings, WG
keep-alives etc. These timers never end so we cannot simply spin "until
we no longer want to send any packets". Currently, we simply hard-stop
after a few seconds and drop the remaining packets and move on to the
next state transition.

At present, this isn't an issue because only our ICE agent adheres to
the simulated time advancement. `boringtun` is still impure and thus we
usually don't get to see any of the WireGuard packets like keep-alives
and session timeouts etc in our tests. The STUN messages are pretty
resilient to retransmissions so the current packet drop doesn't matter.

In the process of adopting our boringtun fork
(https://github.com/firezone/boringtun) where we will eventually fix the
time impurity, dropping some of these packets caused problems.

To fix this, we now drain all remaining packets that are sitting in the
"yet-to-be-delivered" buffer. These packets are delivered to an "inbox"
that is per-host, meaning the host (i.e. client, gateway or relay) will
still perceive the incoming packet with the correct latency.

We extract this functionality from #7120 because it is generally useful.
Merged via the queue into main with commit d38304b Nov 12, 2024
@thomaseizinger
thomaseizinger deleted the chore/depend-on-boringtun-fork branch November 12, 2024 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants