]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3731: FreeBSD requires 32-bit TOS options
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 1 Jan 2013 03:55:32 +0000 (20:55 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 1 Jan 2013 03:55:32 +0000 (20:55 -0700)
src/ip/Qos.cci

index 7551e66e204f16d14579a568ddc15504d80d1d1e..2411fa9545b4750b8e563415c3719418fa058f09 100644 (file)
@@ -5,8 +5,15 @@
 int
 Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
 {
-#ifdef IP_TOS
+#if defined(IP_TOS)
+    // Bug 3731: FreeBSD produces 'invalid option'
+    // unless we pass it a 32-bit variable storing 8-bits of data.
+#if _SQUID_FREEBSD_
+    int32_t bTos = tos;
+    int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &bTos, sizeof(bTos));
+#else
     int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos_t));
+#endif
     if (x < 0)
         debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on " << conn << ": " << xstrerror());
     return x;