1 diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data.pre
2 --- squid-2.6.STABLE12.orig/src/cf.data.pre 2007-03-21 19:43:48.000000000 +0200
3 +++ squid-2.6.STABLE12/src/cf.data.pre 2007-03-21 19:44:08.000000000 +0200
5 to off when using this directive in such configurations.
11 +LOC: Config.zph_tos_local
13 + Allows you to select a TOS/Diffserv value to mark local hits. Read above
14 + (tcp_outgoing_tos) for details/requirements about TOS.
15 + Default: 0 (disabled).
21 +LOC: Config.zph_tos_peer
23 + Allows you to select a TOS/Diffserv value to mark peer hits. Read above
24 + (tcp_outgoing_tos) for details/requirements about TOS.
25 + Default: 0 (disabled).
31 +LOC: Config.onoff.zph_tos_parent
34 + Set this to off if you want only sibling hits to be marked.
35 + If set to on (default), parent hits are being marked too.
38 +NAME: zph_preserve_miss_tos
41 +LOC: Config.onoff.zph_preserve_miss_tos
44 + If set to on (default), any HTTP response towards clients will
45 + have the TOS value of the response comming from the remote
46 + server masked with the value of zph_preserve_miss_tos_mask.
47 + For this to work correctly, you will need to patch your linux
48 + kernel with the TOS preserving ZPH patch.
49 + Has no effect under FreeBSD, works only under linux ZPH patched
53 +NAME: zph_preserve_miss_tos_mask
56 +LOC: Config.zph_preserve_miss_tos_mask
58 + Allows you to mask certain bits in the TOS received from the
59 + remote server, before copying the value to the TOS send towards
61 + See zph_preserve_miss_tos for details.
63 + Default: 255 (TOS from server is not changed).
66 NAME: tcp_outgoing_address
69 diff -Nru squid-2.6.STABLE12.orig/src/client_side.c squid-2.6.STABLE12/src/client_side.c
70 --- squid-2.6.STABLE12.orig/src/client_side.c 2007-03-21 19:43:48.000000000 +0200
71 +++ squid-2.6.STABLE12/src/client_side.c 2007-03-21 19:44:08.000000000 +0200
72 @@ -2621,6 +2621,55 @@
75 assert(http->out.offset == 0);
77 + if ( Config.zph_tos_local || Config.zph_tos_peer ||
78 + (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask) )
80 + int need_change = 0;
84 + int tos_len = sizeof(tos_old);
87 + if (Config.zph_tos_local && isTcpHit(http->log_type)) { /* local hit */
89 + tos = Config.zph_tos_local;
90 + } else if (Config.zph_tos_peer &&
91 + (http->request->hier.code == SIBLING_HIT || /* sibling hit */
92 + (Config.onoff.zph_tos_parent &&
93 + http->request->hier.code == PARENT_HIT))) { /* parent hit */
95 + tos = Config.zph_tos_peer;
97 + if (http->request->flags.proxy_keepalive) {
98 + if (getsockopt(fd, IPPROTO_IP, IP_TOS, &tos_old, &tos_len) < 0) {
99 + debug(33, 1) ("ZPH: getsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
100 + } else if (hit && tos_old != tos) { /* HIT: 1-st request, or previous was MISS, */
101 + need_change = 1; /* or local/parent hit change */
102 + } else if (!hit && (tos_old || /* MISS: previous was HIT */
103 + Config.onoff.zph_preserve_miss_tos)) { /* TOS copying is on */
104 +#if defined(_SQUID_LINUX_)
105 + if ( Config.onoff.zph_preserve_miss_tos ) {
106 + tos = (entry->mem_obj != NULL) ?
107 + (entry->mem_obj->recvTOS & Config.zph_preserve_miss_tos_mask):0;
114 + } else if (hit) { /* no keepalive */
118 + if (!hit) enter_suid(); /* Setting TOS bit6-7 is privilleged */
119 + res = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
120 + if (!hit) leave_suid(); /* Setting bit5-7 is privilleged */
122 + debug(33, 1) ("ZPH: setsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
125 rep = http->reply = clientBuildReply(http, buf, size);
127 /* Forward as HTTP/0.9 body with no reply */
128 diff -Nru squid-2.6.STABLE12.orig/src/http.c squid-2.6.STABLE12/src/http.c
129 --- squid-2.6.STABLE12.orig/src/http.c 2007-03-13 00:27:09.000000000 +0200
130 +++ squid-2.6.STABLE12/src/http.c 2007-03-21 19:44:08.000000000 +0200
131 @@ -1373,6 +1373,53 @@
132 peer *p = httpState->peer;
133 CWCB *sendHeaderDone;
134 int fd = httpState->fd;
136 +#if defined(_SQUID_LINUX_)
137 +/* ZPH patch starts here (M.Stavrev 25-05-2005)
138 + * Retrieve connection peer's TOS value (which its SYN_ACK TCP segment
139 + * was encapsulated into an IP packet)
142 + if ( entry && entry->mem_obj ) { // Is this check necessary ? Seems not, but
143 + // have no time to investigate further.
144 + entry->mem_obj->recvTOS = 0;
146 + tos_len = sizeof(tos);
147 + if ( setsockopt(fd,SOL_IP, IP_RECVTOS, &tos, tos_len) == 0 ) {
148 + unsigned char buf[128];
150 + if (getsockopt(fd, SOL_IP, IP_PKTOPTIONS, buf, &len) == 0)
152 + /* Parse the PKTOPTIONS structure to locate the TOS data message
153 + * prepared in the kernel by the ZPH incoming TCP TOS preserving
154 + * patch. In 99,99% the TOS should be located at buf[12], but
155 + * let's do it the right way.
157 + unsigned char * p = buf;
158 + while ( p-buf < len ) {
159 + struct cmsghdr * o = (struct cmsghdr*)p;
160 + if ( o->cmsg_len <= 0 || o->cmsg_len > 52 )
162 + if ( o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS ) {
163 + entry->mem_obj->recvTOS = (unsigned char)(*(int*)
164 + (p + sizeof(struct cmsghdr)));
165 + debug(11, 5) ("ZPH: Incomming TOS=%d on FD %d\n",
166 + entry->mem_obj->recvTOS, fd );
172 + debug(11, 5) ("ZPH: getsockopt(IP_PKTOPTIONS) on FD %d: %s\n",
176 + debug(11, 5) ("ZPH: setsockopt(IP_RECVTOS) on FD %d: %s\n",
180 +/* ZPH patch ends here */
183 debug(11, 5) ("httpSendRequest: FD %d: httpState %p.\n", fd, httpState);
185 diff -Nru squid-2.6.STABLE12.orig/src/structs.h squid-2.6.STABLE12/src/structs.h
186 --- squid-2.6.STABLE12.orig/src/structs.h 2007-02-27 03:20:01.000000000 +0200
187 +++ squid-2.6.STABLE12/src/structs.h 2007-03-21 19:44:08.000000000 +0200
189 int relaxed_header_parser;
190 int accel_no_pmtu_disc;
191 int global_internal_static;
192 + int zph_tos_parent;
193 + int zph_preserve_miss_tos;
194 int httpd_suppress_version_string;
198 int sleep_after_fork; /* microseconds */
199 time_t minimum_expiry_time; /* seconds */
200 external_acl *externalAclHelperList;
203 + int zph_preserve_miss_tos_mask;
204 errormap *errorMapList;
207 @@ -1724,6 +1729,9 @@
208 const char *vary_encoding;
209 StoreEntry *ims_entry;
210 time_t refresh_timestamp;
211 +#if defined(_SQUID_LINUX_)
212 + unsigned char recvTOS; /* ZPH patch - stores remote server's TOS */