]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3887: tcp_outgoing_tos not working for IPv6
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 1 Nov 2013 01:24:12 +0000 (19:24 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 1 Nov 2013 01:24:12 +0000 (19:24 -0600)
src/ip/Qos.cci

index 51f5ecc502e163591156ff194035f8a314bc26d5..c62f9345b00520b069fa49e3d99b02edc8f6012d 100644 (file)
@@ -5,22 +5,40 @@
 int
 Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
 {
-#if defined(IP_TOS)
     // Bug 3731: FreeBSD produces 'invalid option'
     // unless we pass it a 32-bit variable storing 8-bits of data.
     // NP: it is documented as 'int' for all systems, even those like Linux which accept 8-bit char
     //     so we convert to a int before setting.
     int bTos = tos;
-    int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &bTos, sizeof(bTos));
-    if (x < 0)
-        debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on " << conn << ": " << xstrerror());
-    else
-        conn->tos = tos;
-    return x;
+
+    if (conn->remote.isIPv4()) {
+#if defined(IP_TOS)
+        int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &bTos, sizeof(bTos));
+        if (x < 0)
+            debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on " << conn << ": " << xstrerror());
+        else
+            conn->tos = tos;
+        return x;
 #else
-    debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IP_TOS) not supported on this platform");
-    return -1;
+        debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IP_TOS) not supported on this platform");
+        return -1;
+#endif
+
+    } else { // if (conn->remote.isIPv6()) {
+#if defined(IPV6_TCLASS)
+        int x = setsockopt(conn->fd, IPPROTO_IPV6, IPV6_TCLASS, &bTos, sizeof(bTos));
+        if (x < 0)
+            debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IPV6_TCLASS) on " << conn << ": " << xstrerror());
+        else
+            conn->tos = tos;
+        return x;
+#else
+        debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IPV6_TCLASS) not supported on this platform");
+        return -1;
 #endif
+    }
+
+    /* CANNOT REACH HERE */
 }
 
 int