This patch adds some polish and minor unfinished business in IPv6
support vs delay pools.
Also updates the bucket size to 64-bytes to allow for >4MB traffic caps.
Still need to bump up the refresh size for >4MB/sec flows.
Amos
=== modified file 'src/DelaySpec.cc'
--- src/DelaySpec.cc 2009-01-21 03:47:47 +0000
+++ src/DelaySpec.cc 2009-06-12 10:12:16 +0000
@@ -57,35 +57,32 @@
}
storeAppendPrintf(sentry, "\t%s:\n", label);
- storeAppendPrintf(sentry, "\t\tMax: %d\n", max_bytes);
+ storeAppendPrintf(sentry, "\t\tMax: %"PRId64"\n", max_bytes);
storeAppendPrintf(sentry, "\t\tRestore: %d\n", restore_bps);
}
void
DelaySpec::dump (StoreEntry *entry) const
{
- storeAppendPrintf(entry, " %d/%d", restore_bps, max_bytes);
+ storeAppendPrintf(entry, " %d/%"PRId64"", restore_bps, max_bytes);
}
void
DelaySpec::parse()
{
- int i;
+ int r;
char *token;
token = strtok(NULL, "/");
if (token == NULL)
self_destruct();
- if (sscanf(token, "%d", &i) != 1)
+ if (sscanf(token, "%d", &r) != 1)
self_destruct();
- restore_bps = i;
-
- i = GetInteger();
-
- max_bytes = i;
+ restore_bps = r;
+
+ max_bytes = GetInteger64();
}
#endif
-
=== modified file 'src/DelaySpec.h'
--- src/DelaySpec.h 2009-01-21 03:47:47 +0000
+++ src/DelaySpec.h 2009-06-12 11:52:27 +0000
@@ -32,6 +32,9 @@
#ifndef SQUID_DELAYSPEC_H
#define SQUID_DELAYSPEC_H
+/* for int64_t definition */
+#include "config.h"
+
class StoreEntry;
/// \ingroup DelyPoolsAPI
@@ -44,7 +47,7 @@
void dump(StoreEntry *) const;
void parse();
int restore_bps;
- int max_bytes;
+ int64_t max_bytes;
};
#endif /* SQUID_DELAYSPEC_H */
=== modified file 'src/Parsing.cc'
--- src/Parsing.cc 2009-01-21 03:47:47 +0000
+++ src/Parsing.cc 2009-06-12 10:08:38 +0000
@@ -80,6 +80,20 @@
return port;
}
+int64_t
+GetInteger64(void)
+{
+ char *token = strtok(NULL, w_space);
+ int i;
+
+ if (token == NULL)
+ self_destruct();
+
+ i = strtoll(token, NULL, 10);
+
+ return i;
+}
+
int
GetInteger(void)
{
=== modified file 'src/Parsing.h'
--- src/Parsing.h 2009-01-21 03:47:47 +0000
+++ src/Parsing.h 2009-06-12 10:10:53 +0000
@@ -42,7 +42,18 @@
extern int xatoi(const char *token);
extern long xatol(const char *token);
extern unsigned short xatos(const char *token);
+
+/**
+ * Parse a 64-bit integer value.
+ */
+extern int64_t GetInteger64(void);
+
+/**
+ * Parses an integer value.
+ * Uses a method that obeys hexadecimal 0xN syntax needed for certain bitmasks.
+ */
extern int GetInteger(void);
+
extern u_short GetShort(void);
// on success, returns true and sets *p (if any) to the end of the integer
=== modified file 'src/cf.data.pre'
--- src/cf.data.pre 2009-06-05 23:13:17 +0000
+++ src/cf.data.pre 2009-06-12 09:50:54 +0000
@@ -3924,12 +3924,12 @@
delay pools, one of class 2 and one of class 3, the settings above
and here would be:
-Example:
- delay_pools 4 # 4 delay pools
- delay_class 1 2 # pool 1 is a class 2 pool
- delay_class 2 3 # pool 2 is a class 3 pool
- delay_class 3 4 # pool 3 is a class 4 pool
- delay_class 4 5 # pool 4 is a class 5 pool
+ Example:
+ delay_pools 4 # 4 delay pools
+ delay_class 1 2 # pool 1 is a class 2 pool
+ delay_class 2 3 # pool 2 is a class 3 pool
+ delay_class 3 4 # pool 3 is a class 4 pool
+ delay_class 4 5 # pool 4 is a class 5 pool
The delay pool classes are:
@@ -3938,13 +3938,13 @@
class 2 Everything is limited by a single aggregate
bucket as well as an "individual" bucket chosen
- from bits 25 through 32 of the IP address.
+ from bits 25 through 32 of the IPv4 address.
class 3 Everything is limited by a single aggregate
bucket as well as a "network" bucket chosen
from bits 17 through 24 of the IP address and a
"individual" bucket chosen from bits 17 through
- 32 of the IP address.
+ 32 of the IPv4 address.
class 4 Everything in a class 3 delay pool, with an
additional limit on a per user basis. This
@@ -3959,6 +3959,9 @@
-> bits 25 through 32 are "d"
-> bits 17 through 24 are "c"
-> bits 17 through 32 are "c * 256 + d"
+
+ NOTE-2: Due to the use of bitmasks in class 2,3,4 pools they only apply to
+ IPv4 traffic. Class 1 and 5 pools may be used with IPv6 traffic.
DOC_END
NAME: delay_access
=== modified file 'src/delay_pools.cc'
--- src/delay_pools.cc 2009-01-07 11:24:40 +0000
+++ src/delay_pools.cc 2009-06-13 02:41:28 +0000
@@ -159,7 +159,7 @@
virtual char const *label() const = 0;
- virtual unsigned int makeKey (IpAddress &src_addr) const = 0;
+ virtual unsigned int makeKey(IpAddress &src_addr) const = 0;
DelaySpec spec;
@@ -186,13 +186,11 @@
public:
void *operator new(size_t);
- void operator delete (void *);
+ void operator delete(void *);
protected:
virtual char const *label() const {return "Individual";}
-
- virtual unsigned int makeKey (IpAddress &src_addr) const;
-
+ virtual unsigned int makeKey(IpAddress &src_addr) const;
};
/// \ingroup DelayPoolsInternal
@@ -205,7 +203,6 @@
protected:
virtual char const *label() const {return "Network";}
-
virtual unsigned int makeKey (IpAddress &src_addr) const;
};
@@ -293,10 +290,10 @@
}
void
-CommonPool::operator delete (void *address)
+CommonPool::operator delete(void *address)
{
- DelayPools::MemoryUsed -= sizeof (CommonPool);
- ::operator delete (address);
+ DelayPools::MemoryUsed -= sizeof(CommonPool);
+ ::operator delete(address);
}
CommonPool *
@@ -322,7 +319,6 @@
temp->push_back (new Aggregate);
temp->push_back(new IndividualPool);
}
-
break;
case 3:
@@ -334,7 +330,6 @@
temp->push_back (new ClassCNetPool);
temp->push_back (new ClassCHostPool);
}
-
break;
case 4:
@@ -347,7 +342,6 @@
temp->push_back (new ClassCHostPool);
temp->push_back (new DelayUser);
}
-
break;
case 5:
@@ -504,7 +498,6 @@
}
DelayIdComposite::Pointer
-
Aggregate::id(CompositeSelectionDetails &details)
{
if (rate()->restore_bps != -1)
@@ -800,7 +793,7 @@
VectorMap<Key,Value>::findKeyIndex (Key const key) const
{
for (unsigned int index = 0; index < size(); ++index) {
- assert (indexUsed (index));
+ assert(indexUsed(index));
if (key_map[index] == key)
return index;
@@ -811,20 +804,23 @@
}
DelayIdComposite::Pointer
-
VectorPool::id(CompositeSelectionDetails &details)
{
if (rate()->restore_bps == -1)
return new NullDelayId;
- unsigned int key = makeKey (details.src_addr);
-
- if (keyAllocated (key))
- return new Id (this, buckets.findKeyIndex(key));
+ /* non-IPv4 are not able to provide IPv4-bitmask for this pool type key. */
+ if ( !details.src_addr.IsIPv4() )
+ return new NullDelayId;
+
+ unsigned int key = makeKey(details.src_addr);
+
+ if (keyAllocated(key))
+ return new Id(this, buckets.findKeyIndex(key));
unsigned char const resultIndex = buckets.insert(key);
- buckets.values[resultIndex].init (*rate());
+ buckets.values[resultIndex].init(*rate());
return new Id(this, resultIndex);
}
@@ -837,13 +833,13 @@
}
void
-VectorPool::Id::operator delete (void *address)
+VectorPool::Id::operator delete(void *address)
{
DelayPools::MemoryUsed -= sizeof (Id);
::operator delete (address);
}
-VectorPool::Id::Id (VectorPool::Pointer aPool, int anIndex) : theVector (aPool), theIndex (anIndex)
+VectorPool::Id::Id(VectorPool::Pointer aPool, int anIndex) : theVector (aPool), theIndex (anIndex)
{}
int
@@ -861,11 +857,10 @@
unsigned int
IndividualPool::makeKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
- /* Temporary bypass for IPv4-only */
struct in_addr host;
src_addr.GetInAddr(host);
return (ntohl(host.s_addr) & 0xff);
@@ -888,11 +883,10 @@
unsigned int
ClassCNetPool::makeKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
- /* Temporary bypass for IPv4-only */
struct in_addr net;
src_addr.GetInAddr(net);
return ( (ntohl(net.s_addr) >> 8) & 0xff);
@@ -962,7 +956,7 @@
unsigned char
ClassCHostPool::makeHostKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
@@ -975,23 +969,25 @@
unsigned int
ClassCHostPool::makeKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
- /* Temporary bypass for IPv4-only */
struct in_addr net;
src_addr.GetInAddr(net);
return ( (ntohl(net.s_addr) >> 8) & 0xff);
}
DelayIdComposite::Pointer
-
ClassCHostPool::id(CompositeSelectionDetails &details)
{
if (rate()->restore_bps == -1)
return new NullDelayId;
+ /* non-IPv4 are not able to provide IPv4-bitmask for this pool type key. */
+ if ( !details.src_addr.IsIPv4() )
+ return new NullDelayId;
+
unsigned int key = makeKey (details.src_addr);
unsigned char host = makeHostKey (details.src_addr);