Skip to content

Commit

Permalink
tracing: update log_p2p_traffic.bt bpftrace script
Browse files Browse the repository at this point in the history
bpftrace doesn't have any functions as of writing this commit, so we
have to do a ternary lookup hack that introduces a bit of code
duplication.

Alternatively you could try to use a bpf map, but this uses a lot of
stack space in bpftrace which makes it harder to run this script
effectively.

Signed-off-by: William Casarin <jb55@jb55.com>
  • Loading branch information
jb55 committed Dec 18, 2021
1 parent 99dddf5 commit e049b7d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contrib/tracing/log_p2p_traffic.bt
Expand Up @@ -2,14 +2,15 @@

BEGIN
{
printf("Logging P2P traffic\n")
printf("Logging P2P traffic\n");
}

usdt:./src/bitcoind:net:inbound_message
{
$peer_id = (int64) arg0;
$peer_addr = str(arg1);
$peer_type = str(arg2);
$ct = (uint32)arg2;
$peer_type = ($ct == 0 ? "inbound":($ct == 1 ? "outbound-full-relay":($ct == 2 ? "manual":($ct == 3 ? "feeler":($ct == 4 ? "block-relay":($ct == 5 ? "addr-fetch":"unknown"))))));
$msg_type = str(arg3);
$msg_len = arg4;
printf("inbound '%s' msg from peer %d (%s, %s) with %d bytes\n", $msg_type, $peer_id, $peer_type, $peer_addr, $msg_len);
Expand All @@ -19,7 +20,8 @@ usdt:./src/bitcoind:net:outbound_message
{
$peer_id = (int64) arg0;
$peer_addr = str(arg1);
$peer_type = str(arg2);
$ct = (uint32)arg2;
$peer_type = ($ct == 0 ? "inbound":($ct == 1 ? "outbound-full-relay":($ct == 2 ? "manual":($ct == 3 ? "feeler":($ct == 4 ? "block-relay":($ct == 5 ? "addr-fetch":"unknown"))))));
$msg_type = str(arg3);
$msg_len = arg4;

Expand Down

0 comments on commit e049b7d

Please sign in to comment.