]> git.pld-linux.org Git - packages/squid.git/blame - squid_hit_miss_mark.patch
- updated more patches
[packages/squid.git] / squid_hit_miss_mark.patch
CommitLineData
f4477de3 1diff -Nur squid-3.0.STABLE8/src/cf.data.pre squid-3.0.STABLE8-zph/src/cf.data.pre
2--- squid-3.0.STABLE8/src/cf.data.pre 2008-07-18 13:02:53.000000000 +0300
3+++ squid-3.0.STABLE8-zph/src/cf.data.pre 2008-08-22 13:25:45.000000000 +0300
4@@ -1119,6 +1119,60 @@
0a52bd7c 5 making the request.
d7907af9 6 DOC_END
7
8+NAME: zph_tos_local
9+TYPE: int
10+DEFAULT: 0
11+LOC: Config.zph_tos_local
12+DOC_START
0a52bd7c 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).
d7907af9 16+DOC_END
17+
18+NAME: zph_tos_peer
19+TYPE: int
20+DEFAULT: 0
21+LOC: Config.zph_tos_peer
22+DOC_START
0a52bd7c 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).
d7907af9 26+DOC_END
27+
28+NAME: zph_tos_parent
29+COMMENT: on|off
30+TYPE: onoff
0a52bd7c 31+LOC: Config.onoff.zph_tos_parent
f4477de3 32+DEFAULT: on
d7907af9 33+DOC_START
0a52bd7c 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.
d7907af9 36+DOC_END
37+
38+NAME: zph_preserve_miss_tos
39+COMMENT: on|off
40+TYPE: onoff
0a52bd7c 41+LOC: Config.onoff.zph_preserve_miss_tos
f4477de3 42+DEFAULT: on
d7907af9 43+DOC_START
0a52bd7c 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.
d7907af9 49+DOC_END
50+
51+NAME: zph_preserve_miss_tos_mask
52+TYPE: int
53+DEFAULT: 255
54+LOC: Config.zph_preserve_miss_tos_mask
55+DOC_START
0a52bd7c 56+ Allows you to mask certain bits in the TOS received from the
57+ remote server, before copying the value to the TOS send towards
58+ clients.
59+ Default: 255 (TOS from server is not changed).
d7907af9 60+DOC_END
61+
62 NAME: tcp_outgoing_address
63 TYPE: acl_address
64 DEFAULT: none
f4477de3 65diff -Nur squid-3.0.STABLE8/src/client_side_reply.cc squid-3.0.STABLE8-zph/src/client_side_reply.cc
66--- squid-3.0.STABLE8/src/client_side_reply.cc 2008-07-18 13:02:54.000000000 +0300
67+++ squid-3.0.STABLE8-zph/src/client_side_reply.cc 2008-08-22 13:25:54.000000000 +0300
68@@ -48,6 +48,7 @@
0a52bd7c 69 #include "ESI.h"
70 #endif
71 #include "MemObject.h"
0a52bd7c 72+#include "fde.h"
0a52bd7c 73 #include "ACLChecklist.h"
74 #include "ACL.h"
75 #if DELAY_POOLS
f4477de3 76@@ -1548,6 +1549,11 @@
0a52bd7c 77 /* guarantee nothing has been sent yet! */
78 assert(http->out.size == 0);
79 assert(http->out.offset == 0);
f4477de3 80+ if (Config.zph_tos_local)
81+ {
82+ debugs(33, 1, "ZPH hit hier.code=" << http->request->hier.code <<" TOS="<<Config.zph_tos_local);
83+ comm_set_tos(http->getConn()->fd,Config.zph_tos_local);
84+ }
0a52bd7c 85 tempBuffer.offset = reqofs;
86 tempBuffer.length = getNextNode()->readBuffer.length;
87 tempBuffer.data = getNextNode()->readBuffer.data;
f4477de3 88@@ -1827,6 +1833,24 @@
89 char *buf = next()->readBuffer.data;
0a52bd7c 90
f4477de3 91 char *body_buf = buf;
92+
93+ if (reqofs==0 && !logTypeIsATcpHit(http->logType))
d7907af9 94+ {
f4477de3 95+ int tos = 0;
96+ if (Config.zph_tos_peer &&
97+ (http->request->hier.code==SIBLING_HIT ||
98+ Config.onoff.zph_tos_parent && http->request->hier.code==PARENT_HIT))
99+ {
100+ tos = Config.zph_tos_peer;
101+ debugs(33, 1, "ZPH: Peer hit, TOS="<<tos<<" hier.code="<<http->request->hier.code);
102+ }
103+ else if (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask)
104+ {
105+ tos = fd_table[fd].upstreamTOS & Config.zph_preserve_miss_tos_mask;
106+ debugs(33, 1, "ZPH: Preserving TOS on miss, TOS="<<tos);
107+ }
108+ comm_set_tos(fd,tos);
109+ }
0a52bd7c 110
f4477de3 111 if (buf != result.data) {
112 /* we've got to copy some data */
113diff -Nur squid-3.0.STABLE8/src/fde.h squid-3.0.STABLE8-zph/src/fde.h
114--- squid-3.0.STABLE8/src/fde.h 2008-07-18 13:02:54.000000000 +0300
115+++ squid-3.0.STABLE8-zph/src/fde.h 2008-08-22 13:26:05.000000000 +0300
116@@ -106,7 +106,7 @@
0a52bd7c 117 long handle;
118 } win32;
119 #endif
f4477de3 120-
0a52bd7c 121+ unsigned char upstreamTOS; /* see FwdState::dispatch() */
0a52bd7c 122 };
123
f4477de3 124 #endif /* SQUID_FDE_H */
125diff -Nur squid-3.0.STABLE8/src/forward.cc squid-3.0.STABLE8-zph/src/forward.cc
126--- squid-3.0.STABLE8/src/forward.cc 2008-07-18 13:02:54.000000000 +0300
127+++ squid-3.0.STABLE8-zph/src/forward.cc 2008-08-22 13:26:10.000000000 +0300
128@@ -964,6 +964,52 @@
0a52bd7c 129
130 netdbPingSite(request->host);
131
0a52bd7c 132+ /* Retrieves remote server TOS value, and stores it as part of the
133+ * original client request FD object. It is later used to forward
134+ * remote server's TOS in the response to the client in case of a MISS.
135+ */
f4477de3 136+ fde * clientFde = &fd_table[client_fd];
137+ if (clientFde)
138+ {
139+ int tos = 1;
140+ int tos_len = sizeof(tos);
141+ clientFde->upstreamTOS = 0;
142+ if (setsockopt(server_fd,SOL_IP,IP_RECVTOS,&tos,tos_len)==0)
143+ {
144+ unsigned char buf[512];
145+ int len = 512;
146+ if (getsockopt(server_fd,SOL_IP,IP_PKTOPTIONS,buf,(socklen_t*)&len) == 0)
147+ {
148+ /* Parse the PKTOPTIONS structure to locate the TOS data message
149+ * prepared in the kernel by the ZPH incoming TCP TOS preserving
150+ * patch.
151+ */
152+ unsigned char * p = buf;
153+ while (p-buf < len)
154+ {
155+ struct cmsghdr *o = (struct cmsghdr*)p;
156+ if (o->cmsg_len<=0)
157+ break;
158+
159+ if (o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS)
160+ {
161+ clientFde->upstreamTOS = (unsigned char)(*(int*)CMSG_DATA(o));
162+ break;
163+ }
164+ p += CMSG_LEN(o->cmsg_len);
165+ }
166+ }
167+ else
168+ {
169+ debugs(33, 1, "ZPH: error in getsockopt(IP_PKTOPTIONS) on FD "<<server_fd<<" "<<xstrerror());
170+ }
171+ }
172+ else
173+ {
174+ debugs(33, 1, "ZPH: error in setsockopt(IP_RECVTOS) on FD "<<server_fd<<" "<<xstrerror());
175+ }
176+ }
0a52bd7c 177+
178 if (servers && (p = servers->_peer)) {
179 p->stats.fetches++;
180 request->peer_login = p->login;
f4477de3 181diff -Nur squid-3.0.STABLE8/src/structs.h squid-3.0.STABLE8-zph/src/structs.h
182--- squid-3.0.STABLE8/src/structs.h 2008-07-18 13:02:54.000000000 +0300
183+++ squid-3.0.STABLE8-zph/src/structs.h 2008-08-22 13:26:24.000000000 +0300
184@@ -553,6 +553,8 @@
185 int emailErrData;
0a52bd7c 186 int httpd_suppress_version_string;
187 int global_internal_static;
0a52bd7c 188+ int zph_tos_parent;
189+ int zph_preserve_miss_tos;
f4477de3 190 int debug_override_X;
191 int WIN32_IpAddrChangeMonitor;
192 }
193@@ -721,6 +723,9 @@
d7907af9 194 int sleep_after_fork; /* microseconds */
195 time_t minimum_expiry_time; /* seconds */
196 external_acl *externalAclHelperList;
0a52bd7c 197+ int zph_tos_local;
198+ int zph_tos_peer;
f4477de3 199+ int zph_preserve_miss_tos_mask;
d7907af9 200 #if USE_SSL
91e92d0a 201
0a52bd7c 202 struct
This page took 0.16349 seconds and 4 git commands to generate.