* Added tracing for binds and connects as well.
* Introduced the TCP_TRACING macro in tracing_config.h. * Enlarged the default trace size to something a tiny bit useful (but still acceptable for systems with little RAM). * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25235 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
// tracing buffer size (in bytes)
|
||||
#ifndef MAX_TRACE_SIZE
|
||||
# define MAX_TRACE_SIZE (1024 * 1024)
|
||||
# define MAX_TRACE_SIZE (20 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#define SIGNAL_TRACING 0
|
||||
#define SYSCALL_TRACING 0
|
||||
#define SYSCALL_TRACING_IGNORE_KTRACE_OUTPUT 1
|
||||
#define TCP_TRACING 0
|
||||
#define TEAM_TRACING 0
|
||||
#define USER_MALLOC_TRACING 0
|
||||
|
||||
|
||||
@@ -29,37 +29,96 @@
|
||||
# define TRACE(x)
|
||||
#endif
|
||||
|
||||
//#define ENDPOINT_TRACING
|
||||
#if TCP_TRACING
|
||||
# define ENDPOINT_TRACING
|
||||
#endif
|
||||
#ifdef ENDPOINT_TRACING
|
||||
namespace EndpointTracing {
|
||||
|
||||
class Bind : public AbstractTraceEntry {
|
||||
public:
|
||||
Bind(TCPEndpoint* endpoint, ConstSocketAddress& address, bool ephemeral)
|
||||
:
|
||||
fEndpoint(endpoint),
|
||||
fEphemeral(ephemeral)
|
||||
{
|
||||
address.AsString(fAddress, sizeof(fAddress), true);
|
||||
Initialized();
|
||||
}
|
||||
|
||||
Bind(TCPEndpoint* endpoint, SocketAddress& address, bool ephemeral)
|
||||
:
|
||||
fEndpoint(endpoint),
|
||||
fEphemeral(ephemeral)
|
||||
{
|
||||
address.AsString(fAddress, sizeof(fAddress), true);
|
||||
Initialized();
|
||||
}
|
||||
|
||||
virtual void AddDump(TraceOutput& out)
|
||||
{
|
||||
out.Print("tcp:e:%p bind%s address %s", fEndpoint,
|
||||
fEphemeral ? " ephemeral" : "", fAddress);
|
||||
}
|
||||
|
||||
protected:
|
||||
TCPEndpoint* fEndpoint;
|
||||
char fAddress[32];
|
||||
bool fEphemeral;
|
||||
};
|
||||
|
||||
class Connect : public AbstractTraceEntry {
|
||||
public:
|
||||
Connect(TCPEndpoint* endpoint)
|
||||
:
|
||||
fEndpoint(endpoint)
|
||||
{
|
||||
endpoint->LocalAddress().AsString(fLocal, sizeof(fLocal), true);
|
||||
endpoint->PeerAddress().AsString(fPeer, sizeof(fPeer), true);
|
||||
Initialized();
|
||||
}
|
||||
|
||||
virtual void AddDump(TraceOutput& out)
|
||||
{
|
||||
out.Print("tcp:e:%p connect local %s, peer %s", fEndpoint, fLocal,
|
||||
fPeer);
|
||||
}
|
||||
|
||||
protected:
|
||||
TCPEndpoint* fEndpoint;
|
||||
char fLocal[32];
|
||||
char fPeer[32];
|
||||
};
|
||||
|
||||
class Unbind : public AbstractTraceEntry {
|
||||
public:
|
||||
Unbind(TCPEndpoint* endpoint)
|
||||
:
|
||||
fEndpoint(endpoint)
|
||||
{
|
||||
fStackTrace = capture_tracing_stack_trace(10, 0, false);
|
||||
//fStackTrace = capture_tracing_stack_trace(10, 0, false);
|
||||
|
||||
endpoint->LocalAddress().AsString(fLocal, sizeof(fLocal), true);
|
||||
endpoint->PeerAddress().AsString(fPeer, sizeof(fPeer), true);
|
||||
Initialized();
|
||||
}
|
||||
|
||||
#if 0
|
||||
virtual void DumpStackTrace(TraceOutput& out)
|
||||
{
|
||||
out.PrintStackTrace(fStackTrace);
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void AddDump(TraceOutput& out)
|
||||
{
|
||||
out.Print("tcp:e:unbind: %p, local %s, peer %s"
|
||||
"%lu", fEndpoint, fLocal, fPeer);
|
||||
out.Print("tcp:e:%p unbind, local %s, peer %s", fEndpoint, fLocal,
|
||||
fPeer);
|
||||
}
|
||||
|
||||
protected:
|
||||
TCPEndpoint* fEndpoint;
|
||||
tracing_stack_trace* fStackTrace;
|
||||
//tracing_stack_trace* fStackTrace;
|
||||
char fLocal[32];
|
||||
char fPeer[32];
|
||||
};
|
||||
@@ -67,7 +126,6 @@ class Unbind : public AbstractTraceEntry {
|
||||
} // namespace EndpointTracing
|
||||
|
||||
# define T(x) new(std::nothrow) EndpointTracing::x
|
||||
|
||||
#else
|
||||
# define T(x)
|
||||
#endif // ENDPOINT_TRACING
|
||||
@@ -203,8 +261,8 @@ EndpointManager::_LookupConnection(const sockaddr *local, const sockaddr *peer)
|
||||
|
||||
|
||||
status_t
|
||||
EndpointManager::SetConnection(TCPEndpoint *endpoint,
|
||||
const sockaddr *_local, const sockaddr *peer, const sockaddr *interfaceLocal)
|
||||
EndpointManager::SetConnection(TCPEndpoint* endpoint, const sockaddr* _local,
|
||||
const sockaddr* peer, const sockaddr* interfaceLocal)
|
||||
{
|
||||
TRACE(("EndpointManager::SetConnection(%p)\n", endpoint));
|
||||
|
||||
@@ -224,6 +282,7 @@ EndpointManager::SetConnection(TCPEndpoint *endpoint,
|
||||
|
||||
endpoint->LocalAddress().SetTo(*local);
|
||||
endpoint->PeerAddress().SetTo(peer);
|
||||
T(Connect(endpoint));
|
||||
|
||||
fConnectionHash.Insert(endpoint);
|
||||
return B_OK;
|
||||
@@ -327,12 +386,12 @@ EndpointManager::BindChild(TCPEndpoint *endpoint)
|
||||
status_t
|
||||
EndpointManager::_BindToAddress(TCPEndpoint* endpoint, const sockaddr* _address)
|
||||
{
|
||||
TRACE(("EndpointManager::BindToAddress(%p)\n", endpoint));
|
||||
|
||||
ConstSocketAddress address(AddressModule(), _address);
|
||||
|
||||
uint16 port = address.Port();
|
||||
|
||||
TRACE(("EndpointManager::BindToAddress(%p)\n", endpoint));
|
||||
T(Bind(endpoint, address, false));
|
||||
|
||||
// TODO this check follows very typical UNIX semantics
|
||||
// and generally should be improved.
|
||||
if (ntohs(port) <= kLastReservedPort && geteuid() != 0)
|
||||
@@ -387,6 +446,7 @@ EndpointManager::_BindToEphemeral(TCPEndpoint *endpoint,
|
||||
TRACE((" EndpointManager::BindToEphemeral(%p) -> %s\n",
|
||||
endpoint, AddressString(Domain(), *newAddress,
|
||||
true).Data()));
|
||||
T(Bind(endpoint, newAddress, true));
|
||||
|
||||
return _Bind(endpoint, *newAddress);
|
||||
}
|
||||
@@ -440,8 +500,7 @@ EndpointManager::Unbind(TCPEndpoint *endpoint)
|
||||
|
||||
|
||||
status_t
|
||||
EndpointManager::ReplyWithReset(tcp_segment_header &segment,
|
||||
net_buffer *buffer)
|
||||
EndpointManager::ReplyWithReset(tcp_segment_header& segment, net_buffer* buffer)
|
||||
{
|
||||
TRACE(("TCP: Sending RST...\n"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user