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/10/05 21:14:09 UTC
svn commit: r1179389 [2/2] - in /trafficserver/traffic/trunk: ./ iocore/dns/
iocore/net/ iocore/utils/ lib/ts/ proxy/ proxy/api/ts/ proxy/congest/
proxy/http/ proxy/http/remap/ proxy/logging/
Modified: trafficserver/traffic/trunk/proxy/http/HttpConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpConfig.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpConfig.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpConfig.cc Wed Oct 5 19:14:07 2011
@@ -1142,7 +1142,7 @@ HttpConfig::startup()
if (c.outgoing_ip_to_bind) {
Debug("ip_binding", "outgoing_ip_to_bind: %s", c.outgoing_ip_to_bind);
- c.oride.outgoing_ip_to_bind_saddr = inet_addr(c.outgoing_ip_to_bind);
+ ink_inet_pton(c.outgoing_ip_to_bind, &c.oride.outgoing_ip_to_bind_saddr);
}
HttpEstablishStaticConfigLongLong(c.server_max_connections, "proxy.config.http.server_max_connections");
@@ -1415,7 +1415,7 @@ HttpConfig::reconfigure()
params = NEW(new HttpConfigParams);
params->incoming_ip_to_bind_saddr = m_master.incoming_ip_to_bind_saddr;
- params->oride.outgoing_ip_to_bind_saddr = m_master.oride.outgoing_ip_to_bind_saddr;
+ ink_inet_copy(¶ms->oride.outgoing_ip_to_bind_saddr, &m_master.oride.outgoing_ip_to_bind_saddr);
params->proxy_hostname = ats_strdup(m_master.proxy_hostname);
params->proxy_hostname_len = (params->proxy_hostname) ? strlen(params->proxy_hostname) : 0;
params->no_dns_forward_to_parent = INT_TO_BOOL(m_master.no_dns_forward_to_parent);
Modified: trafficserver/traffic/trunk/proxy/http/HttpConfig.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpConfig.h?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpConfig.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpConfig.h Wed Oct 5 19:14:07 2011
@@ -430,9 +430,10 @@ struct OverridableHttpConfigParams {
// Strings / floats must come last
proxy_response_server_string(NULL), proxy_response_server_string_len(0),
- cache_heuristic_lm_factor(0.0), freshness_fuzz_prob(0.0),
- outgoing_ip_to_bind_saddr(0)
- { }
+ cache_heuristic_lm_factor(0.0), freshness_fuzz_prob(0.0)
+ {
+ ink_zero(outgoing_ip_to_bind_saddr);
+ }
// IMPORTANT: All MgmtInt configs should come before any other string / float
// configs!!!
@@ -564,7 +565,7 @@ struct OverridableHttpConfigParams {
////////////////////////
// Source IP //
////////////////////////
- unsigned int outgoing_ip_to_bind_saddr; // This is kinda ugly for now, whatever ...
+ ts_ip_endpoint outgoing_ip_to_bind_saddr; // This is kinda ugly for now, whatever ...
};
Modified: trafficserver/traffic/trunk/proxy/http/HttpConnectionCount.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpConnectionCount.h?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpConnectionCount.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpConnectionCount.h Wed Oct 5 19:14:07 2011
@@ -46,9 +46,9 @@ public:
* @param ip IP address of the host
* @return Number of connections
*/
- int getCount(const unsigned int ip) {
+ int getCount(const ts_ip_endpoint& addr) {
ink_mutex_acquire(&_mutex);
- int count = _hostCount.get(ip);
+ int count = _hostCount.get(ConnAddr(addr));
ink_mutex_release(&_mutex);
return count;
}
@@ -58,20 +58,36 @@ public:
* @param ip IP address of the host
* @param delta Default is +1, can be set to negative to decrement
*/
- void incrementCount(const unsigned int ip, const int delta = 1) {
+ void incrementCount(const ts_ip_endpoint& addr, const int delta = 1) {
+ ConnAddr caddr(addr);
ink_mutex_acquire(&_mutex);
- int count = _hostCount.get(ip);
- _hostCount.put(ip, count + delta);
+ int count = _hostCount.get(caddr);
+ _hostCount.put(caddr, count + delta);
ink_mutex_release(&_mutex);
}
+ struct ConnAddr {
+ ts_ip_endpoint _addr;
+
+ ConnAddr() { ink_zero(_addr); }
+ ConnAddr(int x) { ink_release_assert(x == 0); ink_zero(_addr); }
+ ConnAddr(const ts_ip_endpoint& addr) : _addr(addr) { }
+ operator bool() { return ink_inet_is_ip(&_addr); }
+ };
+
+ class ConnAddrHashFns {
+ public:
+ static uintptr_t hash(ConnAddr& addr) { return (uintptr_t) ink_inet_hash(&addr._addr.sa); }
+ static int equal(ConnAddr& a, ConnAddr& b) { return ink_inet_eq(&a._addr, &b._addr); }
+ };
+
private:
// Hide the constructor and copy constructor
ConnectionCount() { }
ConnectionCount(const ConnectionCount & x) { NOWARN_UNUSED(x); }
static ConnectionCount _connectionCount;
- Map<unsigned int, int> _hostCount;
+ HashMap<ConnAddr, ConnAddrHashFns, int> _hostCount;
static ink_mutex _mutex;
};
Modified: trafficserver/traffic/trunk/proxy/http/HttpSM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpSM.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpSM.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpSM.cc Wed Oct 5 19:14:07 2011
@@ -599,16 +599,10 @@ HttpSM::attach_client_session(HttpClient
NetVConnection* netvc = client_vc->get_netvc();
- t_state.client_info.ip = netvc->get_remote_ip();
+ ink_inet_copy(&t_state.client_info.addr, netvc->get_remote_addr());
t_state.client_info.port = netvc->get_local_port();
t_state.client_info.is_transparent = netvc->get_is_transparent();
t_state.backdoor_request = client_vc->backdoor_connect;
- memset(&(t_state.client_info.addr), 0, sizeof(t_state.client_info.addr));
- ink_inet_copy(
- ink_inet_sa_cast(&t_state.client_info.addr),
- client_vc->get_netvc()->get_remote_addr()
- );
-// t_state.client_info.addr = ink_inet_ip6_cast(*client_vc->get_netvc()->get_remote_addr());
t_state.client_info.port_attribute = (HttpPortTypes) netvc->attributes;
HTTP_INCREMENT_DYN_STAT(http_current_client_transactions_stat);
@@ -1629,9 +1623,9 @@ HttpSM::state_http_server_open(int event
UnixNetVConnection *server_vc = (UnixNetVConnection*)data;
printf("client fd is :%d , server fd is %d\n",vc->con.fd,
server_vc->con.fd); */
- session->server_ip = t_state.current.server->ip;
+ ink_inet_copy(&session->server_ip, &t_state.current.server->addr);
session->new_connection((NetVConnection *) data);
- session->server_port = t_state.current.server->port;
+ ink_inet_port_cast(&session->server_ip) = htons(t_state.current.server->port);
session->state = HSS_ACTIVE;
attach_server_session(session);
@@ -2005,14 +1999,10 @@ HttpSM::process_hostdb_info(HostDBInfo *
t_state.dns_info.lookup_success = true;
if (r->round_robin) {
- // TODO: IPv6 ?
- sockaddr_in ip4;
-
- ink_inet_ip4_set(&ip4, t_state.client_info.ip);
// Since the time elapsed between current time and client_request_time
// may be very large, we cannot use client_request_time to approximate
// current time when calling select_best_http().
- rr = r->rr()->select_best_http(ink_inet_sa_cast(&ip4), ink_cluster_time(), (int) t_state.txn_conf->down_server_timeout);
+ rr = r->rr()->select_best_http(&t_state.client_info.addr.sa, ink_cluster_time(), (int) t_state.txn_conf->down_server_timeout);
t_state.dns_info.round_robin = true;
} else {
rr = r;
@@ -2022,7 +2012,7 @@ HttpSM::process_hostdb_info(HostDBInfo *
// m_s.host_db_info = m_updated_host_db_info = *rr;
t_state.host_db_info = *rr;
ink_release_assert(!t_state.host_db_info.reverse_dns);
- ink_release_assert(t_state.host_db_info.ip() > 0);
+ ink_release_assert(ink_inet_is_ip(t_state.host_db_info.ip()));
}
} else {
Debug("http", "[%" PRId64 "] DNS lookup failed for '%s'", sm_id, t_state.dns_info.lookup_name);
@@ -2120,10 +2110,7 @@ HttpSM::state_mark_os_down(int event, vo
ink_assert(t_state.current.server != NULL);
ink_assert(t_state.current.request_to == HttpTransact::ORIGIN_SERVER);
if (t_state.current.server) {
- ts_ip_endpoint ip;
- ink_inet_ip4_set(&ip.sa, t_state.current.server->ip);
- mark_down = r->rr()->find_ip(&ip.sa);
-// mark_down = r->rr()->find_ip(t_state.current.server->ip);
+ mark_down = r->rr()->find_ip(&t_state.current.server->addr.sa);
}
} else {
// No longer a round robin, check to see if our address is the same
@@ -3798,9 +3785,7 @@ HttpSM::do_hostdb_update_if_necessary()
}
// If we failed back over to the origin server, we don't have our
// hostdb information anymore which means we shouldn't update the hostdb
- ts_ip_endpoint ip;
- ink_inet_ip4_set(&ip.sa, t_state.current.server->ip);
- if (!ink_inet_eq(&ip.sa, t_state.host_db_info.ip())) {
+ if (!ink_inet_eq(&t_state.current.server->addr.sa, t_state.host_db_info.ip())) {
Debug("http", "[%" PRId64 "] skipping hostdb update due to server failover", sm_id);
return;
}
@@ -3827,25 +3812,25 @@ HttpSM::do_hostdb_update_if_necessary()
} else {
if (t_state.host_db_info.app.http_data.last_failure != 0) {
t_state.host_db_info.app.http_data.last_failure = 0;
+ ink_inet_port_cast(&t_state.current.server->addr) = htons(t_state.current.server->port);
issue_update |= 1;
- Debug("http", "[%" PRId64 "] hostdb update marking IP: %u.%u.%u.%u (port %d) as up",
+ char addrbuf[INET6_ADDRPORTSTRLEN];
+ Debug("http", "[%" PRId64 "] hostdb update marking IP: %s as up",
sm_id,
- ((unsigned char *) &t_state.current.server->ip)[0],
- ((unsigned char *) &t_state.current.server->ip)[1],
- ((unsigned char *) &t_state.current.server->ip)[2],
- ((unsigned char *) &t_state.current.server->ip)[3], t_state.current.server->port);
+ ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
}
}
if (issue_update) {
- ts_ip_endpoint ip;
hostDBProcessor.setby(t_state.current.server->name,
strlen(t_state.current.server->name),
- ink_inet_ip4_set(&ip.sa, t_state.current.server->ip, htons(t_state.current.server->port)),
+ &t_state.current.server->addr.sa,
&t_state.host_db_info.app
);
}
+ char addrbuf[INET6_ADDRPORTSTRLEN];
+ Debug("http", "server info = %s", ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
return;
}
@@ -4086,16 +4071,19 @@ HttpSM::do_http_server_open(bool raw)
t_state.txn_conf->sock_send_buffer_size_out,
t_state.txn_conf->sock_option_flag_out);
- if (t_state.txn_conf->outgoing_ip_to_bind_saddr) {
+ if (ink_inet_is_ip(&t_state.txn_conf->outgoing_ip_to_bind_saddr)) {
opt.addr_binding = NetVCOptions::INTF_ADDR;
- ink_inet_ip4_set(&opt.local_addr, t_state.txn_conf->outgoing_ip_to_bind_saddr);
+ ink_inet_copy(&opt.local_addr, &t_state.txn_conf->outgoing_ip_to_bind_saddr);
} else if (t_state.server_info.is_transparent) {
opt.addr_binding = NetVCOptions::FOREIGN_ADDR;
- ink_inet_ip4_set(&opt.local_addr, t_state.client_info.ip);
+ ink_inet_copy(&opt.local_addr, &t_state.client_info.addr);
}
+ ink_inet_port_cast(&t_state.current.server->addr) = htons(t_state.current.server->port);
- Debug("http", "[%" PRId64 "] open connection to %s: %u.%u.%u.%u",
- sm_id, t_state.current.server->name, PRINT_IP(t_state.current.server->ip));
+ char addrbuf[INET6_ADDRPORTSTRLEN];
+ Debug("http", "[%" PRId64 "] open connection to %s: %s",
+ sm_id, t_state.current.server->name,
+ ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
if (plugin_tunnel) {
PluginVCCore *t = plugin_tunnel;
@@ -4144,8 +4132,7 @@ HttpSM::do_http_server_open(bool raw)
(t_state.txn_conf->keep_alive_post_out == 1 || t_state.hdr_info.request_content_length == 0) &&
ua_session != NULL) {
shared_result = httpSessionManager.acquire_session(this, // state machine
- t_state.current.server->ip, // host_op
- t_state.current.server->port, // host_port
+ &t_state.current.server->addr.sa, // ip + port
t_state.current.server->name, // hostname
ua_session, // has ptr to bound ua sessions
this // sm
@@ -4174,8 +4161,7 @@ HttpSM::do_http_server_open(bool raw)
HttpServerSession *existing_ss = ua_session->get_server_session();
if (existing_ss) {
- if (existing_ss->server_ip == t_state.current.server->ip
- && existing_ss->server_port == t_state.current.server->port) {
+ if (ink_inet_cmp(&existing_ss->server_ip.sa, &t_state.current.server->addr.sa) == 0) {
ua_session->attach_server_session(NULL);
existing_ss->state = HSS_ACTIVE;
this->attach_server_session(existing_ss);
@@ -4224,8 +4210,10 @@ HttpSM::do_http_server_open(bool raw)
if (t_state.txn_conf->origin_max_connections > 0) {
ConnectionCount *connections = ConnectionCount::getInstance();
- if (connections->getCount((t_state.current.server->ip)) >= t_state.txn_conf->origin_max_connections) {
- Debug("http", "[%" PRId64 "] over the number of connection for this host: %u", sm_id, t_state.current.server->ip);
+ char addrbuf[INET6_ADDRSTRLEN];
+ if (connections->getCount((t_state.current.server->addr)) >= t_state.txn_conf->origin_max_connections) {
+ Debug("http", "[%" PRId64 "] over the number of connection for this host: %s", sm_id,
+ ink_inet_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
ink_debug_assert(pending_action == NULL);
pending_action = eventProcessor.schedule_in(this, HRTIME_MSECONDS(100));
return;
@@ -4234,23 +4222,18 @@ HttpSM::do_http_server_open(bool raw)
// We did not manage to get an exisiting session
// and need to open a new connection
- unsigned int srv_ip = t_state.current.server->ip;
- int srv_port = t_state.current.server->port;
-
Action *connect_action_handle;
if (t_state.scheme == URL_WKSIDX_HTTPS) {
Debug("http", "calling sslNetProcessor.connect_re");
connect_action_handle = sslNetProcessor.connect_re(this, // state machine
- srv_ip, // host_op
- srv_port, // host_port
+ &t_state.current.server->addr.sa, // addr + port
&opt);
} else {
if (t_state.method != HTTP_WKSIDX_CONNECT) {
Debug("http", "calling netProcessor.connect_re");
connect_action_handle = netProcessor.connect_re(this, // state machine
- srv_ip, // host_op
- srv_port, // host_port
+ &t_state.current.server->addr.sa, // addr + port
&opt);
} else {
// Setup the timeouts
@@ -4270,8 +4253,7 @@ HttpSM::do_http_server_open(bool raw)
}
Debug("http", "calling netProcessor.connect_s");
connect_action_handle = netProcessor.connect_s(this, // state machine
- srv_ip, // host_op
- srv_port, // host_port
+ &t_state.current.server->addr.sa, // addr + port
connect_timeout, &opt);
}
}
@@ -4411,14 +4393,13 @@ HttpSM::do_transform_open()
void
HttpSM::mark_host_failure(HostDBInfo * info, time_t time_down)
{
+ char addrbuf[INET6_ADDRPORTSTRLEN];
+
if (info->app.http_data.last_failure == 0) {
char *url_str = t_state.hdr_info.client_request.url_string_get(&t_state.arena, 0);
- Log::error("CONNECT: could not connect to %u.%u.%u.%u "
+ Log::error("CONNECT: could not connect to %s "
"for '%s' (setting last failure time)",
- ((unsigned char *) &t_state.current.server->ip)[0],
- ((unsigned char *) &t_state.current.server->ip)[1],
- ((unsigned char *) &t_state.current.server->ip)[2],
- ((unsigned char *) &t_state.current.server->ip)[3],
+ ink_inet_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)),
url_str ? url_str : "<none>"
);
if (url_str)
@@ -4432,12 +4413,9 @@ HttpSM::mark_host_failure(HostDBInfo * i
ink_assert(ink_cluster_time() + t_state.txn_conf->down_server_timeout > time_down);
#endif
- Debug("http", "[%" PRId64 "] hostdb update marking IP: %u.%u.%u.%u (port %d) as down",
+ Debug("http", "[%" PRId64 "] hostdb update marking IP: %s as down",
sm_id,
- ((unsigned char *) &t_state.current.server->ip)[0],
- ((unsigned char *) &t_state.current.server->ip)[1],
- ((unsigned char *) &t_state.current.server->ip)[2],
- ((unsigned char *) &t_state.current.server->ip)[3], t_state.current.server->port);
+ ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
}
void
@@ -6420,7 +6398,7 @@ HttpSM::set_next_state()
break;
} else if (t_state.parent_result.r == PARENT_UNDEFINED && t_state.dns_info.lookup_success) {
// Already set, and we don't have a parent proxy to lookup
- ink_assert(t_state.host_db_info.ip());
+ ink_assert(ink_inet_is_ip(t_state.host_db_info.ip()));
Debug("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup, provided by plugin");
call_transact_and_set_next_state(NULL);
break;
Modified: trafficserver/traffic/trunk/proxy/http/HttpServerSession.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpServerSession.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpServerSession.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpServerSession.cc Wed Oct 5 19:14:07 2011
@@ -78,7 +78,10 @@ HttpServerSession::new_connection(NetVCo
if (connection_count == NULL)
connection_count = ConnectionCount::getInstance();
connection_count->incrementCount(server_ip);
- Debug("http_ss", "[%" PRId64 "] new connection, ip: %u, count: %u", con_id, server_ip, connection_count->getCount(server_ip));
+ char addrbuf[INET6_ADDRSTRLEN];
+ Debug("http_ss", "[%" PRId64 "] new connection, ip: %s, count: %u",
+ con_id,
+ ink_inet_ntop(&server_ip.sa, addrbuf, sizeof(addrbuf)), connection_count->getCount(server_ip));
}
#ifdef LAZY_BUF_ALLOC
read_buffer = new_empty_MIOBuffer(HTTP_SERVER_RESP_HDR_BUFFER_INDEX);
@@ -128,8 +131,11 @@ HttpServerSession::do_io_close(int alerr
if (enable_origin_connection_limiting == true) {
if (connection_count->getCount(server_ip) > 0) {
connection_count->incrementCount(server_ip, -1);
+ char addrbuf[INET6_ADDRSTRLEN];
Debug("http_ss", "[%" PRId64 "] connection closed, ip: %u, count: %u",
- con_id, server_ip, connection_count->getCount(server_ip));
+ con_id,
+ ink_inet_ntop(&server_ip.sa, addrbuf, sizeof(addrbuf)),
+ connection_count->getCount(server_ip));
} else {
Error("http_ss", "[%" PRId64 "] number of connections should be greater then zero: %u",
con_id, connection_count->getCount(server_ip));
Modified: trafficserver/traffic/trunk/proxy/http/HttpServerSession.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpServerSession.h?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpServerSession.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpServerSession.h Wed Oct 5 19:14:07 2011
@@ -69,14 +69,16 @@ class HttpServerSession : public VConnec
public:
HttpServerSession()
: VConnection(NULL),
- server_ip(0), server_port(0), hostname_hash(),
+ hostname_hash(),
host_hash_computed(false), con_id(0), transact_count(0),
state(HSS_INIT), to_parent_proxy(false), server_trans_stat(0),
private_session(false), share_session(0),
enable_origin_connection_limiting(false),
connection_count(NULL), read_buffer(NULL),
server_vc(NULL), magic(HTTP_SS_MAGIC_DEAD), buf_reader(NULL)
- { }
+ {
+ ink_zero(server_ip);
+ }
void destroy();
void new_connection(NetVConnection *new_vc);
@@ -112,8 +114,7 @@ public:
};
// Keys for matching hostnames
- unsigned int server_ip;
- int server_port;
+ ts_ip_endpoint server_ip;
INK_MD5 hostname_hash;
bool host_hash_computed;
Modified: trafficserver/traffic/trunk/proxy/http/HttpSessionManager.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpSessionManager.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpSessionManager.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpSessionManager.cc Wed Oct 5 19:14:07 2011
@@ -36,8 +36,8 @@
#include "HttpSM.h"
#include "HttpDebugNames.h"
-#define FIRST_LEVEL_HASH(x) x % HSM_LEVEL1_BUCKETS
-#define SECOND_LEVEL_HASH(x) x % HSM_LEVEL2_BUCKETS
+#define FIRST_LEVEL_HASH(x) ink_inet_hash(x) % HSM_LEVEL1_BUCKETS
+#define SECOND_LEVEL_HASH(x) ink_inet_hash(x) % HSM_LEVEL2_BUCKETS
// Initialize a thread to handle HTTP session management
void
@@ -89,7 +89,7 @@ SessionBucket::session_handler(int event
}
// Search the 2nd level bucket for appropriate netvc
- int l2_index = SECOND_LEVEL_HASH(net_vc->get_remote_ip());
+ int l2_index = SECOND_LEVEL_HASH(net_vc->get_remote_addr());
HttpConfigParams *http_config_params = HttpConfig::acquire();
bool found = false;
@@ -167,7 +167,7 @@ HttpSessionManager::purge_keepalives()
while (b->lru_list.head) {
HttpServerSession *sess = b->lru_list.head;
b->lru_list.remove(sess);
- int l2_index = SECOND_LEVEL_HASH(sess->server_ip);
+ int l2_index = SECOND_LEVEL_HASH(&sess->server_ip.sa);
b->l2_hash[l2_index].remove(sess);
sess->do_io_close();
}
@@ -178,7 +178,7 @@ HttpSessionManager::purge_keepalives()
}
HSMresult_t
-_acquire_session(SessionBucket *bucket, unsigned int ip, int port, INK_MD5 &hostname_hash, HttpSM *sm)
+_acquire_session(SessionBucket *bucket, sockaddr const* ip, INK_MD5 &hostname_hash, HttpSM *sm)
{
HttpServerSession *b;
HttpServerSession *to_return = NULL;
@@ -190,7 +190,9 @@ _acquire_session(SessionBucket *bucket,
// the 2nd level bucket
b = bucket->l2_hash[l2_index].head;
while (b != NULL) {
- if (b->server_ip == ip && b->server_port == port) {
+ if (ink_inet_eq(&b->server_ip.sa, ip) &&
+ ink_inet_port_cast(ip) == ink_inet_port_cast(&b->server_ip)
+ ) {
if (hostname_hash == b->hostname_hash) {
bucket->lru_list.remove(b);
bucket->l2_hash[l2_index].remove(b);
@@ -209,7 +211,7 @@ _acquire_session(SessionBucket *bucket,
}
HSMresult_t
-HttpSessionManager::acquire_session(Continuation *cont, unsigned int ip, int port,
+HttpSessionManager::acquire_session(Continuation *cont, sockaddr const* ip,
const char *hostname, HttpClientSession *ua_session, HttpSM *sm)
{
NOWARN_UNUSED(cont);
@@ -234,7 +236,9 @@ HttpSessionManager::acquire_session(Cont
if (to_return != NULL) {
ua_session->attach_server_session(NULL);
- if (to_return->server_ip == ip && to_return->server_port == port) {
+ if (ink_inet_eq(&to_return->server_ip.sa, ip) &&
+ ink_inet_port_cast(&to_return->server_ip) == ink_inet_port_cast(ip)
+ ) {
if (!hash_computed) {
ink_code_MMH((unsigned char *) hostname, strlen(hostname), (unsigned char *) &hostname_hash);
hash_computed = true;
@@ -267,13 +271,13 @@ HttpSessionManager::acquire_session(Cont
if (2 == sm->t_state.txn_conf->share_server_sessions) {
ink_assert(ethread->l1_hash);
- return _acquire_session(ethread->l1_hash + l1_index, ip, port, hostname_hash, sm);
+ return _acquire_session(ethread->l1_hash + l1_index, ip, hostname_hash, sm);
} else {
SessionBucket *bucket = g_l1_hash + l1_index;
MUTEX_TRY_LOCK(lock, bucket->mutex, ethread);
if (lock) {
- return _acquire_session(bucket, ip, port, hostname_hash, sm);
+ return _acquire_session(bucket, ip, hostname_hash, sm);
} else {
Debug("http_ss", "[acquire session] could not acquire session due to lock contention");
}
@@ -286,7 +290,7 @@ HttpSessionManager::acquire_session(Cont
HSMresult_t
_release_session(SessionBucket *bucket, HttpServerSession *to_release)
{
- int l2_index = SECOND_LEVEL_HASH(to_release->server_ip);
+ int l2_index = SECOND_LEVEL_HASH(&to_release->server_ip.sa);
ink_assert(l2_index < HSM_LEVEL2_BUCKETS);
@@ -317,7 +321,7 @@ HSMresult_t
HttpSessionManager::release_session(HttpServerSession *to_release)
{
EThread *ethread = this_ethread();
- int l1_index = FIRST_LEVEL_HASH(to_release->server_ip);
+ int l1_index = FIRST_LEVEL_HASH(&to_release->server_ip.sa);
ink_assert(l1_index < HSM_LEVEL1_BUCKETS);
Modified: trafficserver/traffic/trunk/proxy/http/HttpSessionManager.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpSessionManager.h?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpSessionManager.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpSessionManager.h Wed Oct 5 19:14:07 2011
@@ -73,7 +73,7 @@ public:
{ }
HSMresult_t acquire_session(Continuation *cont,
- unsigned int ip, int port,
+ sockaddr const* addr,
const char *hostname, HttpClientSession *ua_session, HttpSM *sm);
HSMresult_t release_session(HttpServerSession *to_release);
void purge_keepalives();
Modified: trafficserver/traffic/trunk/proxy/http/HttpTransact.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpTransact.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpTransact.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpTransact.cc Wed Oct 5 19:14:07 2011
@@ -318,7 +318,7 @@ find_server_and_update_current_info(Http
// to go the origin server, we can only obey this if we
// dns'ed the origin server
if (s->parent_result.r == PARENT_DIRECT && s->http_config_param->no_dns_forward_to_parent != 0) {
- ink_assert(s->server_info.ip == 0);
+ ink_assert(!ink_inet_is_ip(&s->server_info.addr));
s->parent_result.r = PARENT_FAIL;
}
break;
@@ -1219,10 +1219,11 @@ HttpTransact::HandleRequest(State* s)
// origin server. Ignore the no_dns_just_forward_to_parent setting.
// we need to see if the hostname is an
// ip address since the parent selection code result
- // could change as a result of this ip address
- uint32_t addr = ink_inet_addr(s->server_info.name);
- if ((int32_t) addr != -1) {
- s->request_data.dest_ip = addr;
+ // could change as a result of this ip address
+ ts_ip_endpoint addr;
+ ink_inet_pton(s->server_info.name, &addr);
+ if (ink_inet_is_ip(&addr)) {
+ ink_inet_copy(&s->request_data.dest_ip, &addr);
}
if (s->parent_params->parentExists(&s->request_data)) {
@@ -1230,7 +1231,7 @@ HttpTransact::HandleRequest(State* s)
// DNS service available, we just want to forward the request
// the parent proxy. In this case, we never find out the
// origin server's ip. So just skip past OSDNS
- s->server_info.ip = 0;
+ ink_inet_invalidate(&s->server_info.addr);
StartAccessControl(s);
return;
} else if (s->http_config_param->no_origin_server_dns) {
@@ -1382,7 +1383,7 @@ HttpTransact::PPDNSLookup(State* s)
if (!s->dns_info.lookup_success) {
// DNS lookup of parent failed, find next parent or o.s.
find_server_and_update_current_info(s);
- if (s->current.server->ip == 0) {
+ if (!ink_inet_is_ip(&s->current.server->addr)) {
if (s->current.request_to == PARENT_PROXY) {
TRANSACT_RETURN(DNS_LOOKUP, PPDNSLookup);
} else {
@@ -1395,12 +1396,13 @@ HttpTransact::PPDNSLookup(State* s)
}
} else {
// lookup succeeded, open connection to p.p.
- s->parent_info.ip = ink_inet_ip4_addr_cast(s->host_db_info.ip());
+ ink_inet_copy(&s->parent_info.addr, s->host_db_info.ip());
get_ka_info_from_host_db(s, &s->parent_info, &s->client_info, &s->host_db_info);
s->parent_info.dns_round_robin = s->dns_info.round_robin;
- Debug("http_trans", "[PPDNSLookup] DNS lookup for sm_id[%d] successful IP: %u.%u.%u.%u", s->state_machine->sm_id,
- PRINT_IP(s->parent_info.ip));
+ char addrbuf[INET6_ADDRSTRLEN];
+ Debug("http_trans", "[PPDNSLookup] DNS lookup for sm_id[%d] successful IP: %s", s->state_machine->sm_id,
+ ink_inet_ntop(&s->parent_info.addr.sa, addrbuf, sizeof(addrbuf)));
}
// Since this function can be called serveral times while retrying
@@ -1449,13 +1451,14 @@ HttpTransact::ReDNSRoundRobin(State* s)
// Our ReDNS of the server succeeeded so update the necessary
// information and try again
- s->server_info.ip =ink_inet_ip4_addr_cast( s->host_db_info.ip());
- s->request_data.dest_ip = s->server_info.ip;
+ ink_inet_copy(&s->server_info.addr, s->host_db_info.ip());
+ ink_inet_copy(&s->request_data.dest_ip, &s->server_info.addr);
get_ka_info_from_host_db(s, &s->server_info, &s->client_info, &s->host_db_info);
s->server_info.dns_round_robin = s->dns_info.round_robin;
- Debug("http_trans", "[ReDNSRoundRobin] DNS lookup for O.S. successful IP: %u.%u.%u.%u",
- PRINT_IP(s->server_info.ip));
+ char addrbuf[INET6_ADDRSTRLEN];
+ Debug("http_trans", "[ReDNSRoundRobin] DNS lookup for O.S. successful IP: %s",
+ ink_inet_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf)));
s->next_action = how_to_open_connection(s);
} else {
@@ -1591,12 +1594,14 @@ HttpTransact::OSDNSLookup(State* s)
// Check to see if can fullfill expect requests based on the cached
// update some state variables with hostdb information that has
// been provided.
- s->server_info.ip = ink_inet_ip4_addr_cast(s->host_db_info.ip());
- s->request_data.dest_ip = s->server_info.ip;
+ ink_inet_copy(&s->server_info.addr, s->host_db_info.ip());
+ ink_inet_copy(&s->request_data.dest_ip, &s->server_info.addr);
get_ka_info_from_host_db(s, &s->server_info, &s->client_info, &s->host_db_info);
s->server_info.dns_round_robin = s->dns_info.round_robin;
+
+ char addrbuf[INET6_ADDRSTRLEN];
Debug("http_trans", "[OSDNSLookup] DNS lookup for O.S. successful "
- "IP: %u.%u.%u.%u", PRINT_IP(s->server_info.ip));
+ "IP: %s", ink_inet_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf)));
// so the dns lookup was a success, but the lookup succeeded on
// a hostname which was expanded by the traffic server. we should
@@ -2543,7 +2548,7 @@ HttpTransact::HandleCacheOpenReadHit(Sta
}
if (server_up || s->stale_icp_lookup) {
- if (!s->stale_icp_lookup && s->current.server->ip == 0) {
+ if (!s->stale_icp_lookup && !ink_inet_is_ip(&s->current.server->addr)) {
// ink_release_assert(s->current.request_to == PARENT_PROXY ||
// s->http_config_param->no_dns_forward_to_parent != 0);
@@ -2933,7 +2938,7 @@ HttpTransact::HandleCacheOpenReadMiss(St
if (!h->is_cache_control_set(HTTP_VALUE_ONLY_IF_CACHED)) {
find_server_and_update_current_info(s);
- if (s->current.server->ip == 0) {
+ if (!ink_inet_is_ip(&s->current.server->addr)) {
ink_release_assert(s->current.request_to == PARENT_PROXY ||
s->http_config_param->no_dns_forward_to_parent != 0);
if (s->current.request_to == PARENT_PROXY) {
@@ -2978,13 +2983,15 @@ HttpTransact::HandleICPLookup(State* s)
if (s->icp_lookup_success == true) {
HTTP_INCREMENT_TRANS_STAT(http_icp_suggested_lookups_stat);
Debug("http_trans", "[HandleICPLookup] Success, sending request to icp suggested host.");
- s->icp_info.ip = s->icp_ip_result.sin_addr.s_addr;
- // store the port information in native byte order
+ ink_inet_ip4_set(&s->icp_info.addr, s->icp_ip_result.sin_addr.s_addr);
s->icp_info.port = ntohs(s->icp_ip_result.sin_port);
// TODO in this case we should go to the miss case
// just a little shy about using goto's, that's all.
- ink_release_assert((s->icp_info.port != s->client_info.port) || (s->icp_info.ip != this_machine()->ip));
+ ink_release_assert(
+ (s->icp_info.port != s->client_info.port) ||
+ (ink_inet_cmp(&s->icp_info.addr.sa, &Machine::instance()->ip.sa) != 0)
+ );
// Since the ICPDNSLookup is not called, these two
// values are not initialized.
@@ -3006,10 +3013,10 @@ HttpTransact::HandleICPLookup(State* s)
SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_NOT_CACHED);
Debug("http_trans", "[HandleICPLookup] Failure, sending request to forward server.");
s->parent_info.name = NULL;
- s->parent_info.port = 0;
+ ink_zero(s->parent_info.addr);
find_server_and_update_current_info(s);
- if (s->current.server->ip == 0) {
+ if (!ink_inet_is_ip(&s->current.server->addr)) {
if (s->current.request_to == PARENT_PROXY) {
TRANSACT_RETURN(DNS_LOOKUP, PPDNSLookup);
} else {
@@ -3288,7 +3295,7 @@ HttpTransact::handle_response_from_icp_s
// send request to parent proxy now if there is
// one or else directly to the origin server.
find_server_and_update_current_info(s);
- if (s->current.server->ip == 0) {
+ if (!ink_inet_is_ip(&s->current.server->addr)) {
if (s->current.request_to == PARENT_PROXY) {
TRANSACT_RETURN(DNS_LOOKUP, PPDNSLookup);
} else {
@@ -3352,8 +3359,9 @@ HttpTransact::handle_response_from_paren
s->current.server->connect_failure = 1;
- Debug("http_trans", "[%d] failed to connect to parent %u.%u.%u.%u", s->current.attempts,
- PRINT_IP(s->current.server->ip));
+ char addrbuf[INET6_ADDRSTRLEN];
+ Debug("http_trans", "[%d] failed to connect to parent %s", s->current.attempts,
+ ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)));
// If the request is not retryable, just give up!
if (!is_request_retryable(s)) {
@@ -3676,9 +3684,11 @@ HttpTransact::delete_srv_entry(State* s,
void
HttpTransact::delete_server_rr_entry(State* s, int max_retries)
{
+ char addrbuf[INET6_ADDRSTRLEN];
+
if (diags->on()) {
- DebugOn("http_trans", "[%d] failed to connect to %u.%u.%u.%u", s->current.attempts,
- PRINT_IP(s->current.server->ip));
+ DebugOn("http_trans", "[%d] failed to connect to %s", s->current.attempts,
+ ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)));
DebugOn("http_trans", "[delete_server_rr_entry] marking rr entry " "down and finding next one");
}
ink_debug_assert(s->current.server->connect_failure);
@@ -3709,20 +3719,23 @@ HttpTransact::retry_server_connection_no
ink_debug_assert(s->current.state != ACTIVE_TIMEOUT);
ink_debug_assert(s->current.attempts <= max_retries);
ink_debug_assert(s->current.server->connect_failure != 0);
+ char addrbuf[INET6_ADDRSTRLEN];
char *url_string = s->hdr_info.client_request.url_string_get(&s->arena);
- Debug("http_trans", "[%d] failed to connect [%d] to %u.%u.%u.%u", s->current.attempts, conn_state,
- PRINT_IP(s->current.server->ip));
+ Debug("http_trans", "[%d] failed to connect [%d] to %s", s->current.attempts, conn_state,
+ ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)));
//////////////////////////////////////////
// on the first connect attempt failure //
// record the failue //
//////////////////////////////////////////
if (0 == s->current.attempts)
- Log::error("CONNECT:[%d] could not connect [%s] to %u.%u.%u.%u for '%s'", s->current.attempts,
- HttpDebugNames::get_server_state_name(conn_state),
- PRINT_IP(s->current.server->ip), url_string ? url_string : "<none>");
+ Log::error("CONNECT:[%d] could not connect [%s] to %s for '%s'",
+ s->current.attempts,
+ HttpDebugNames::get_server_state_name(conn_state),
+ ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)), url_string ? url_string : "<none>"
+ );
if (url_string) {
s->arena.str_free(url_string);
@@ -5151,13 +5164,12 @@ HttpTransact::add_client_ip_to_outgoing_
{
char ip_string[INET6_ADDRSTRLEN + 1] = {'\0'};
size_t ip_string_size = 0;
- unsigned char *p = (unsigned char *) &s->client_info.ip;
- if (unlikely(!p))
+ if (!ink_inet_is_ip(&s->client_info.addr.sa))
return;
// Always prepare the IP string.
- if (ink_inet_ntop((struct sockaddr *)&s->client_info.addr, ip_string + 1, sizeof(ip_string) - 1) != NULL) {
+ if (ink_inet_ntop(&s->client_info.addr.sa, ip_string + 1, sizeof(ip_string) - 1) != NULL) {
ip_string[0] = ' '; // Leading space always, in case we need to concatenate this IP
ip_string_size += strlen(ip_string);
} else {
@@ -5676,10 +5688,10 @@ HttpTransact::initialize_state_variables
}
s->request_data.hdr = &s->hdr_info.client_request;
s->request_data.hostname_str = s->arena.str_store(host_name, host_len);
- s->request_data.src_ip = s->client_info.ip;
- s->request_data.dest_ip = 0;
+ ink_inet_copy(&s->request_data.src_ip, &s->client_info.addr);
+ memset(&s->request_data.dest_ip, 0, sizeof(s->request_data.dest_ip));
if (s->state_machine->ua_session) {
- s->request_data.incoming_port = (uint16_t) ntohs(s->state_machine->ua_session->get_netvc()->get_local_port());
+ s->request_data.incoming_port = s->state_machine->ua_session->get_netvc()->get_local_port();
}
s->request_data.xact_start = s->client_request_time;
s->request_data.api_info = &s->api_info;
@@ -6566,9 +6578,8 @@ HttpTransact::process_quick_http_filter(
return;
}
- // TODO: This currently only deal with IPv4, we should support ::1 for IPv6 too.
// Exempt for "localhost", avoid denying for localhost.
- if (((int)s->client_info.ip == 16777343)) {
+ if (ink_inet_is_loopback(&s->client_info.addr)) {
return;
}
@@ -6680,14 +6691,9 @@ HttpTransact::will_this_request_self_loo
// check if we are about to self loop //
////////////////////////////////////////
if (s->dns_info.lookup_success) {
- int dns_host_ip, host_port, local_ip, local_port;
-
- dns_host_ip = ink_inet_ip4_addr_cast(s->host_db_info.ip());
- local_ip = this_machine()->ip;
-
- if (dns_host_ip == local_ip) {
- host_port = s->hdr_info.client_request.url_get()->port_get();
- local_port = s->client_info.port;
+ if (ink_inet_eq(s->host_db_info.ip(), &Machine::instance()->ip.sa)) {
+ uint16_t host_port = s->hdr_info.client_request.url_get()->port_get();
+ uint16_t local_port = ink_inet_get_port(&s->client_info.addr);
if (host_port == local_port) {
switch (s->dns_info.looking_up) {
case ORIGIN_SERVER:
@@ -6711,7 +6717,7 @@ HttpTransact::will_this_request_self_loo
// Now check for a loop using the Via string.
// Since we insert our ip_address (in hex) into outgoing Via strings,
// look for our_ip address in the request's via string.
- if (local_ip > 0) {
+ if (ink_inet_is_ip(&Machine::instance()->ip)) {
MIMEField *via_field = s->hdr_info.client_request.field_find(MIME_FIELD_VIA, MIME_LEN_VIA);
while (via_field) {
@@ -6720,9 +6726,9 @@ HttpTransact::will_this_request_self_loo
int via_len;
const char *via_string = via_field->value_get(&via_len);
- if (via_string && ptr_len_str(via_string, via_len, this_machine()->ip_hex_string)) {
+ if (via_string && ptr_len_str(via_string, via_len, Machine::instance()->ip_hex_string)) {
Debug("http_transact", "[will_this_request_self_loop] Incoming via: %.*s has (%s[%s] (%s))", via_len, via_string,
- s->http_config_param->proxy_hostname, this_machine()->ip_hex_string, s->http_config_param->proxy_request_via_string);
+ s->http_config_param->proxy_hostname, Machine::instance()->ip_hex_string, s->http_config_param->proxy_request_via_string);
build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Multi-Hop Cycle Detected",
"request#cycle_detected", "Your request is prohibited because it would cause a cycle.");
return TRUE;
@@ -8197,12 +8203,13 @@ HttpTransact::build_error_response(State
}
if (s->http_config_param->errors_log_error_pages) {
- char ip_string[128];
- unsigned char *p = (unsigned char *) &s->client_info.ip;
+ char ip_string[INET6_ADDRSTRLEN];
- snprintf(ip_string, sizeof(ip_string), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
- Log::error("RESPONSE: sent %s status %d (%s) for '%s'", ip_string, status_code, reason_phrase,
- (url_string ? url_string : "<none>"));
+ Log::error("RESPONSE: sent %s status %d (%s) for '%s'",
+ ink_inet_ntop(&s->client_info.addr.sa, ip_string, sizeof(ip_string)),
+ status_code,
+ reason_phrase,
+ (url_string ? url_string : "<none>"));
}
if (url_string) {
Modified: trafficserver/traffic/trunk/proxy/http/HttpTransact.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpTransact.h?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpTransact.h (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpTransact.h Wed Oct 5 19:14:07 2011
@@ -779,17 +779,16 @@ public:
bool connect_failure;
TransferEncoding_t transfer_encoding;
- // The mapping is that the IP is an unsigned network
- // (big-endian) 32-bit number. Each of the dotted
- // components is a byte, so:
- // 0x25364758 = 0x25.0x36.0x47.0x58 = 37.54.71.88 in decimal.
- in_addr_t ip;
- sockaddr_in6 addr;
-
+ ts_ip_endpoint addr; // replaces 'ip' field
+
// port to connect to, except for client
// connection where it is port on proxy
// that client connected to.
- int port;
+ // This field is managed separately from the port
+ // part of 'addr' above as in various cases the two
+ // are set/manipulated independently and things are
+ // clearer this way.
+ uint16_t port; // host order.
ServerState_t state;
AbortState_t abort;
HttpPortTypes port_attribute;
@@ -807,7 +806,7 @@ public:
dns_round_robin(false),
connect_failure(false),
transfer_encoding(NO_TRANSFER_ENCODING),
- ip(0), port(0),
+ port(0),
state(STATE_UNDEFINED),
abort(ABORT_UNDEFINED),
port_attribute(SERVER_PORT_DEFAULT),
Modified: trafficserver/traffic/trunk/proxy/http/HttpTransactHeaders.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpTransactHeaders.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpTransactHeaders.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpTransactHeaders.cc Wed Oct 5 19:14:07 2011
@@ -1067,8 +1067,8 @@ HttpTransactHeaders::insert_via_header_i
}
via_string += nstrcpy(via_string, http_config_param->proxy_hostname);
*via_string++ = '[';
- memcpy(via_string, this_machine()->ip_hex_string, this_machine()->ip_hex_string_len);
- via_string += this_machine()->ip_hex_string_len;
+ memcpy(via_string, Machine::instance()->ip_hex_string, Machine::instance()->ip_hex_string_len);
+ via_string += Machine::instance()->ip_hex_string_len;
*via_string++ = ']';
*via_string++ = ' ';
*via_string++ = '(';
Modified: trafficserver/traffic/trunk/proxy/http/HttpUpdateSM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpUpdateSM.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpUpdateSM.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpUpdateSM.cc Wed Oct 5 19:14:07 2011
@@ -75,8 +75,7 @@ HttpUpdateSM::start_scheduled_update(Con
// Fix ME: What should these be set to since there is not a
// real client
- t_state.client_info.ip = inet_addr("127.0.0.1");
- t_state.client_info.port = 0;
+ ink_inet_ip4_set(&t_state.client_info.addr, htonl(INADDR_LOOPBACK), 0);
t_state.backdoor_request = 0;
t_state.client_info.port_attribute = SERVER_PORT_DEFAULT;
Modified: trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.cc Wed Oct 5 19:14:07 2011
@@ -50,7 +50,7 @@ acl_filter_rule::reset(void)
acl_filter_rule::acl_filter_rule():next(NULL), filter_name_size(0), filter_name(NULL), allow_flag(1),
method_valid(0), src_ip_valid(0), active_queue_flag(0), argc(0)
{
- memset(argv, 0, sizeof(argv));
+ ink_zero(argv);
reset();
}
@@ -100,10 +100,11 @@ acl_filter_rule::print(void)
printf("\n");
printf("src_ip_cnt=%d\n", src_ip_cnt);
for (i = 0; i < src_ip_cnt; i++) {
- struct in_addr in;
- in.s_addr = htonl((uint32_t) src_ip_array[i].start);
- in.s_addr = htonl((uint32_t) src_ip_array[i].end);
- printf(" - %s\n", inet_ntoa(in));
+ ip_text_buffer b1, b2;
+ printf("%s - %s"
+ , ink_inet_ntop(&src_ip_array[i].start.sa, b1, sizeof(b1))
+ , ink_inet_ntop(&src_ip_array[i].end.sa, b2, sizeof(b2))
+ );
}
for (i = 0; i < argc; i++) {
printf("argv[%d] = \"%s\"\n", i, argv[i]);
Modified: trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.h?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.h (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/AclFiltering.h Wed Oct 5 19:14:07 2011
@@ -30,23 +30,26 @@
// ===============================================================================
// ACL like filtering defs (per one remap rule)
-#define ACL_FILTER_MAX_METHODS 16
-#define ACL_FILTER_MAX_SRC_IP 128
-#define ACL_FILTER_MAX_ARGV 512
-
-typedef struct src_ip_info_t
-{
- in_addr_t start; // IPv4 address value stores start of a range (host byte order)
- in_addr_t end; // IPv4 address value stores end of a range (host byte order)
- bool invert; // Should we "invert" the meaning of this IP range ("not in range")
-
- void reset(void)
- {
- start = (end = 0);
+static int const ACL_FILTER_MAX_METHODS = 16;
+static int const ACL_FILTER_MAX_SRC_IP = 128;
+static int const ACL_FILTER_MAX_ARGV = 512;
+
+struct src_ip_info_t {
+ ts_ip_endpoint start; ///< Minimum value in range.
+ ts_ip_endpoint end; ///< Maximum value in range.
+ bool invert; ///< Should we "invert" the meaning of this IP range ("not in range")
+
+ void reset() {
+ ink_zero(start);
+ ink_zero(end);
invert = false;
}
-} SRC_IP_INFO;
+ /// @return @c true if @a ip is inside @a this range.
+ bool contains(ts_ip_endpoint const& ip) {
+ return ink_inet_cmp(&start, &ip) <= 0 && ink_inet_cmp(&ip, &end) <= 0;
+ }
+};
/**
*
@@ -76,9 +79,9 @@ public:
// src_ip
int src_ip_cnt; // how many valid src_ip rules we have
- SRC_IP_INFO src_ip_array[ACL_FILTER_MAX_SRC_IP];
- acl_filter_rule();
- ~acl_filter_rule();
+ src_ip_info_t src_ip_array[ACL_FILTER_MAX_SRC_IP];
+ acl_filter_rule();
+ ~acl_filter_rule();
int name(const char *_name = NULL);
int add_argv(int _argc, char *_argv[]);
void print(void);
Modified: trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/RemapProcessor.cc Wed Oct 5 19:14:07 2011
@@ -91,8 +91,8 @@ RemapProcessor::setup_for_remap(HttpTran
if (rewrite_table->num_rules_forward_with_recv_port) {
Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d",
- s->client_info.port);
- if (rewrite_table->forwardMappingWithRecvPortLookup(request_url, s->client_info.port,
+ ink_inet_get_port(&s->client_info.addr));
+ if (rewrite_table->forwardMappingWithRecvPortLookup(request_url, ink_inet_get_port(&s->client_info.addr),
request_host, request_host_len, s->url_map)) {
Debug("url_rewrite", "Found forward mapping with recv port");
mapping_found = true;
Modified: trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/remap/UrlRewrite.cc Wed Oct 5 19:14:07 2011
@@ -179,7 +179,7 @@ validate_filter_args(acl_filter_rule **
acl_filter_rule *rule;
unsigned long ul;
char *argptr, tmpbuf[1024];
- SRC_IP_INFO *ipi;
+ src_ip_info_t *ipi;
int i, j, m;
bool new_rule_flg = false;
@@ -310,7 +310,7 @@ validate_filter_args(acl_filter_rule **
ipi->invert = true;
ink_strlcpy(tmpbuf, argptr, sizeof(tmpbuf));
// important! use copy of argument
- if (ExtractIpRange(tmpbuf, &ipi->start, &ipi->end) != NULL) {
+ if (ExtractIpRange(tmpbuf, &ipi->start.sa, &ipi->end.sa) != NULL) {
Debug("url_rewrite", "[validate_filter_args] Unable to parse IP value in %s", argv[i]);
snprintf(errStrBuf, errStrBufSize, "Unable to parse IP value in %s", argv[i]);
errStrBuf[errStrBufSize - 1] = 0;
@@ -846,7 +846,7 @@ UrlRewrite::PerformACLFiltering(HttpTran
i = (method = s->hdr_info.client_request.method_get_wksidx()) - HTTP_WKSIDX_CONNECT;
if (likely(i >= 0 && i < ACL_FILTER_MAX_METHODS)) {
bool client_enabled_flag = true;
- unsigned long client_ip = ntohl(s->client_info.ip);
+ ink_release_assert(ink_inet_is_ip(&s->client_info.addr));
for (acl_filter_rule * rp = map->filter; rp; rp = rp->next) {
bool match = true;
if (rp->method_valid) {
@@ -856,7 +856,7 @@ UrlRewrite::PerformACLFiltering(HttpTran
if (match && rp->src_ip_valid) {
match = false;
for (int j = 0; j < rp->src_ip_cnt && !match; j++) {
- res = (rp->src_ip_array[j].start <= client_ip && client_ip <= rp->src_ip_array[j].end) ? 1 : 0;
+ res = rp->src_ip_array[j].contains(s->client_info.addr) ? 1 : 0;
if (rp->src_ip_array[j].invert) {
if (res != 1)
match = true;
Modified: trafficserver/traffic/trunk/proxy/logging/LogAccess.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccess.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccess.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccess.cc Wed Oct 5 19:14:07 2011
@@ -369,7 +369,7 @@ int
LogAccess::marshal_proxy_host_name(char *buf)
{
char *str = NULL;
- Machine *machine = this_machine();
+ Machine *machine = Machine::instance();
if (machine) {
str = machine->hostname;
@@ -388,7 +388,7 @@ int
LogAccess::marshal_proxy_host_ip(char *buf)
{
char *str = NULL;
- Machine *machine = this_machine();
+ Machine *machine = Machine::instance();
int len = 0;
if (machine) {
Modified: trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc Wed Oct 5 19:14:07 2011
@@ -639,13 +639,14 @@ LogAccessHttp::marshal_proxy_req_server_
return len;
}
+// TODO: Change marshalling code to support both IPv4 and IPv6 addresses.
int
LogAccessHttp::marshal_proxy_req_server_ip(char *buf)
{
if (buf) {
unsigned int the_ip = 0;
if (m_http_sm->t_state.current.server != NULL) {
- the_ip = m_http_sm->t_state.current.server->ip;
+ the_ip = ink_inet_ip4_addr_cast(&m_http_sm->t_state.current.server->addr);
}
marshal_int(buf, (int64_t)ntohl(the_ip));
}
@@ -668,15 +669,16 @@ LogAccessHttp::marshal_proxy_hierarchy_r
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
+// TODO: Change marshalling code to support both IPv4 and IPv6 addresses.
int
LogAccessHttp::marshal_server_host_ip(char *buf)
{
if (buf) {
unsigned int val = 0;
- val = m_http_sm->t_state.server_info.ip;
+ val = ink_inet_ip4_addr_cast(&m_http_sm->t_state.server_info.addr);
if (val == 0) {
if (m_http_sm->t_state.current.server != NULL) {
- val = m_http_sm->t_state.current.server->ip;
+ val = ink_inet_ip4_addr_cast(&m_http_sm->t_state.current.server->addr);
}
}
marshal_int(buf, (int64_t)ntohl(val));
Modified: trafficserver/traffic/trunk/proxy/logging/LogFile.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogFile.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogFile.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogFile.cc Wed Oct 5 19:14:07 2011
@@ -445,7 +445,7 @@ LogFile::roll(long interval_start, long
snprintf(roll_name, MAXPATHLEN, "%s%s%s.%s-%s%s",
m_name,
LOGFILE_SEPARATOR_STRING,
- this_machine()->hostname, start_time_ext, end_time_ext, LOGFILE_ROLLED_EXTENSION);
+ Machine::instance()->hostname, start_time_ext, end_time_ext, LOGFILE_ROLLED_EXTENSION);
//
// It may be possible that the file we want to roll into already
@@ -460,7 +460,7 @@ LogFile::roll(long interval_start, long
snprintf(roll_name, MAXPATHLEN, "%s%s%s.%s-%s.%d%s",
m_name,
LOGFILE_SEPARATOR_STRING,
- this_machine()->hostname, start_time_ext, end_time_ext, version, LOGFILE_ROLLED_EXTENSION);
+ Machine::instance()->hostname, start_time_ext, end_time_ext, version, LOGFILE_ROLLED_EXTENSION);
version++;
}
Modified: trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc Wed Oct 5 19:14:07 2011
@@ -256,7 +256,7 @@ init_log_standalone(const char *pgm_name
1) does not call initialize_process_manager
2) initializes the diags with use_records = false
- 3) does not call create_this_machine
+ 3) does not call Machine::init()
4) assumes multiple copies of the application can run, so does not
do lock checking
-------------------------------------------------------------------------*/
Modified: trafficserver/traffic/trunk/proxy/sac.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/sac.cc?rev=1179389&r1=1179388&r2=1179389&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/sac.cc (original)
+++ trafficserver/traffic/trunk/proxy/sac.cc Wed Oct 5 19:14:07 2011
@@ -134,7 +134,7 @@ main(int argc, char *argv[])
eventProcessor.start(ink_number_of_processors());
ink_net_init(makeModuleVersion(1, 0, PRIVATE_MODULE_HEADER));
netProcessor.start();
- create_this_machine(NULL, 0);
+ Machine::init();
Log::init(Log::NO_REMOTE_MANAGEMENT | Log::STANDALONE_COLLATOR);