Skip to content

Commit

Permalink
Add fddev quic-trace command
Browse files Browse the repository at this point in the history
Adds a command to trace incoming QUIC STREAM frames to stdout.

Introduces scaffold to allow other processes to join fdctl quic tile
data structures.

- Add fd_quic_tile.h
- Add a magic number to fd_quic_ctx_t
- Rename tiles/fd_quic.c => tiles/fd_quic_tile.c to fix object name
  collision with waltz/fd_quic.c.
  • Loading branch information
riptl authored and ripatel-fd committed Nov 26, 2024
1 parent 3aa2a23 commit cfb24dd
Show file tree
Hide file tree
Showing 12 changed files with 656 additions and 103 deletions.
1 change: 1 addition & 0 deletions src/app/fdctl/fdctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ typedef struct fd_caps_ctx fd_caps_ctx_t;
typedef struct {
const char * name;
const char * description;
uchar is_diagnostic; /* 1 implies action should be allowed for prod debugging */

void (*args)( int * pargc, char *** pargv, args_t * args );
void (*perm)( args_t * args, fd_caps_ctx_t * caps, config_t * const config );
Expand Down
59 changes: 1 addition & 58 deletions src/app/fdctl/run/tiles/fd_quic_tile.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "fd_quic_tile.h"
#include "../../../../disco/metrics/fd_metrics.h"
#include "../../../../disco/stem/fd_stem.h"
#include "../../../../disco/topo/fd_topo.h"
Expand Down Expand Up @@ -26,64 +27,6 @@
(multiplexer). An arbitrary number of QUIC tiles can be run. Each
UDP flow must stick to one QUIC tile. */

typedef struct {
fd_tpu_reasm_t * reasm;

fd_stem_context_t * stem;

fd_quic_t * quic;
fd_aio_t quic_tx_aio[1];

# define ED25519_PRIV_KEY_SZ (32)
# define ED25519_PUB_KEY_SZ (32)
uchar tls_priv_key[ ED25519_PRIV_KEY_SZ ];
uchar tls_pub_key [ ED25519_PUB_KEY_SZ ];
fd_sha512_t sha512[1]; /* used for signing */

uchar buffer[ FD_NET_MTU ];

ulong round_robin_cnt;
ulong round_robin_id;

fd_wksp_t * in_mem;
ulong in_chunk0;
ulong in_wmark;

fd_frag_meta_t * net_out_mcache;
ulong * net_out_sync;
ulong net_out_depth;
ulong net_out_seq;

fd_wksp_t * net_out_mem;
ulong net_out_chunk0;
ulong net_out_wmark;
ulong net_out_chunk;

fd_wksp_t * verify_out_mem;

double ns_per_tick;
ulong last_tick;
ulong last_wall;

struct {
ulong txns_received_udp;
ulong txns_received_quic_fast;
ulong txns_received_quic_frag;
ulong frag_ok_cnt;
ulong frag_gap_cnt;
ulong frag_dup_cnt;
long reasm_active;
ulong reasm_overrun;
ulong reasm_abandoned;
ulong reasm_started;
ulong udp_pkt_too_small;
ulong udp_pkt_too_large;
ulong quic_pkt_too_small;
ulong quic_txn_too_small;
ulong quic_txn_too_large;
} metrics;
} fd_quic_ctx_t;

FD_FN_CONST static inline fd_quic_limits_t
quic_limits( fd_topo_tile_t const * tile ) {
fd_quic_limits_t limits = {
Expand Down
66 changes: 66 additions & 0 deletions src/app/fdctl/run/tiles/fd_quic_tile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#ifndef HEADER_fd_src_app_fdctl_run_tiles_fd_quic_tile_h
#define HEADER_fd_src_app_fdctl_run_tiles_fd_quic_tile_h

#include "../../../../disco/quic/fd_tpu.h"
#include "../../../../disco/stem/fd_stem.h"
#include "../../../../waltz/quic/fd_quic.h"

typedef struct {
fd_tpu_reasm_t * reasm;

fd_stem_context_t * stem;

fd_quic_t * quic;
fd_aio_t quic_tx_aio[1];

# define ED25519_PRIV_KEY_SZ (32)
# define ED25519_PUB_KEY_SZ (32)
uchar tls_priv_key[ ED25519_PRIV_KEY_SZ ];
uchar tls_pub_key [ ED25519_PUB_KEY_SZ ];
fd_sha512_t sha512[1]; /* used for signing */

uchar buffer[ FD_NET_MTU ];

ulong round_robin_cnt;
ulong round_robin_id;

fd_wksp_t * in_mem;
ulong in_chunk0;
ulong in_wmark;

fd_frag_meta_t * net_out_mcache;
ulong * net_out_sync;
ulong net_out_depth;
ulong net_out_seq;

fd_wksp_t * net_out_mem;
ulong net_out_chunk0;
ulong net_out_wmark;
ulong net_out_chunk;

fd_wksp_t * verify_out_mem;

double ns_per_tick;
ulong last_tick;
ulong last_wall;

struct {
ulong txns_received_udp;
ulong txns_received_quic_fast;
ulong txns_received_quic_frag;
ulong frag_ok_cnt;
ulong frag_gap_cnt;
ulong frag_dup_cnt;
long reasm_active;
ulong reasm_overrun;
ulong reasm_abandoned;
ulong reasm_started;
ulong udp_pkt_too_small;
ulong udp_pkt_too_large;
ulong quic_pkt_too_small;
ulong quic_txn_too_small;
ulong quic_txn_too_large;
} metrics;
} fd_quic_ctx_t;

#endif /* HEADER_fd_src_app_fdctl_run_tiles_fd_quic_tile_h */
9 changes: 9 additions & 0 deletions src/app/fddev/fddev.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,13 @@ void
flame_cmd_fn( args_t * args,
config_t * const config );

void
quic_trace_cmd_args( int * pargc,
char *** pargv,
args_t * args);

void
quic_trace_cmd_fn( args_t * args,
config_t * const config );

#endif /* HEADER_fd_src_app_fddev_fddev_h */
7 changes: 4 additions & 3 deletions src/app/fddev/main1.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ static action_t DEV_ACTIONS[] = {
{ .name = "txn", .args = txn_cmd_args, .fn = txn_cmd_fn, .perm = txn_cmd_perm },
{ .name = "bench", .args = bench_cmd_args, .fn = bench_cmd_fn, .perm = bench_cmd_perm },
{ .name = "load", .args = load_cmd_args, .fn = load_cmd_fn, .perm = load_cmd_perm },
{ .name = "dump", .args = dump_cmd_args, .fn = dump_cmd_fn, .perm = NULL },
{ .name = "flame", .args = flame_cmd_args, .fn = flame_cmd_fn, .perm = flame_cmd_perm },
{ .name = "dump", .args = dump_cmd_args, .fn = dump_cmd_fn, .perm = NULL, .is_diagnostic=1 },
{ .name = "flame", .args = flame_cmd_args, .fn = flame_cmd_fn, .perm = flame_cmd_perm, .is_diagnostic=1 },
{ .name = "quic-trace", .args = quic_trace_cmd_args, .fn = quic_trace_cmd_fn, .perm = NULL, .is_diagnostic=1 },
};

extern char fd_log_private_path[ 1024 ];
Expand Down Expand Up @@ -196,7 +197,7 @@ fddev_main( int argc,

if( FD_UNLIKELY( !action ) ) FD_LOG_ERR(( "unknown subcommand `%s`", action_name ));

int is_allowed_live = !strcmp( action->name, "flame" ) || !strcmp( action->name, "dump" );
int is_allowed_live = action->is_diagnostic==1;
if( FD_UNLIKELY( config.is_live_cluster && !is_allowed_live ) )
FD_LOG_ERR(( "The `fddev` command is for development and test environments but your "
"configuration targets a live cluster. Use `fdctl` if this is a "
Expand Down
5 changes: 5 additions & 0 deletions src/app/fddev/quic_trace/Local.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ifdef FD_HAS_SSE
$(call add-objs,fd_quic_trace_frame,fd_fddev)
$(call add-objs,fd_quic_trace_main,fd_fddev)
$(call add-objs,fd_quic_trace_rx_tile,fd_fddev)
endif
51 changes: 51 additions & 0 deletions src/app/fddev/quic_trace/fd_quic_trace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef HEADER_fd_src_app_fddev_quic_trace_fd_quic_trace_h
#define HEADER_fd_src_app_fddev_quic_trace_fd_quic_trace_h

#include "../../../disco/topo/fd_topo.h"
#include "../../fdctl/run/tiles/fd_quic_tile.h"

/* fd_quic_trace_ctx is the relocated fd_quic_ctx_t of the target quic
tile. fd_quic_trace_ctx_remote is the original fd_quic_ctx_t, but
the pointer itself is in the local address space. */

extern fd_quic_ctx_t fd_quic_trace_ctx;
extern fd_quic_ctx_t const * fd_quic_trace_ctx_remote;
extern ulong fd_quic_trace_ctx_raddr;
extern ulong volatile * fd_quic_trace_link_metrics;

/* fd_quic_trace_target_fseq are the fseq counters published by the
target quic tile */

extern ulong ** fd_quic_trace_target_fseq;

/* fd_tile_quic_trace_rx is the tile in fd_quic_trace_tx_tile.c */

extern fd_topo_run_tile_t fd_tile_quic_trace_rx;


struct fd_quic_trace_frame_ctx {
ulong conn_id;
uint src_ip;
ushort src_port;
ulong pkt_num;
};

typedef struct fd_quic_trace_frame_ctx fd_quic_trace_frame_ctx_t;

FD_PROTOTYPES_BEGIN

void
fd_quic_trace_frames( fd_quic_trace_frame_ctx_t * context,
uchar const * data,
ulong data_sz );

FD_PROTOTYPES_END


#define translate_ptr( ptr ) __extension__({ \
ulong rel = (ulong)(ptr) - fd_quic_trace_ctx_raddr; \
ulong laddr = (ulong)fd_quic_trace_ctx_remote + rel; \
(__typeof__(ptr))(laddr); \
})

#endif /* HEADER_fd_src_app_fddev_quic_trace_fd_quic_trace_h */
Loading

0 comments on commit cfb24dd

Please sign in to comment.