From b4956717b0b0abf89cefa5cf73721276207ee6f3 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 8 Jan 2013 17:14:43 -0700 Subject: [PATCH] Bug 3731: TOS setsockopt() requires int value FreeBSD is confirmed errors on 8-bit variable size. Other BSD are documented in a way that implies they do as well, although not at this stage confirmed to be failing. Linux seems to be the only confirmed system working with 8-bit size sent to setsockopt(). So we revert this to 'int' (32-bit or 64-bit) as was working in Squid 3.1. --- src/ip/Qos.cci | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ip/Qos.cci b/src/ip/Qos.cci index 035f8a864e..ad77c452a4 100644 --- a/src/ip/Qos.cci +++ b/src/ip/Qos.cci @@ -4,8 +4,13 @@ int Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos) { -#ifdef IP_TOS - int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos_t)); +#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()); return x; -- 2.47.2