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(connlib): remove Option<RawFd>
return value from Callbacks
#4471
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Terraform Cloud Plan Output
|
Performance Test ResultsTCP
UDP
|
4c0eecb
to
f7ccba4
Compare
.expect("session must be set once callbacks get called") | ||
.set_tun(tun), | ||
Err(e) => { | ||
tracing::error!("Failed to make new `Tun`: {e}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, any error when creating a new Tun
device is also only bubbled up
) -> Result<(), ConnlibError> { |
tracing::warn!("Tunnel error: {e}"); |
so this isn't a change in behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we fail to create the Tun for some reason, will the app silently go on without tunneling any traffic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is the behaviour today.
I still need to test this on an actual device. |
let fd = callbacks | ||
.on_set_interface_config(config.ipv4, config.ipv6, dns_config) | ||
.ok_or(Error::NoFd)?; | ||
pub fn with_fd(fd: RawFd) -> Result<Self> { | ||
// Safety: File descriptor is open. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this function safe if its safety depends on the caller passing an open fd?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't but this is already what is on main, I just moved things around a bit.
.expect("session must be set once callbacks get called") | ||
.set_tun(tun), | ||
Err(e) => { | ||
tracing::error!("Failed to make new `Tun`: {e}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we fail to create the Tun for some reason, will the app silently go on without tunneling any traffic?
Some(MAX_PARTITION_TIME), | ||
runtime.handle().clone(), | ||
); | ||
|
||
callback_handler.session = Some(session.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't gonna work because the instance of CallbackHandler
that got passed into Session
doesn't have the Session
set 🤦♂️
Need to think of something else here.
|
||
// SAFETY: we expect the callback to return a valid file descriptor | ||
unsafe { self.replace_fd(fd)? }; | ||
let fd = callbacks.on_update_routes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let fd = callbacks.on_update_routes( | |
callbacks.on_update_routes( |
Assignment of a unit-value.
f7ccba4
to
c91ea2e
Compare
Outdated. |
This represents a more minimal version of #4159 where we for now only change the Android-related code, making this a much smaller change.
The idea is that, instead of setting the new file descriptor based on the return value from the callback, it is the responsibility of the
connlib-client-android
glue code to construct a newTun
device and set it on theTunnel
using a new command.Related: #4473.