1 diff -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
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.
51 +NAME: zph_preserve_miss_tos_mask
54 +LOC: Config.zph_preserve_miss_tos_mask
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
59 + Default: 255 (TOS from server is not changed).
62 NAME: tcp_outgoing_address
65 diff -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
71 #include "MemObject.h"
73 #include "ACLChecklist.h"
76 @@ -1548,6 +1549,11 @@
77 /* guarantee nothing has been sent yet! */
78 assert(http->out.size == 0);
79 assert(http->out.offset == 0);
80 + if (Config.zph_tos_local)
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);
85 tempBuffer.offset = reqofs;
86 tempBuffer.length = getNextNode()->readBuffer.length;
87 tempBuffer.data = getNextNode()->readBuffer.data;
88 @@ -1827,6 +1833,24 @@
89 char *buf = next()->readBuffer.data;
93 + if (reqofs==0 && !logTypeIsATcpHit(http->logType))
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))
100 + tos = Config.zph_tos_peer;
101 + debugs(33, 1, "ZPH: Peer hit, TOS="<<tos<<" hier.code="<<http->request->hier.code);
103 + else if (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask)
105 + tos = fd_table[fd].upstreamTOS & Config.zph_preserve_miss_tos_mask;
106 + debugs(33, 1, "ZPH: Preserving TOS on miss, TOS="<<tos);
108 + comm_set_tos(fd,tos);
111 if (buf != result.data) {
112 /* we've got to copy some data */
113 diff -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
121 + unsigned char upstreamTOS; /* see FwdState::dispatch() */
124 #endif /* SQUID_FDE_H */
125 diff -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
130 netdbPingSite(request->host);
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.
136 + fde * clientFde = &fd_table[client_fd];
140 + int tos_len = sizeof(tos);
141 + clientFde->upstreamTOS = 0;
142 + if (setsockopt(server_fd,SOL_IP,IP_RECVTOS,&tos,tos_len)==0)
144 + unsigned char buf[512];
146 + if (getsockopt(server_fd,SOL_IP,IP_PKTOPTIONS,buf,(socklen_t*)&len) == 0)
148 + /* Parse the PKTOPTIONS structure to locate the TOS data message
149 + * prepared in the kernel by the ZPH incoming TCP TOS preserving
152 + unsigned char * p = buf;
153 + while (p-buf < len)
155 + struct cmsghdr *o = (struct cmsghdr*)p;
156 + if (o->cmsg_len<=0)
159 + if (o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS)
161 + clientFde->upstreamTOS = (unsigned char)(*(int*)CMSG_DATA(o));
164 + p += CMSG_LEN(o->cmsg_len);
169 + debugs(33, 1, "ZPH: error in getsockopt(IP_PKTOPTIONS) on FD "<<server_fd<<" "<<xstrerror());
174 + debugs(33, 1, "ZPH: error in setsockopt(IP_RECVTOS) on FD "<<server_fd<<" "<<xstrerror());
178 if (servers && (p = servers->_peer)) {
180 request->peer_login = p->login;
181 diff -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
186 int httpd_suppress_version_string;
187 int global_internal_static;
188 + int zph_tos_parent;
189 + int zph_preserve_miss_tos;
190 int debug_override_X;
191 int WIN32_IpAddrChangeMonitor;
194 int sleep_after_fork; /* microseconds */
195 time_t minimum_expiry_time; /* seconds */
196 external_acl *externalAclHelperList;
199 + int zph_preserve_miss_tos_mask;