]> git.pld-linux.org Git - packages/squid.git/blobdiff - squid_hit_miss_mark.patch
- %addusertogroup R: /usr/sbin/usermod,
[packages/squid.git] / squid_hit_miss_mark.patch
index 34f83ebcfb80f1ac712fd063dc40cc3b20b159aa..481d28b65b3514573c0c79678ab4a7b52803851c 100644 (file)
@@ -1,8 +1,8 @@
-diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data.pre
---- squid-2.6.STABLE12.orig/src/cf.data.pre    2007-03-21 19:43:48.000000000 +0200
-+++ squid-2.6.STABLE12/src/cf.data.pre 2007-03-21 19:44:08.000000000 +0200
-@@ -3193,6 +3193,64 @@
-       to off when using this directive in such configurations.
+diff -Nur squid-3.0.STABLE8/src/cf.data.pre squid-3.0.STABLE8-zph/src/cf.data.pre
+--- squid-3.0.STABLE8/src/cf.data.pre  2008-07-18 13:02:53.000000000 +0300
++++ squid-3.0.STABLE8-zph/src/cf.data.pre      2008-08-22 13:25:45.000000000 +0300
+@@ -1119,6 +1119,60 @@
+       making the request.
  DOC_END
  
 +NAME: zph_tos_local
@@ -10,9 +10,9 @@ diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data
 +DEFAULT: 0
 +LOC: Config.zph_tos_local
 +DOC_START
-+      Allows you to select a TOS/Diffserv value to mark local hits. Read above
-+      (tcp_outgoing_tos) for details/requirements about TOS.
-+      Default: 0 (disabled).
++       Allows you to select a TOS/Diffserv value to mark local hits. Read above
++       (tcp_outgoing_tos) for details/requirements about TOS.
++       Default: 0 (disabled).
 +DOC_END
 +
 +NAME: zph_tos_peer
@@ -20,9 +20,9 @@ diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data
 +DEFAULT: 0
 +LOC: Config.zph_tos_peer
 +DOC_START
-+      Allows you to select a TOS/Diffserv value to mark peer hits. Read above
-+      (tcp_outgoing_tos) for details/requirements about TOS.
-+      Default: 0 (disabled).
++       Allows you to select a TOS/Diffserv value to mark peer hits. Read above
++       (tcp_outgoing_tos) for details/requirements about TOS.
++       Default: 0 (disabled).
 +DOC_END
 +
 +NAME: zph_tos_parent
@@ -31,8 +31,8 @@ diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data
 +LOC: Config.onoff.zph_tos_parent
 +DEFAULT: on
 +DOC_START
-+      Set this to off if you want only sibling hits to be marked.
-+      If set to on (default), parent hits are being marked too.
++       Set this to off if you want only sibling hits to be marked.
++       If set to on (default), parent hits are being marked too.
 +DOC_END
 +
 +NAME: zph_preserve_miss_tos
@@ -41,13 +41,11 @@ diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data
 +LOC: Config.onoff.zph_preserve_miss_tos
 +DEFAULT: on
 +DOC_START
-+      If set to on (default), any HTTP response towards clients will
-+      have the TOS value of the response comming from the remote
-+      server masked with the value of zph_preserve_miss_tos_mask.
-+      For this to work correctly, you will need to patch your linux
-+      kernel with the TOS preserving ZPH patch.
-+      Has no effect under FreeBSD, works only under linux ZPH patched
-+      kernels.
++       If set to on (default), any HTTP response towards clients will
++       have the TOS value of the response comming from the remote
++       server masked with the value of zph_preserve_miss_tos_mask.
++       For this to work correctly, you will need to patch your linux
++       kernel with the TOS preserving ZPH patch.
 +DOC_END
 +
 +NAME: zph_preserve_miss_tos_mask
@@ -55,162 +53,150 @@ diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data
 +DEFAULT: 255
 +LOC: Config.zph_preserve_miss_tos_mask
 +DOC_START
-+      Allows you to mask certain bits in the TOS received from the
-+      remote server, before copying the value to the TOS send towards
-+      clients.
-+      See zph_preserve_miss_tos for details.
-+      
-+      Default: 255 (TOS from server is not changed).
++       Allows you to mask certain bits in the TOS received from the
++       remote server, before copying the value to the TOS send towards
++       clients.
++       Default: 255 (TOS from server is not changed).
 +DOC_END
 +
  NAME: tcp_outgoing_address
  TYPE: acl_address
  DEFAULT: none
