From 8f5532f1d949c92bb9f88ffe9b0a872fb2ae29ee Mon Sep 17 00:00:00 2001 From: Zang MingJie Date: Tue, 2 Nov 2021 03:05:46 +0800 Subject: [PATCH] Enforce interface match for unauthenticated session, temporary fix #11120 --- src/transport/UnauthenticatedSessionTable.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/transport/UnauthenticatedSessionTable.h b/src/transport/UnauthenticatedSessionTable.h index eb063494e0dc05..0ea26704421ae1 100644 --- a/src/transport/UnauthenticatedSessionTable.h +++ b/src/transport/UnauthenticatedSessionTable.h @@ -175,6 +175,21 @@ class UnauthenticatedSessionTable return result; } + // A temporary solution for #11120 + // Enforce interface match if not null + static bool MatchInterface(Inet::InterfaceId i1, Inet::InterfaceId i2) + { + if (i1.IsPresent() && i2.IsPresent()) + { + return i1 == i2; + } + else + { + // One of the interface is null + return true; + } + } + static bool MatchPeerAddress(const PeerAddress & a1, const PeerAddress & a2) { if (a1.GetTransportType() != a2.GetTransportType()) @@ -188,7 +203,9 @@ class UnauthenticatedSessionTable case Transport::Type::kTcp: return a1.GetIPAddress() == a2.GetIPAddress() && a1.GetPort() == a2.GetPort() && // Enforce interface equal-ness if the address is link-local, otherwise ignore interface - (a1.GetIPAddress().IsIPv6LinkLocal() ? a1.GetInterface() == a2.GetInterface() : true); + // Use MatchInterface for a temporary solution for #11120 + (a1.GetIPAddress().IsIPv6LinkLocal() ? a1.GetInterface() == a2.GetInterface() + : MatchInterface(a1.GetInterface(), a2.GetInterface())); case Transport::Type::kBle: // TODO: complete BLE address comparation return true;