Zero Penalty Hit patch for SQUID (ZPH)




Important note: All patches presented here must be applied over a clean source tree of the indicated SQUID's version.
Do not try to apply more than one patch at a time, older patches are published for consistency only !!!

Latest (recomended) ZPH patches
ZPH type    Date of last modification    Description
TOS preserving on MISS    26-Mar-2011 - Linux kernel 2.6.35 patch
   (tested on Ubuntu 10.10 Maverick Meerkat)
The Squid caching engine version 3.1.x has the ZPH feature build-in, so you no longer need to patch the source code yourself. For those, who require the incoming TOS preserving feature (on cache MISS), I'm providing the linux kernel 2.6.35 patch:
Kernel 2.6.35 ZPH TOS preserving patch.
Note: The same patch applies (ignore the hunks) on the latest vanilla kernel at the time of writing (2.6.38.1)
TOS marking with
TOS preserving on MISS
   25-Aug-2008 - Patch version for SQUID-3.0STABLE8. A bug has been fixed in this updated Squid patch. The bug prevented marking parent/sibling hits with the value of zph_tos_peer. The value of zph_tos_local was used instead.
Additionally the kernel patch has been updated to support latest kernel source tree. The kernel patch has also been improved - it shall now capture the TOS value in the first data segment received from the remote peer. This allows preserving the TOS value of a missed request coming from a parent cache that is also ZPH patched. Links:
Squid-3.0STABLE8 ZPH patch
Kernel 2.6.26.3 ZPH patch.
TOS marking with
TOS preserving on MISS
   24-Apr-2008 - Patch version for SQUID-3.0STABLE4. No changes in patch, simply adjusted to apply cleanly on the latest SQUID 3.0 source tree. To have the TOS preserving feature working, you will also need a kernel patch. Links:
Squid-3.0STABLE4 ZPH patch
Kernel 2.6.25 ZPH patch.
TOS marking with
TOS preserving on MISS
   13-Aug-2006 - Patch version for SQUID 2.6STABLE2. No changes in patch, simply adjusted to apply cleanly on the latest SQUID 2.6 source tree. Here it is: squid-2.6.STABLE2
TOS marking with
TOS preserving on MISS
   05-March-2006 - Patch version for SQUID 2.5STABLE12-20060305 snapshot build.
   I hope it will aslo apply for STABLE13 when it is released.
No changes in patch, simply adjusted to apply cleanly. Here it is: SQUID2.5STABLE12-20060305
TOS marking with
TOS preserving on MISS
   03-March-2006 - Updated patch versions for SQUID 2.5STABLE12
   and latest 2.6 kernel 2.6.15.5
