Skip to content

Commit 7dfc5d8

Browse files
quic_trace: full client support
1 parent 6731262 commit 7dfc5d8

File tree

7 files changed

+250
-231
lines changed

7 files changed

+250
-231
lines changed

src/app/shared/fd_action.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ union fdctl_args {
9494
int dump; /* whether the user requested --dump */
9595
int dump_config; /* whether the user requested to dump the quic config */
9696
int dump_conns; /* whether the user requested to dump the quic connections */
97+
int trace_send; /* whether the user requested tracing send tile (1) or quic tile (0) */
9798
} quic_trace;
9899

99100
struct {

src/app/shared_dev/commands/quic_trace/fd_quic_trace.h

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "../../../shared/fd_config.h"
55
#include "../../../shared/fd_action.h"
6+
#include "../../../../disco/net/fd_net_tile.h"
67
#include "../../../../disco/quic/fd_quic_tile.h"
78
#include "../../../../waltz/quic/fd_quic_private.h"
89

@@ -24,15 +25,12 @@ typedef struct peer_conn_id_map peer_conn_id_map_t;
2425
#define MAP_LG_SLOT_CNT PEER_MAP_LG_SLOT_CNT
2526
#include "../../../../util/tmpl/fd_map.c"
2627

27-
/* fd_quic_trace_ctx is the relocated fd_quic_ctx_t of the target quic
28-
tile. fd_quic_trace_ctx_remote is the original fd_quic_ctx_t, but
29-
the pointer itself is in the local address space. */
30-
31-
extern fd_quic_ctx_t fd_quic_trace_ctx;
32-
extern fd_quic_ctx_t const * fd_quic_trace_ctx_remote;
33-
extern ulong fd_quic_trace_ctx_raddr;
34-
extern ulong volatile * fd_quic_trace_link_metrics;
35-
extern void const * fd_quic_trace_log_base;
28+
/* fd_quic_trace_ctx_remote is the original fd_quic_ctx_t, but the
29+
pointer itself is in the local address space. */
30+
extern void const * fd_quic_trace_tile_ctx_remote; /* local ptr to remote ctx */
31+
extern ulong fd_quic_trace_tile_ctx_raddr; /* remote addr of remote ctx */
32+
extern ulong volatile * fd_quic_trace_link_metrics;
33+
extern void const * fd_quic_trace_log_base;
3634
extern peer_conn_id_map_t _fd_quic_trace_peer_map[1UL<<PEER_MAP_LG_SLOT_CNT];
3735
extern peer_conn_id_map_t * fd_quic_trace_peer_map;
3836

@@ -45,8 +43,12 @@ struct fd_quic_trace_ctx {
4543
int dump; /* whether the user requested --dump */
4644
int dump_config; /* whether the user requested --dump-config */
4745
int dump_conns; /* whether the user requested --dump-conns */
48-
int net_out; /* whether to include tx (net-out) packets */
46+
int trace_send; /* whether the user requested tracing send tile (1) or quic tile (0) */
4947
ulong net_out_base; /* base address of net-out chunks in local addr space */
48+
49+
fd_quic_t * quic; /* local join to remote quic */
50+
fd_net_rx_bounds_t net_in_bounds[1]; /* bounds of net-in chunks in local addr space */
51+
uchar buffer[ FD_NET_MTU ];
5052
};
5153

5254
typedef struct fd_quic_trace_ctx fd_quic_trace_ctx_t;
@@ -61,29 +63,41 @@ struct fd_quic_trace_frame_ctx {
6163

6264
typedef struct fd_quic_trace_frame_ctx fd_quic_trace_frame_ctx_t;
6365

66+
#define translate_ptr( ptr ) __extension__({ \
67+
ulong rel = (ulong)(ptr) - fd_quic_trace_tile_ctx_raddr; \
68+
ulong laddr = (ulong)fd_quic_trace_tile_ctx_remote + rel; \
69+
(__typeof__(ptr))(laddr); \
70+
})
71+
72+
#define tile_member( ctx_ptr, field, is_send ) \
73+
*fd_ptr_if( is_send, &(((fd_send_tile_ctx_t*)(ctx_ptr))->field), &(((fd_quic_ctx_t*)(ctx_ptr))->field))
74+
75+
6476
FD_PROTOTYPES_BEGIN
6577

6678
void
6779
fd_quic_trace_frames( fd_quic_trace_frame_ctx_t * context,
68-
uchar const * data,
69-
ulong data_sz );
80+
uchar const * data,
81+
ulong data_sz );
7082

