From: Christos Tsantilas Date: Mon, 14 Apr 2014 17:01:18 +0000 (+0300) Subject: author: Alex Rousskov X-Git-Tag: SQUID_3_5_0_1~289 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ee88490f030008e81b1a3eff09664f4d456989e;p=thirdparty%2Fsquid.git author: Alex Rousskov Encapsulated commonly reused ToS and NfMark code into GetMarkingsToServer() --- diff --git a/src/FwdState.cc b/src/FwdState.cc index 8392b3ab51..dbc6abeee5 100644 --- a/src/FwdState.cc +++ b/src/FwdState.cc @@ -1191,18 +1191,7 @@ 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 && USE_LIBCAP - serverDestinations[0]->nfmark = GetNfmarkToServer(request); - debugs(17, 3, "fwdConnectStart: got outgoing addr " << serverDestinations[0]->local << ", tos " << int(serverDestinations[0]->tos) - << ", netfilter mark " << serverDestinations[0]->nfmark); -#else - serverDestinations[0]->nfmark = 0; - debugs(17, 3, "fwdConnectStart: got outgoing addr " << serverDestinations[0]->local << ", tos " << int(serverDestinations[0]->tos)); -#endif + GetMarkingsToServer(request, *serverDestinations[0]); calls.connector = commCbCall(17,3, "fwdConnectDoneWrapper", CommConnectCbPtrFun(fwdConnectDoneWrapper, this)); Comm::ConnOpener *cs = new Comm::ConnOpener(serverDestinations[0], calls.connector, ctimeout); @@ -1584,3 +1573,20 @@ GetNfmarkToServer(HttpRequest * request) ACLFilledChecklist ch(NULL, request, NULL); return aclMapNfmark(Ip::Qos::TheConfig.nfmarkToServer, &ch); } + +void +GetMarkingsToServer(HttpRequest * request, Comm::Connection &conn) +{ + // Get the server side TOS and Netfilter mark to be set on the connection. + if (Ip::Qos::TheConfig.isAclTosActive()) { + conn.tos = GetTosToServer(request); + debugs(17, 3, "from " << conn.local << " tos " << int(conn.tos)); + } + +#if SO_MARK && USE_LIBCAP + conn.nfmark = GetNfmarkToServer(request); + debugs(17, 3, "from " << conn.local << " netfilter mark " << conn.nfmark); +#else + conn.nfmark = 0; +#endif +} diff --git a/src/FwdState.h b/src/FwdState.h index d19aea6d8a..0117e028af 100644 --- a/src/FwdState.h +++ b/src/FwdState.h @@ -39,6 +39,9 @@ tos_t GetTosToServer(HttpRequest * request); */ nfmark_t GetNfmarkToServer(HttpRequest * request); +/// Sets initial TOS value and Netfilter for the future outgoing connection. +void GetMarkingsToServer(HttpRequest * request, Comm::Connection &conn); + class HelperReply; class FwdState : public RefCountable diff --git a/src/tunnel.cc b/src/tunnel.cc index 6f9aecd3b4..c04a9498c7 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -777,15 +777,7 @@ tunnelConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int xe tunnelState->serverDestinations.erase(tunnelState->serverDestinations.begin()); if (status != COMM_TIMEOUT && tunnelState->serverDestinations.size() > 0) { /* Try another IP of this destination host */ - - if (Ip::Qos::TheConfig.isAclTosActive()) { - tunnelState->serverDestinations[0]->tos = GetTosToServer(tunnelState->request.getRaw()); - } - -#if SO_MARK && USE_LIBCAP - tunnelState->serverDestinations[0]->nfmark = GetNfmarkToServer(tunnelState->request.getRaw()); -#endif - + GetMarkingsToServer(tunnelState->request.getRaw(), *tunnelState->serverDestinations[0]); debugs(26, 4, HERE << "retry with : " << tunnelState->serverDestinations[0]); AsyncCall::Pointer call = commCbCall(26,3, "tunnelConnectDone", CommConnectCbPtrFun(tunnelConnectDone, tunnelState)); Comm::ConnOpener *cs = new Comm::ConnOpener(tunnelState->serverDestinations[0], call, Config.Timeout.connect); @@ -974,13 +966,7 @@ tunnelPeerSelectComplete(Comm::ConnectionList *peer_paths, ErrorState *err, void } delete err; - if (Ip::Qos::TheConfig.isAclTosActive()) { - tunnelState->serverDestinations[0]->tos = GetTosToServer(tunnelState->request.getRaw()); - } - -#if SO_MARK && USE_LIBCAP - tunnelState->serverDestinations[0]->nfmark = GetNfmarkToServer(tunnelState->request.getRaw()); -#endif + GetMarkingsToServer(tunnelState->request.getRaw(), *tunnelState->serverDestinations[0]); debugs(26, 3, HERE << "paths=" << peer_paths->size() << ", p[0]={" << (*peer_paths)[0] << "}, serverDest[0]={" << tunnelState->serverDestinations[0] << "}");