]> git.pld-linux.org Git - packages/squid.git/blame - squid_hit_miss_mark.patch
- updated for 3.0STABLE4
[packages/squid.git] / squid_hit_miss_mark.patch
CommitLineData
d7907af9 1diff -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
4@@ -3193,6 +3193,64 @@
5 to off when using this directive in such configurations.
6 DOC_END
7
8+NAME: zph_tos_local
9+TYPE: int
10+DEFAULT: 0
11+LOC: Config.zph_tos_local
12+DOC_START
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).
16+DOC_END
17+
18+NAME: zph_tos_peer
19+TYPE: int
20+DEFAULT: 0
21+LOC: Config.zph_tos_peer
22+DOC_START
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).
26+DOC_END
27+
28+NAME: zph_tos_parent
29+COMMENT: on|off
30+TYPE: onoff
31+LOC: Config.onoff.zph_tos_parent
32+DEFAULT: on
33+DOC_START
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.
36+DOC_END
37+
38+NAME: zph_preserve_miss_tos
39+COMMENT: on|off
40+TYPE: onoff
41+LOC: Config.onoff.zph_preserve_miss_tos
42+DEFAULT: on
43+DOC_START
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
50+ kernels.
51+DOC_END
52+
53+NAME: zph_preserve_miss_tos_mask
54+TYPE: int
55+DEFAULT: 255
56+LOC: Config.zph_preserve_miss_tos_mask
57+DOC_START
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
60+ clients.
61+ See zph_preserve_miss_tos for details.
62+
63+ Default: 255 (TOS from server is not changed).
64+DOC_END
65+
66 NAME: tcp_outgoing_address
67 TYPE: acl_address
68 DEFAULT: none
69diff -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 @@
91e92d0a 73 return;
41c7a9fd 74 }
d7907af9 75 assert(http->out.offset == 0);
76+
77+ if ( Config.zph_tos_local || Config.zph_tos_peer ||
78+ (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask) )
79+ {
80+ int need_change = 0;
81+ int hit = 0;
82+ int tos = 0;
83+ int tos_old = 0;
84+ int tos_len = sizeof(tos_old);
85+ int res;
86+
87+ if (Config.zph_tos_local && isTcpHit(http->log_type)) { /* local hit */
88+ hit = 1;
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 */
94+ hit = 1;
95+ tos = Config.zph_tos_peer;
96+ }
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;
108+ } else tos = 0;
109+#else
110+ tos = 0;
111+#endif
112+ need_change = 1;
113+ }
114+ } else if (hit) { /* no keepalive */
115+ need_change = 1;
116+ }
117+ if (need_change) {
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 */
121+ if ( res < 0)
122+ debug(33, 1) ("ZPH: setsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
123+ }
41c7a9fd 124+ }
d7907af9 125 rep = http->reply = clientBuildReply(http, buf, size);
126 if (!rep) {
127 /* Forward as HTTP/0.9 body with no reply */
128diff -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;
135+
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)
140+ */
141+ int tos, tos_len;
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;
145+ tos = 1;
146+ tos_len = sizeof(tos);
147+ if ( setsockopt(fd,SOL_IP, IP_RECVTOS, &tos, tos_len) == 0 ) {
148+ unsigned char buf[128];
149+ int len = 128;
150+ if (getsockopt(fd, SOL_IP, IP_PKTOPTIONS, buf, &len) == 0)
151+ {
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.
156+ */
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 )
161+ break;
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 );
167+ break;
168+ }
169+ p += o->cmsg_len;
170+ }
171+ } else {
172+ debug(11, 5) ("ZPH: getsockopt(IP_PKTOPTIONS) on FD %d: %s\n",
173+ fd, xstrerror());
174+ }
175+ } else {
176+ debug(11, 5) ("ZPH: setsockopt(IP_RECVTOS) on FD %d: %s\n",
177+ fd, xstrerror());
178+ }
179+ }
180+/* ZPH patch ends here */
181+#endif
30a5a2e5 182
d7907af9 183 debug(11, 5) ("httpSendRequest: FD %d: httpState %p.\n", fd, httpState);
30a5a2e5 184
d7907af9 185diff -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
188@@ -669,6 +669,8 @@
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;
195 int via;
196 int check_hostnames;
197@@ -793,6 +795,9 @@
198 int sleep_after_fork; /* microseconds */
199 time_t minimum_expiry_time; /* seconds */
200 external_acl *externalAclHelperList;
201+ int zph_tos_local;
202+ int zph_tos_peer;
203+ int zph_preserve_miss_tos_mask;
204 errormap *errorMapList;
205 #if USE_SSL
206 struct {
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 */
213+#endif
214 };
91e92d0a 215
d7907af9 216 struct _StoreEntry {
This page took 0.054261 seconds and 4 git commands to generate.