mozilla / mtu

Rust crate for obtaining the local network interface name and MTU towards a given IP address
https://crates.io/crates/mtu
Apache License 2.0
12 stars 2 forks source link

Support BSDs #20

Closed larseggert closed 2 weeks ago

larseggert commented 1 month ago

The macOS code path should roughly work on the BSDs, too. It would be good to confirm that, maybe by adding CI support based on https://github.com/vmactions for them and then work out any kinks.

miguelcsx commented 1 month ago

interface_and_mtu_impl Errors on BSD During CI Execution

I have been working on extending the macOS code path to BSD systems, using the vmactions GitHub Actions to add CI support for these systems. To achieve this, I created a separate CI job specifically for BSD, following a similar build and test setup used in other CI/CD. The CI/CD implementation can be found in my fork in this commit

However, during the build, I encountered some type mismatch errors in the interface_and_mtu_impl function. These errors occur without any modifications to the lib.rs file — the only change was adding the BSD CI job.

The errors I received were:


error[E0308]: mismatched types
   --> src/lib.rs:99:5
   |
76 | pub fn interface_and_mtu<A>(addrs: A) -> Result<(String, usize), Error>
   | -------------------------------------- expected `Result<(String, usize), Error>` because of return type
99 | interface_and_mtu_impl(&socket)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<(String, usize), Error>`, found `Result<usize, Error>`

The function is expecting a result with a tuple (String, usize), but the interface_and_mtu_impl is returning Result<usize, Error> instead.

Steps Taken:

mxinden commented 1 month ago

Thanks for the report. I will open a pull request in a couple of minutes @miguelcsx.

mxinden commented 1 month ago

@miguelcsx https://github.com/mozilla/mtu/pull/21 should resolve the issues you were seeing. Mind testing it out?

miguelcsx commented 1 month ago

@miguelcsx #21 should resolve the issues you were seeing. Mind testing it out?

@mxinden I tested it on a freebsd virtual machine and it runs without any errors, it seems to solve the error presented

mxinden commented 1 month ago

Great. Let us know if you need any more help. Thanks for the work @miguelcsx!