You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2011/07/29 16:04:39 UTC
svn commit: r1152228 - in /trafficserver/traffic/trunk: ./ iocore/dns/
lib/ts/ mgmt/utils/ proxy/ proxy/api/ts/ proxy/congest/ proxy/http/
Author: amc
Date: Fri Jul 29 14:04:36 2011
New Revision: 1152228
URL: http://svn.apache.org/viewvc?rev=1152228&view=rev
Log:
IPv6 updates - replaced IpLookup with IpMap, changed some uses of ip_addr_t to in_addr_t
Removed:
trafficserver/traffic/trunk/mgmt/utils/IpLookup.cc
trafficserver/traffic/trunk/mgmt/utils/IpLookup.h
Modified:
trafficserver/traffic/trunk/CHANGES
trafficserver/traffic/trunk/iocore/dns/P_SplitDNSProcessor.h
trafficserver/traffic/trunk/lib/ts/IntrusiveDList.h
trafficserver/traffic/trunk/lib/ts/IpMap.cc
trafficserver/traffic/trunk/lib/ts/IpMap.h
trafficserver/traffic/trunk/lib/ts/MatcherUtils.h
trafficserver/traffic/trunk/mgmt/utils/Makefile.am
trafficserver/traffic/trunk/proxy/ControlBase.cc
trafficserver/traffic/trunk/proxy/ControlMatcher.cc
trafficserver/traffic/trunk/proxy/ControlMatcher.h
trafficserver/traffic/trunk/proxy/IPAllow.cc
trafficserver/traffic/trunk/proxy/IPAllow.h
trafficserver/traffic/trunk/proxy/InkAPI.cc
trafficserver/traffic/trunk/proxy/InkAPITest.cc
trafficserver/traffic/trunk/proxy/Main.cc
trafficserver/traffic/trunk/proxy/ParentSelection.cc
trafficserver/traffic/trunk/proxy/api/ts/experimental.h
trafficserver/traffic/trunk/proxy/congest/Congestion.cc
trafficserver/traffic/trunk/proxy/congest/Congestion.h
trafficserver/traffic/trunk/proxy/congest/CongestionDB.cc
trafficserver/traffic/trunk/proxy/congest/CongestionTest.cc
trafficserver/traffic/trunk/proxy/http/HttpAccept.cc
Modified: trafficserver/traffic/trunk/CHANGES
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/CHANGES?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/CHANGES (original)
+++ trafficserver/traffic/trunk/CHANGES Fri Jul 29 14:04:36 2011
@@ -2,6 +2,8 @@
Changes with Apache Traffic Server 3.1.0
+ *) IpLookup was removed from the experimental API.
+
*) proxy.config.http.cache.cache_responses_to_cookies can now be overridden
on a per request basis in cache.config.
Modified: trafficserver/traffic/trunk/iocore/dns/P_SplitDNSProcessor.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/dns/P_SplitDNSProcessor.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/dns/P_SplitDNSProcessor.h (original)
+++ trafficserver/traffic/trunk/iocore/dns/P_SplitDNSProcessor.h Fri Jul 29 14:04:36 2011
@@ -199,8 +199,8 @@ public:
const char *get_host();
- ip_addr_t get_ip();
- ip_addr_t get_client_ip();
+ in_addr_t get_ip();
+ in_addr_t get_client_ip();
const char *m_pHost;
};
@@ -238,18 +238,18 @@ DNSRequestData::get_host()
/* --------------------------------------------------------------
DNSRequestData::get_ip()
-------------------------------------------------------------- */
-TS_INLINE ip_addr_t DNSRequestData::get_ip()
+TS_INLINE in_addr_t DNSRequestData::get_ip()
{
- return (ip_addr_t) 0;
+ return (in_addr_t) 0;
}
/* --------------------------------------------------------------
DNSRequestData::get_client_ip()
-------------------------------------------------------------- */
-TS_INLINE ip_addr_t DNSRequestData::get_client_ip()
+TS_INLINE in_addr_t DNSRequestData::get_client_ip()
{
- return (ip_addr_t) 0;
+ return (in_addr_t) 0;
}
/* --------------------------------------------------------------
Modified: trafficserver/traffic/trunk/lib/ts/IntrusiveDList.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/IntrusiveDList.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/IntrusiveDList.h (original)
+++ trafficserver/traffic/trunk/lib/ts/IntrusiveDList.h Fri Jul 29 14:04:36 2011
@@ -179,7 +179,7 @@ public:
};
/// Default constructor (empty list).
- IntrusiveDList() : _head(0), _tail(0) { }
+ IntrusiveDList() : _head(0), _tail(0), _count(0) { }
/// Empty check.
/// @return @c true if the list is empty.
bool isEmpty() const { return 0 == _head; }
@@ -193,6 +193,7 @@ public:
if (_head) _head->*P = elt;
_head = elt;
if (! _tail) _tail = _head; // empty to non-empty transition
+ ++_count;
return *this;
}
/// Add @elt as the last element in the list.
@@ -205,6 +206,7 @@ public:
if (_tail) _tail->*N = elt;
_tail = elt;
if (! _head) _head = _tail; // empty to non-empty transition
+ ++_count;
return *this;
}
/// Remove the first element of the list.
@@ -218,6 +220,7 @@ public:
else _tail = 0; // non-empty to empty transition.
zret->*N = 0; // erase traces of list.
zret->*P = 0;
+ --_count;
}
return zret;
}
@@ -232,6 +235,7 @@ public:
else _head = 0; // non-empty to empty transition.
zret->*N = 0; // erase traces of list.
zret->*P = 0;
+ --_count;
}
return zret;
}
@@ -249,6 +253,7 @@ public:
target->*N = elt;
if (elt->*N) elt->*N->*P = elt;
if (target == _tail) _tail = elt;
+ ++_count;
return *this;
}
/// Insert a new element @a elt before @a target.
@@ -265,6 +270,7 @@ public:
target->*P = elt;
if (elt->*P) elt->*P->*N = elt;
if (target == _head) _head = elt;
+ ++_count;
return *this;
}
/// Take @a elt out of this list.
@@ -277,12 +283,15 @@ public:
if (elt == _head) _head = elt->*N;
if (elt == _tail) _tail = elt->*P;
elt->*P = elt->*N = 0;
+ --_count;
return *this;
}
/// Remove all elements.
/// @note @b No memory management is done!
/// @return This container.
- self& clear() { _head = _tail = 0; return *this; }
+ self& clear() { _head = _tail = 0; _count = 0; return *this; }
+ /// @return Number of elements in the list.
+ size_t getCount() const { return _count; }
/// Get an iterator to the first element.
iterator begin() { return iterator(this, _head); }
@@ -295,6 +304,7 @@ public:
protected:
T* _head; ///< First element in list.
T* _tail; ///< Last element in list.
+ size_t _count; ///< # of elements in list.
};
# endif // TS_INTRUSIVE_DOUBLE_LIST_HEADER
Modified: trafficserver/traffic/trunk/lib/ts/IpMap.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/IpMap.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/IpMap.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/IpMap.cc Fri Jul 29 14:04:36 2011
@@ -413,7 +413,7 @@ template <
bool contains(
ArgType target, ///< Search target value.
void **ptr = 0 ///< Client data return.
- );
+ ) const;
/** Erase entire map.
@@ -466,16 +466,19 @@ template <
*/
void validate();
+ /// @return The number of distinct ranges.
+ size_t getCount() const;
+
/// Print all spans.
/// @return This map.
self& print();
// Helper methods.
- N* prev(RBNode* n) { return static_cast<N*>(n->_prev); }
- N* next(RBNode* n) { return static_cast<N*>(n->_next); }
- N* parent(RBNode* n) { return static_cast<N*>(n->_parent); }
- N* left(RBNode* n) { return static_cast<N*>(n->_left); }
- N* right(RBNode* n) { return static_cast<N*>(n->_right); }
+ N* prev(RBNode* n) const { return static_cast<N*>(n->_prev); }
+ N* next(RBNode* n) const { return static_cast<N*>(n->_next); }
+ N* parent(RBNode* n) const { return static_cast<N*>(n->_parent); }
+ N* left(RBNode* n) const { return static_cast<N*>(n->_left); }
+ N* right(RBNode* n) const { return static_cast<N*>(n->_right); }
N* getHead() { return static_cast<N*>(_list.getHead()); }
N* getTail() { return static_cast<N*>(_list.getTail()); }
@@ -523,8 +526,20 @@ IpMapBase<N>::mark(ArgType min, ArgType
N* n = this->lowerBound(min); // current node.
N* x = 0; // New node, gets set if we re-use an existing one.
- /* We have lots of special cases here primarily to minimize memory allocation
- by re-using an existing node as often as possible.
+ /* Some subtlety - for IPv6 we overload the compare operators to do
+ the right thing, but we can't overload pointer
+ comparisons. Therefore we carefully never compare pointers in
+ this logic. Only @a min and @a max can be pointers, everything
+ else is an instance or a reference. Since there's no good reason
+ to compare @a min and @a max this isn't particularly tricky, but
+ it's good to keep in mind. If we were somewhat more clever, we
+ would provide static less than and equal operators in the
+ template class @a N and convert all the comparisons to use only
+ those two via static function call.
+ */
+
+ /* We have lots of special cases here primarily to minimize memory
+ allocation by re-using an existing node as often as possible.
*/
if (n) {
Metric min_1 = N::deref(min);
@@ -532,9 +547,10 @@ IpMapBase<N>::mark(ArgType min, ArgType
if (n->_min == min) {
// Could be another span further left which is adjacent.
// Coalesce if the data is the same.
- if (n->_prev && prev(n)->_data == payload && prev(n)->_max == min_1) {
- x = prev(n);
- n = x; // need to back up n because we've moved our frame of reference back.
+ N* p = prev(n);
+ if (p && p->_data == payload && p->_max == min_1) {
+ x = p;
+ n = x; // need to back up n because frame of reference moved.
x->setMax(max);
} else if (n->_max <= max) {
// Span will be subsumed by request span so it's available for use.
@@ -697,7 +713,7 @@ IpMapBase<N>::remove(N* n) {
}
template <typename N> bool
-IpMapBase<N>::contains(ArgType x, void** ptr) {
+IpMapBase<N>::contains(ArgType x, void** ptr) const {
bool zret = false;
N* n = _root; // current node to test.
while (n) {
@@ -711,6 +727,8 @@ IpMapBase<N>::contains(ArgType x, void**
}
return zret;
}
+
+template < typename N > size_t IpMapBase<N>::getCount() const { return _list.getCount(); }
//----------------------------------------------------------------------------
template <typename N> void
IpMapBase<N>::validate() {
@@ -758,12 +776,12 @@ public:
/// Construct with values.
Ip4Node(
- ArgType min, ///< Minimum address (network order).
- ArgType max, ///< Maximum address (network order).
+ ArgType min, ///< Minimum address (host order).
+ ArgType max, ///< Maximum address (host order).
void* data ///< Client data.
- ) : Node(data), Ip4Span(ntohl(min), ntohl(max)) {
- ink_inet_ip4_set(ink_inet_sa_cast(&_sa._min), min);
- ink_inet_ip4_set(ink_inet_sa_cast(&_sa._max), max);
+ ) : Node(data), Ip4Span(min, max) {
+ ink_inet_ip4_set(ink_inet_sa_cast(&_sa._min), htonl(min));
+ ink_inet_ip4_set(ink_inet_sa_cast(&_sa._max), htonl(max));
}
/// @return The minimum value of the interval.
virtual sockaddr const* min() {
@@ -802,24 +820,6 @@ protected:
return *this;
}
- // Static helper methods for Metric.
-
- /** Compare two metrics.
- @return
- - -1 if @a lhs < @a rhs
- - 0 if @a lhs == @a rhs
- - 1 if @a lhs > @a rhs
- */
- static int cmp(
- ArgType lhs,
- ArgType rhs
- ) {
- return lhs < rhs ? -1
- : lhs > rhs ? 1
- : 0
- ;
- }
-
/// Increment a metric.
static void inc(
Metric& m ///< Incremented in place.
@@ -840,6 +840,13 @@ protected:
) {
return addr;
}
+
+ /// @return The argument type for the @a metric.
+ static ArgType argue(
+ Metric const& metric
+ ) {
+ return metric;
+ }
struct {
sockaddr_in _min;
@@ -931,21 +938,6 @@ protected:
return this->setMax(&max);
}
- // Static helper methods for Metric.
-
- /** Compare two metrics.
- @return
- - -1 if @a lhs < @a rhs
- - 0 if @a lhs == @a rhs
- - 1 if @a lhs > @a rhs
- */
- static int cmp(
- ArgType lhs,
- ArgType rhs
- ) {
- return ink_inet_cmp(ink_inet_sa_cast(lhs), ink_inet_sa_cast(rhs));
- }
-
/// Increment a metric.
static void inc(
Metric& m ///< Incremented in place.
@@ -1019,19 +1011,15 @@ inline bool operator>(sockaddr_in6 const
return 1 == ts::detail::cmp(lhs, *rhs);
}
+// We declare this after the helper operators and inside this namespace
+// so that the template uses these for comparisons.
+
class Ip6Map : public IpMapBase<Ip6Node> {
friend class ::IpMap;
};
-}} // end namespaces
-
+}} // end ts::detail
//----------------------------------------------------------------------------
-namespace {
- ///< @return The network order IPv4 address in @a target.
- inline in_addr_t const& ip4_addr(sockaddr const* target) {
- return ink_inet_ip4_cast(target)->sin_addr.s_addr;
- }
-}
IpMap::~IpMap() {
delete _m4;
delete _m6;
@@ -1044,11 +1032,11 @@ IpMap::force4() {
}
bool
-IpMap::contains(sockaddr const* target, void** ptr) {
+IpMap::contains(sockaddr const* target, void** ptr) const {
bool zret = false;
if (AF_INET == target->sa_family) {
if (_m4) {
- zret = _m4->contains(ntohl(ip4_addr(target)));
+ zret = _m4->contains(ntohl(ink_inet_ip4_addr_cast(target)));
}
} else if (AF_INET6 == target->sa_family) {
if (_m6) {
@@ -1059,8 +1047,8 @@ IpMap::contains(sockaddr const* target,
}
bool
-IpMap::contains(in_addr_t target, void** ptr) {
- return _m4->contains(ntohl(target));
+IpMap::contains(in_addr_t target, void** ptr) const {
+ return _m4->contains(ntohl(target), ptr);
}
IpMap&
@@ -1071,10 +1059,14 @@ IpMap::mark(
) {
ink_assert(min->sa_family == max->sa_family);
if (AF_INET == min->sa_family) {
- this->force4()->mark(ip4_addr(min), ip4_addr(max), data);
+ this->force4()->mark(
+ ntohl(ink_inet_ip4_addr_cast(min)),
+ ntohl(ink_inet_ip4_addr_cast(max)),
+ data
+ );
} else if (AF_INET6 == min->sa_family) {
if (!_m6) _m6 = new ts::detail::Ip6Map;
- _m6->mark(ink_inet_ip6_cast(min), ink_inet_ip6_cast(max));
+ _m6->mark(ink_inet_ip6_cast(min), ink_inet_ip6_cast(max), data);
}
return *this;
}
@@ -1092,13 +1084,21 @@ IpMap::unmark(
) {
ink_assert(min->sa_family == max->sa_family);
if (AF_INET == min->sa_family) {
- if (_m4) _m4->unmark(ip4_addr(min), ip4_addr(max));
+ if (_m4) _m4->unmark(ink_inet_ip4_addr_cast(min), ink_inet_ip4_addr_cast(max));
} else if (AF_INET6 == min->sa_family) {
if (_m6) _m6->unmark(ink_inet_ip6_cast(min), ink_inet_ip6_cast(max));
}
return *this;
}
+size_t
+IpMap::getCount() const {
+ size_t zret = 0;
+ if (_m4) zret += _m4->getCount();
+ if (_m6) zret += _m6->getCount();
+ return zret;
+}
+
IpMap::iterator
IpMap::begin() {
Node* x = 0;
@@ -1114,7 +1114,7 @@ IpMap::iterator::operator ++ () {
// and if so, move to the v6 list (if it's there).
Node* x = static_cast<Node*>(_node->_next);
if (!x && _tree->_m4 && _tree->_m6 && _node == _tree->_m4->getTail())
- x = _tree->_m6->getTail();
+ x = _tree->_m6->getHead();
_node = x;
}
return *this;
Modified: trafficserver/traffic/trunk/lib/ts/IpMap.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/IpMap.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/IpMap.h (original)
+++ trafficserver/traffic/trunk/lib/ts/IpMap.h Fri Jul 29 14:04:36 2011
@@ -403,7 +403,7 @@ public:
bool contains(
sockaddr const* target, ///< Search target (network order).
void **ptr = 0 ///< Client data return.
- );
+ ) const;
/** Test for membership.
@@ -416,12 +416,14 @@ public:
bool contains(
in_addr_t target, ///< Search target (network order).
void **ptr = 0 ///< Client data return.
- );
+ ) const;
/// Iterator for first element.
iterator begin();
/// Iterator past last element.
iterator end();
+ /// @return Number of distinct ranges in the map.
+ size_t getCount() const;
/** Validate internal data structures.
@note Intended for debugging, not general client use.
Modified: trafficserver/traffic/trunk/lib/ts/MatcherUtils.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/MatcherUtils.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/MatcherUtils.h (original)
+++ trafficserver/traffic/trunk/lib/ts/MatcherUtils.h Fri Jul 29 14:04:36 2011
@@ -55,6 +55,15 @@ char const* ExtractIpRange(
in_addr_t * addr2 ///< [in,out] Returned address in host order.
);
+/// Convenience overload for IPv6.
+inline char const* ExtractIpRange(
+ char *match_str,
+ sockaddr_in6* addr1, ///< [in,out] Returned address in network order.
+ sockaddr_in6* addr2 ///< [in,out] Returned address in network order.
+) {
+ return ExtractIpRange(match_str, ink_inet_sa_cast(addr1), ink_inet_sa_cast(addr2));
+}
+
char *tokLine(char *buf, char **last);
const char *processDurationString(char *str, int *seconds);
Modified: trafficserver/traffic/trunk/mgmt/utils/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/utils/Makefile.am?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/utils/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/utils/Makefile.am Fri Jul 29 14:04:36 2011
@@ -45,8 +45,6 @@ libutils_lm_a_SOURCES = \
EnvBlock.h \
ExpandingArray.cc \
ExpandingArray.h \
- IpLookup.cc \
- IpLookup.h \
MgmtSchema.cc \
MgmtSchema.h \
MgmtUtils.cc \
@@ -57,8 +55,6 @@ libutils_lm_a_SOURCES = \
XmlUtils.h
libutils_p_a_SOURCES = \
- IpLookup.cc \
- IpLookup.h \
MgmtUtils.cc \
MgmtUtils.h \
XmlUtils.cc \
Modified: trafficserver/traffic/trunk/proxy/ControlBase.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/ControlBase.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/ControlBase.cc (original)
+++ trafficserver/traffic/trunk/proxy/ControlBase.cc Fri Jul 29 14:04:36 2011
@@ -267,8 +267,8 @@ ControlBase::Modifier::Type SrcIPMod::ty
char const * SrcIPMod::name() const { return NAME; }
void SrcIPMod::print(FILE* f) const {
- ip_addr_t a1 = htonl(start_addr);
- ip_addr_t a2 = htonl(end_addr);
+ in_addr_t a1 = htonl(start_addr);
+ in_addr_t a2 = htonl(end_addr);
fprintf(f, "%s=%d.%d.%d.%d-%d.%d.%d.%d ",
this->name(), TS_IP_OCTETS(a1), TS_IP_OCTETS(a2)
);
Modified: trafficserver/traffic/trunk/proxy/ControlMatcher.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/ControlMatcher.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/ControlMatcher.cc (original)
+++ trafficserver/traffic/trunk/proxy/ControlMatcher.cc Fri Jul 29 14:04:36 2011
@@ -70,13 +70,13 @@ HttpRequestData::get_host()
return hostname_str;
}
-ip_addr_t
+in_addr_t
HttpRequestData::get_ip()
{
return dest_ip;
}
-ip_addr_t
+in_addr_t
HttpRequestData::get_client_ip()
{
return src_ip;
@@ -436,7 +436,6 @@ template<class Data, class Result> void
// IpMatcher<Data,Result>::IpMatcher()
//
template<class Data, class Result> IpMatcher<Data, Result>::IpMatcher(const char *name, const char *filename):
-ip_lookup(NULL),
data_array(NULL),
array_len(-1),
num_el(-1),
@@ -450,7 +449,6 @@ file_name(filename)
//
template<class Data, class Result> IpMatcher<Data, Result>::~IpMatcher()
{
- delete ip_lookup;
delete[]data_array;
}
@@ -462,8 +460,6 @@ template<class Data, class Result> void
// Should not have been allocated before
ink_assert(array_len == -1);
- ip_lookup = NEW(new IpLookup(matcher_name));
-
data_array = NEW(new Data[num_entries]);
array_len = num_entries;
@@ -522,49 +518,40 @@ template<class Data, class Result> char
return errBuf;
}
- ip_lookup->NewEntry(addr1, addr2, cur_d);
+ ip_map.mark(addr1, addr2, cur_d);
- num_el++;
+ ++num_el;
return NULL;
}
//
-// void IpMatcherData,Result>::Match(ip_addr_t addr, RD* rdata, Result* result)
+// void IpMatcherData,Result>::Match(in_addr_t addr, RD* rdata, Result* result)
//
template<class Data, class Result>
- void IpMatcher<Data, Result>::Match(ip_addr_t addr, RD * rdata, Result * result)
+ void IpMatcher<Data, Result>::Match(in_addr_t addr, RD * rdata, Result * result)
{
- Data *cur;
- bool found;
- IpLookupState s;
-
- found = ip_lookup->MatchFirst(addr, &s, (void **) &cur);
-
- while (found == true) {
-
- ink_assert(cur != NULL);
-
+ void* raw;
+ if (ip_map.contains(addr, &raw)) {
+ Data *cur = static_cast<Data*>(raw);
+ ink_assert(cur != 0);
cur->UpdateMatch(result, rdata);
-
- found = ip_lookup->MatchNext(&s, (void **) &cur);
}
}
template<class Data, class Result> void IpMatcher<Data, Result>::Print()
{
- printf("\tIp Matcher with %d elements\n", num_el);
- if (ip_lookup != NULL) {
- ip_lookup->Print(IpMatcher<Data, Result>::PrintFunc);
+ printf("\tIp Matcher with %d elements, %d ranges.\n", num_el, ip_map.getCount());
+ for ( IpMap::iterator spot(ip_map.begin()), limit(ip_map.end()) ; spot != limit ; ++spot) {
+ char b1[INET6_ADDRSTRLEN], b2[INET6_ADDRSTRLEN];
+ printf("\tRange %s - %s ",
+ ink_inet_ntop(spot->min(), b1, sizeof b1),
+ ink_inet_ntop(spot->max(), b2, sizeof b2)
+ );
+ static_cast<Data*>(spot->data())->Print();
}
}
-template<class Data, class Result> void IpMatcher<Data, Result>::PrintFunc(void *opaque_data)
-{
- Data *ptr = (Data *) opaque_data;
- ptr->Print();
-}
-
template<class Data, class Result>
ControlMatcher<Data, Result>::ControlMatcher(const char *file_var, const char *name,
const matcher_tags * tags, int flags_in)
Modified: trafficserver/traffic/trunk/proxy/ControlMatcher.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/ControlMatcher.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/ControlMatcher.h (original)
+++ trafficserver/traffic/trunk/proxy/ControlMatcher.h Fri Jul 29 14:04:36 2011
@@ -98,7 +98,7 @@
#endif
#include "DynArray.h"
-#include "IpLookup.h"
+#include <ts/IpMap.h>
#include "ink_port.h"
#include "HTTP.h"
@@ -121,9 +121,9 @@ public:
}
virtual char *get_string() = 0;
virtual const char *get_host() = 0;
- virtual ip_addr_t get_ip() = 0;
+ virtual in_addr_t get_ip() = 0;
- virtual ip_addr_t get_client_ip() = 0;
+ virtual in_addr_t get_client_ip() = 0;
enum RD_Type
{ RD_NULL, RD_HTTP, RD_CONGEST_ENTRY };
virtual RD_Type data_type(void)
@@ -138,8 +138,8 @@ class HttpRequestData:public RequestData
public:
inkcoreapi char *get_string();
inkcoreapi const char *get_host();
- inkcoreapi ip_addr_t get_ip();
- inkcoreapi ip_addr_t get_client_ip();
+ inkcoreapi in_addr_t get_ip();
+ inkcoreapi in_addr_t get_client_ip();
HttpRequestData()
: hdr(NULL), hostname_str(NULL), api_info(NULL),
@@ -150,8 +150,8 @@ public:
char *hostname_str;
_HttpApiInfo *api_info;
time_t xact_start;
- ip_addr_t src_ip;
- ip_addr_t dest_ip;
+ in_addr_t src_ip;
+ in_addr_t dest_ip;
uint16_t incoming_port;
char *tag;
};
@@ -227,7 +227,7 @@ template<class Data, class Result> class
public:
IpMatcher(const char *name, const char *filename);
~IpMatcher();
- void Match(ip_addr_t ip_addr, RD * rdata, Result * result);
+ void Match(in_addr_t ip_addr, RD * rdata, Result * result);
void AllocateSpace(int num_entries);
char *NewEntry(matcher_line * line_info);
void Print();
@@ -241,9 +241,9 @@ public:
};
//private:
- //void MatchArray(ip_addr_t addr, RD* rdata, Result* result, void* array);
+ //void MatchArray(in_addr_t addr, RD* rdata, Result* result, void* array);
static void PrintFunc(void *opaque_data);
- IpLookup *ip_lookup; // Data structure to do lookups
+ IpMap ip_map; // Data structure to do lookups
Data *data_array; // array of the data lements with in the table
int array_len; // size of the arrays
int num_el; // number of elements in the table
Modified: trafficserver/traffic/trunk/proxy/IPAllow.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/IPAllow.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/IPAllow.cc (original)
+++ trafficserver/traffic/trunk/proxy/IPAllow.cc Fri Jul 29 14:04:36 2011
@@ -36,11 +36,14 @@
#include "P_EventSystem.h"
#include "P_Cache.h"
+#include <sstream>
+
#define IPAllowRegisterConfigUpdateFunc REC_RegisterConfigUpdateFunc
#define IPAllowReadConfigStringAlloc REC_ReadConfigStringAlloc
-IpAllow *ip_allow_table = NULL;
-Ptr<ProxyMutex> ip_reconfig_mutex;
+IpAllow* IpAllow::_instance = NULL;
+
+static Ptr<ProxyMutex> ip_reconfig_mutex;
//
// struct IPAllow_FreerContinuation
@@ -59,7 +62,7 @@ struct IPAllow_FreerContinuation: public
Debug("ip-allow", "Deleting old table");
delete p;
delete this;
- return EVENT_DONE;
+ return EVENT_DONE;
}
IPAllow_FreerContinuation(IpAllow * ap):Continuation(NULL), p(ap)
{
@@ -78,7 +81,7 @@ struct IPAllow_UpdateContinuation: publi
{
NOWARN_UNUSED(etype);
NOWARN_UNUSED(data);
- reloadIPAllow();
+ IpAllow::ReloadInstance();
delete this;
return EVENT_DONE;
}
@@ -103,34 +106,31 @@ ipAllowFile_CB(const char *name, RecData
// Begin API functions
//
void
-initIPAllow()
-{
-
+IpAllow::InitInstance() {
// Should not have been initialized before
- ink_assert(ip_allow_table == NULL);
+ ink_assert(_instance == NULL);
ip_reconfig_mutex = new_ProxyMutex();
- ip_allow_table = NEW(new IpAllow("proxy.config.cache.ip_allow.filename", "IpAllow", "ip_allow"));
- ip_allow_table->BuildTable();
+ _instance = NEW(new self("proxy.config.cache.ip_allow.filename", "IpAllow", "ip_allow"));
+ _instance->BuildTable();
IPAllowRegisterConfigUpdateFunc("proxy.config.cache.ip_allow.filename", ipAllowFile_CB, NULL);
}
void
-reloadIPAllow()
-{
- IpAllow *new_table;
+IpAllow::ReloadInstance() {
+ self *new_table;
Debug("ip_allow", "ip_allow.config updated, reloading");
// Schedule the current table for deallocation in the future
- eventProcessor.schedule_in(NEW(new IPAllow_FreerContinuation(ip_allow_table)), IP_ALLOW_TIMEOUT, ET_CACHE);
+ eventProcessor.schedule_in(NEW(new IPAllow_FreerContinuation(_instance)), IP_ALLOW_TIMEOUT, ET_CACHE);
- new_table = NEW(new IpAllow("proxy.config.cache.ip_allow.filename", "IpAllow", "ip_allow"));
+ new_table = NEW(new self("proxy.config.cache.ip_allow.filename", "IpAllow", "ip_allow"));
new_table->BuildTable();
- ink_atomic_swap_ptr(&ip_allow_table, new_table);
+ ink_atomic_swap_ptr(_instance, new_table);
}
//
@@ -138,12 +138,14 @@ reloadIPAllow()
//
-IpAllow::IpAllow(const char *config_var, const char *name, const char *action_val):
-IpLookup(name),
-config_file_var(config_var),
-module_name(name),
-action(action_val),
-err_allow_all(false)
+IpAllow::IpAllow(
+ const char *config_var,
+ const char *name,
+ const char *action_val
+) : config_file_var(config_var),
+ module_name(name),
+ action(action_val),
+ _allow_all(false)
{
char *config_file;
@@ -162,13 +164,27 @@ IpAllow::~IpAllow()
}
void
-IpAllow::Print()
-{
- printf("IpAllow Table with %d entries\n", num_el);
- if (err_allow_all == true) {
- printf("\t err_allow_all is true\n");
+IpAllow::Print() {
+ std::ostringstream s;
+ s << _map.getCount() << " ACL entries";
+ if (_allow_all) s << " - ACLs are disabled, all connections are permitted";
+ s << '.';
+ for ( IpMap::iterator spot(_map.begin()), limit(_map.end())
+ ; spot != limit
+ ; ++spot
+ ) {
+ char text[INET6_ADDRSTRLEN];
+ AclRecord const* ar = static_cast<AclRecord const*>(spot->data());
+
+ s << std::endl << " Line " << ar->_src_line << ": "
+ << (ACL_OP_ALLOW == ar->_op ? "allow " : "deny ")
+ << ink_inet_ntop(spot->min(), text, sizeof text)
+ ;
+ if (0 != ink_inet_cmp(spot->min(), spot->max())) {
+ s << " - " << ink_inet_ntop(spot->max(), text, sizeof text);
+ }
}
- IpLookup::Print();
+ Debug("ip-allow", "%s", s.str().c_str());
}
int
@@ -180,18 +196,18 @@ IpAllow::BuildTable()
char errBuf[1024];
char *file_buf = NULL;
int line_num = 0;
- in_addr_t addr1 = 0;
- in_addr_t addr2 = 0;
+ sockaddr_in6 addr1;
+ sockaddr_in6 addr2;
matcher_line line_info;
bool alarmAlready = false;
// Table should be empty
- ink_assert(num_el == 0);
+ ink_assert(_map.getCount() == 0);
file_buf = readIntoBuffer(config_file_path, module_name, NULL);
if (file_buf == NULL) {
- err_allow_all = false;
+ _allow_all = false;
Warning("%s Failed to read %s. All IP Addresses will be blocked", module_name, config_file_path);
return 1;
}
@@ -199,7 +215,7 @@ IpAllow::BuildTable()
line = tokLine(file_buf, &tok_state);
while (line != NULL) {
- line_num++;
+ ++line_num;
// skip all blank spaces at beginning of line
while (*line && isspace(*line)) {
@@ -228,30 +244,32 @@ IpAllow::BuildTable()
// INKqa05845
// Search for "action=ip_allow" or "action=ip_deny".
char *label, *val;
- IpAllowRecord *rec;
for (int i = 0; i < MATCHER_MAX_TOKENS; i++) {
label = line_info.line[0][i];
val = line_info.line[1][i];
if (label == NULL)
continue;
if (strcasecmp(label, "action") == 0) {
- if (strcasecmp(val, "ip_allow") == 0) {
- rec = (IpAllowRecord *) xmalloc(sizeof(IpAllowRecord));
- rec->access = IP_ALLOW;
- rec->line_num = line_num;
- this->NewEntry(addr1, addr2, (void *) rec);
- } else if (strcasecmp(val, "ip_deny") == 0) {
- rec = (IpAllowRecord *) xmalloc(sizeof(IpAllowRecord));
- rec->access = IP_DENY;
- rec->line_num = line_num;
- this->NewEntry(addr1, addr2, (void *) rec);
+ bool found = false;
+ AclOp op;
+ if (strcasecmp(val, "ip_allow") == 0)
+ found = true, op = ACL_OP_ALLOW;
+ else if (strcasecmp(val, "ip_deny") == 0)
+ found = true, op = ACL_OP_DENY;
+ if (found) {
+ _acls.push_back(AclRecord(op, line_num));
+ // Color with index because at this point the address
+ // is volatile.
+ _map.mark(
+ &addr1, &addr2,
+ reinterpret_cast<void*>(_acls.size()-1)
+ );
} else {
snprintf(errBuf, sizeof(errBuf), "%s discarding %s entry at line %d : %s", module_name, config_file_path, line_num, "Invalid action specified"); //changed by YTS Team, yamsat bug id -59022
SignalError(errBuf, alarmAlready);
}
}
}
- // this->NewEntry(addr1, addr2, NULL);
}
}
}
@@ -259,9 +277,17 @@ IpAllow::BuildTable()
line = tokLine(NULL, &tok_state);
}
- if (num_el == 0) {
+ if (_map.getCount() == 0) {
Warning("%s No entries in %s. All IP Addresses will be blocked", module_name, config_file_path);
- err_allow_all = false;
+ _allow_all = false;
+ } else {
+ // convert the coloring from indices to pointers.
+ for ( IpMap::iterator spot(_map.begin()), limit(_map.end())
+ ; spot != limit
+ ; ++spot
+ ) {
+ spot->setData(&_acls[reinterpret_cast<size_t>(spot->data())]);
+ }
}
if (is_debug_tag_set("ip-allow")) {
Modified: trafficserver/traffic/trunk/proxy/IPAllow.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/IPAllow.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/IPAllow.h (original)
+++ trafficserver/traffic/trunk/proxy/IPAllow.h Fri Jul 29 14:04:36 2011
@@ -31,11 +31,12 @@
#ifndef _IP_ALLOW_H_
#define _IP_ALLOW_H_
-#include "IpLookup.h"
#include "Main.h"
+#include <ts/IpMap.h>
+#include <vector>
-void initIPAllow();
-void reloadIPAllow();
+// forward declare in name only so it can be a friend.
+struct IPAllow_UpdateContinuation;
//
// Timeout the IpAllowTable * this amount of time after the
@@ -44,53 +45,61 @@ void reloadIPAllow();
//
static uint64_t const IP_ALLOW_TIMEOUT = HRTIME_HOUR;
-// INKqa05845
-static int const IP_ALLOW = 1;
-static int const IP_DENY = -1;
-
-struct IpAllowRecord {
- int access;
- int line_num;
+enum AclOp {
+ ACL_OP_ALLOW, ///< Allow access.
+ ACL_OP_DENY, ///< Deny access.
};
-class IpAllow:public IpLookup
-{
+struct AclRecord {
+ AclOp _op;
+ int _src_line;
+
+ AclRecord(AclOp op, int ln) : _op(op), _src_line(ln) { }
+};
+
+class IpAllow {
+ friend int main(int, char**);
+ friend struct IPAllow_UpdateContinuation;
public:
+ typedef IpAllow self; ///< Self reference type.
+
IpAllow(const char *config_var, const char *name, const char *action_val);
~IpAllow();
int BuildTable();
void Print();
- bool match(ip_addr_t ip);
+ bool match(in_addr_t addr);
+
+ /// @return The global instance.
+ static self* instance();
private:
+
+ static void InitInstance();
+ static void ReloadInstance();
+
const char *config_file_var;
char config_file_path[PATH_NAME_MAX];
const char *module_name;
const char *action;
- bool err_allow_all;
+ bool _allow_all;
+ IpMap _map;
+ std::vector<AclRecord> _acls;
+
+ static self* _instance;
};
-extern IpAllow *ip_allow_table;
+inline IpAllow* IpAllow::instance() { return _instance; }
-// INKqa05845
inline bool
-IpAllow::match(ip_addr_t ip)
-{
- if (err_allow_all == true) {
- return true;
- } else {
- IpAllowRecord *cur = NULL, *result = NULL;
- IpLookupState s;
- bool found;
- found = IpLookup::MatchFirst(ip, &s, (void **) &cur);
- result = cur;
- while (found) {
- if (cur->line_num < result->line_num) {
- result = cur;
- }
- found = IpLookup::MatchNext(&s, (void **) &cur);
+IpAllow::match(in_addr_t addr) {
+ bool zret = _allow_all;
+ if (!zret) {
+ void* raw;
+ if (_map.contains(addr, &raw)) {
+ AclRecord* acl = static_cast<AclRecord*>(raw);
+ zret = acl && ACL_OP_ALLOW == acl->_op;
}
- return ((result != NULL) && (result->access == IP_ALLOW));
}
+ return zret;
}
#endif
Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Fri Jul 29 14:04:36 2011
@@ -6794,64 +6794,6 @@ TSHttpTxnClientRemotePortGet(TSHttpTxn t
return TS_SUCCESS;
}
-/* IP Lookup */
-
-// This is very suspicious, TSILookup is a (void *), so how on earth
-// can we try to delete an instance of it?
-void
-TSIPLookupNewEntry(TSIPLookup iplu, uint32_t addr1, uint32_t addr2, void *data)
-{
- IpLookup *my_iplu = (IpLookup *) iplu;
-
- if (my_iplu) {
- my_iplu->NewEntry((ip_addr_t) addr1, (ip_addr_t) addr2, data);
- }
-}
-
-int
-TSIPLookupMatch(TSIPLookup iplu, uint32_t addr, void **data)
-{
- void *dummy;
- IpLookup *my_iplu = (IpLookup *) iplu;
-
- if (!data) {
- data = &dummy;
- }
- return (my_iplu ? my_iplu->Match((ip_addr_t) addr, data) : 0);
-}
-
-TSReturnCode
-TSIPLookupMatchFirst(TSIPLookup iplu, uint32_t addr, TSIPLookupState iplus, void **data)
-{
- IpLookup *my_iplu = (IpLookup *) iplu;
- IpLookupState *my_iplus = (IpLookupState *) iplus;
- if (my_iplu && my_iplus && my_iplu->MatchFirst(addr, my_iplus, data))
- return TS_SUCCESS;
-
- return TS_ERROR;
-}
-
-TSReturnCode
-TSIPLookupMatchNext(TSIPLookup iplu, TSIPLookupState iplus, void **data)
-{
- IpLookup *my_iplu = (IpLookup *) iplu;
- IpLookupState *my_iplus = (IpLookupState *) iplus;
-
- if (my_iplu && my_iplus && my_iplu->MatchNext(my_iplus, data))
- return TS_SUCCESS;
-
- return TS_ERROR;
-}
-
-void
-TSIPLookupPrint(TSIPLookup iplu, TSIPLookupPrintFunc pf)
-{
- IpLookup *my_iplu = (IpLookup *) iplu;
-
- if (my_iplu)
- my_iplu->Print((IpLookupPrintFunc) pf);
-}
-
/* Matcher Utils */
char *
TSMatcherReadIntoBuffer(char *file_name, int *file_len)
Modified: trafficserver/traffic/trunk/proxy/InkAPITest.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITest.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITest.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITest.cc Fri Jul 29 14:04:36 2011
@@ -7355,9 +7355,11 @@ cont_test_handler(TSCont contp, TSEvent
} else {
body_expected = "Body for response 10";
}
- TSDebug(UTDBG_TAG, "Body Response = \n|%s|\nBody Expected = \n|%s|", body_response, body_expected);
+ TSDebug(UTDBG_TAG, "Body Response = \n|%s|\nBody Expected = \n|%s|", body_response ? body_response : "*NULL*", body_expected);
- if (strncmp(body_response, body_expected, strlen(body_expected)) != 0) {
+ if (!body_response
+ || strncmp(body_response, body_expected, strlen(body_expected)) != 0
+ ) {
if (data->test_case == TEST_CASE_CONNECT_ID1) {
SDK_RPRINT(data->test, "TSHttpConnect", "TestCase1", TC_FAIL, "Unexpected response");
SDK_RPRINT(data->test, "TSHttpTxnIntercept", "TestCase1", TC_FAIL, "Unexpected response");
Modified: trafficserver/traffic/trunk/proxy/Main.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Main.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Main.cc (original)
+++ trafficserver/traffic/trunk/proxy/Main.cc Fri Jul 29 14:04:36 2011
@@ -1747,7 +1747,7 @@ main(int argc, char **argv)
initCacheControl();
#endif
initCongestionControl();
- initIPAllow();
+ IpAllow::InitInstance();
ParentConfig::startup();
#ifdef SPLIT_DNS
SplitDNSConfig::startup();
Modified: trafficserver/traffic/trunk/proxy/ParentSelection.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/ParentSelection.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/ParentSelection.cc (original)
+++ trafficserver/traffic/trunk/proxy/ParentSelection.cc Fri Jul 29 14:04:36 2011
@@ -1052,7 +1052,7 @@ SocksServerConfig::print()
}
void
-request_to_data(HttpRequestData * req, ip_addr_t srcip, ip_addr_t dstip, const char *str)
+request_to_data(HttpRequestData * req, in_addr_t srcip, in_addr_t dstip, const char *str)
{
HTTPParser parser;
Modified: trafficserver/traffic/trunk/proxy/api/ts/experimental.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/experimental.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/experimental.h (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/experimental.h Fri Jul 29 14:04:36 2011
@@ -56,17 +56,6 @@ extern "C"
tsapi int TSMimeHdrFieldEqual(TSMBuffer bufp, TSMLoc hdr_obj, TSMLoc field1, TSMLoc field2);
tsapi TSReturnCode TSHttpTxnHookRegisteredFor(TSHttpTxn txnp, TSHttpHookID id, TSEventFunc funcp);
- /* IP Lookup */
- typedef struct tsapi_iplookup* TSIPLookup;
- typedef struct tsapi_iplookupstate* TSIPLookupState;
- typedef void (*TSIPLookupPrintFunc) (void *data);
-
- tsapi void TSIPLookupPrint(TSIPLookup iplu, TSIPLookupPrintFunc pf);
- tsapi void TSIPLookupNewEntry(TSIPLookup iplu, uint32_t addr1, uint32_t addr2, void *data);
- tsapi int TSIPLookupMatch(TSIPLookup iplu, uint32_t addr, void **data);
- tsapi TSReturnCode TSIPLookupMatchFirst(TSIPLookup iplu, uint32_t addr, TSIPLookupState iplus, void **data);
- tsapi TSReturnCode TSIPLookupMatchNext(TSIPLookup iplu, TSIPLookupState iplus, void **data);
-
/* for Media-IXT mms over http */
typedef enum
{
Modified: trafficserver/traffic/trunk/proxy/congest/Congestion.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/congest/Congestion.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/congest/Congestion.cc (original)
+++ trafficserver/traffic/trunk/proxy/congest/Congestion.cc Fri Jul 29 14:04:36 2011
@@ -608,7 +608,7 @@ FailHistory::regist_event(long t, int n)
//----------------------------------------------------------
// CongestionEntry Implementation
//----------------------------------------------------------
-CongestionEntry::CongestionEntry(const char *hostname, ip_addr_t ip, CongestionControlRecord * rule, uint64_t key)
+CongestionEntry::CongestionEntry(const char *hostname, in_addr_t ip, CongestionControlRecord * rule, uint64_t key)
:m_key(key),
m_ip(ip),
m_last_congested(0),
Modified: trafficserver/traffic/trunk/proxy/congest/Congestion.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/congest/Congestion.h?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/congest/Congestion.h (original)
+++ trafficserver/traffic/trunk/proxy/congest/Congestion.h Fri Jul 29 14:04:36 2011
@@ -204,7 +204,7 @@ struct CongestionEntry: public RequestDa
// key in the hash table;
uint64_t m_key;
// host info
- ip_addr_t m_ip;
+ in_addr_t m_ip;
char *m_hostname;
// Pointer to the congestion.config entry
@@ -228,7 +228,7 @@ struct CongestionEntry: public RequestDa
// Reference count
int m_ref_count;
- CongestionEntry(const char *hostname, ip_addr_t ip, CongestionControlRecord * rule, uint64_t key);
+ CongestionEntry(const char *hostname, in_addr_t ip, CongestionControlRecord * rule, uint64_t key);
CongestionEntry();
virtual ~ CongestionEntry();
@@ -241,13 +241,13 @@ struct CongestionEntry: public RequestDa
{
return m_hostname;
}
- virtual ip_addr_t get_ip()
+ virtual in_addr_t get_ip()
{
return m_ip;
}
- virtual ip_addr_t get_client_ip()
+ virtual in_addr_t get_client_ip()
{
- return (ip_addr_t) 0;
+ return (in_addr_t) 0;
}
virtual RD_Type data_type(void)
{
Modified: trafficserver/traffic/trunk/proxy/congest/CongestionDB.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/congest/CongestionDB.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/congest/CongestionDB.cc (original)
+++ trafficserver/traffic/trunk/proxy/congest/CongestionDB.cc Fri Jul 29 14:04:36 2011
@@ -75,7 +75,7 @@ public:
{
uint64_t m_key;
char *m_hostname;
- ip_addr_t m_ip;
+ in_addr_t m_ip;
CongestionControlRecord *m_rule;
CongestionEntry **m_ppEntry;
} entry_info;
@@ -624,7 +624,7 @@ remove_congested_entry(char *buf, MIOBuf
len = snprintf(msg, MSG_LEN, "host=%s prefix=%s removed\n", p, prefix ? prefix : "(nil)");
} else if (strncasecmp(buf, "ip=", 3) == 0) {
char *p = buf + 3;
- ip_addr_t ip = 0;
+ in_addr_t ip = 0;
char *prefix = strchr(p, '/');
int prelen = 0;
if (prefix) {
@@ -633,7 +633,7 @@ remove_congested_entry(char *buf, MIOBuf
prelen = strlen(prefix);
}
ip = htonl(inet_addr(p));
- if (ip == (ip_addr_t) - 1 && strcmp(p, "255.255.255.255") != 0) {
+ if (ip == (in_addr_t) - 1 && strcmp(p, "255.255.255.255") != 0) {
len = snprintf(msg, MSG_LEN, "invalid ip: %s\n", buf);
} else {
key = make_key(NULL, 0, ip, prefix, prelen);
Modified: trafficserver/traffic/trunk/proxy/congest/CongestionTest.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/congest/CongestionTest.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/congest/CongestionTest.cc (original)
+++ trafficserver/traffic/trunk/proxy/congest/CongestionTest.cc Fri Jul 29 14:04:36 2011
@@ -383,7 +383,7 @@ struct CCCongestionDBTestCont: public Co
CongestionControlRecord *rule;
CongestionDB *db;
int dbsize;
- CongestionEntry *gen_CongestionEntry(ip_addr_t ip, int congested = 0);
+ CongestionEntry *gen_CongestionEntry(in_addr_t ip, int congested = 0);
CCCongestionDBTestCont(ProxyMutexPtr _mutex, RegressionTest * _test):Continuation(_mutex),
@@ -403,7 +403,7 @@ struct CCCongestionDBTestCont: public Co
};
CongestionEntry *
-CCCongestionDBTestCont::gen_CongestionEntry(ip_addr_t ip, int congested)
+CCCongestionDBTestCont::gen_CongestionEntry(in_addr_t ip, int congested)
{
char *hostname;
struct in_addr addr;
Modified: trafficserver/traffic/trunk/proxy/http/HttpAccept.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpAccept.cc?rev=1152228&r1=1152227&r2=1152228&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpAccept.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpAccept.cc Fri Jul 29 14:04:36 2011
@@ -38,11 +38,11 @@ HttpAccept::mainEvent(int event, void *d
// if client address forbidden, close immediately //
////////////////////////////////////////////////////
NetVConnection *netvc = (NetVConnection *) data;
- unsigned int client_ip = netvc->get_remote_ip();
+ in_addr_t client_ip = netvc->get_remote_ip();
// The backdoor port is now only bound to "localhost", so reason to
// check for if it's incoming from "localhost" or not.
- if (!backdoor && ip_allow_table && (!ip_allow_table->match(client_ip))) {
+ if (!backdoor && IpAllow::instance() && (!IpAllow::instance()->match(client_ip))) {
char ip_string[32];
unsigned char *p = (unsigned char *) &(client_ip);