Repository: cloudflare/boringtun (language: rust)

Issue:
change SIOCGIFMTU type to i32 (musl ioctl)
ioctl function signature differs on glibc and musl libc.
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
vs.
int ioctl (int, int, ...);

To avoid mismatched types errors on musl I shamelessly copied tun_darwin.rs' definition of SIOCGIFMTU.


Discussion / hints:
Actually this is something the libc crate should handle, IMHO.

But as soon as I find out how to cast 'as i32' on musl only in an elegant way I will try that, thanks!

Fix patch:
diff --git a/src/device/tun_linux.rs b/src/device/tun_linux.rs
index ffac9c6e..71675531 100644
--- a/src/device/tun_linux.rs
+++ b/src/device/tun_linux.rs
@@ -122,7 +122,7 @@ impl TunSocket {
 
         ifr.ifr_name[..iface_name.len()].copy_from_slice(iface_name);
 
-        if unsafe { ioctl(fd, SIOCGIFMTU, &ifr) } < 0 {
+        if unsafe { ioctl(fd, SIOCGIFMTU as _, &ifr) } < 0 {
             return Err(Error::IOCtl(errno_str()));
         }
 


Test patch: