From dfdfa5d9b0fa7a8f80df6367ff3cb8c1c9d68459 Mon Sep 17 00:00:00 2001 From: John Hood Date: Thu, 13 Aug 2015 20:20:49 -0400 Subject: [PATCH] FreeBSD TOS issues --- src/network/network.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/network/network.cc b/src/network/network.cc index 730a4db..69c8e8a 100644 --- a/src/network/network.cc +++ b/src/network/network.cc @@ -175,7 +175,10 @@ Connection::Socket::Socket( int family ) int tosflag = true; socklen_t tosoptlen = sizeof( tosflag ); if ( setsockopt( _fd, IPPROTO_IP, IP_RECVTOS, &tosflag, tosoptlen ) < 0 ) { - perror( "setsockopt( IP_RECVTOS )" ); + /* FreeBSD disallows this option on IPv6 sockets. */ + if ( family == IPPROTO_IP ) { + perror( "setsockopt( IP_RECVTOS )" ); + } } #endif } @@ -503,7 +506,11 @@ string Connection::recv_one( int sock_to_recv, bool nonblocking ) struct cmsghdr *ecn_hdr = CMSG_FIRSTHDR( &header ); if ( ecn_hdr && (ecn_hdr->cmsg_level == IPPROTO_IP) - && (ecn_hdr->cmsg_type == IP_TOS) ) { + && ((ecn_hdr->cmsg_type == IP_TOS) +#ifdef IP_RECVTOS + || (ecn_hdr->cmsg_type == IP_RECVTOS) +#endif + )) { /* got one */ uint8_t *ecn_octet_p = (uint8_t *)CMSG_DATA( ecn_hdr ); assert( ecn_octet_p );