No changes in patches, simply adjusted to apply cleanly on the latest versions of SQUID and linux 2.6 kernel. Links follow:
  • patch for SQUID2.5STABLE12
  • patch for linux kernel 2.6.15.5
  • TOS marking with
    TOS preserving on MISS
       03-June-2005 - small fix that cleans SQUID
       compilation problems under gcc 2.95 series
       (patch has been overwritten)

       26-May-2005 - initial release
    Extension of the ZPH TOS marking patch which preserves the original TOS received from the remote server when a cache MISS occures (TOS copying). It consists of two patches - one for SQUID, and another for the linux kernel. This is the initial release which supports squid-2.5.STABLE10 combined with linux kernel version 2.4.30(and possibly up) or 2.6.11.10 (and possibly up) . Read more info here.
    TOS marking    16-May-2005   Update of ZPH Evgeni Gechev's TOS marking patch for STABLE10 (at least RC3) - squid-2.5.STABLE10-ToS_Hit.patch. There are no differences compared to the STABLE7 patch - just a fix to make it apply cleanly for STABLE10 source tree. Here is documentation about applying.
    TOS marking    16-May-2005   Update of ZPH Evgeni Gechev's TOS marking patch for STABLE9 - squid-2.5.STABLE9-ToS_Hit.patch. There are no differences compared to the STABLE7 patch - just a fix to make it apply cleanly for STABLE9 source tree. Here is documentation about applying.
    IP Option marking    13-Dec-2004   ZPH with IP option marking for squid-2.5.STABLE7 - nothing new, just synchronized with the latest squid source. Applies cleanly on STABLE9 and STABLE10 (At least for RC3) source trees.
     
    Older versions of ZPH patches (not needed when using the latest one)
    11-Dec-2004   Stable ZPH TOS marking patch, by Evgeni Gechev for STABLE7 - squid-2.5.STABLE7-ToS_Hit.patch. There are no differences compared to the STABLE5 patch (which is compatible with STABLE6, too) - just a fix to make it apply cleanly for STABLE7. Here is documentation about applying.
    02-Oct-2004   ZPH with IP option marking for squid-2.5.STABLE6 by Teodor Yantchev. Thanks Teodor !
    27-Apr-2004   Stable ZPH TOS marking patch, by Evgeni Gechev for STABLE5, here is the changelog and documentation about applying.
    20-Mar-2004   Yet another important development of ZPH TOS marking patch, by Evgeni Gechev. Here's the changelog
    20-Feb-2004   A subtle, but important for some cases contribution by Evgeni Gechev to the TOS marking option. Read more...
    08-Dec-2003   Thanks to Venkatesh K. Reddy we have a TOS marking option for HIT packets.
    16-Oct-2003   A new version is available - the ultimate HIT packets marking solution.

    About

    My name is Marin Stavrev and I used to work as an instructor at a local Cisco Network Academy at Plovdiv, Bulgaria (IT-Academy). Part of my job was to take care of our academy's LAN. Connectivity to the Internet was a major concern because of the regular on-line exams CNA students attended. This patch was "fabricated" in a couple of hours (from idea to a .diff file), so do not expected it to be very configurable. I have never before dealt with SQUID's source tree, and after those two hours I still lack a lot of details about its inner working. In spite of that, I think this patch is vital and it really serves me well. I'll be glad to see a more competent SQUID hacker use this idea and contribute to the public a more user-friendly patch that deals with HIT/MISS classification.

    Availability

    Currently there are 3 different versions of the patch. The old one has one major limitation - traffic shaping has to be done on the same machine, where Squid engine is running. It is still published here, but I recomend the usage of the latest versions of either TOS or IP option marking solutions:

    1. Here is the latest version (11-Dec-2004) of the TOS marking. Take a look at the Documentation before applying the patch.

    2. Here is the latest version (13-Dec-2004) of the IP option marking. Take a look at the Documentation before applying the patch. An older version covering squid STABLE3/4/5 can be downloaded from here.

    3. The oldest version of the patch can be found here. It should compile with squid-2.5.STABLE-3, STABLE-4 and probably older versions as well (though not tested). Documentation about applying the patch can be found here.

    Purpose

    The idea behind this patch is to allow classification of packets generated from the squid cache engine towards clients. The classification is based on whether the content is being served from cache (a cache HIT), or is being retrieved from a remote server (a cache MISS).

    Background

    I made this patch to deal with a problem of the current QoS design I have implemented. I'm using a single Linux box to act as Firewall/NAT/Transparent HTTP cache for a small network of computers. The box also imposes the QoS policies for the communications to/from the Internet. The QoS is based on HTB+SFQ queuing disciplines. Statistics gathered from the squid cache (through SNMP) clearly show an average monthly HIT rate of about 25%. Unfortunately, unless using the delay pools feature of SQUID, there is no way to limit only those requests served from remote servers. The Delay pools are a nice feature of SQUID, but cannot work efficiently due to the lack of communication with the QoS policies beneath. What I needed was a way to classify packets and set no penalty in bandwidth and delay, when the information is served from SQUID's cache.

    FAQ

    Comming soon..., may be..

    Credits

    This whole patch is inspired by the patch Patrick McHardy made available to the general public. You can find it here.


    Everything here is published under the terms of the GPL. Any questions or suggestions e-mail to the author at mstavrev@gmail.com