Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: introduce the packetmuxer layer #49

Merged
merged 62 commits into from
Jan 15, 2024

Conversation

ainghazal
Copy link
Collaborator

This is the second commit in the series of incremental refactoring of the current minivpn tree.

In this commit, we introduce the packet muxer, which is the layer just above the networkio. The packet muxer handles and routes data or control packets, and it also handles reset packets.

As dependencies for packetmuxer, we're also introducing the optional and session packages.

Reference issue: #47

ainghazal and others added 30 commits May 8, 2023 15:46
I've tried to achieve te minimal incremental change that adds resilience
in the face of network noise.

To achieve that, the simple thing to do was to make session an object
owned by an implementation of reliableTransport. I've reused the
reliableUDP implementation in govpn, and I like the simplicity of that
implementation a lot. A lot of our current logic (ackqueue/retries)
needed to move from the tlsTransport minivpn implementation into
reliableTransport.

Although the DoS documented in the MIV-01 report is not done, we add the
e2e testing script to facilitate further development.

- Related: ooni#32

more tests
In particular, make sure it's ~easy to connect them all.
@ainghazal ainghazal requested a review from bassosimone January 10, 2024 20:55
@ainghazal ainghazal self-assigned this Jan 10, 2024
// increments the counter for the local data packet ID.
func (m *Manager) localDataPacketIDLocked() (model.PacketID, error) {
pid := m.localDataPacketID
if pid == math.MaxUint32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if pid == math.MaxUint32 {
if pid >= math.MaxUint32 {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is not correct right? PacketID is a uint32 so it should not overflow.
This is a very improbable error, but the only way of returning it meaningfully is to error on the last usable PacketID, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to like expressing this kind of checks in a more defensive way which makes them more robust to refactoring like "let's change this to int64 now", but feel free to ignore if you don't like it.

// increments the counter for the local control packet ID.
func (m *Manager) localControlPacketIDLocked() (model.PacketID, error) {
pid := m.localControlPacketID
if pid == math.MaxUint32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if pid == math.MaxUint32 {
if pid >= math.MaxUint32 {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same as above.

Copy link
Contributor

@bassosimone bassosimone left a comment

Choose a reason for hiding this comment

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

🐳

@ainghazal ainghazal merged commit 4d0ca13 into ooni:main Jan 15, 2024
@ainghazal ainghazal deleted the refactor-packetmuxer branch January 15, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants