SOURCES: squid_hit_miss_mark.patch - updated from http://www.it-ac...
dzeus
dzeus at pld-linux.org
Sun Mar 25 23:46:46 CEST 2007
Author: dzeus Date: Sun Mar 25 21:46:46 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- updated from http://www.it-academy.bg/zph/
---- Files affected:
SOURCES:
squid_hit_miss_mark.patch (1.4 -> 1.5)
---- Diffs:
================================================================
Index: SOURCES/squid_hit_miss_mark.patch
diff -u SOURCES/squid_hit_miss_mark.patch:1.4 SOURCES/squid_hit_miss_mark.patch:1.5
--- SOURCES/squid_hit_miss_mark.patch:1.4 Tue Nov 14 18:43:52 2006
+++ SOURCES/squid_hit_miss_mark.patch Sun Mar 25 23:46:41 2007
@@ -1,66 +1,216 @@
---- squid-2.6.STABLE5.orig/src/client_side.c 2006-09-30 23:10:48.000000000 +0200
-+++ squid-2.6.STABLE5/src/client_side.c 2006-11-14 18:26:59.459231147 +0100
-@@ -3000,6 +3000,9 @@
- if (!http->request->range) {
- /* Avoid copying to MemBuf for non-range requests */
- http->out.offset += size;
-+ { int tos=isTcpHit(http->log_type) ? 0 : 8;
-+ setsockopt(fd,SOL_IP,IP_TOS,&tos,4);
-+ }
- comm_write(fd, buf, size, clientWriteBodyComplete, http, NULL);
- /* NULL because clientWriteBodyComplete frees it */
+diff -Nru squid-2.6.STABLE12.orig/src/cf.data.pre squid-2.6.STABLE12/src/cf.data.pre
+--- squid-2.6.STABLE12.orig/src/cf.data.pre 2007-03-21 19:43:48.000000000 +0200
++++ squid-2.6.STABLE12/src/cf.data.pre 2007-03-21 19:44:08.000000000 +0200
+@@ -3193,6 +3193,64 @@
+ to off when using this directive in such configurations.
+ DOC_END
+
++NAME: zph_tos_local
++TYPE: int
++DEFAULT: 0
++LOC: Config.zph_tos_local
++DOC_START
++ Allows you to select a TOS/Diffserv value to mark local hits. Read above
++ (tcp_outgoing_tos) for details/requirements about TOS.
++ Default: 0 (disabled).
++DOC_END
++
++NAME: zph_tos_peer
++TYPE: int
++DEFAULT: 0
++LOC: Config.zph_tos_peer
++DOC_START
++ Allows you to select a TOS/Diffserv value to mark peer hits. Read above
++ (tcp_outgoing_tos) for details/requirements about TOS.
++ Default: 0 (disabled).
++DOC_END
++
++NAME: zph_tos_parent
++COMMENT: on|off
++TYPE: onoff
++LOC: Config.onoff.zph_tos_parent
++DEFAULT: on
++DOC_START
++ Set this to off if you want only sibling hits to be marked.
++ If set to on (default), parent hits are being marked too.
++DOC_END
++
++NAME: zph_preserve_miss_tos
++COMMENT: on|off
++TYPE: onoff
++LOC: Config.onoff.zph_preserve_miss_tos
++DEFAULT: on
++DOC_START
++ If set to on (default), any HTTP response towards clients will
++ have the TOS value of the response comming from the remote
++ server masked with the value of zph_preserve_miss_tos_mask.
++ For this to work correctly, you will need to patch your linux
++ kernel with the TOS preserving ZPH patch.
++ Has no effect under FreeBSD, works only under linux ZPH patched
++ kernels.
++DOC_END
++
++NAME: zph_preserve_miss_tos_mask
++TYPE: int
++DEFAULT: 255
++LOC: Config.zph_preserve_miss_tos_mask
++DOC_START
++ Allows you to mask certain bits in the TOS received from the
++ remote server, before copying the value to the TOS send towards
++ clients.
++ See zph_preserve_miss_tos for details.
++
++ Default: 255 (TOS from server is not changed).
++DOC_END
++
+ NAME: tcp_outgoing_address
+ TYPE: acl_address
+ DEFAULT: none
+diff -Nru squid-2.6.STABLE12.orig/src/client_side.c squid-2.6.STABLE12/src/client_side.c
+--- squid-2.6.STABLE12.orig/src/client_side.c 2007-03-21 19:43:48.000000000 +0200
++++ squid-2.6.STABLE12/src/client_side.c 2007-03-21 19:44:08.000000000 +0200
+@@ -2621,6 +2621,55 @@
return;
-@@ -3034,6 +3037,9 @@
- memBufAppend(&mb, buf, size);
}
- /* write */
-+ { int tos=isTcpHit(http->log_type) ? 0 : 8;
-+ setsockopt(fd,SOL_IP,IP_TOS,&tos,4);
+ assert(http->out.offset == 0);
++
++ if ( Config.zph_tos_local || Config.zph_tos_peer ||
++ (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask) )
++ {
++ int need_change = 0;
++ int hit = 0;
++ int tos = 0;
++ int tos_old = 0;
++ int tos_len = sizeof(tos_old);
++ int res;
++
++ if (Config.zph_tos_local && isTcpHit(http->log_type)) { /* local hit */
++ hit = 1;
++ tos = Config.zph_tos_local;
++ } else if (Config.zph_tos_peer &&
++ (http->request->hier.code == SIBLING_HIT || /* sibling hit */
++ (Config.onoff.zph_tos_parent &&
++ http->request->hier.code == PARENT_HIT))) { /* parent hit */
++ hit = 1;
++ tos = Config.zph_tos_peer;
++ }
++ if (http->request->flags.proxy_keepalive) {
++ if (getsockopt(fd, IPPROTO_IP, IP_TOS, &tos_old, &tos_len) < 0) {
++ debug(33, 1) ("ZPH: getsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
++ } else if (hit && tos_old != tos) { /* HIT: 1-st request, or previous was MISS, */
++ need_change = 1; /* or local/parent hit change */
++ } else if (!hit && (tos_old || /* MISS: previous was HIT */
++ Config.onoff.zph_preserve_miss_tos)) { /* TOS copying is on */
++#if defined(_SQUID_LINUX_)
++ if ( Config.onoff.zph_preserve_miss_tos ) {
++ tos = (entry->mem_obj != NULL) ?
++ (entry->mem_obj->recvTOS & Config.zph_preserve_miss_tos_mask):0;
++ } else tos = 0;
++#else
++ tos = 0;
++#endif
++ need_change = 1;
++ }
++ } else if (hit) { /* no keepalive */
++ need_change = 1;
++ }
++ if (need_change) {
++ if (!hit) enter_suid(); /* Setting TOS bit6-7 is privilleged */
++ res = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
++ if (!hit) leave_suid(); /* Setting bit5-7 is privilleged */
++ if ( res < 0)
++ debug(33, 1) ("ZPH: setsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
++ }
+ }
- comm_write_mbuf(fd, mb, clientWriteComplete, http);
- /* if we don't do it, who will? */
- memFree(buf, MEM_CLIENT_SOCK_BUF);
-diff -urN squid-2.6.STABLE5.orig/src/defines.h squid-2.6.STABLE5/src/defines.h
---- squid-2.6.STABLE5.orig/src/defines.h 2006-08-19 14:40:31.000000000 +0200
-+++ squid-2.6.STABLE5/src/defines.h 2006-11-13 21:15:47.563667677 +0100
-@@ -41,6 +41,8 @@
- #define FALSE 0
- #endif
+ rep = http->reply = clientBuildReply(http, buf, size);
+ if (!rep) {
+ /* Forward as HTTP/0.9 body with no reply */
+diff -Nru squid-2.6.STABLE12.orig/src/http.c squid-2.6.STABLE12/src/http.c
+--- squid-2.6.STABLE12.orig/src/http.c 2007-03-13 00:27:09.000000000 +0200
++++ squid-2.6.STABLE12/src/http.c 2007-03-21 19:44:08.000000000 +0200
+@@ -1373,6 +1373,53 @@
+ peer *p = httpState->peer;
+ CWCB *sendHeaderDone;
+ int fd = httpState->fd;
++
++#if defined(_SQUID_LINUX_)
++/* ZPH patch starts here (M.Stavrev 25-05-2005)
++ * Retrieve connection peer's TOS value (which its SYN_ACK TCP segment
++ * was encapsulated into an IP packet)
++ */
++ int tos, tos_len;
++ if ( entry && entry->mem_obj ) { // Is this check necessary ? Seems not, but
++ // have no time to investigate further.
++ entry->mem_obj->recvTOS = 0;
++ tos = 1;
++ tos_len = sizeof(tos);
++ if ( setsockopt(fd,SOL_IP, IP_RECVTOS, &tos, tos_len) == 0 ) {
++ unsigned char buf[128];
++ int len = 128;
++ if (getsockopt(fd, SOL_IP, IP_PKTOPTIONS, buf, &len) == 0)
++ {
++ /* Parse the PKTOPTIONS structure to locate the TOS data message
++ * prepared in the kernel by the ZPH incoming TCP TOS preserving
++ * patch. In 99,99% the TOS should be located at buf[12], but
++ * let's do it the right way.
++ */
++ unsigned char * p = buf;
++ while ( p-buf < len ) {
++ struct cmsghdr * o = (struct cmsghdr*)p;
++ if ( o->cmsg_len <= 0 || o->cmsg_len > 52 )
++ break;
++ if ( o->cmsg_level == SOL_IP && o->cmsg_type == IP_TOS ) {
++ entry->mem_obj->recvTOS = (unsigned char)(*(int*)
++ (p + sizeof(struct cmsghdr)));
++ debug(11, 5) ("ZPH: Incomming TOS=%d on FD %d\n",
++ entry->mem_obj->recvTOS, fd );
++ break;
++ }
++ p += o->cmsg_len;
++ }
++ } else {
++ debug(11, 5) ("ZPH: getsockopt(IP_PKTOPTIONS) on FD %d: %s\n",
++ fd, xstrerror());
++ }
++ } else {
++ debug(11, 5) ("ZPH: setsockopt(IP_RECVTOS) on FD %d: %s\n",
++ fd, xstrerror());
++ }
++ }
++/* ZPH patch ends here */
++#endif
-+#define SQUID_TCP_RCVBUF SQUID_TCP_SO_RCVBUF
-+
- /* Define load weights for cache_dir types */
- #define MAX_LOAD_VALUE 1000
+ debug(11, 5) ("httpSendRequest: FD %d: httpState %p.\n", fd, httpState);
-diff -urN squid-2.6.STABLE5.orig/src/ftp.c squid-2.6.STABLE5/src/ftp.c
---- squid-2.6.STABLE5.orig/src/ftp.c 2006-09-19 01:03:36.000000000 +0200
-+++ squid-2.6.STABLE5/src/ftp.c 2006-11-13 21:16:59.616675539 +0100
-@@ -1152,7 +1152,7 @@
- ftpState->ctrl.last_command = xstrdup("Connect to server");
- ftpState->ctrl.buf = memAllocBuf(4096, &ftpState->ctrl.size);
- ftpState->ctrl.offset = 0;
-- ftpState->data.buf = memAllocBuf(SQUID_TCP_SO_RCVBUF, &ftpState->data.size);
-+ ftpState->data.buf = memAllocBuf(SQUID_TCP_RCVBUF < SQUID_TCP_SO_RCVBUF ? SQUID_TCP_RCVBUF : SQUID_TCP_SO_RCVBUF, &ftpState->data.size);
- ftpScheduleReadControlReply(ftpState, 0);
- }
+diff -Nru squid-2.6.STABLE12.orig/src/structs.h squid-2.6.STABLE12/src/structs.h
+--- squid-2.6.STABLE12.orig/src/structs.h 2007-02-27 03:20:01.000000000 +0200
++++ squid-2.6.STABLE12/src/structs.h 2007-03-21 19:44:08.000000000 +0200
+@@ -669,6 +669,8 @@
+ int relaxed_header_parser;
+ int accel_no_pmtu_disc;
+ int global_internal_static;
++ int zph_tos_parent;
++ int zph_preserve_miss_tos;
+ int httpd_suppress_version_string;
+ int via;
+ int check_hostnames;
+@@ -793,6 +795,9 @@
+ int sleep_after_fork; /* microseconds */
+ time_t minimum_expiry_time; /* seconds */
+ external_acl *externalAclHelperList;
++ int zph_tos_local;
++ int zph_tos_peer;
++ int zph_preserve_miss_tos_mask;
+ errormap *errorMapList;
+ #if USE_SSL
+ struct {
+@@ -1724,6 +1729,9 @@
+ const char *vary_encoding;
+ StoreEntry *ims_entry;
+ time_t refresh_timestamp;
++#if defined(_SQUID_LINUX_)
++ unsigned char recvTOS; /* ZPH patch - stores remote server's TOS */
++#endif
+ };
-diff -urN squid-2.6.STABLE5.orig/src/http.c squid-2.6.STABLE5/src/http.c
---- squid-2.6.STABLE5.orig/src/http.c 2006-10-23 23:34:17.000000000 +0200
-+++ squid-2.6.STABLE5/src/http.c 2006-11-13 21:19:13.214294384 +0100
-@@ -622,14 +622,14 @@
- httpReadReply(int fd, void *data)
- {
- HttpStateData *httpState = data;
-- LOCAL_ARRAY(char, buf, SQUID_TCP_SO_RCVBUF);
-+ LOCAL_ARRAY(char, buf, SQUID_TCP_RCVBUF < SQUID_TCP_SO_RCVBUF ? SQUID_TCP_RCVBUF : SQUID_TCP_SO_RCVBUF);
- StoreEntry *entry = httpState->entry;
- const request_t *request = httpState->request;
- const request_t *orig_request = httpState->orig_request;
- int len;
- int bin;
- int clen;
-- size_t read_sz = SQUID_TCP_SO_RCVBUF;
-+ size_t read_sz = (SQUID_TCP_RCVBUF < SQUID_TCP_SO_RCVBUF ? SQUID_TCP_RCVBUF : SQUID_TCP_SO_RCVBUF);
- struct in_addr *client_addr = NULL;
- u_short client_port = 0;
- #if DELAY_POOLS
+ struct _StoreEntry {
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/squid_hit_miss_mark.patch?r1=1.4&r2=1.5&f=u
More information about the pld-cvs-commit
mailing list