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

Fails to build on FreeBSD #1142

Closed
jbeich opened this issue Jun 12, 2021 · 15 comments · Fixed by #1447
Closed

Fails to build on FreeBSD #1142

jbeich opened this issue Jun 12, 2021 · 15 comments · Fixed by #1447
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@jbeich
Copy link

jbeich commented Jun 12, 2021

Regressed by b681c65 (usize) and 1bc75aa (in_pktinfo)

$ pkg install rust
$ rustc -vV
rustc 1.52.1
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-freebsd
release: 1.52.1
LLVM version: 12.0.0

$ cargo build
[...]
error[E0422]: cannot find struct, variant or union type `in_pktinfo` in crate `libc`
   --> quinn/src/platform/unix.rs:387:41
    |
387 |                       let pktinfo = libc::in_pktinfo {
    |                                           ^^^^^^^^^^ help: a struct with a similar name exists: `in6_pktinfo`
    |
   ::: ../libc-0.2.97/src/unix/bsd/freebsdlike/mod.rs:82:1
    |
82  | / s! {
83  | |     pub struct in_addr {
84  | |         pub s_addr: ::in_addr_t,
85  | |     }
...   |
346 | |     }
347 | | }
    | |_- similarly named struct `in6_pktinfo` defined here

error[E0425]: cannot find value `IP_PKTINFO` in crate `libc`
   --> quinn/src/platform/unix.rs:394:58
    |
394 |                     encoder.push(libc::IPPROTO_IP, libc::IP_PKTINFO, pktinfo);
    |                                                          ^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_PKTINFO`
    |
   ::: ../libc-0.2.97/src/unix/bsd/freebsdlike/mod.rs:919:1
    |
919 | pub const IPV6_PKTINFO: ::c_int = 46;
    | ------------------------------------- similarly named constant `IPV6_PKTINFO` defined here

error[E0531]: cannot find unit struct, unit variant or constant `IP_PKTINFO` in crate `libc`
   --> quinn/src/platform/unix.rs:454:38
    |
454 |             (libc::IPPROTO_IP, libc::IP_PKTINFO) => unsafe {
    |                                      ^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_PKTINFO`
    |
   ::: ../libc-0.2.97/src/unix/bsd/freebsdlike/mod.rs:919:1
    |
919 | pub const IPV6_PKTINFO: ::c_int = 46;
    | ------------------------------------- similarly named constant `IPV6_PKTINFO` defined here

error[E0412]: cannot find type `in_pktinfo` in crate `libc`
   --> quinn/src/platform/unix.rs:455:52
    |
455 |                   let pktinfo = cmsg::decode::<libc::in_pktinfo>(cmsg);
    |                                                      ^^^^^^^^^^ help: a struct with a similar name exists: `in6_pktinfo`
    |
   ::: ../libc-0.2.97/src/unix/bsd/freebsdlike/mod.rs:82:1
    |
82  | / s! {
83  | |     pub struct in_addr {
84  | |         pub s_addr: ::in_addr_t,
85  | |     }
...   |
346 | |     }
347 | | }
    | |_- similarly named struct `in6_pktinfo` defined here

error[E0308]: mismatched types
   --> quinn/src/platform/unix.rs:287:17
    |
287 |                 bufs.len().min(BATCH_SIZE) as libc::c_uint,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `u32`
    |
help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
    |
287 |                 (bufs.len().min(BATCH_SIZE) as libc::c_uint).try_into().unwrap(),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0308, E0412, E0422, E0425, E0531.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `quinn`
@djc
Copy link
Member

djc commented Jun 12, 2021

For the usize we should probably change not(macos) to linux? For the pktinfo types, do those exist on BSDs? Maybe add them in libc upstream?

@jbeich
Copy link
Author

jbeich commented Jun 12, 2021

For the pktinfo types, do those exist on BSDs? Maybe add them in libc upstream?

IP_PKTINFO exists on NetBSD but not DragonFly, FreeBSD, OpenBSD. CC @asomers

@asomers
Copy link

asomers commented Jun 12, 2021

That's right, FreeBSD doesn't implement IP_PKTINFO. The closest thing it has, I think, is getsockname. You should just not compile those sections on FreeBSD.

@Matthias247
Copy link
Contributor

Keep in mind this is more than just "doesn't compile", and fixing the compilation won't fix the underlying problem.
Without IP_PKTINFO you won't be able to bind the server to a wildcard IPv4 address, since outgoing packets won't find the right way.

So you have to choose between binding to a specific listener, using IPv6 or not using server support.

@Ralith
Copy link
Collaborator

Ralith commented Jun 12, 2021

outgoing packets won't find the right way

This is only a problem if the machine actually has multiple addresses on the same subnet, right?

@Ralith Ralith added bug Something isn't working help wanted Extra attention is needed labels Sep 19, 2021
@DemiMarie
Copy link

@Matthias247 @Ralith IP_RECVDSTADDR and IP_SENDSRCADDR might help.

@Ralith
Copy link
Collaborator

Ralith commented Nov 16, 2021

Those do sound relevant! I don't think we have any capacity to test on BSD ourselves, however, so in any case we need someone with a suitable environment to contribute.

@Error996
Copy link

Error996 commented Apr 3, 2022

i can test,anytime unless sleep

@Ralith
Copy link
Collaborator

Ralith commented Apr 3, 2022

Nice! If you're interested in implementing this, we'd be happy to review a PR.

@xpader
Copy link

xpader commented Apr 27, 2022

Any updates? I can help to test too.

@djc
Copy link
Member

djc commented Apr 28, 2022

There are no updates as far as I know -- someone still needs to make the required code changes.

@b-ncMN
Copy link

b-ncMN commented Jun 18, 2022

I'd be willing to put some work into this; we (the veloren project) use quinn and quinn-udp for our game
fixing this issue would not only make the game one step closer to running on freebsd but also help a whole lot of other people

@Ralith
Copy link
Collaborator

Ralith commented Jun 18, 2022

Thanks for your interest! Feel free to reach out on gitter/matrix if you have any questions. Should be limited to mostly boring changes to quinn-udp/src/unix.rs.

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 2, 2022
It doesn't build with rust 1.61 and the latest version (1.9.24) is affected by this bug:
quinn-rs/quinn#1142

PR:		264292
Approved by:	maintainer timeout
ocochard pushed a commit to ocochard/freebsd-ports that referenced this issue Jul 6, 2022
It doesn't build with rust 1.61 and the latest version (1.9.24) is affected by this bug:
quinn-rs/quinn#1142

PR:		264292
Approved by:	maintainer timeout
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 21, 2022
It doesn't build with rust 1.61 and the latest version (1.9.24) is affected by this bug:
quinn-rs/quinn#1142

PR:		264292
Approved by:	maintainer timeout

(cherry picked from commit 5973697)
@p-kraszewski
Copy link

What fascinates me the most, the troubleigiving fragment of the code is guarded by if cfg!(target_os = "linux") { } and should not be interpreted on FreeBSD in the first place...

@Ralith
Copy link
Collaborator

Ralith commented Sep 9, 2022

That expands to if false { ... } on FreeBSD, in which case the ... must still be well-formed code. Does suggest a simple fix, though, if someone's motivated to try and validate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants