]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix build errors and integrate MARK patch with comm updates
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 9 Oct 2010 02:37:38 +0000 (15:37 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 9 Oct 2010 02:37:38 +0000 (15:37 +1300)
src/client_side_reply.cc
src/client_side_request.cc
src/comm.cc
src/comm/ConnOpener.cc
src/comm/Connection.h
src/forward.cc
src/ip/Qos.cci
src/ip/QosConfig.cc
src/ip/QosConfig.h
src/peer_select.cc

index e9a1540e2d8b8857904a5f41aac98e159ca8ab8c..2d79a115a166eaca664be906e08356469a71411e 100644 (file)
@@ -1689,11 +1689,11 @@ clientReplyContext::doGetMoreData()
         assert(http->out.offset == 0);
 
         if (Ip::Qos::TheConfig.isHitTosActive()) {
-            Ip::Qos::doTosLocalHit(http->getConn()->fd);
+            Ip::Qos::doTosLocalHit(http->getConn()->clientConn);
         }
 
         if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
-            Ip::Qos::doNfmarkLocalHit(http->getConn()->fd);
+            Ip::Qos::doNfmarkLocalHit(http->getConn()->clientConn);
         }
 
         localTempBuffer.offset = reqofs;
index a1f9889c273ca2ba473259c74e86b1e04babb23c..df77f1e34a57e1995e716f3c967b7a5edefe2447 100644 (file)
@@ -1343,7 +1343,7 @@ ClientHttpRequest::doCallouts()
             ch.my_addr = request->my_addr;
             tos_t tos = aclMapTOS(Ip::Qos::TheConfig.tosToClient, &ch);
             if (tos)
-                Ip::Qos::setSockTos(getConn()->clientConn->fd, tos);
+                Ip::Qos::setSockTos(getConn()->clientConn, tos);
         }
     }
 
@@ -1355,7 +1355,7 @@ ClientHttpRequest::doCallouts()
             ch.my_addr = request->my_addr;
             nfmark_t mark = aclMapNfmark(Ip::Qos::TheConfig.nfmarkToClient, &ch);
             if (mark)
-                Ip::Qos::setSockNfmark(getConn()->clientConn->fd, mark);
+                Ip::Qos::setSockNfmark(getConn()->clientConn, mark);
         }
     }
 
index 7f506f25112eee3e37bd12e24b246554c94dbd89..4f3187c453fba532cab5b860ba176c162dba97c8 100644 (file)
@@ -569,7 +569,7 @@ comm_open_listener(int sock_type,
     conn->flags |= COMM_DOBIND;
 
     /* attempt native enabled port. */
-    conn->fd = comm_openex(sock_type, proto, conn->local, conn->flags, 0, note);
+    conn->fd = comm_openex(sock_type, proto, conn->local, conn->flags, 0, 0, note);
 }
 
 int
@@ -643,6 +643,10 @@ comm_openex(int sock_type,
     int new_socket;
     struct addrinfo *AI = NULL;
 
+    // temporary for the transition. comm_openex will eventually have a conn to play with.
+    Comm::ConnectionPointer conn = new Comm::Connection;
+    conn->local = addr;
+
     PROF_start(comm_open);
     /* Create socket for accepting new connections. */
     statCounter.syscalls.sock.sockets++;
@@ -652,8 +656,7 @@ comm_openex(int sock_type,
     AI->ai_socktype = sock_type;
     AI->ai_protocol = proto;
 
-    debugs(50, 3, "comm_openex: Attempt open socket for: " << addr );
-
+    debugs(50, 3, "comm_openex: Attempt open socket for: " << conn );
     new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
 
     /* under IPv6 there is the possibility IPv6 is present but disabled. */
@@ -688,35 +691,35 @@ comm_openex(int sock_type,
         return -1;
     }
 
-    debugs(50, 3, "comm_openex: Opened socket FD " << new_socket << " : family=" << AI->ai_family << ", type=" << AI->ai_socktype << ", protocol=" << AI->ai_protocol );
+    conn->fd = new_socket;
+
+    debugs(50, 3, "comm_openex: Opened socket " << conn << " : family=" << AI->ai_family << ", type=" << AI->ai_socktype << ", protocol=" << AI->ai_protocol );
 
     /* set TOS if needed */
     if (tos)
-        Ip::Qos::setSockTos(new_socket, tos);
+        Ip::Qos::setSockTos(conn, tos);
 
     /* set netfilter mark if needed */
     if (nfmark)
-        Ip::Qos::setSockNfmark(new_socket, nfmark);
+        Ip::Qos::setSockNfmark(conn, nfmark);
 
     if ( Ip::EnableIpv6&IPV6_SPECIAL_SPLITSTACK && addr.IsIPv6() )
-        comm_set_v6only(new_socket, 1);
+        comm_set_v6only(conn->fd, 1);
 
     /* Windows Vista supports Dual-Sockets. BUT defaults them to V6ONLY. Turn it OFF. */
     /* Other OS may have this administratively disabled for general use. Same deal. */
     if ( Ip::EnableIpv6&IPV6_SPECIAL_V4MAPPING && addr.IsIPv6() )
-        comm_set_v6only(new_socket, 0);
+        comm_set_v6only(conn->fd, 0);
 
-    // temporary for te transition. comm_openex will eventually have a conn to play with.
-    Comm::ConnectionPointer temp = new Comm::Connection;
-    temp->fd = new_socket;
-    temp->local = addr;
-    comm_init_opened(temp, tos, nfmark, note, AI);
-    new_socket = comm_apply_flags(new_socket, addr, flags, AI);
+    comm_init_opened(conn, tos, nfmark, note, AI);
+    new_socket = comm_apply_flags(conn->fd, addr, flags, AI);
 
     addr.FreeAddrInfo(AI);
 
     PROF_stop(comm_open);
 
+    // XXX transition only. prevent conn from closing the new FD on functio exit.
+    conn->fd = -1;
     return new_socket;
 }
 
index 81bed1997a4acc8cecd2441aca209954fd169d01..62218b83a26fc57c7c4ce5d8f5f4e68f26bdadcf 100644 (file)
@@ -130,7 +130,7 @@ Comm::ConnOpener::start()
             conn_->local.SetIPv4();
         }
 #endif
-        conn_->fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, conn_->local, conn_->flags, conn_->tos, host_);
+        conn_->fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, conn_->local, conn_->flags, conn_->tos, conn_->nfmark, host_);
         if (!conn_->isOpen()) {
             doneConnecting(COMM_ERR_CONNECT, 0);
             return;
index b529ca49c11ae2a4dcafdceac7524aca6f512a7d..fef288f8d23a07eb8942ebf2121eb5827c4374e5 100644 (file)
@@ -132,7 +132,10 @@ public:
     int fd;
 
     /** Quality of Service TOS values currently sent on this connection */
-    int tos;
+    tos_t tos;
+
+    /** Netfilter MARK values currently sent on this connection */
+    nfmark_t nfmark;
 
     /** COMM flags set on this connection */
     int flags;
index e2e25467156ecf85684019d765c193089ad50764..9e75724ca24638d8d23ccaeaf2df56a431ced0ee 100644 (file)
@@ -833,6 +833,19 @@ FwdState::connectStart()
 
         updateHierarchyInfo();
         comm_add_close_handler(serverConnection()->fd, fwdServerClosedWrapper, this);
+
+        /* Update server side TOS and Netfilter mark on the connection. */
+        if (Ip::Qos::TheConfig.isAclTosActive()) {
+            temp->tos = GetTosToServer(request);
+            Ip::Qos::setSockTos(temp, temp->tos);
+        }
+#if SO_MARK
+        if (Ip::Qos::TheConfig.isAclNfmarkActive()) {
+            temp->nfmark = GetNfmarkToServer(request);
+            Ip::Qos::setSockNfmark(temp, temp->nfmark);
+        }
+#endif
+
         dispatch();
         return;
     }
@@ -841,6 +854,16 @@ FwdState::connectStart()
     entry->mem_obj->checkUrlChecksum();
 #endif
 
+    /* Get the server side TOS and Netfilter mark to be set on the connection. */
+    if (Ip::Qos::TheConfig.isAclTosActive()) {
+        serverDestinations[0]->tos = GetTosToServer(request);
+    }
+#if SO_MARK
+    if (Ip::Qos::TheConfig.isAclNfmarkActive()) {
+        serverDestinations[0]->nfmark = GetNfmarkToServer(request);
+    }
+#endif
+
     AsyncCall::Pointer call = commCbCall(17,3, "fwdConnectDoneWrapper", CommConnectCbPtrFun(fwdConnectDoneWrapper, this));
     Comm::ConnOpener *cs = new Comm::ConnOpener(serverDestinations[0], call, ctimeout);
     cs->setHost(host);
@@ -858,17 +881,6 @@ FwdState::dispatch()
      */
     assert(Comm::IsConnOpen(serverConn));
 
-    tos_t tos = GetTosToServer(request);
-
-#if SO_MARK
-    nfmark_t mark = GetNfmarkToServer(request);
-    debugs(17, 3, HERE << "got outgoing addr " << serverConn << ", tos " << int(tos)
-                    << ", netfilter mark " << mark);
-#else
-    nfmark_t mark = 0;
-    debugs(17, 3, HERE << "got outgoing addr " << serverConn << ", tos " << int(tos));
-#endif
-
     fd_note(serverConnection()->fd, entry->url());
 
     fd_table[serverConnection()->fd].noteUse(fwdPconnPool);
@@ -882,40 +894,25 @@ FwdState::dispatch()
 
     netdbPingSite(request->GetHost());
 
-    /* Update server side TOS and Netfilter mark if using persistent connections. */
-    if (Config.onoff.server_pconns) {
-        if (Ip::Qos::TheConfig.isAclTosActive()) {
-            tos_t tos = GetTosToServer(request);
-            Ip::Qos::setSockTos(server_fd, tos);
-        }
-#if SO_MARK
-        if (Ip::Qos::TheConfig.isAclNfmarkActive()) {
-            nfmark_t mark = GetNfmarkToServer(request);
-            Ip::Qos::setSockNfmark(server_fd, mark);
-        }
-#endif
-    }
-
     /* Retrieves remote server TOS or MARK value, and stores it as part of the
      * original client request FD object. It is later used to forward
      * remote server's TOS/MARK in the response to the client in case of a MISS.
      */
     if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
-        fde * clientFde = &fd_table[clientConn->fd]; // XXX: move the fd_table access into Ip::Qos
-        fde * servFde = &fd_table[serverConnection()->fd];
-        if (clientFde && servFde) {
+        if (Comm::IsConnOpen(clientConn) && Comm::IsConnOpen(serverConnection())) {
+            fde * clientFde = &fd_table[clientConn->fd]; // XXX: move the fd_table access into Ip::Qos
             /* Get the netfilter mark for the connection */
-            Ip::Qos::getNfmarkFromServer(serverConnection()->fd, servFde, clientFde);
+            Ip::Qos::getNfmarkFromServer(serverConnection(), clientFde);
         }
     }
 
 #if _SQUID_LINUX_
     /* Bug 2537: The TOS forward part of QOS only applies to patched Linux kernels. */
     if (Ip::Qos::TheConfig.isHitTosActive()) {
-        fde * clientFde = &fd_table[clientConn->fd]; // XXX: move the fd_table access into Ip::Qos
-        if (clientFde) {
+        if (Comm::IsConnOpen(clientConn)) {
+            fde * clientFde = &fd_table[clientConn->fd]; // XXX: move the fd_table access into Ip::Qos
             /* Get the TOS value for the packet */
-            Ip::Qos::getTosFromServer(serverConnection()->fd, clientFde);
+            Ip::Qos::getTosFromServer(serverConnection(), clientFde);
         }
     }
 #endif
@@ -1289,6 +1286,7 @@ getOutgoingAddress(HttpRequest * request, Comm::ConnectionPointer conn)
     }
 }
 
+// XXX: convert this to accepting a serverConn and migrate to QosConfig.cc
 tos_t
 GetTosToServer(HttpRequest * request)
 {
@@ -1302,6 +1300,7 @@ GetTosToServer(HttpRequest * request)
     return aclMapTOS(Ip::Qos::TheConfig.tosToServer, &ch);
 }
 
+// XXX: convert this to accepting a serverConn and migrate to QosConfig.cc
 nfmark_t
 GetNfmarkToServer(HttpRequest * request)
 {
index f2a53bc63293919ae37b9fcf546071e6a4a12b9f..58abce8e25f36fac36f71b023fd29eeb04809b8d 100644 (file)
@@ -1,12 +1,13 @@
 /* Inline QOS functions */
+#include "comm/Connection.h"
 
 int
-Ip::Qos::setSockTos(int fd, tos_t tos)
+Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
 {
 #ifdef IP_TOS
-    int x = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos_t));
+    int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos_t));
     if (x < 0)
-        debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on FD " << fd << ": " << xstrerror());
+        debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on " << conn << ": " << xstrerror());
     return x;
 #else
     debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(IP_TOS) not supported on this platform");
@@ -15,12 +16,12 @@ Ip::Qos::setSockTos(int fd, tos_t tos)
 }
 
 int
