quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.81k stars 389 forks source link

help build err in openbsd (bug report) #1469

Open littlesum opened 1 year ago

littlesum commented 1 year ago

log

sur# cargo build
   Compiling quinn-udp v0.3.2 (/home/build/quinn-0.9.3/quinn-udp)
error[E0425]: cannot find value `IP_RECVTOS` in crate `libc`
    --> quinn-udp/src/unix.rs:94:75
     |
94   |         if let Err(err) = set_socket_option(&*io, libc::IPPROTO_IP, libc::IP_RECVTOS, OPTION_ON) {
     |                                                                           ^^^^^^^^^^ help: a constant with a similar name exists: `IP_RECVIF`
     |
    ::: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/src/unix/bsd/netbsdlike/openbsd/mod.rs:1068:1
     |
1068 | pub const IP_RECVIF: ::c_int = 30;
     | ---------------------------------- similarly named constant `IP_RECVIF` defined here

error[E0412]: cannot find type `mmsghdr` in crate `libc`
   --> quinn-udp/src/unix.rs:166:26
    |
166 |       let mut msgs: [libc::mmsghdr; BATCH_SIZE] = unsafe { mem::zeroed() };
    |                            ^^^^^^^ help: a struct with a similar name exists: `cmsghdr`
    |
   ::: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/src/unix/bsd/mod.rs:10:1
    |
10  | / s! {
11  | |     pub struct sockaddr {
12  | |         pub sa_len: u8,
13  | |         pub sa_family: sa_family_t,
...   |
124 | |     }
125 | | }
    | |_- similarly named struct `cmsghdr` defined here

error[E0425]: cannot find function `sendmmsg` in crate `libc`
   --> quinn-udp/src/unix.rs:197:32
    |
197 |         let n = unsafe { libc::sendmmsg(io.as_raw_fd(), msgs.as_mut_ptr(), num_transmits as _, 0) };
    |                                ^^^^^^^^ help: a function with a similar name exists: `sendmsg`
    |
   ::: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/src/unix/bsd/mod.rs:743:5
    |
743 |     pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
    |     ------------------------------------------------------------------------------- similarly named function `sendmsg` defined here

error[E0412]: cannot find type `mmsghdr` in crate `libc`
   --> quinn-udp/src/unix.rs:296:50
    |
296 |       let mut hdrs = unsafe { mem::zeroed::<[libc::mmsghdr; BATCH_SIZE]>() };
    |                                                    ^^^^^^^ help: a struct with a similar name exists: `cmsghdr`
    |
   ::: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/src/unix/bsd/mod.rs:10:1
    |
10  | / s! {
11  | |     pub struct sockaddr {
12  | |         pub sa_len: u8,
13  | |         pub sa_family: sa_family_t,
...   |
124 | |     }
125 | | }
    | |_- similarly named struct `cmsghdr` defined here

error[E0425]: cannot find function `recvmmsg` in crate `libc`
   --> quinn-udp/src/unix.rs:308:19
    |
308 |             libc::recvmmsg(
    |                   ^^^^^^^^ help: a function with a similar name exists: `recvmsg`
    |
   ::: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/src/unix/bsd/mod.rs:748:5
    |
748 |     pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
    |     ----------------------------------------------------------------------------- similarly named function `recvmsg` defined here

error[E0531]: cannot find unit struct, unit variant or constant `IP_RECVTOS` in crate `libc`
    --> quinn-udp/src/unix.rs:472:73
     |
472  |             (libc::IPPROTO_IP, libc::IP_TOS) | (libc::IPPROTO_IP, libc::IP_RECVTOS) => unsafe {
     |                                                                         ^^^^^^^^^^ help: a constant with a similar name exists: `IP_RECVIF`
     |
    ::: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.138/src/unix/bsd/netbsdlike/openbsd/mod.rs:1068:1
     |
1068 | pub const IP_RECVIF: ::c_int = 30;
     | ---------------------------------- similarly named constant `IP_RECVIF` defined here

Some errors have detailed explanations: E0412, E0425, E0531.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `quinn-udp` due to 6 previous errors
littlesum commented 1 year ago

e0412

djc commented 1 year ago

So is this a regression? Probably has something to do with the changes in #1447 (or maybe #1448). Can you submit a PR for these? We don't really have expertise on the subtle differences between FreeBSD and OpenBSD.

lucifer9 commented 1 year ago

There's no sendmmsg in libc crate for openbsd. So I think it is better to wait until the relevant functions are implemented by upstream?

djc commented 1 year ago

I guess the question is if sendmmsg() is implemented by OpenBSD and just unsupported in libc at this point or if OpenBSD lacks sendmmsg() completely. In the former case, it's probably straightforward to add support in libc. If the latter, we'd be open to an alternative UDP socket implementation that doesn't rely on sendmmsg() for such platforms.

lucifer9 commented 1 year ago

You are right. It is the former case. There is sendmmsg in OpenBSD, (man page), just no support in libc now.

link2xt commented 5 months ago

One difference is that IP_RECVTOS is not defined by libc crate on OpenBSD. This is correct, FreeBSD has IP_RECVTOS constant but OpenBSD and NetBSD do not. It is documented in the ip(4) man pages of these operating system and I also checked with http://fxr.watson.org/