]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Import initial code
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 19 Nov 2008 06:59:00 +0000 (19:59 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 19 Nov 2008 06:59:00 +0000 (19:59 +1300)
src/Makefile.am
src/cf.data.depend
src/cf.data.pre
src/client_side_reply.cc
src/icmp/Makefile.am
src/ip/QosConfig.cc [new file with mode: 0644]
src/ip/QosConfig.h [new file with mode: 0644]
src/ip/stubQosConfig.cc [new file with mode: 0644]
src/structs.h

index 9e2899998342de72133ce3a640eb38b33de94710..594e4328a75dd5f1aeac4f78bc3d073a1e043f7d 100644 (file)
@@ -243,7 +243,13 @@ libexec_PROGRAMS = \
        @DISK_PROGRAMS@ \
        $(UNLINKD)
 
-cf_gen_SOURCES = cf_gen.cc defines.h debug.cc time.cc
+cf_gen_SOURCES = \
+       cf_gen.cc \
+       defines.h \
+       debug.cc \
+       stubQosConfig.cc \
+       time.cc
+
 nodist_cf_gen_SOURCES = globals.cc
 nodist_cf_gen_HEADER = cf_gen_defines.h
 cf_gen.$(OBJEXT): cf_gen_defines.h
@@ -421,7 +427,6 @@ libsquid_la_SOURCES = \
         TextException.cc \
         TextException.h
 
-
 # authentication framework
 libauth_la_SOURCES = \
        AuthConfig.cc \
@@ -582,6 +587,8 @@ squid_SOURCES = \
        PeerSelectState.h \
        PingData.h \
        protos.h \
+       QosConfig.cc \
+       QosConfig.h \
        redirect.cc \
        referer.cc \
        refresh.cc \
@@ -861,6 +868,7 @@ ufsdump_SOURCES = \
        peer_sourcehash.cc \
        peer_userhash.cc \
        protos.h \
+       stubQosConfig.cc \
        redirect.cc \
        referer.cc \
        refresh.cc \
@@ -1198,6 +1206,7 @@ tests_testAuth_SOURCES= tests/testAuth.cc tests/testMain.cc  tests/testAuth.h $(
        tests/stub_store.cc HttpHeaderTools.cc HttpHeader.cc acl.cc mem.cc \
        MemBuf.cc HttpHdrContRange.cc Packer.cc ACLChecklist.cc HttpHdrCc.cc HttpHdrSc.cc \
        HttpHdrScTarget.cc url.cc ACLProxyAuth.cc ACLRegexData.cc ACLUserData.cc \
+       stubQosConfig.cc \
        StatHist.cc HttpHdrRange.cc ETag.cc tests/stub_errorpage.cc \
        tests/stub_HttpRequest.cc tests/stub_DelayId.cc \
        tests/stub_MemObject.cc mem_node.cc \
@@ -1272,6 +1281,7 @@ tests_testACLMaxUserIP_SOURCES= \
        mem_node.cc \
        Packer.cc \
        Parsing.cc \
+       stubQosConfig.cc \
        StatHist.cc \
        stmem.cc \
        String.cc \
@@ -1407,6 +1417,7 @@ tests_testCacheManager_SOURCES = \
        peer_select.cc \
        peer_sourcehash.cc \
        peer_userhash.cc \
+       stubQosConfig.cc \
        redirect.cc \
        referer.cc \
        refresh.cc \
@@ -1476,7 +1487,8 @@ tests_testDiskIO_SOURCES= \
        tests/testDiskIO.cc \
        tests/testDiskIO.h \
        tests/testMain.cc \
-       tests/stub_cache_manager.cc
+       tests/stub_cache_manager.cc \
+       stubQosConfig.cc
 
 tests_testDiskIO_LDADD= \
        $(SWAP_TEST_LDADD) \
@@ -1581,6 +1593,7 @@ tests_testEvent_SOURCES = \
        peer_select.cc \
        peer_sourcehash.cc \
        peer_userhash.cc \
+       stubQosConfig.cc \
        redirect.cc \
        referer.cc \
        refresh.cc \
@@ -1737,6 +1750,7 @@ tests_testEventLoop_SOURCES = \
        peer_select.cc \
        peer_sourcehash.cc \
        peer_userhash.cc \
+       stubQosConfig.cc \
        redirect.cc \
        referer.cc \
        refresh.cc \
@@ -1883,6 +1897,7 @@ tests_test_http_range_SOURCES = \
        peer_sourcehash.cc \
        peer_userhash.cc \
        pconn.cc \
+       stubQosConfig.cc \
        redirect.cc \
        referer.cc \
        refresh.cc \
@@ -2044,6 +2059,7 @@ tests_testHttpRequest_SOURCES = \
        peer_select.cc \
        peer_sourcehash.cc \
        peer_userhash.cc \
+       stubQosConfig.cc \
        redirect.cc \
        referer.cc \
        refresh.cc \
@@ -2143,6 +2159,7 @@ STORE_TEST_SOURCES=\
        HttpHdrScTarget.cc url.cc ACLProxyAuth.cc ACLRegexData.cc ACLUserData.cc \
        StatHist.cc HttpHdrRange.cc ETag.cc tests/stub_errorpage.cc \
        tests/stub_HttpRequest.cc tests/stub_access_log.cc \
+       stubQosConfig.cc \
        refresh.cc \
        tests/stub_store_client.cc \
        tests/stub_tools.cc \
@@ -2186,16 +2203,17 @@ tests_testStore_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
        @SQUID_CPPUNIT_LA@
 
 # string needs mem.cc.
+# libsquid pulls in SquidConfig and children. stub them.
 tests_testString_SOURCES= \
        mem.cc \
+       stubQosConfig.cc \
        String.cc \
        tests/testMain.cc \
        tests/testString.cc \
        tests/testString.h \
        tests/stub_cache_manager.cc \
        $(TESTSOURCES) \
-       time.cc 
-
+       time.cc
 tests_testString_LDADD= \
        libsquid.la \
        -L../lib -lmiscutil \
@@ -2387,6 +2405,7 @@ tests_testURL_SOURCES = \
        peer_select.cc \
        peer_sourcehash.cc \
        peer_userhash.cc \
+       stubQosConfig.cc \
        redirect.cc \
        referer.cc \
        refresh.cc \
index 54b5c33cefe548877b4eff46080a851153add4a9..6a459ccb772da7c8162996598ef742902a67a2c5 100644 (file)
@@ -38,6 +38,7 @@ logformat
 onoff
 peer
 peer_access            cache_peer acl
+QosConfig
 refreshpattern
 removalpolicy
 size_t
index eef5511ade84281563df07af71579a1a585b38f4..51da08b729a9d8ff44809e634a9cbcfe8c88ea85 100644 (file)
@@ -1226,8 +1226,8 @@ DOC_START
        tcp_outgoing_tos 0x20 good_service_net
 
        TOS/DSCP values really only have local significance - so you should
-       know what you're specifying. For more information, see RFC2474 and
-       RFC3260.
+       know what you're specifying. For more information, see RFC2474,
+       RFC2475, and RFC3260.
 
        The TOS/DSCP byte must be exactly that - a octet value  0 - 255, or
        "default" to use whatever default your host has. Note that in
@@ -1253,64 +1253,49 @@ DOC_START
        making the request.
 DOC_END
 
-NAME: zph_tos_local
-TYPE: int
+NAME: qos_flows
+TYPE: QosConfig
 IFDEF: USE_ZPH_QOS
-DEFAULT: 0
-LOC: Config.zph_tos_local
+DEFAULT: none
+LOC: Config.zph
 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
+       Allows you to select a TOS/DSCP value to mark outgoing
+       connections with, based on where the reply was sourced.
 
-NAME: zph_tos_peer
-TYPE: int
-IFDEF: USE_ZPH_QOS
-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
+       TOS values really only have local significance - so you should
+       know what you're specifying. For more information, see RFC2474,
+       RFC2475, and RFC3260.
 
-NAME: zph_tos_parent
-COMMENT: on|off
-TYPE: onoff
-IFDEF: USE_ZPH_QOS
-DEFAULT: on
-LOC: Config.onoff.zph_tos_parent
-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
+       The TOS/DSCP byte must be exactly that - octet value 0x00-0xFF.
+       Note that in practice often only values up to 0x3F are usable
+       as the two highest bits have been redefined for use by ECN
+       (RFC3168).
 
-NAME: zph_preserve_miss_tos
-COMMENT: on|off
-TYPE: onoff
-IFDEF: USE_ZPH_QOS
-DEFAULT: on
-LOC: Config.onoff.zph_preserve_miss_tos
-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.
-       The kernel patch can be downloaded from http://zph.bratcheda.org
-DOC_END
+       This setting is configured by setting the source TOS values:
+
+       local-hit=0xFF          Value to mark local cache hits.
+
+       sibling-hit=0xFF        Value to mark hits from sibling peers.
+
+       parent-hit=0xFF         Value to mark hits from parent peers.
+
+
+       For the following to work correctly, you will need to patch your
+       linux kernel with the TOS preserving ZPH patch.
+       The kernel patch can be downloaded from http://zph.bratcheda.org
+
+
+       disable-preserve-miss
+               If set, any HTTP response towards clients will
+               have the TOS value of the response comming from the
+               remote server masked with the value of miss-mask.
+
+       miss-mask=0xFF
+               Allows you to mask certain bits in the TOS received from the
+               remote server, before copying the value to the TOS sent
+               towards clients.
+               Default: 0xFF (TOS from server is not changed).
 
-NAME: zph_preserve_miss_tos_mask
-TYPE: int
-IFDEF: USE_ZPH_QOS
-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.
-       Default: 255 (TOS from server is not changed).
 DOC_END
 
 NAME: tcp_outgoing_address
index 6d9a58d80447e25982507656fa33a460471813c5..c6f92167188f07df2fe61252fbd2388c01959a86 100644 (file)
@@ -1635,9 +1635,9 @@ clientReplyContext::doGetMoreData()
         assert(http->out.size == 0);
         assert(http->out.offset == 0);
 #if USE_ZPH_QOS
-        if (Config.zph_tos_local) {
-            debugs(33, 2, "ZPH Local hit, TOS="<<Config.zph_tos_local);
-            comm_set_tos(http->getConn()->fd,Config.zph_tos_local);
+        if (Config.zph.tos_local_hit) {
+            debugs(33, 2, "ZPH Local hit, TOS=" << Config.zph.tos_local_hit);
+            comm_set_tos(http->getConn()->fd, Config.zph.tos_local_hit);
         }
 #endif /* USE_ZPH_QOS */
         tempBuffer.offset = reqofs;
@@ -1915,13 +1915,14 @@ clientReplyContext::sendMoreData (StoreIOBuffer result)
     if (reqofs==0 && !logTypeIsATcpHit(http->logType)) {
         assert(fd >= 0); // the beginning of this method implies fd may be -1
         int tos = 0;
-        if (Config.zph_tos_peer &&
-                (http->request->hier.code==SIBLING_HIT ||
-                 (Config.onoff.zph_tos_parent && http->request->hier.code==PARENT_HIT) ) ) {
-            tos = Config.zph_tos_peer;
-            debugs(33, 2, "ZPH: Peer hit with hier.code="<<http->request->hier.code<<", TOS="<<tos);
-        } else if (Config.onoff.zph_preserve_miss_tos && Config.zph_preserve_miss_tos_mask) {
-            tos = fd_table[fd].upstreamTOS & Config.zph_preserve_miss_tos_mask;
+        if (Config.zph.tos_sibling_hit && http->request->hier.code==SIBLING_HIT ) {
+            tos = Config.zph.tos_sibling_hit;
+            debugs(33, 2, "ZPH: Sibling Peer hit with hier.code=" << http->request->hier.code << ", TOS=" << tos);
+        } else if (Config.zph.tos_parent_hit && http->request->hier.code==PARENT_HIT) {
+            tos = Config.zph.tos_parent_hit;
+            debugs(33, 2, "ZPH: Parent Peer hit with hier.code=" << http->request->hier.code << ", TOS=" << tos);
+        } else if (Config.zph.preserve_miss_tos && Config.zph.preserve_miss_tos_mask) {
+            tos = fd_table[fd].upstreamTOS & Config.zph.preserve_miss_tos_mask;
             debugs(33, 2, "ZPH: Preserving TOS on miss, TOS="<<tos);
         }
         comm_set_tos(fd,tos);
index 55dd2f54955abb5d5567de05e4d52f0b5b4b2f5d..66a2a59a266ef858314298d31ccd36bce0680d04 100644 (file)
@@ -61,10 +61,11 @@ pinger_SOURCES = \
 nodist_pinger_SOURCES = \
        Icmp.h \
        ../debug.cc \
+       ../globals.cc \
        ../time.cc \
        ../SquidConfig.cc \
        ../SquidNew.cc \
-       ../globals.cc
+       ../stubQosConfig.cc
 
 pinger_LDFLAGS = $(LIBADD_DL)
 pinger_LDADD=\
diff --git a/src/ip/QosConfig.cc b/src/ip/QosConfig.cc
new file mode 100644 (file)
index 0000000..3ce3687
--- /dev/null
@@ -0,0 +1,69 @@
+#include "squid.h"
+
+#if USE_ZPH_QOS
+
+#include "QosConfig.h"
+#include "Store.h"
+
+QosConfig::QosConfig() : 
+       tos_local_hit(0),
+       tos_sibling_hit(0),
+       tos_parent_hit(0),
+       preserve_miss_tos(1),
+       preserve_miss_tos_mask(255)
+{
+    ;
+}
+
+void
+QosConfig::parseConfigLine()
+{
+    // %i honors 0 and 0x prefixes, which are important for things like umask
+    /* parse options ... */
+    char *token;
+    while( (token = strtok(NULL, w_space)) ) {
+
+        if(strncmp(token, "local-hit=",10) == 0) {
+            sscanf(&token[10], "%i", &tos_local_hit);
+        }
+        else if(strncmp(token, "sibling-hit=",12) == 0) {
+            sscanf(&token[12], "%i", &tos_sibling_hit);
+        }
+        else if(strncmp(token, "parent-hit=",11) == 0) {
+            sscanf(&token[11], "%i", &tos_parent_hit);
+        }
+        else if(strcmp(token, "disable-preserve-miss") == 0) {
+            preserve_miss_tos = 0;
+            preserve_miss_tos_mask = 0;
+        }
+        else if(preserve_miss_tos && strncmp(token, "miss-mask=",10) == 0) {
+            sscanf(&token[10], "%i", &preserve_miss_tos_mask);
+        }
+    }
+}
+
+void
+QosConfig::dumpConfigLine(StoreEntry * entry, const char *name) const
+{
+    storeAppendPrintf(entry, "%s", name);
+
+    if (tos_local_hit >0) {
+        storeAppendPrintf(entry, " local-hit=%2x", tos_local_hit);
+    }
+
+    if (tos_sibling_hit >0) {
+        storeAppendPrintf(entry, " sibling-hit=%2x", tos_sibling_hit);
+    }
+    if (tos_parent_hit >0) {
+        storeAppendPrintf(entry, " parent-hit=%2x", tos_parent_hit);
+    }
+    if (preserve_miss_tos != 0) {
+        storeAppendPrintf(entry, " disable-preserve-miss");
+    }
+    if (preserve_miss_tos && preserve_miss_tos_mask != 0) {
+        storeAppendPrintf(entry, " miss-mask=%2x", preserve_miss_tos_mask);
+    }
+    storeAppendPrintf(entry, "\n");
+}
+
+#endif /* USE_ZPH_QOS */
diff --git a/src/ip/QosConfig.h b/src/ip/QosConfig.h
new file mode 100644 (file)
index 0000000..61d400a
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef SQUID_QOSCONFIG_H
+#define SQUID_QOSCONFIG_H
+
+#include "config.h"
+
+#if USE_ZPH_QOS
+
+class StoreEntry;
+
+class QosConfig
+{
+public:
+    int tos_local_hit;
+    int tos_sibling_hit;
+    int tos_parent_hit;
+    int preserve_miss_tos;
+    int preserve_miss_tos_mask;
+
+public:
+    QosConfig();
+    ~QosConfig() {};
+
+    void parseConfigLine();
+    void dumpConfigLine(StoreEntry *entry, const char *name) const;
+};
+
+/* legacy parser access wrappers */
+#define parse_QosConfig(X)     (X)->parseConfigLine()
+#define dump_QosConfig(e,n,X)  (X).dumpConfigLine(e,n)
+#define free_QosConfig(X)
+
+#endif /* USE_ZPH_QOS */
+#endif /* SQUID_QOSCONFIG_H */
diff --git a/src/ip/stubQosConfig.cc b/src/ip/stubQosConfig.cc
new file mode 100644 (file)
index 0000000..dc7a666
--- /dev/null
@@ -0,0 +1,51 @@
+#include "squid.h"
+
+#if USE_ZPH_QOS
+
+#include "QosConfig.h"
+#include "Store.h"
+
+QosConfig::QosConfig() : 
+       tos_local_hit(0),
+       tos_sibling_hit(0),
+       tos_parent_hit(0),
+       preserve_miss_tos(1),
+       preserve_miss_tos_mask(255)
+{
+    ;
+}
+
+void
+QosConfig::parseConfigLine()
+{
+    // %i honors 0 and 0x prefixes, which are important for things like umask
+    /* parse options ... */
+    char *token;
+    while( (token = strtok(NULL, w_space)) ) {
+
+        if(strncmp(token, "local-hit=",10) == 0) {
+            sscanf(&token[10], "%i", &tos_local_hit);
+        }
+        else if(strncmp(token, "sibling-hit=",12) == 0) {
+            sscanf(&token[12], "%i", &tos_sibling_hit);
+        }
+        else if(strncmp(token, "parent-hit=",11) == 0) {
+            sscanf(&token[11], "%i", &tos_parent_hit);
+        }
+        else if(strcmp(token, "disable-preserve-miss") == 0) {
+            preserve_miss_tos = 0;
+            preserve_miss_tos_mask = 0;
+        }
+        else if(preserve_miss_tos && strncmp(token, "miss-mask=",10) == 0) {
+            sscanf(&token[10], "%i", &preserve_miss_tos_mask);
+        }
+    }
+}
+
+void
+QosConfig::dumpConfigLine(StoreEntry * entry, const char *name) const
+{
+    ; /* Not needed in stub */
+}
+
+#endif /* USE_ZPH_QOS */
index f30c87a48865c85e75e252038020c3d814d241af..bdf93c85ded328039659747b7309e259c146c945 100644 (file)
@@ -133,6 +133,10 @@ struct relist
 #include "icmp/IcmpConfig.h"
 #endif
 
+#if USE_ZPH_QOS
+#include "QosConfig.h"
+#endif
+
 /* forward decl for SquidConfig, see RemovalPolicy.h */
 
 class RemovalPolicySettings;
@@ -471,10 +475,6 @@ struct SquidConfig
         int log_uses_indirect_client;
 #endif /* FOLLOW_X_FORWARDED_FOR */
 
-#if USE_ZPH_QOS
-        int zph_tos_parent;
-        int zph_preserve_miss_tos;
-#endif
         int WIN32_IpAddrChangeMonitor;
     } onoff;
 
@@ -631,11 +631,11 @@ struct SquidConfig
     int sleep_after_fork;      /* microseconds */
     time_t minimum_expiry_time;        /* seconds */
     external_acl *externalAclHelperList;
+
 #if USE_ZPH_QOS
-    int zph_tos_local;
-    int zph_tos_peer;
-    int zph_preserve_miss_tos_mask; 
+    QosConfig zph;
 #endif
+
 #if USE_SSL
 
     struct