diff options
author | Jonathan de Jong <jonathandejong02@gmail.com> | 2022-11-14 09:56:02 +0000 |
---|---|---|
committer | Jonathan de Jong <jonathandejong02@gmail.com> | 2022-11-23 10:48:48 +0000 |
commit | e9f07eea61d78dd1b4555e0e7814ab1078cb10d9 (patch) | |
tree | f4911e1e919175e08b1e631c3803021f3c5fc9fb /test | |
parent | a75a3494cebde67764f523930b77ddceb902f57f (diff) | |
download | nix-e9f07eea61d78dd1b4555e0e7814ab1078cb10d9.zip |
add IpMtu sockopt
Diffstat (limited to 'test')
-rw-r--r-- | test/sys/test_sockopt.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/sys/test_sockopt.rs b/test/sys/test_sockopt.rs index e6acfa59..47b01c16 100644 --- a/test/sys/test_sockopt.rs +++ b/test/sys/test_sockopt.rs @@ -237,6 +237,33 @@ fn test_so_tcp_keepalive() { } #[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg_attr(qemu, ignore)] +fn test_get_mtu() { + use nix::sys::socket::{bind, connect, SockaddrIn}; + use std::net::SocketAddrV4; + use std::str::FromStr; + + let std_sa = SocketAddrV4::from_str("127.0.0.1:4001").unwrap(); + let std_sb = SocketAddrV4::from_str("127.0.0.1:4002").unwrap(); + + let usock = socket( + AddressFamily::Inet, + SockType::Datagram, + SockFlag::empty(), + SockProtocol::Udp, + ) + .unwrap(); + + // Bind and initiate connection + bind(usock, &SockaddrIn::from(std_sa)).unwrap(); + connect(usock, &SockaddrIn::from(std_sb)).unwrap(); + + // Loopback connections have 2^16 - the maximum - MTU + assert_eq!(getsockopt(usock, sockopt::IpMtu), Ok(u16::MAX as i32)) +} + +#[test] #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] fn test_ttl_opts() { let fd4 = socket( |