diff -Nur squid-2.5.STABLE5-20040302/src/cf.data.pre squid-2.5.STABLE5-20040302.new/src/cf.data.pre --- squid-2.5.STABLE5-20040302/src/cf.data.pre 2004-02-10 23:01:21.000000000 +0200 +++ squid-2.5.STABLE5-20040302.new/src/cf.data.pre 2004-03-20 02:05:35.000000000 +0200 @@ -2311,6 +2311,25 @@ matching line. DOC_END +NAME: zph_tos +TYPE: int +DEFAULT: 0 +LOC: Config.zph_tos +DOC_START + Allows you to select a TOS/Diffserv value to mark local and peer + hits. Read above (tcp_outgoing_tos) for details/requirements about TOS. + Default: 0 (disabled). +DOC_END + +NAME: zph_tos_peer +COMMENT: on|off +TYPE: onoff +LOC: Config.onoff.zph_tos_peer +DEFAULT: on +DOC_START + Set this to off if you want only local hits to be marked. +DOC_END + NAME: tcp_outgoing_address TYPE: acl_address DEFAULT: none diff -Nur squid-2.5.STABLE5-20040302/src/client_side.c squid-2.5.STABLE5-20040302.new/src/client_side.c --- squid-2.5.STABLE5-20040302/src/client_side.c 2004-02-18 20:51:16.000000000 +0200 +++ squid-2.5.STABLE5-20040302.new/src/client_side.c 2004-03-20 02:40:21.000000000 +0200 @@ -1971,6 +1971,40 @@ return; } if (http->out.offset == 0) { + if (Config.zph_tos) { + int need_change = 0; + int hit = 0; + int tos = Config.zph_tos; + int tos_old = 0; + int tos_len = sizeof(tos_old); + + if (isTcpHit(http->log_type) || + (Config.onoff.zph_tos_peer && + (http->request->hier.code == PARENT_HIT || + http->request->hier.code == SIBLING_HIT))) { + hit = 1; + } + 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; + } else if (!hit && tos_old) { /* MISS: previous was HIT */ + tos = 0; + need_change = 1; + } + } else if (hit) { /* no keepalive */ + need_change = 1; + } + if (need_change) { + enter_suid(); + if (setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) { + debug(33, 1) ("ZPH: setsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror()); + } + leave_suid(); + } + } + rep = clientBuildReply(http, buf, size); if (rep) { aclCheck_t *ch; diff -Nur squid-2.5.STABLE5-20040302/src/structs.h squid-2.5.STABLE5-20040302.new/src/structs.h --- squid-2.5.STABLE5-20040302/src/structs.h 2004-02-04 19:42:28.000000000 +0200 +++ squid-2.5.STABLE5-20040302.new/src/structs.h 2004-03-18 00:55:07.000000000 +0200 @@ -594,6 +594,7 @@ int pipeline_prefetch; int request_entities; int detect_broken_server_pconns; + int zph_tos_peer; } onoff; acl *aclList; struct { @@ -695,6 +696,7 @@ char *store_dir_select_algorithm; int sleep_after_fork; /* microseconds */ external_acl *externalAclHelperList; + int zph_tos; }; struct _SquidConfig2 {