7183
void
72-
fd_quic_trace_rx_tile( fd_quic_trace_ctx_t * trace_ctx,
84+
fd_quic_trace_rx_tile( fd_quic_trace_ctx_t * trace_ctx,
7385
fd_frag_meta_t const * rx_mcache,
7486
fd_frag_meta_t const * tx_mcache );
7587

7688
void
77-
fd_quic_trace_log_tile( fd_frag_meta_t const * in_mcache );
89+
fd_quic_trace_log_tile( fd_quic_trace_ctx_t * ctx,
90+
fd_frag_meta_t const * in_mcache );
7891

79-
FD_PROTOTYPES_END
92+
static inline fd_quic_conn_t const *
93+
fd_quic_trace_conn_at_idx( fd_quic_t const * quic, ulong idx ) {
94+
fd_quic_state_t const * state = fd_quic_get_state_const( quic );
95+
ulong const local_conn_base = translate_ptr( state->conn_base );
96+
return (fd_quic_conn_t *)( local_conn_base + idx * state->conn_sz );
97+
}
8098

99+
FD_PROTOTYPES_END
81100

82-
#define translate_ptr( ptr ) __extension__({ \
83-
ulong rel = (ulong)(ptr) - fd_quic_trace_ctx_raddr; \
84-
ulong laddr = (ulong)fd_quic_trace_ctx_remote + rel; \
85-
(__typeof__(ptr))(laddr); \
86-
})
87101

88102
extern action_t fd_action_quic_trace;
89103

src/app/shared_dev/commands/quic_trace/fd_quic_trace_log_tile.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,25 @@ before_frag( void * _ctx FD_FN_UNUSED,
1313
}
1414

1515
static void
16-
during_frag( void * _ctx FD_PARAM_UNUSED,
17-
ulong in_idx FD_PARAM_UNUSED,
18-
ulong seq FD_PARAM_UNUSED,
19-
ulong sig FD_PARAM_UNUSED,
20-
ulong chunk,
21-
ulong sz,
22-
ulong ctl FD_PARAM_UNUSED ) {
23-
fd_quic_ctx_t * ctx = &fd_quic_trace_ctx;
16+
during_frag( fd_quic_trace_ctx_t * ctx,
17+
ulong in_idx FD_PARAM_UNUSED,
18+
ulong seq FD_PARAM_UNUSED,
19+
ulong sig FD_PARAM_UNUSED,
20+
ulong chunk,
21+
ulong sz,
22+
ulong ctl FD_PARAM_UNUSED ) {
2423
fd_memcpy( ctx->buffer, fd_chunk_to_laddr_const( fd_quic_trace_log_base, chunk ), sz );
2524
}
2625

2726
static void
28-
after_frag( void * _ctx FD_FN_UNUSED,
29-
ulong in_idx FD_FN_UNUSED,
30-
ulong seq FD_FN_UNUSED,
31-
ulong sig FD_FN_UNUSED,
32-
ulong sz FD_FN_UNUSED,
33-
ulong tsorig FD_FN_UNUSED,
34-
ulong tspub FD_FN_UNUSED,
35-
fd_stem_context_t * stem FD_FN_UNUSED ) {
36-
fd_quic_ctx_t * ctx = &fd_quic_trace_ctx;
27+
after_frag( fd_quic_trace_ctx_t * ctx,
28+
ulong in_idx FD_FN_UNUSED,
29+
ulong seq FD_FN_UNUSED,
30+
ulong sig FD_FN_UNUSED,
31+
ulong sz FD_FN_UNUSED,
32+
ulong tsorig FD_FN_UNUSED,
33+
ulong tspub FD_FN_UNUSED,
34+
fd_stem_context_t * stem FD_FN_UNUSED ) {
3735
fd_quic_log_error_t const * error = fd_type_pun_const( ctx->buffer );
3836
printf( "event=conn_close_quic conn_id=%016lx src_ip=%08x enc=%d pktnum=%8lu close_code=0x%lx loc=%.*s(%u)\n",
3937
error->hdr.conn_id,
@@ -49,16 +47,18 @@ after_frag( void * _ctx FD_FN_UNUSED,
4947

5048
#define STEM_BURST (1UL)
5149

52-
#define STEM_CALLBACK_CONTEXT_TYPE void
53-
#define STEM_CALLBACK_CONTEXT_ALIGN 1
50+
#define STEM_CALLBACK_CONTEXT_TYPE fd_quic_trace_ctx_t
51+
#define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_quic_trace_ctx_t)
52+
5453
#define STEM_CALLBACK_BEFORE_FRAG before_frag
5554
#define STEM_CALLBACK_DURING_FRAG during_frag
5655
#define STEM_CALLBACK_AFTER_FRAG after_frag
5756

5857
#include "../../../../disco/stem/fd_stem.c"
5958

6059
void
61-
fd_quic_trace_log_tile( fd_frag_meta_t const * in_mcache ) {
60+
fd_quic_trace_log_tile( fd_quic_trace_ctx_t * ctx,
61+
fd_frag_meta_t const * in_mcache ) {
6262
fd_frag_meta_t const * in_mcache_tbl[1] = { in_mcache };
6363

6464
uchar fseq_mem[ FD_FSEQ_FOOTPRINT ] __attribute__((aligned(FD_FSEQ_ALIGN)));
@@ -82,7 +82,7 @@ fd_quic_trace_log_tile( fd_frag_meta_t const * in_mcache ) {
8282
/* stem_lazy */ 0L,
8383
/* rng */ rng,
8484
/* scratch */ scratch,
85-
/* ctx */ NULL );
85+
/* ctx */ ctx );
8686

8787
fd_fseq_delete( fd_fseq_leave( fseq ) );
8888
}

0 commit comments

Comments
 (0)