Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,7 @@ AC_CONFIG_FILES([
proxy/http2/Makefile
proxy/logging/Makefile
proxy/shared/Makefile
proxy/l4r/Makefile
rc/Makefile
rc/trafficserver
rc/trafficserver.conf
Expand Down
2 changes: 2 additions & 0 deletions iocore/eventsystem/I_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class Thread
ProxyAllocator ioDataAllocator;
ProxyAllocator ioAllocator;
ProxyAllocator ioBlockAllocator;
ProxyAllocator l4rClientSessionAllocator;
ProxyAllocator l4rServerSessionAllocator;

public:
/** Start the underlying thread.
Expand Down
2 changes: 1 addition & 1 deletion proxy/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

include $(top_srcdir)/build/tidy.mk

SUBDIRS = hdrs shared http http2 logging config
SUBDIRS = hdrs shared http http2 logging config l4r

noinst_LIBRARIES = libproxy.a

Expand Down
6 changes: 5 additions & 1 deletion proxy/ProtocolProbeSessionAccept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ struct ProtocolProbeTrampoline : public Continuation, public ProtocolProbeSessio
goto done;
}

if (proto_is_http2(reader)) {
// Hardcode port 8000 to L4R
if (netvc->get_local_port() == 8000) {
key = PROTO_L4R;
}
else if (proto_is_http2(reader)) {
key = PROTO_HTTP2;
} else {
key = PROTO_HTTP;
Expand Down
1 change: 1 addition & 0 deletions proxy/ProtocolProbeSessionAccept.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct ProtocolProbeSessionAcceptEnums {
enum ProtoGroupKey {
PROTO_HTTP, ///< HTTP group (0.9-1.1)
PROTO_HTTP2, ///< HTTP 2 group
PROTO_L4R, ///< Layer 4 routing
N_PROTO_GROUPS ///< Size value.
};
};
Expand Down
26 changes: 15 additions & 11 deletions proxy/ProxyClientSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ ProxyError::str(char *buf, size_t buf_len)
return len;
}

ProxyClientSession::ProxyClientSession() : VConnection(nullptr)
ProxyClientSession::ProxyClientSession() : BasicProxyClientSession()
{
}

BasicProxyClientSession::BasicProxyClientSession() : VConnection(nullptr)
{
ink_zero(this->user_args);
}

void
ProxyClientSession::set_session_active()
BasicProxyClientSession::set_session_active()
{
if (!m_active) {
m_active = true;
Expand All @@ -60,7 +64,7 @@ ProxyClientSession::set_session_active()
}

void
ProxyClientSession::clear_session_active()
BasicProxyClientSession::clear_session_active()
{
if (m_active) {
m_active = false;
Expand All @@ -69,7 +73,7 @@ ProxyClientSession::clear_session_active()
}

int64_t
ProxyClientSession::next_connection_id()
BasicProxyClientSession::next_connection_id()
{
return ink_atomic_increment(&next_cs_id, 1);
}
Expand Down Expand Up @@ -102,7 +106,7 @@ is_valid_hook(TSHttpHookID hookid)
}

void
ProxyClientSession::free()
BasicProxyClientSession::free()
{
if (schedule_event) {
schedule_event->cancel();
Expand All @@ -113,7 +117,7 @@ ProxyClientSession::free()
}

int
ProxyClientSession::state_api_callout(int event, void *data)
BasicProxyClientSession::state_api_callout(int event, void *data)
{
Event *e = static_cast<Event *>(data);
if (e == schedule_event) {
Expand Down Expand Up @@ -144,7 +148,7 @@ ProxyClientSession::state_api_callout(int event, void *data)
plugin_mutex = hook->m_cont->mutex;
plugin_lock = MUTEX_TAKE_TRY_LOCK(hook->m_cont->mutex, mutex->thread_holding);
if (!plugin_lock) {
SET_HANDLER(&ProxyClientSession::state_api_callout);
SET_HANDLER(&BasicProxyClientSession::state_api_callout);
if (!schedule_event) { // Don't bother to schedule is there is already one out.
schedule_event = mutex->thread_holding->schedule_in(this, HRTIME_MSECONDS(10));
}
Expand Down Expand Up @@ -179,7 +183,7 @@ ProxyClientSession::state_api_callout(int event, void *data)
}

void
ProxyClientSession::do_api_callout(TSHttpHookID id)
BasicProxyClientSession::do_api_callout(TSHttpHookID id)
{
ink_assert(id == TS_HTTP_SSN_START_HOOK || id == TS_HTTP_SSN_CLOSE_HOOK);

Expand All @@ -188,19 +192,19 @@ ProxyClientSession::do_api_callout(TSHttpHookID id)
this->api_current = nullptr;

if (this->hooks_on && this->has_hooks()) {
SET_HANDLER(&ProxyClientSession::state_api_callout);
SET_HANDLER(&BasicProxyClientSession::state_api_callout);
this->state_api_callout(EVENT_NONE, nullptr);
} else {
this->handle_api_return(TS_EVENT_HTTP_CONTINUE);
}
}

void
ProxyClientSession::handle_api_return(int event)
BasicProxyClientSession::handle_api_return(int event)
{
TSHttpHookID hookid = this->api_hookid;

SET_HANDLER(&ProxyClientSession::state_api_callout);
SET_HANDLER(&BasicProxyClientSession::state_api_callout);

this->api_hookid = TS_HTTP_LAST_HOOK;
this->api_scope = API_HOOK_SCOPE_NONE;
Expand Down
65 changes: 46 additions & 19 deletions proxy/ProxyClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ struct ProxyError {
uint32_t code = 0;
};

class ProxyClientSession : public VConnection
class BasicProxyClientSession : public VConnection
{
public:
ProxyClientSession();
BasicProxyClientSession();

virtual void destroy() = 0;
virtual void free();
Expand Down Expand Up @@ -147,19 +147,6 @@ class ProxyClientSession : public VConnection
// Initiate an API hook invocation.
void do_api_callout(TSHttpHookID id);

// Override if your session protocol allows this.
virtual bool
is_transparent_passthrough_allowed() const
{
return false;
}

virtual bool
is_chunked_encoding_supported() const
{
return false;
}

// Override if your session protocol cares.
virtual void
set_half_close_flag(bool flag)
Expand Down Expand Up @@ -200,11 +187,11 @@ class ProxyClientSession : public VConnection
}

virtual void
attach_server_session(HttpServerSession *ssession, bool transaction_done = true)
attach_server_session(VConnection *ssession, bool transaction_done = true)
{
}

virtual HttpServerSession *
virtual VConnection *
get_server_session() const
{
return nullptr;
Expand Down Expand Up @@ -286,8 +273,8 @@ class ProxyClientSession : public VConnection
ink_hrtime ssn_last_txn_time = 0;

// noncopyable
ProxyClientSession(ProxyClientSession &) = delete;
ProxyClientSession &operator=(const ProxyClientSession &) = delete;
BasicProxyClientSession(BasicProxyClientSession &) = delete;
BasicProxyClientSession &operator=(const BasicProxyClientSession &) = delete;

protected:
// XXX Consider using a bitwise flags variable for the following flags, so
Expand Down Expand Up @@ -317,3 +304,43 @@ class ProxyClientSession : public VConnection
// aborts.
bool m_active = false;
};

class ProxyClientSession : public BasicProxyClientSession
{
public:
ProxyClientSession();

// Override if your session protocol allows this.
virtual bool
is_transparent_passthrough_allowed() const
{
return false;
}

virtual bool
is_chunked_encoding_supported() const
{
return false;
}

virtual void
attach_server_session(HttpServerSession *ssession, bool transaction_done = true)
{
}

virtual HttpServerSession *
get_server_session() const
{
return nullptr;
}

// noncopyable
ProxyClientSession(ProxyClientSession &) = delete;
ProxyClientSession &operator=(const ProxyClientSession &) = delete;

protected:
// XXX Consider using a bitwise flags variable for the following flags, so
// that we can make the best use of internal alignment padding.

private:
};
Loading