-Ip::Qos::setSockNfmark(int fd, nfmark_t mark)
+Ip::Qos::setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark)
 {
 #if SO_MARK
-    int x = setsockopt(fd, SOL_SOCKET, SO_MARK, &mark, sizeof(nfmark_t));
+    int x = setsockopt(conn->fd, SOL_SOCKET, SO_MARK, &mark, sizeof(nfmark_t));
     if (x < 0)
-        debugs(50, 2, "setSockNfmark: setsockopt(SO_MARK) on FD " << fd << ": " << xstrerror());
+        debugs(50, 2, "setSockNfmark: setsockopt(SO_MARK) on " << conn << ": " << xstrerror());
     return x;
 #else
     debugs(50, DBG_IMPORTANT, "WARNING: setsockopt(SO_MARK) not supported on this platform");
index 36ce6cadac9d759ab91760b9400820af0a69a718..8064cf7b7f69a397c9460def84a0b568133afd56 100644 (file)
@@ -1,6 +1,7 @@
 #include "squid.h"
 
 #include "acl/Gadgets.h"
+#include "comm/Connection.h"
 #include "ConfigParser.h"
 #include "fde.h"
 #include "hier_code.h"
 /* Qos namespace */
 
 void
-Ip::Qos::getTosFromServer(const int server_fd, fde *clientFde)
+Ip::Qos::getTosFromServer(const Comm::ConnectionPointer &server, fde *clientFde)
 {
 #if USE_QOS_TOS && _SQUID_LINUX_
     /* Bug 2537: This part of ZPH only applies to patched Linux kernels. */
     tos_t tos = 1;
-    int tos_len = sizeof(tos); 
+    int tos_len = sizeof(tos);
     clientFde->tosFromServer = 0;
-    if (setsockopt(server_fd,SOL_IP,IP_RECVTOS,&tos,tos_len)==0) {
+    if (setsockopt(server->fd,SOL_IP,IP_RECVTOS,&tos,tos_len)==0) {
         unsigned char buf[512];
         int len = 512;
-        if (getsockopt(server_fd,SOL_IP,IP_PKTOPTIONS,buf,(socklen_t*)&len) == 0) {
+        if (getsockopt(server->fd,SOL_IP,IP_PKTOPTIONS,buf,(socklen_t*)&len) == 0) {
             /* Parse the PKTOPTIONS structure to locate the TOS data message
              * prepared in the kernel by the ZPH incoming TCP TOS preserving
              * patch.
@@ -40,15 +41,15 @@ Ip::Qos::getTosFromServer(const int server_fd, fde *clientFde)
                 pbuf += CMSG_LEN(o->cmsg_len);
             }
         } else {
-            debugs(33, 1, "QOS: error in getsockopt(IP_PKTOPTIONS) on FD " << server_fd << " " << xstrerror());
+            debugs(33, DBG_IMPORTANT, "QOS: error in getsockopt(IP_PKTOPTIONS) on " << server << " " << xstrerror());
         }
     } else {
-        debugs(33, 1, "QOS: error in setsockopt(IP_RECVTOS) on FD " << server_fd << " " << xstrerror());
+        debugs(33, DBG_IMPORTANT, "QOS: error in setsockopt(IP_RECVTOS) on " << server << " " << xstrerror());
     }
 #endif
 }
 
-void Ip::Qos::getNfmarkFromServer(const int server_fd, const fde *servFde, const fde *clientFde)
+void Ip::Qos::getNfmarkFromServer(const Comm::ConnectionPointer &server, const fde *clientFde)
 {
 #if USE_LIBNETFILTERCONNTRACK
     /* Allocate a new conntrack */
@@ -59,47 +60,38 @@ void Ip::Qos::getNfmarkFromServer(const int server_fd, const fde *servFde, const
          * port numbers.
          */
 
-        Ip::Address serv_fde_local_conn;
-        struct addrinfo *addr = NULL;
-        serv_fde_local_conn.InitAddrInfo(addr);
-        getsockname(server_fd, addr->ai_addr, &(addr->ai_addrlen));
-        serv_fde_local_conn = *addr;
-        serv_fde_local_conn.GetAddrInfo(addr);
-
-        unsigned short serv_fde_local_port = ((struct sockaddr_in*)addr->ai_addr)->sin_port;
-        struct in6_addr serv_fde_local_ip6;
-        struct in_addr serv_fde_local_ip;
-
-        if (Ip::EnableIpv6 && serv_fde_local_conn.IsIPv6()) {
-            serv_fde_local_ip6 = ((struct sockaddr_in6*)addr->ai_addr)->sin6_addr;
+        if (Ip::EnableIpv6 && server->local.IsIPv6()) {
             nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET6);
             struct in6_addr serv_fde_remote_ip6;
-            inet_pton(AF_INET6,servFde->ipaddr,(struct in6_addr*)&serv_fde_remote_ip6);
+            server->remote.GetAddr(&serv_fde_remote_ip6);
             nfct_set_attr(ct, ATTR_IPV6_DST, serv_fde_remote_ip6.s6_addr);
-            nfct_set_attr(ct, ATTR_IPV6_SRC, serv_fde_local_ip6.s6_addr); 
+            struct in6_addr serv_fde_local_ip6;
+            server->local.GetAddr(serv_fde_local_ip6);
+            nfct_set_attr(ct, ATTR_IPV6_SRC, serv_fde_local_ip6.s6_addr);
         } else {
-            serv_fde_local_ip = ((struct sockaddr_in*)addr->ai_addr)->sin_addr;
             nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);
-            nfct_set_attr_u32(ct, ATTR_IPV4_DST, inet_addr(servFde->ipaddr));
-            nfct_set_attr_u32(ct, ATTR_IPV4_SRC, serv_fde_local_ip.s_addr);  
+            struct in6_addr serv_fde_remote_ip;
+            server->remote.GetAddr(&serv_fde_remote_ip);
+            nfct_set_attr_u32(ct, ATTR_IPV4_DST, serv_fde_remote_ip.s_addr);
+            struct in_addr serv_fde_local_ip;
+            server->local.GetAddr(serv_fde_local_ip);
+            nfct_set_attr_u32(ct, ATTR_IPV4_SRC, serv_fde_local_ip.s_addr);
         }
 
         nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_TCP);
-        nfct_set_attr_u16(ct, ATTR_PORT_DST, htons(servFde->remote_port));
-        nfct_set_attr_u16(ct, ATTR_PORT_SRC, serv_fde_local_port);
+        nfct_set_attr_u16(ct, ATTR_PORT_DST, htons(server->remote.GetPort()));
+        nfct_set_attr_u16(ct, ATTR_PORT_SRC, htons(server->local.GetPort()));
 
         /* Open a handle to the conntrack */
         if (struct nfct_handle *h = nfct_open(CONNTRACK, 0)) {
             /* Register the callback. The callback function will record the mark value. */
-            nfct_callback_register(h, NFCT_T_ALL, getNfMarkCallback, (void *)clientFde);  
+            nfct_callback_register(h, NFCT_T_ALL, getNfMarkCallback, (void *)clientFde);
             /* Query the conntrack table using the data previously set */
             int x = nfct_query(h, NFCT_Q_GET, ct);
             if (x == -1) {
-                debugs(17, 2, "QOS: Failed to retrieve connection mark: (" << x << ") " << strerror(errno)
-                  << " (Destination " << servFde->ipaddr << ":" << servFde->remote_port
-                  << ", source " << serv_fde_local_conn << ")" );
+                debugs(17, 2, "QOS: Failed to retrieve connection mark: (" << x << ") " << xstrerror(errno)
+                       << " (Destination " << server->remote << ", source " << server->local << ")" );
             }
-             
             nfct_close(h);
         } else {
             debugs(17, 2, "QOS: Failed to open conntrack handle for upstream netfilter mark retrieval.");
@@ -128,7 +120,7 @@ Ip::Qos::getNfMarkCallback(enum nf_conntrack_msg_type type,
 #endif
 
 int
-Ip::Qos::doTosLocalMiss(const int fd, const hier_code hierCode)
+Ip::Qos::doTosLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode)
 {
     tos_t tos = 0;
     if (Ip::Qos::TheConfig.tosSiblingHit && hierCode==SIBLING_HIT) {
@@ -141,14 +133,14 @@ Ip::Qos::doTosLocalMiss(const int fd, const hier_code hierCode)
         tos = Ip::Qos::TheConfig.tosMiss;
         debugs(33, 2, "QOS: Cache miss, setting TOS=" << int(tos));
     } else if (Ip::Qos::TheConfig.preserveMissTos && Ip::Qos::TheConfig.preserveMissTosMask) {
-        tos = fd_table[fd].tosFromServer & Ip::Qos::TheConfig.preserveMissTosMask;
+        tos = fd_table[conn->fd].tosFromServer & Ip::Qos::TheConfig.preserveMissTosMask;
         debugs(33, 2, "QOS: Preserving TOS on miss, TOS=" << int(tos));
     }
-    return setSockTos(fd, tos);
+    return setSockTos(conn, tos);
 }
 
 int
-Ip::Qos::doNfmarkLocalMiss(const int fd, const hier_code hierCode)
+Ip::Qos::doNfmarkLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode)
 {
     nfmark_t mark = 0;
     if (Ip::Qos::TheConfig.markSiblingHit && hierCode==SIBLING_HIT) {
@@ -161,24 +153,24 @@ Ip::Qos::doNfmarkLocalMiss(const int fd, const hier_code hierCode)
         mark = Ip::Qos::TheConfig.markMiss;
         debugs(33, 2, "QOS: Cache miss, setting Mark=" << mark);
     } else if (Ip::Qos::TheConfig.preserveMissMark) {
-        mark = fd_table[fd].nfmarkFromServer & Ip::Qos::TheConfig.preserveMissMarkMask;
+        mark = fd_table[conn->fd].nfmarkFromServer & Ip::Qos::TheConfig.preserveMissMarkMask;
         debugs(33, 2, "QOS: Preserving mark on miss, Mark=" << mark);
     }
-    return setSockNfmark(fd, mark);
+    return setSockNfmark(conn, mark);
 }
 
 int
-Ip::Qos::doTosLocalHit(const int fd)
+Ip::Qos::doTosLocalHit(const Comm::ConnectionPointer &conn)
 {
     debugs(33, 2, "QOS: Setting TOS for local hit, TOS=" << int(Ip::Qos::TheConfig.tosLocalHit));
-    return setSockTos(fd, Ip::Qos::TheConfig.tosLocalHit);
+    return setSockTos(conn, Ip::Qos::TheConfig.tosLocalHit);
 }
 
 int
-Ip::Qos::doNfmarkLocalHit(const int fd)
+Ip::Qos::doNfmarkLocalHit(const Comm::ConnectionPointer &conn)
 {
     debugs(33, 2, "QOS: Setting netfilter mark for local hit, mark=" << Ip::Qos::TheConfig.markLocalHit);
-    return setSockNfmark(fd, Ip::Qos::TheConfig.markLocalHit);
+    return setSockNfmark(conn, Ip::Qos::TheConfig.markLocalHit);
 }
 
 /* Qos::Config class */
@@ -380,7 +372,7 @@ Ip::Qos::Config::dumpConfigLine(char *entry, const char *name) const
         }
         p += snprintf(p, 2, "\n");
     }
-    
+
     if (isHitNfmarkActive()) {
         p += snprintf(p, 11, "%s", name); // strlen("qos_flows ");
         p += snprintf(p, 5, "%s", "mark");
index 9ad9c48fc8ae80c3a9eec633500e75b6a4181f47..59e010d311a1a0fac00dfe9222e06d3b18dbc54f 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "config.h"
 #include "hier_code.h"
+#include "ip/forward.h"
 
 #if HAVE_LIBNETFILTER_CONNTRACK_LIBNETFILTER_CONNTRACK_H
 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
@@ -33,27 +34,26 @@ namespace Qos
     * Function to retrieve the TOS value of the inbound packet.
     * Called by FwdState::dispatch if QOS options are enabled.
     * Bug 2537: This part of ZPH only applies to patched Linux kernels
-    * @param server_fd Server side descriptor of connection to get TOS for
+    * @param server    Server side descriptor of connection to get TOS for
     * @param clientFde Pointer to client side fde instance to set tosFromServer in
-    */ 
-    void getTosFromServer(const int server_fd, fde *clientFde);
-    
+    */
+    void getTosFromServer(const Comm::ConnectionPointer &server, fde *clientFde);
+
     /**
     * Function to retrieve the netfilter mark value of the connection
     * to the upstream server. Called by FwdState::dispatch if QOS
     * options are enabled.
-    * @param server_fd Server side descriptor of connection to get mark for
-    * @param servFde Pointer to server side fde instance to get mark for
+    * @param server    Server side descriptor of connection to get mark for
     * @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
     */
-    void getNfmarkFromServer(const int server_fd, const fde *servFde, const fde *clientFde);
+    void getNfmarkFromServer(const Comm::ConnectionPointer &server, const fde *clientFde);
 
 #if USE_LIBNETFILTERCONNTRACK
-    /**          
+    /**
     * Callback function to mark connection once it's been found.
     * This function is called by the libnetfilter_conntrack
     * libraries, during nfct_query in Ip::Qos::getNfmarkFromServer.
-    * nfct_callback_register is used to register this function.   
+    * nfct_callback_register is used to register this function.
     * @param nf_conntrack_msg_type Type of conntrack message
     * @param nf_conntrack Pointer to the conntrack structure
     * @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
@@ -64,54 +64,54 @@ namespace Qos
     /**
     * Function to work out and then apply to the socket the appropriate
     * TOS value to set on packets when items have not been retrieved from
-    * local cache. Called by clientReplyContext::sendMoreData if QOS is  
+    * local cache. Called by clientReplyContext::sendMoreData if QOS is
     * enabled for TOS.
-    * @param fd Descriptor of socket to set the TOS for
+    * @param conn     Descriptor of socket to set the TOS for
     * @param hierCode Hier code of request
     */
-    int doTosLocalMiss(const int fd, const hier_code hierCode);
-    
+    int doTosLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode);
+
     /**
     * Function to work out and then apply to the socket the appropriate
-    * netfilter mark value to set on packets when items have not been  
+    * netfilter mark value to set on packets when items have not been
     * retrieved from local cache. Called by clientReplyContext::sendMoreData
     * if QOS is enabled for TOS.
-    * @param fd Descriptor of socket to set the mark for
+    * @param conn     Descriptor of socket to set the mark for
     * @param hierCode Hier code of request
     */
-    int doNfmarkLocalMiss(const int fd, const hier_code hierCode);
-    
+    int doNfmarkLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode);
+
     /**
     * Function to work out and then apply to the socket the appropriate
     * TOS value to set on packets when items *have* been retrieved from
     * local cache. Called by clientReplyContext::doGetMoreData if QOS is
     * enabled for TOS.
-    * @param fd Descriptor of socket to set the TOS for
+    * @param conn Descriptor of socket to set the TOS for
     */
-    int doTosLocalHit(const int fd);
-    
+    int doTosLocalHit(const Comm::ConnectionPointer &conn);
+
     /**
     * Function to work out and then apply to the socket the appropriate
     * netfilter mark value to set on packets when items *have* been
     * retrieved from local cache. Called by clientReplyContext::doGetMoreData
     * if QOS is enabled for TOS.
-    * @param fd Descriptor of socket to set the mark for
+    * @param conn Descriptor of socket to set the mark for
     */
-    int doNfmarkLocalHit(const int fd);
-    
+    int doNfmarkLocalHit(const Comm::ConnectionPointer &conn);
+
     /**
     * Function to set the TOS value of packets. Sets the value on the socket
     * which then gets copied to the packets.
-    * @param fd Descriptor of socket to set the TOS for
-    */   
-    _SQUID_INLINE_ int setSockTos(int fd, tos_t tos);
-    
+    * @param conn Descriptor of socket to set the TOS for
+    */
+    _SQUID_INLINE_ int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
+
     /**
     * Function to set the netfilter mark value of packets. Sets the value on the
     * socket which then gets copied to the packets. Called from Ip::Qos::doNfmarkLocalMiss
-    * @param fd Descriptor of socket to set the mark for
-    */ 
-    _SQUID_INLINE_ int setSockNfmark(int fd, nfmark_t mark);
+    * @param conn Descriptor of socket to set the mark for
+    */
+    _SQUID_INLINE_ int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark);
 
 /**
  * QOS configuration class. Contains all the parameters for QOS functions as well
@@ -146,7 +146,7 @@ public:
     * to find out if any Netfilter marking is required.
     * This function is used on initialisation to define capabilities required (Netfilter
     * marking requires CAP_NET_ADMIN).
-    */ 
+    */
     _SQUID_INLINE_ bool isAclNfmarkActive() const;
 
     /**
index 18ea8ac02f1e64234f9ea393a874b151f87b5b42..27401de98f45108c9a6727a0927d981ec0129832 100644 (file)
@@ -270,8 +270,6 @@ peerSelectDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &details, v
 
             // check for a configured outgoing address for this destination...
             getOutgoingAddress(psstate->request, p);
-            p->tos = getOutgoingTOS(psstate->request);
-
             psstate->paths->push_back(p);
         }
     } else {