mirror of
https://github.com/cloudflare/pingora.git
synced 2024-09-20 02:31:35 +02:00
Ignore 0.0.0.0 when checking fd mismatch
Avoid false positive since 0.0.0.0 in some systems is mapped to other IPs.
This commit is contained in:
parent
09b5e03fb1
commit
2ff09e727d
2 changed files with 10 additions and 1 deletions
2
.bleep
2
.bleep
|
@ -1 +1 @@
|
|||
940539c7d0bff45d8182d4eb6c40d099b20ed44e
|
||||
05356d8d19882e125b57f2b855ec744bec733d40
|
|
@ -29,6 +29,7 @@ pub use ssl::ALPN;
|
|||
|
||||
use async_trait::async_trait;
|
||||
use std::fmt::Debug;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Define how a protocol should shutdown its connection.
|
||||
|
@ -256,6 +257,14 @@ impl ConnFdReusable for InetSocketAddr {
|
|||
let fd = fd.as_raw_fd();
|
||||
match getpeername::<SockaddrStorage>(fd) {
|
||||
Ok(peer) => {
|
||||
const ZERO: IpAddr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
if self.ip() == ZERO {
|
||||
// https://www.rfc-editor.org/rfc/rfc1122.html#section-3.2.1.3
|
||||
// 0.0.0.0 should only be used as source IP not destination
|
||||
// However in some systems this destination IP is mapped to 127.0.0.1.
|
||||
// We just skip this check here to avoid false positive mismatch.
|
||||
return true;
|
||||
}
|
||||
let addr = SockaddrStorage::from(*self);
|
||||
if addr == peer {
|
||||
debug!("Inet FD to: {addr} is reusable");
|
||||
|
|
Loading…
Reference in a new issue