]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added 'clientside_tos' directive and feature.
authorwessels <>
Sat, 26 May 2007 12:38:03 +0000 (12:38 +0000)
committerwessels <>
Sat, 26 May 2007 12:38:03 +0000 (12:38 +0000)
Much like 'tcp_outgoing_tos' except that this affect connections
between Squid and its clients instead of server-side connections.

src/ClientRequestContext.h
src/cf.data.pre
src/client_side_request.cc
src/comm.cc
src/comm.h
src/forward.cc
src/structs.h

index 64b57aff681aa5976c07286a48db6a578a73af04..bc6bff53e681e64bdeba2373e2582055cfdf7516 100644 (file)
@@ -38,6 +38,7 @@ public:
     bool redirect_done;
     bool no_cache_done;
     bool interpreted_req_hdrs;
+    bool clientside_tos_done;
 
 private:
     CBDATA_CLASS(ClientRequestContext);
index 298ab8532da3914fbe421a00bcd497edd6a20f65..fada4e4cb6d6abc32cd7ce60f2b242a9f1874980 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.437 2007/05/22 17:12:38 rousskov Exp $
+# $Id: cf.data.pre,v 1.438 2007/05/26 06:38:03 wessels Exp $
 #
 #
 # SQUID Web Proxy Cache                http://www.squid-cache.org/
@@ -2922,6 +2922,16 @@ DOC_START
        matching line.
 DOC_END
 
+NAME: clientside_tos
+TYPE: acl_tos
+DEFAULT: none
+LOC: Config.accessList.clientside_tos
+DOC_START
+       Allows you to select a TOS/Diffserv value to mark client-side
+       connections with, based on the username or source address
+       making the request.
+DOC_END
+
 NAME: tcp_outgoing_address
 TYPE: acl_address
 DEFAULT: none
index 42cb7dae043e63a055fa5b493dd5269b3932207e..08d269c30daa8756e103f5fddb186b867f5c4a8a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.cc,v 1.87 2007/05/18 18:26:01 wessels Exp $
+ * $Id: client_side_request.cc,v 1.88 2007/05/26 06:38:04 wessels Exp $
  * 
  * DEBUG: section 85    Client-side Request Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -999,6 +999,8 @@ ClientHttpRequest::loggingEntry(StoreEntry *newEntry)
  * the callout.  This is strictly for convenience.
  */
 
+extern int aclMapTOS (acl_tos * head, ACLChecklist * ch);
+
 void
 ClientHttpRequest::doCallouts()
 {
@@ -1049,6 +1051,20 @@ ClientHttpRequest::doCallouts()
         }
     }
 
+    if (!calloutContext->clientside_tos_done) {
+        calloutContext->clientside_tos_done = true;
+       if (getConn() != NULL) {
+           ACLChecklist ch;
+            ch.src_addr = request->client_addr;
+            ch.my_addr = request->my_addr;
+            ch.my_port = request->my_port;
+            ch.request = HTTPMSGLOCK(request);
+           int tos = aclMapTOS(Config.accessList.clientside_tos, &ch);
+           if (tos)
+               comm_set_tos(getConn()->fd, tos);
+       }
+    }
+
     cbdataReferenceDone(calloutContext->http);
     delete calloutContext;
     calloutContext = NULL;
index c59ddae0437317ef693ba22479fadd3c7c8484cc..2dd4a58a33a8c5158d629cf3c4de3f4325aa3be7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.430 2007/04/30 16:56:09 wessels Exp $
+ * $Id: comm.cc,v 1.431 2007/05/26 06:38:04 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -822,6 +822,21 @@ limitError(int const anErrno)
     return anErrno == ENFILE || anErrno == EMFILE;
 }
 
+int
+comm_set_tos(int fd, int tos)
+{
+#ifdef IP_TOS
+       int x = setsockopt(fd, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(int));
+        if (x < 0)
+            debugs(50, 1, "comm_set_tos: setsockopt(IP_TOS) on FD " << fd << ": " << xstrerror());
+       return x;
+#else
+        debugs(50, 0, "comm_set_tos: setsockopt(IP_TOS) not supported on this platform");
+       return -1
+#endif
+}
+
+
 /* Create a socket. Default is blocking, stream (TCP) socket.  IO_TYPE
  * is OR of flags specified in defines.h:COMM_* */
 int
index ab42717262ab4060a92979c11f9aea5a3e9a6476..e4dd0b3e866be861533d004878cdd72bc70307a5 100644 (file)
@@ -53,6 +53,7 @@ SQUIDCEXTERN int comm_open(int, int, struct IN_ADDR, u_short port, int, const ch
 
 SQUIDCEXTERN int comm_openex(int, int, struct IN_ADDR, u_short, int, unsigned char TOS, const char *);
 SQUIDCEXTERN u_short comm_local_port(int fd);
+SQUIDCEXTERN int comm_set_tos(int fd, int tos);
 
 SQUIDCEXTERN void commSetSelect(int, unsigned int, PF *, void *, time_t);
 
index 40a943e8a63ba16e301f6222575cdf748d39a4af..2ad70f34d1d0c8df08e25448ab7c05a5536ea01a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.164 2007/05/11 13:20:57 rousskov Exp $
+ * $Id: forward.cc,v 1.165 2007/05/26 06:38:04 wessels Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -1197,7 +1197,11 @@ static struct IN_ADDR
     return addr;
 }
 
-static int
+/*
+ * DPW 2007-05-19
+ * Formerly static, but now used by client_side_request.cc
+ */
+int
 aclMapTOS(acl_tos * head, ACLChecklist * ch)
 {
     acl_tos *l;
index a170e231a482f889da3ace07e0312af6771791cd..2817123724c2c95b3597fc8d86d7581458875a5b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.556 2007/05/18 06:41:25 amosjeffries Exp $
+ * $Id: structs.h,v 1.557 2007/05/26 06:38:05 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -584,6 +584,7 @@ struct _SquidConfig
         acl_access *reply;
         acl_address *outgoing_address;
         acl_tos *outgoing_tos;
+        acl_tos *clientside_tos;
 #if USE_HTCP
 
         acl_access *htcp;