From 08956fe84037721289c05c6d47ed199c14f13c83 Mon Sep 17 00:00:00 2001 From: vars1ty Date: Wed, 30 Aug 2023 13:29:19 +0200 Subject: [PATCH 01/12] make iov live longer --- src/adapters/udp.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 35b4695..542c7ba 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -193,11 +193,11 @@ impl Remote for RemoteResource { } Err(ref err) if err.kind() == ErrorKind::ConnectionRefused => { // Avoid ICMP generated error to be logged - break ReadStatus::WaitNextEvent + break ReadStatus::WaitNextEvent; } Err(err) => { log::error!("UDP receive error: {}", err); - break ReadStatus::WaitNextEvent // Should not happen + break ReadStatus::WaitNextEvent; // Should not happen } } } @@ -236,9 +236,10 @@ impl LocalResource { let mut control_buffer = nix::cmsg_space!(libc::sockaddr_storage); loop { + let mut iov = [io::IoSliceMut::new(&mut input_buffer)]; let result = socket::recvmsg::( self.socket.as_raw_fd(), - &mut [io::IoSliceMut::new(&mut input_buffer)], + &mut iov, Some(&mut control_buffer), MsgFlags::empty(), ); @@ -261,15 +262,15 @@ impl LocalResource { }; if !ingress_addresses.contains(&ingress_ip) { - continue + continue; } fn convert_sockaddr(addr: SockaddrStorage) -> Option { if let Some(addr) = addr.as_sockaddr_in() { - return Some(SocketAddr::V4((*addr).into())) + return Some(SocketAddr::V4((*addr).into())); } if let Some(addr) = addr.as_sockaddr_in6() { - return Some(SocketAddr::V6((*addr).into())) + return Some(SocketAddr::V6((*addr).into())); } None } @@ -385,16 +386,14 @@ impl Local for LocalResource { Some(ingress_addresses) } } - } - else { + } else { None }; if let Some(multicast) = multicast { socket.join_multicast_v4(multicast.ip(), &Ipv4Addr::UNSPECIFIED)?; socket.bind(&SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, addr.port()).into())?; - } - else { + } else { socket.bind(&addr.into())?; } @@ -416,7 +415,7 @@ impl Local for LocalResource { #[cfg(target_os = "linux")] if let Some(ingress_addresses) = &self.ingress_addresses { self.accept_filtered(ingress_addresses, accept_remote); - return + return; } let buffer: MaybeUninit<[u8; MAX_LOCAL_PAYLOAD_LEN]> = MaybeUninit::uninit(); @@ -463,7 +462,7 @@ fn send_packet(data: &[u8], send_method: impl Fn(&[u8]) -> io::Result) -> } Err(err) => { log::error!("UDP send error: {}", err); - break SendStatus::ResourceNotFound // should not happen + break SendStatus::ResourceNotFound; // should not happen } } } From 663f750a92fd4c93a85aa3736ed5f2e8b02657b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:16:49 +0200 Subject: [PATCH 02/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 542c7ba..1e54be2 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -193,7 +193,7 @@ impl Remote for RemoteResource { } Err(ref err) if err.kind() == ErrorKind::ConnectionRefused => { // Avoid ICMP generated error to be logged - break ReadStatus::WaitNextEvent; + break ReadStatus::WaitNextEvent } Err(err) => { log::error!("UDP receive error: {}", err); From 5f862ae0ef075eda585d6f951218fdddcf0956df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:16:54 +0200 Subject: [PATCH 03/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 1e54be2..c149813 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -197,7 +197,7 @@ impl Remote for RemoteResource { } Err(err) => { log::error!("UDP receive error: {}", err); - break ReadStatus::WaitNextEvent; // Should not happen + break ReadStatus::WaitNextEvent // Should not happen } } } From de5e068d29c24ba34fc477470ae01581170302b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:16:58 +0200 Subject: [PATCH 04/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index c149813..c046168 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -262,7 +262,7 @@ impl LocalResource { }; if !ingress_addresses.contains(&ingress_ip) { - continue; + continue } fn convert_sockaddr(addr: SockaddrStorage) -> Option { From 2680f55456806f1f2c331b6ea8ff768553ae27f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:17:03 +0200 Subject: [PATCH 05/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index c046168..202c1c7 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -267,7 +267,7 @@ impl LocalResource { fn convert_sockaddr(addr: SockaddrStorage) -> Option { if let Some(addr) = addr.as_sockaddr_in() { - return Some(SocketAddr::V4((*addr).into())); + return Some(SocketAddr::V4((*addr).into())) } if let Some(addr) = addr.as_sockaddr_in6() { return Some(SocketAddr::V6((*addr).into())); From b5ef7200343fce55c88eeaf9b28e48553a9e9712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:17:08 +0200 Subject: [PATCH 06/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 202c1c7..3c45f29 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -270,7 +270,7 @@ impl LocalResource { return Some(SocketAddr::V4((*addr).into())) } if let Some(addr) = addr.as_sockaddr_in6() { - return Some(SocketAddr::V6((*addr).into())); + return Some(SocketAddr::V6((*addr).into())) } None } From b62365a3d9dae78f370b0fc5d373544a601d56b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:17:13 +0200 Subject: [PATCH 07/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 3c45f29..7fa33bd 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -386,7 +386,8 @@ impl Local for LocalResource { Some(ingress_addresses) } } - } else { + } + else { None }; From e99b2c472959bd8145349dba0871aacf878bc561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:17:18 +0200 Subject: [PATCH 08/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 7fa33bd..6488109 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -394,7 +394,8 @@ impl Local for LocalResource { if let Some(multicast) = multicast { socket.join_multicast_v4(multicast.ip(), &Ipv4Addr::UNSPECIFIED)?; socket.bind(&SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, addr.port()).into())?; - } else { + } + else { socket.bind(&addr.into())?; } From 90d576a3614ab187305070be818238617b2f591e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:17:23 +0200 Subject: [PATCH 09/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 6488109..1020795 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -417,7 +417,7 @@ impl Local for LocalResource { #[cfg(target_os = "linux")] if let Some(ingress_addresses) = &self.ingress_addresses { self.accept_filtered(ingress_addresses, accept_remote); - return; + return } let buffer: MaybeUninit<[u8; MAX_LOCAL_PAYLOAD_LEN]> = MaybeUninit::uninit(); From 079a6e829bb3ad06791ee33da781ec3ba64733a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:17:27 +0200 Subject: [PATCH 10/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 1020795..a10e990 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -464,7 +464,7 @@ fn send_packet(data: &[u8], send_method: impl Fn(&[u8]) -> io::Result) -> } Err(err) => { log::error!("UDP send error: {}", err); - break SendStatus::ResourceNotFound; // should not happen + break SendStatus::ResourceNotFound // should not happen } } } From bcce8aff298d970ab79ef15984fb78e9ab453d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:18:01 +0200 Subject: [PATCH 11/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index a10e990..05f6072 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -386,7 +386,7 @@ impl Local for LocalResource { Some(ingress_addresses) } } - } + } else { None }; From 793662c60f04a535464cf4e14dbea4df25a6e69d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Wed, 13 Sep 2023 14:18:10 +0200 Subject: [PATCH 12/12] Update src/adapters/udp.rs --- src/adapters/udp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/udp.rs b/src/adapters/udp.rs index 05f6072..b658e07 100644 --- a/src/adapters/udp.rs +++ b/src/adapters/udp.rs @@ -394,7 +394,7 @@ impl Local for LocalResource { if let Some(multicast) = multicast { socket.join_multicast_v4(multicast.ip(), &Ipv4Addr::UNSPECIFIED)?; socket.bind(&SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, addr.port()).into())?; - } + } else { socket.bind(&addr.into())?; }