]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix IPv6 site-local IP detection
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 3 Mar 2012 23:35:08 +0000 (16:35 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 3 Mar 2012 23:35:08 +0000 (16:35 -0700)
RFC 4193 the site-local allocated range is fc00::/7.

Squid has been using IN6_IS_ADDR_SITELOCAL() but it turns out Linux and
OpenBSD at least still define that to test for the long obsolete fec0::/10.

src/ip/Address.cc
src/ip/Address.h

index b577c750745b4d69c0cc1657e3c4229a2ca50230..74521b220621e65150ea8ebccc2c3076ba81445c 100644 (file)
@@ -270,7 +270,11 @@ Ip::Address::SetLocalhost()
 bool
 Ip::Address::IsSiteLocal6() const
 {
-    return IN6_IS_ADDR_SITELOCAL( &m_SocketAddr.sin6_addr );
+    // RFC 4193 the site-local allocated range is fc00::/7
+    // with fd00::/8 as the only currently allocated range (so we test it first).
+    // BUG: as of 2010-02 Linux and BSD define IN6_IS_ADDR_SITELOCAL() to check for fec::/10
+    return m_SocketAddr.sin6_addr.s6_addr[0] == static_cast<uint8_t>(0xfd) ||
+           m_SocketAddr.sin6_addr.s6_addr[0] == static_cast<uint8_t>(0xfc);
 }
 
 bool
index 512ffd40e72833ee04af1cba9aec1e11a68fa8cb..9591aca4628e82e47cc08b40c760ff36b3a177c4 100644 (file)
@@ -165,9 +165,9 @@ public:
     bool IsLocalhost() const;
 
     /** Test whether content is an IPv6 Site-Local address.
-     \retval true  if address begins with fe80::/10.
+     \retval true  if address begins with fd00::/8.
      \retval false if --disable-ipv6 has been compiled.
-     \retval false if address does not match fe80::/10
+     \retval false if address does not match fd00::/8
      */
     bool IsSiteLocal6() const;