]>
Commit | Line | Data |
---|---|---|
0a52bd7c | 1 | --- /configure.in 2008-04-29 02:52:30 +0000 |
2 | +++ /configure.in 2008-05-03 23:37:00 +0000 | |
3 | @@ -1733,6 +1733,16 @@ | |
4 | fi | |
5 | ]) | |
6 | ||
7 | +AC_ARG_ENABLE(zph-qos, | |
8 | +[ --enable-zph-qos Enable ZPH QOS support], | |
9 | +[ if test "$enableval" = "yes" ; then | |
10 | + echo "ZPH QOS enabled" | |
11 | + AC_DEFINE(USE_ZPH_QOS,1, | |
12 | + [ Define this to use Squid's ZPH (Zero Penalty Hit) QOS features. | |
13 | + When enabled, Squid will alter TOS field of HIT responses for better QOS on intermediate routing/shaping devices.]) | |
14 | + fi | |
15 | +]) | |
16 | + | |
17 | AC_ARG_WITH(filedescriptors, | |
18 | [ --with-filedescriptors=NUMBER | |
19 | Force squid to support NUMBER filedescriptors], | |
20 | ||
21 | --- /src/cf.data.pre 2008-05-02 11:12:10 +0000 | |
22 | +++ /src/cf.data.pre 2008-05-03 23:37:00 +0000 | |
23 | @@ -1103,6 +1103,66 @@ | |
24 | making the request. | |
d7907af9 | 25 | DOC_END |
26 | ||
27 | +NAME: zph_tos_local | |
28 | +TYPE: int | |
0a52bd7c | 29 | +IFDEF: USE_ZPH_QOS |
d7907af9 | 30 | +DEFAULT: 0 |
31 | +LOC: Config.zph_tos_local | |
32 | +DOC_START | |
0a52bd7c | 33 | + Allows you to select a TOS/Diffserv value to mark local hits. Read above |
34 | + (tcp_outgoing_tos) for details/requirements about TOS. | |
35 | + Default: 0 (disabled). | |
d7907af9 | 36 | +DOC_END |
37 | + | |
38 | +NAME: zph_tos_peer | |
39 | +TYPE: int | |
0a52bd7c | 40 | +IFDEF: USE_ZPH_QOS |
d7907af9 | 41 | +DEFAULT: 0 |
42 | +LOC: Config.zph_tos_peer | |
43 | +DOC_START | |
0a52bd7c | 44 | + Allows you to select a TOS/Diffserv value to mark peer hits. Read above |
45 | + (tcp_outgoing_tos) for details/requirements about TOS. | |
46 | + Default: 0 (disabled). | |
d7907af9 | 47 | +DOC_END |
48 | + | |
49 | +NAME: zph_tos_parent | |
50 | +COMMENT: on|off | |
51 | +TYPE: onoff | |
0a52bd7c | 52 | +IFDEF: USE_ZPH_QOS |
d7907af9 | 53 | +DEFAULT: on |
0a52bd7c | 54 | +LOC: Config.onoff.zph_tos_parent |
d7907af9 | 55 | +DOC_START |
0a52bd7c | 56 | + Set this to off if you want only sibling hits to be marked. |
57 | + If set to on (default), parent hits are being marked too. | |
d7907af9 | 58 | +DOC_END |
59 | + | |
60 | +NAME: zph_preserve_miss_tos | |
61 | +COMMENT: on|off | |
62 | +TYPE: onoff | |
0a52bd7c | 63 | +IFDEF: USE_ZPH_QOS |
d7907af9 | 64 | +DEFAULT: on |
0a52bd7c | 65 | +LOC: Config.onoff.zph_preserve_miss_tos |
d7907af9 | 66 | +DOC_START |
0a52bd7c | 67 | + If set to on (default), any HTTP response towards clients will |
68 | + have the TOS value of the response comming from the remote | |
69 | + server masked with the value of zph_preserve_miss_tos_mask. | |
70 | + For this to work correctly, you will need to patch your linux | |
71 | + kernel with the TOS preserving ZPH patch. | |
72 | + The kernel patch can be downloaded from http://zph.bratcheda.org | |
d7907af9 | 73 | +DOC_END |
74 | + | |
75 | +NAME: zph_preserve_miss_tos_mask | |
76 | +TYPE: int | |
0a52bd7c | 77 | +IFDEF: USE_ZPH_QOS |
d7907af9 | 78 | +DEFAULT: 255 |
79 | +LOC: Config.zph_preserve_miss_tos_mask | |
80 | +DOC_START | |
0a52bd7c | 81 | + Allows you to mask certain bits in the TOS received from the |
82 | + remote server, before copying the value to the TOS send towards | |
83 | + clients. | |
84 | + Default: 255 (TOS from server is not changed). | |
d7907af9 | 85 | +DOC_END |
86 | + | |
87 | NAME: tcp_outgoing_address | |
88 | TYPE: acl_address | |
89 | DEFAULT: none | |
0a52bd7c | 90 | |
91 | --- /src/client_side_reply.cc 2008-03-30 14:29:57 +0000 | |
92 | +++ /src/client_side_reply.cc 2008-05-03 23:37:00 +0000 | |
93 | @@ -48,6 +48,9 @@ | |
94 | #include "ESI.h" | |
95 | #endif | |
96 | #include "MemObject.h" | |
97 | +#if USE_ZPH_QOS | |
98 | +#include "fde.h" | |
99 | +#endif | |
100 | #include "ACLChecklist.h" | |
101 | #include "ACL.h" | |
102 | #if DELAY_POOLS | |
103 | @@ -1548,6 +1551,58 @@ | |
104 | /* guarantee nothing has been sent yet! */ | |
105 | assert(http->out.size == 0); | |
106 | assert(http->out.offset == 0); | |
107 | +#if USE_ZPH_QOS | |
108 | + if (Config.zph_tos_local || | |
109 | + Config.zph_tos_peer || | |
110 | + Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask) | |
111 | + { | |
112 | + int need_change = 0; | |
113 | + int hit = 0; | |
114 | + int tos = 0; | |
115 | + int tos_old = 0; | |
116 | + int tos_len = sizeof(tos_old); | |
117 | + int res; | |
118 | + | |
119 | + if (Config.zph_tos_local) | |
120 | + { | |
121 | + /* local hit */ | |
122 | + hit = 1; | |
123 | + tos = Config.zph_tos_local; | |
124 | + } | |
125 | + else if (Config.zph_tos_peer && | |
126 | + (http->request->hier.code==SIBLING_HIT || | |
127 | + Config.onoff.zph_tos_parent&&http->request->hier.code==PARENT_HIT)) | |
128 | + { | |
129 | + /* sibling or parent hit */ | |
130 | + hit = 1; | |
131 | + tos = Config.zph_tos_peer; | |
132 | + } | |
133 | + | |
134 | + if (http->request->flags.proxy_keepalive) | |
135 | + { | |
136 | + res = getsockopt(http->getConn()->fd, IPPROTO_IP, IP_TOS, &tos_old, (socklen_t*)&tos_len); | |
137 | + if (res < 0) | |
138 | + { | |
139 | + debugs(33, 1, "ZPH: error in getsockopt(IP_TOS) on keepalived FD "<< http->getConn()->fd << " " << xstrerror()); | |
140 | + } | |
141 | + else if (hit && tos_old != tos) | |
142 | + { | |
143 | + /* HIT: 1-st request, or previous was MISS, | |
144 | + * or local/parent hit change. | |
145 | + */ | |
146 | + need_change = 1; | |
147 | + } | |
148 | + } | |
149 | + else if (hit) | |
150 | + { | |
151 | + /* no keepalive */ | |
152 | + need_change = 1; | |
153 | + } | |
154 | + if (need_change) { | |
155 | + comm_set_tos(http->getConn()->fd,tos); | |
156 | + } | |
157 | + } | |
158 | +#endif /* USE_ZPH_QOS */ | |
159 | tempBuffer.offset = reqofs; | |
160 | tempBuffer.length = getNextNode()->readBuffer.length; | |
161 | tempBuffer.data = getNextNode()->readBuffer.data; | |
162 | @@ -1833,6 +1888,16 @@ | |
163 | body_buf = buf; | |
41c7a9fd | 164 | } |
0a52bd7c | 165 | |
166 | +#if USE_ZPH_QOS | |
167 | + if (reqofs==0 && !logTypeIsATcpHit(http->logType) && | |
168 | + Config.onoff.zph_preserve_miss_tos && | |
169 | + Config.zph_preserve_miss_tos_mask) | |
d7907af9 | 170 | + { |
0a52bd7c | 171 | + int tos = fd_table[fd].upstreamTOS & Config.zph_preserve_miss_tos_mask; |
172 | + comm_set_tos(fd,tos); | |
41c7a9fd | 173 | + } |
0a52bd7c | 174 | +#endif |
175 | + | |
176 | /* We've got the final data to start pushing... */ | |
177 | flags.storelogiccomplete = 1; | |
178 | ||
179 | ||
180 | --- /src/fde.h 2007-08-13 23:20:50 +0000 | |
181 | +++ /src/fde.h 2008-05-03 23:37:00 +0000 | |
182 | @@ -106,6 +106,9 @@ | |
183 | long handle; | |
184 | } win32; | |
185 | #endif | |
186 | +#if USE_ZPH_QOS | |
187 | + unsigned char upstreamTOS; /* see FwdState::dispatch() */ | |
188 | +#endif | |
189 | ||
190 | }; | |
191 | ||
192 | ||
193 | --- /src/forward.cc 2008-04-12 15:16:27 +0000 | |
194 | +++ /src/forward.cc 2008-05-03 23:37:00 +0000 | |
195 | @@ -964,6 +964,54 @@ | |
196 | ||
197 | netdbPingSite(request->host); | |
198 | ||
199 | +#if USE_ZPH_QOS | |
200 | + /* Retrieves remote server TOS value, and stores it as part of the | |
201 | + * original client request FD object. It is later used to forward | |
202 | + * remote server's TOS in the response to the client in case of a MISS. | |
203 | + */ | |
204 | + fde * clientFde = &fd_table[client_fd]; | |
205 | + if (clientFde) | |
206 | + { | |
207 | + int tos = 1; | |
208 | + int tos_len = sizeof(tos); | |
209 | + clientFde->upstreamTOS = 0; | |
210 | + if (setsockopt(server_fd,SOL_IP,IP_RECVTOS,&tos,tos_len)==0) | |
211 | + { | |
212 | + unsigned char buf[512]; | |
213 | + int len = 512; | |
214 | + if (getsockopt(server_fd,SOL_IP,IP_PKTOPTIONS,buf,(socklen_t*)&len) == 0) | |
215 | + { | |
216 | + /* Parse the PKTOPTIONS structure to locate the TOS data message | |
217 | + * prepared in the kernel by the ZPH incoming TCP TOS preserving | |
218 | + * patch. | |
219 | + */ | |
220 | + unsigned char * p = buf; | |
221 | + while (p-buf < len) | |
222 | + { | |
223 | + struct cmsghdr *o = (struct cmsghdr*)p; | |
224 | + if (o->cmsg_len<=0) | |
225 | + break; | |
d7907af9 | 226 | + |
0a52bd7c | 227 | + if (o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS) |
228 | + { | |
229 | + clientFde->upstreamTOS = (unsigned char)(*(int*)CMSG_DATA(o)); | |
230 | + break; | |
231 | + } | |
232 | + p += CMSG_LEN(o->cmsg_len); | |
233 | + } | |
234 | + } | |
235 | + else | |
236 | + { | |
237 | + debugs(33, 1, "ZPH: error in getsockopt(IP_PKTOPTIONS) on FD "<<server_fd<<" "<<xstrerror()); | |
238 | + } | |
239 | + } | |
240 | + else | |
241 | + { | |
242 | + debugs(33, 1, "ZPH: error in setsockopt(IP_RECVTOS) on FD "<<server_fd<<" "<<xstrerror()); | |
243 | + } | |
244 | + } | |
245 | +#endif | |
246 | + | |
247 | if (servers && (p = servers->_peer)) { | |
248 | p->stats.fetches++; | |
249 | request->peer_login = p->login; | |
250 | ||
251 | --- /src/structs.h 2008-05-02 11:12:10 +0000 | |
252 | +++ /src/structs.h 2008-05-03 23:37:00 +0000 | |
253 | @@ -554,9 +554,11 @@ | |
254 | int httpd_suppress_version_string; | |
255 | int global_internal_static; | |
256 | int debug_override_X; | |
257 | - } | |
258 | - | |
259 | - onoff; | |
260 | +#if USE_ZPH_QOS | |
261 | + int zph_tos_parent; | |
262 | + int zph_preserve_miss_tos; | |
d7907af9 | 263 | +#endif |
0a52bd7c | 264 | + } onoff; |
30a5a2e5 | 265 | |
0a52bd7c | 266 | class ACL *aclList; |
30a5a2e5 | 267 | |
0a52bd7c | 268 | @@ -720,6 +722,11 @@ |
d7907af9 | 269 | int sleep_after_fork; /* microseconds */ |
270 | time_t minimum_expiry_time; /* seconds */ | |
271 | external_acl *externalAclHelperList; | |
0a52bd7c | 272 | +#if USE_ZPH_QOS |
273 | + int zph_tos_local; | |
274 | + int zph_tos_peer; | |
275 | + int zph_preserve_miss_tos_mask; | |
276 | +#endif | |
d7907af9 | 277 | #if USE_SSL |
91e92d0a | 278 | |
0a52bd7c | 279 | struct |