* 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)
|
// tracing buffer size (in bytes)
|
||||||
#ifndef MAX_TRACE_SIZE
|
#ifndef MAX_TRACE_SIZE
|
||||||
# define MAX_TRACE_SIZE (1024 * 1024)
|
# define MAX_TRACE_SIZE (20 * 1024 * 1024)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#define SIGNAL_TRACING 0
|
#define SIGNAL_TRACING 0
|
||||||
#define SYSCALL_TRACING 0
|
#define SYSCALL_TRACING 0
|
||||||
#define SYSCALL_TRACING_IGNORE_KTRACE_OUTPUT 1
|
#define SYSCALL_TRACING_IGNORE_KTRACE_OUTPUT 1
|
||||||
|
#define TCP_TRACING 0
|
||||||
#define TEAM_TRACING 0
|
#define TEAM_TRACING 0
|
||||||
#define USER_MALLOC_TRACING 0
|
#define USER_MALLOC_TRACING 0
|
||||||
|
|
||||||
|
|||||||
@@ -29,37 +29,96 @@
|
|||||||
# define TRACE(x)
|
# define TRACE(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define ENDPOINT_TRACING
|
#if TCP_TRACING
|
||||||
|
# define ENDPOINT_TRACING
|
||||||
|
#endif
|
||||||
#ifdef ENDPOINT_TRACING
|
#ifdef ENDPOINT_TRACING
|
||||||
namespace EndpointTracing {
|
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 {
|
class Unbind : public AbstractTraceEntry {
|
||||||
public:
|
public:
|
||||||
Unbind(TCPEndpoint* endpoint)
|
Unbind(TCPEndpoint* endpoint)
|
||||||
:
|
:
|
||||||
fEndpoint(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->LocalAddress().AsString(fLocal, sizeof(fLocal), true);
|
||||||
endpoint->PeerAddress().AsString(fPeer, sizeof(fPeer), true);
|
endpoint->PeerAddress().AsString(fPeer, sizeof(fPeer), true);
|
||||||
Initialized();
|
Initialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
virtual void DumpStackTrace(TraceOutput& out)
|
virtual void DumpStackTrace(TraceOutput& out)
|
||||||
{
|
{
|
||||||
out.PrintStackTrace(fStackTrace);
|
out.PrintStackTrace(fStackTrace);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void AddDump(TraceOutput& out)
|
virtual void AddDump(TraceOutput& out)
|
||||||
{
|
{
|
||||||
out.Print("tcp:e:unbind: %p, local %s, peer %s"
|
out.Print("tcp:e:%p unbind, local %s, peer %s", fEndpoint, fLocal,
|
||||||
"%lu", fEndpoint, fLocal, fPeer);
|
fPeer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TCPEndpoint* fEndpoint;
|
TCPEndpoint* fEndpoint;
|
||||||
tracing_stack_trace* fStackTrace;
|
//tracing_stack_trace* fStackTrace;
|
||||||
char fLocal[32];
|
char fLocal[32];
|
||||||
char fPeer[32];
|
char fPeer[32];
|
||||||
};
|
};
|
||||||
@@ -67,7 +126,6 @@ class Unbind : public AbstractTraceEntry {
|
|||||||
} // namespace EndpointTracing
|
} // namespace EndpointTracing
|
||||||
|
|
||||||
# define T(x) new(std::nothrow) EndpointTracing::x
|
# define T(x) new(std::nothrow) EndpointTracing::x
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define T(x)
|
# define T(x)
|
||||||
#endif // ENDPOINT_TRACING
|
#endif // ENDPOINT_TRACING
|
||||||
@@ -203,8 +261,8 @@ EndpointManager::_LookupConnection(const sockaddr *local, const sockaddr *peer)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
EndpointManager::SetConnection(TCPEndpoint *endpoint,
|
EndpointManager::SetConnection(TCPEndpoint* endpoint, const sockaddr* _local,
|
||||||
const sockaddr *_local, const sockaddr *peer, const sockaddr *interfaceLocal)
|
const sockaddr* peer, const sockaddr* interfaceLocal)
|
||||||
{
|
{
|
||||||
TRACE(("EndpointManager::SetConnection(%p)\n", endpoint));
|
TRACE(("EndpointManager::SetConnection(%p)\n", endpoint));
|
||||||
|
|
||||||
@@ -224,6 +282,7 @@ EndpointManager::SetConnection(TCPEndpoint *endpoint,
|
|||||||
|
|
||||||
endpoint->LocalAddress().SetTo(*local);
|
endpoint->LocalAddress().SetTo(*local);
|
||||||
endpoint->PeerAddress().SetTo(peer);
|
endpoint->PeerAddress().SetTo(peer);
|
||||||
|
T(Connect(endpoint));
|
||||||
|
|
||||||
fConnectionHash.Insert(endpoint);
|
fConnectionHash.Insert(endpoint);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -327,12 +386,12 @@ EndpointManager::BindChild(TCPEndpoint *endpoint)
|
|||||||
status_t
|
status_t
|
||||||
EndpointManager::_BindToAddress(TCPEndpoint* endpoint, const sockaddr* _address)
|
EndpointManager::_BindToAddress(TCPEndpoint* endpoint, const sockaddr* _address)
|
||||||
{
|
{
|
||||||
TRACE(("EndpointManager::BindToAddress(%p)\n", endpoint));
|
|
||||||
|
|
||||||
ConstSocketAddress address(AddressModule(), _address);
|
ConstSocketAddress address(AddressModule(), _address);
|
||||||
|
|
||||||
uint16 port = address.Port();
|
uint16 port = address.Port();
|
||||||
|
|
||||||
|
TRACE(("EndpointManager::BindToAddress(%p)\n", endpoint));
|
||||||
|
T(Bind(endpoint, address, false));
|
||||||
|
|
||||||
// TODO this check follows very typical UNIX semantics
|
// TODO this check follows very typical UNIX semantics
|
||||||
// and generally should be improved.
|
// and generally should be improved.
|
||||||
if (ntohs(port) <= kLastReservedPort && geteuid() != 0)
|
if (ntohs(port) <= kLastReservedPort && geteuid() != 0)
|
||||||
@@ -387,6 +446,7 @@ EndpointManager::_BindToEphemeral(TCPEndpoint *endpoint,
|
|||||||
TRACE((" EndpointManager::BindToEphemeral(%p) -> %s\n",
|
TRACE((" EndpointManager::BindToEphemeral(%p) -> %s\n",
|
||||||
endpoint, AddressString(Domain(), *newAddress,
|
endpoint, AddressString(Domain(), *newAddress,
|
||||||
true).Data()));
|
true).Data()));
|
||||||
|
T(Bind(endpoint, newAddress, true));
|
||||||
|
|
||||||
return _Bind(endpoint, *newAddress);
|
return _Bind(endpoint, *newAddress);
|
||||||
}
|
}
|
||||||
@@ -440,8 +500,7 @@ EndpointManager::Unbind(TCPEndpoint *endpoint)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
EndpointManager::ReplyWithReset(tcp_segment_header &segment,
|
EndpointManager::ReplyWithReset(tcp_segment_header& segment, net_buffer* buffer)
|
||||||
net_buffer *buffer)
|
|
||||||
{
|
{
|
||||||
TRACE(("TCP: Sending RST...\n"));
|
TRACE(("TCP: Sending RST...\n"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user