-diff -Nru squid-2.6.STABLE12.orig/src/client_side.c squid-2.6.STABLE12/src/client_side.c
---- squid-2.6.STABLE12.orig/src/client_side.c  2007-03-21 19:43:48.000000000 +0200
-+++ squid-2.6.STABLE12/src/client_side.c       2007-03-21 19:44:08.000000000 +0200
-@@ -2621,6 +2621,55 @@
-       return;
-     }
-     assert(http->out.offset == 0);
-+      
-+      if ( Config.zph_tos_local || Config.zph_tos_peer ||
-+         (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask) )
-+    {
-+       int need_change = 0;
-+       int hit = 0;
-+       int tos = 0;
-+       int tos_old = 0;
-+       int tos_len = sizeof(tos_old);
-+       int res;
-+                   
-+       if (Config.zph_tos_local && isTcpHit(http->log_type)) {     /* local hit */
-+           hit = 1;
-+           tos = Config.zph_tos_local;
-+       } else if (Config.zph_tos_peer &&
-+           (http->request->hier.code == SIBLING_HIT ||             /* sibling hit */
-+           (Config.onoff.zph_tos_parent &&
-+           http->request->hier.code == PARENT_HIT))) {             /* parent hit */
-+           hit = 1;
-+           tos = Config.zph_tos_peer;
-+       }
-+       if (http->request->flags.proxy_keepalive) {
-+           if (getsockopt(fd, IPPROTO_IP, IP_TOS, &tos_old, &tos_len) < 0) {
-+               debug(33, 1) ("ZPH: getsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
-+           } else if (hit && tos_old != tos) {     /* HIT: 1-st request, or previous was MISS, */
-+               need_change = 1;                    /* or local/parent hit change */
-+           } else if (!hit && (tos_old ||  /* MISS: previous was HIT */
-+                            Config.onoff.zph_preserve_miss_tos)) { /* TOS copying is on */
-+#if defined(_SQUID_LINUX_)                        
-+                   if ( Config.onoff.zph_preserve_miss_tos ) {
-+                     tos = (entry->mem_obj != NULL) ?
-+                           (entry->mem_obj->recvTOS & Config.zph_preserve_miss_tos_mask):0;
-+                   } else tos = 0;
-+#else
-+                  tos = 0;
-+#endif                   
-+               need_change = 1;
-+           } 
-+       } else if (hit) {                           /* no keepalive */
-+           need_change = 1;
-+       }
-+       if (need_change) {
-+           if (!hit) enter_suid(); /* Setting TOS bit6-7 is privilleged */
-+           res = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
-+           if (!hit) leave_suid(); /* Setting bit5-7 is privilleged */
-+           if ( res < 0)
-+               debug(33, 1) ("ZPH: setsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
-+       }
-+    }
-     rep = http->reply = clientBuildReply(http, buf, size);
-     if (!rep) {
-       /* Forward as HTTP/0.9 body with no reply */
-diff -Nru squid-2.6.STABLE12.orig/src/http.c squid-2.6.STABLE12/src/http.c
---- squid-2.6.STABLE12.orig/src/http.c 2007-03-13 00:27:09.000000000 +0200
-+++ squid-2.6.STABLE12/src/http.c      2007-03-21 19:44:08.000000000 +0200
-@@ -1373,6 +1373,53 @@
-     peer *p = httpState->peer;
-     CWCB *sendHeaderDone;
-     int fd = httpState->fd;
+diff -Nur squid-3.0.STABLE8/src/client_side_reply.cc squid-3.0.STABLE8-zph/src/client_side_reply.cc
+--- squid-3.0.STABLE8/src/client_side_reply.cc 2008-07-18 13:02:54.000000000 +0300
++++ squid-3.0.STABLE8-zph/src/client_side_reply.cc     2008-08-22 13:25:54.000000000 +0300
+@@ -48,6 +48,7 @@
+ #include "ESI.h"
+ #endif
+ #include "MemObject.h"
++#include "fde.h"
+ #include "ACLChecklist.h"
+ #include "ACL.h"
+ #if DELAY_POOLS
+@@ -1548,6 +1549,11 @@
+         /* guarantee nothing has been sent yet! */
+         assert(http->out.size == 0);
+         assert(http->out.offset == 0);
++        if (Config.zph_tos_local)
++              {
++                      debugs(33, 1, "ZPH hit hier.code=" << http->request->hier.code <<" TOS="<<Config.zph_tos_local);
++              comm_set_tos(http->getConn()->fd,Config.zph_tos_local);
++              }             
+         tempBuffer.offset = reqofs;
+         tempBuffer.length = getNextNode()->readBuffer.length;
+         tempBuffer.data = getNextNode()->readBuffer.data;
+@@ -1827,6 +1833,24 @@
+     char *buf = next()->readBuffer.data;
+     char *body_buf = buf;
 +    
-+#if defined(_SQUID_LINUX_)    
-+/* ZPH patch starts here (M.Stavrev 25-05-2005)
-+ * Retrieve connection peer's TOS value (which its SYN_ACK TCP segment
-+ * was encapsulated into an IP packet)
-+ */
-+    int tos, tos_len;
-+    if ( entry && entry->mem_obj ) { // Is this check necessary ? Seems not, but
-+                               // have no time to investigate further.
-+          entry->mem_obj->recvTOS = 0;
-+          tos = 1;
-+          tos_len = sizeof(tos);
-+              if ( setsockopt(fd,SOL_IP, IP_RECVTOS, &tos, tos_len) == 0 ) {
-+                  unsigned char buf[128];
-+                  int len = 128;
-+                  if (getsockopt(fd, SOL_IP, IP_PKTOPTIONS, buf, &len) == 0)
-+                  {
-+                      /* Parse the PKTOPTIONS structure to locate the TOS data message
-+                       * prepared in the kernel by the ZPH incoming TCP TOS preserving
-+                       * patch. In 99,99% the TOS should be located at buf[12], but
-+                       * let's do it the right way.
-+                       */
-+                      unsigned char * p = buf;
-+                      while ( p-buf < len ) {
-+                              struct cmsghdr * o = (struct cmsghdr*)p;
-+                              if ( o->cmsg_len <= 0 || o->cmsg_len > 52 )
-+                                 break;
-+                              if ( o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS ) {
-+                                 entry->mem_obj->recvTOS = (unsigned char)(*(int*)
-+                                                                              (p + sizeof(struct cmsghdr)));
-+                                     debug(11, 5) ("ZPH: Incomming TOS=%d on FD %d\n",
-+                                                      entry->mem_obj->recvTOS, fd );
-+                                 break;
-+                              }
-+                              p += o->cmsg_len;
-+                      }
-+                  } else {
-+                      debug(11, 5) ("ZPH: getsockopt(IP_PKTOPTIONS) on FD %d: %s\n",
-+                                               fd, xstrerror());
-+                  }
-+              } else {
-+              debug(11, 5) ("ZPH: setsockopt(IP_RECVTOS) on FD %d: %s\n",
-+                                               fd, xstrerror());
++    if (reqofs==0 && !logTypeIsATcpHit(http->logType))
++    {
++              int tos = 0;
++              if (Config.zph_tos_peer && 
++               (http->request->hier.code==SIBLING_HIT ||
++                       Config.onoff.zph_tos_parent && http->request->hier.code==PARENT_HIT))
++              {
++                      tos = Config.zph_tos_peer;
++                      debugs(33, 1, "ZPH: Peer hit, TOS="<<tos<<" hier.code="<<http->request->hier.code);
++              }
++              else if (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask)
++              {
++                      tos = fd_table[fd].upstreamTOS & Config.zph_preserve_miss_tos_mask;
++                      debugs(33, 1, "ZPH: Preserving TOS on miss, TOS="<<tos);
 +              }
-+    }
-+/* ZPH patch ends here */    
-+#endif
++              comm_set_tos(fd,tos);
++    }     
  
-     debug(11, 5) ("httpSendRequest: FD %d: httpState %p.\n", fd, httpState);
+     if (buf != result.data) {
+         /* we've got to copy some data */
+diff -Nur squid-3.0.STABLE8/src/fde.h squid-3.0.STABLE8-zph/src/fde.h
+--- squid-3.0.STABLE8/src/fde.h        2008-07-18 13:02:54.000000000 +0300
++++ squid-3.0.STABLE8-zph/src/fde.h    2008-08-22 13:26:05.000000000 +0300
+@@ -106,7 +106,7 @@
+         long handle;
+     } win32;
+ #endif
+-
++    unsigned char upstreamTOS;                        /* see FwdState::dispatch()  */
+ };
+ #endif /* SQUID_FDE_H */
+diff -Nur squid-3.0.STABLE8/src/forward.cc squid-3.0.STABLE8-zph/src/forward.cc
+--- squid-3.0.STABLE8/src/forward.cc   2008-07-18 13:02:54.000000000 +0300
++++ squid-3.0.STABLE8-zph/src/forward.cc       2008-08-22 13:26:10.000000000 +0300
+@@ -964,6 +964,52 @@
  
-diff -Nru squid-2.6.STABLE12.orig/src/structs.h squid-2.6.STABLE12/src/structs.h
---- squid-2.6.STABLE12.orig/src/structs.h      2007-02-27 03:20:01.000000000 +0200
-+++ squid-2.6.STABLE12/src/structs.h   2007-03-21 19:44:08.000000000 +0200
-@@ -669,6 +669,8 @@
-       int relaxed_header_parser;
-       int accel_no_pmtu_disc;
-       int global_internal_static;
-+      int zph_tos_parent;
-+      int zph_preserve_miss_tos;      
-       int httpd_suppress_version_string;
-       int via;
-       int check_hostnames;
-@@ -793,6 +795,9 @@
+     netdbPingSite(request->host);
++    /* Retrieves remote server TOS value, and stores it as part of the
++     * original client request FD object. It is later used to forward
++     * remote server's TOS in the response to the client in case of a MISS.
++     */
++      fde * clientFde = &fd_table[client_fd];
++      if (clientFde)
++      {
++              int tos = 1;
++              int tos_len = sizeof(tos);
++              clientFde->upstreamTOS = 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)
++             {
++                 /* Parse the PKTOPTIONS structure to locate the TOS data message
++                  * prepared in the kernel by the ZPH incoming TCP TOS preserving
++                  * patch.
++                  */
++                 unsigned char * p = buf;
++                 while (p-buf < len)
++                 {
++                    struct cmsghdr *o = (struct cmsghdr*)p;
++                    if (o->cmsg_len<=0)
++                       break;
++      
++                    if (o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS)
++                    {
++                        clientFde->upstreamTOS = (unsigned char)(*(int*)CMSG_DATA(o));
++                        break;
++                    }
++                    p += CMSG_LEN(o->cmsg_len);
++                 }
++             }
++             else
++             {
++                 debugs(33, 1, "ZPH: error in getsockopt(IP_PKTOPTIONS) on FD "<<server_fd<<" "<<xstrerror());
++             }
++          }
++          else
++          {
++              debugs(33, 1, "ZPH: error in setsockopt(IP_RECVTOS) on FD "<<server_fd<<" "<<xstrerror());
++          }
++      }    
++
+     if (servers && (p = servers->_peer)) {
+         p->stats.fetches++;
+         request->peer_login = p->login;
+diff -Nur squid-3.0.STABLE8/src/structs.h squid-3.0.STABLE8-zph/src/structs.h
+--- squid-3.0.STABLE8/src/structs.h    2008-07-18 13:02:54.000000000 +0300
++++ squid-3.0.STABLE8-zph/src/structs.h        2008-08-22 13:26:24.000000000 +0300
+@@ -553,6 +553,8 @@
+         int emailErrData;
+         int httpd_suppress_version_string;
+         int global_internal_static;
++        int zph_tos_parent;
++        int zph_preserve_miss_tos;
+         int debug_override_X;
+         int WIN32_IpAddrChangeMonitor;
+     }
+@@ -721,6 +723,9 @@
      int sleep_after_fork;     /* microseconds */
      time_t minimum_expiry_time;       /* seconds */
      external_acl *externalAclHelperList;
-+      int zph_tos_local;
-+      int zph_tos_peer;
-+      int zph_preserve_miss_tos_mask;    
-     errormap *errorMapList;
++    int zph_tos_local;
++    int zph_tos_peer;
++    int zph_preserve_miss_tos_mask;
  #if USE_SSL
-     struct {
-@@ -1724,6 +1729,9 @@
-     const char *vary_encoding;
-     StoreEntry *ims_entry;
-     time_t refresh_timestamp;
-+#if defined(_SQUID_LINUX_)    
-+    unsigned char recvTOS; /* ZPH patch - stores remote server's TOS */
-+#endif        
- };
  
- struct _StoreEntry {
+     struct
This page took 0.551454 seconds and 4 git commands to generate.