Skip to content

Commit f361a55

Browse files
committed
gossip2, snaprd: plumbing for gossip2 to snaprd tile contact info updates
1 parent dd70fa6 commit f361a55

File tree

3 files changed

+176
-69
lines changed

3 files changed

+176
-69
lines changed

src/discof/restore/fd_snaprd_tile.c

Lines changed: 171 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "../../disco/topo/fd_topo.h"
77
#include "../../disco/metrics/fd_metrics.h"
8+
#include "../../flamenco/gossip/fd_gossip_types.h"
89

910
#include <errno.h>
1011
#include <fcntl.h>
@@ -39,6 +40,10 @@
3940

4041
#define SNAPRD_FILE_BUF_SZ (1024UL*1024UL) /* 1 MiB */
4142

43+
#define IN_KIND_SNAPCTL (0)
44+
#define IN_KIND_GOSSIP (1)
45+
#define MAX_IN_LINKS (3)
46+
4247
struct fd_snaprd_tile {
4348
fd_ssping_t * ssping;
4449
fd_sshttp_t * sshttp;
@@ -64,6 +69,15 @@ struct fd_snaprd_tile {
6469
int incremental_snapshot_fd;
6570
} local_out;
6671

72+
struct {
73+
fd_wksp_t * mem;
74+
ulong chunk0;
75+
ulong wmark;
76+
ulong mtu;
77+
} gossip_in;
78+
79+
uchar in_kind[ MAX_IN_LINKS ];
80+
6781
struct {
6882
ulong full_snapshot_slot;
6983
int full_snapshot_fd;
@@ -98,6 +112,11 @@ struct fd_snaprd_tile {
98112
} incremental;
99113
} metrics;
100114

115+
struct {
116+
fd_ip4_port_t * ci_table;
117+
fd_gossip_update_message_t tmp_upd_buf;
118+
} gossip;
119+
101120
struct {
102121
fd_wksp_t * wksp;
103122
ulong chunk0;
@@ -121,6 +140,7 @@ scratch_footprint( fd_topo_tile_t const * tile ) {
121140
l = FD_LAYOUT_APPEND( l, alignof(fd_snaprd_tile_t), sizeof(fd_snaprd_tile_t) );
122141
l = FD_LAYOUT_APPEND( l, fd_sshttp_align(), fd_sshttp_footprint() );
123142
l = FD_LAYOUT_APPEND( l, fd_ssping_align(), fd_ssping_footprint( 65536UL ) );
143+
l = FD_LAYOUT_APPEND( l, alignof(fd_ip4_port_t), sizeof(fd_ip4_port_t)*FD_CONTACT_INFO_TABLE_SIZE );
124144
return FD_LAYOUT_FINI( l, alignof(fd_snaprd_tile_t) );
125145
}
126146

@@ -204,7 +224,7 @@ read_http_data( fd_snaprd_tile_t * ctx,
204224
case FD_SSHTTP_ADVANCE_AGAIN: break;
205225
case FD_SSHTTP_ADVANCE_ERROR: {
206226
FD_LOG_NOTICE(( "error downloading snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2",
207-
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), ctx->addr.port ));
227+
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), fd_ushort_bswap( ctx->addr.port ) ));
208228
fd_ssping_invalidate( ctx->ssping, ctx->addr, now );
209229
fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_RESET_FULL, 0UL, 0UL, 0UL, 0UL, 0UL );
210230
ctx->state = FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET;
@@ -378,7 +398,7 @@ after_credit( fd_snaprd_tile_t * ctx,
378398
FD_LOG_NOTICE(( "loading full snapshot from local file `%s`", ctx->local_in.full_snapshot_path ));
379399
ctx->state = FD_SNAPRD_STATE_READING_FULL_FILE;
380400
} else {
381-
FD_LOG_NOTICE(( "downloading full snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2", FD_IP4_ADDR_FMT_ARGS( best.addr ), best.port ));
401+
FD_LOG_NOTICE(( "downloading full snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2", FD_IP4_ADDR_FMT_ARGS( best.addr ), fd_ushort_bswap( best.port ) ));
382402
ctx->addr = best;
383403
ctx->state = FD_SNAPRD_STATE_READING_FULL_HTTP;
384404
fd_sshttp_init( ctx->sshttp, best, "/snapshot.tar.bz2", 17UL, now );
@@ -445,7 +465,7 @@ after_credit( fd_snaprd_tile_t * ctx,
445465
break;
446466
}
447467

448-
FD_LOG_NOTICE(( "downloading incremental snapshot from http://" FD_IP4_ADDR_FMT ":%hu/incremental-snapshot.tar.bz2", FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), ctx->addr.port ));
468+
FD_LOG_NOTICE(( "downloading incremental snapshot from http://" FD_IP4_ADDR_FMT ":%hu/incremental-snapshot.tar.bz2", FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), fd_ushort_bswap(ctx->addr.port) ));
449469
fd_sshttp_init( ctx->sshttp, ctx->addr, "/incremental-snapshot.tar.bz2", 29UL, fd_log_wallclock() );
450470
ctx->state = FD_SNAPRD_STATE_READING_INCREMENTAL_HTTP;
451471
break;
@@ -474,6 +494,37 @@ after_credit( fd_snaprd_tile_t * ctx,
474494
}
475495
}
476496

497+
static int
498+
before_frag( fd_snaprd_tile_t * ctx FD_PARAM_UNUSED,
499+
ulong in_idx,
500+
ulong seq FD_PARAM_UNUSED,
501+
ulong sig ) {
502+
if( ctx->in_kind[ in_idx ]==IN_KIND_GOSSIP ) {
503+
return !( sig==FD_GOSSIP_UPDATE_TAG_CONTACT_INFO ||
504+
sig==FD_GOSSIP_UPDATE_TAG_CONTACT_INFO_REMOVE ||
505+
sig==FD_GOSSIP_UPDATE_TAG_SNAPSHOT_HASHES );
506+
}
507+
return 0;
508+
}
509+
510+
static void
511+
during_frag( fd_snaprd_tile_t * ctx,
512+
ulong in_idx,
513+
ulong seq FD_PARAM_UNUSED,
514+
ulong sig FD_PARAM_UNUSED,
515+
ulong chunk,
516+
ulong sz,
517+
ulong ctl FD_PARAM_UNUSED) {
518+
if( ctx->in_kind[ in_idx ]!=IN_KIND_GOSSIP ) return;
519+
520+
if( FD_UNLIKELY( chunk<ctx->gossip_in.chunk0 ||
521+
chunk>ctx->gossip_in.wmark ||
522+
sz>sizeof(fd_gossip_update_message_t) ) ) {
523+
FD_LOG_ERR(( "snaprd: unexpected chunk %lu", chunk ));
524+
}
525+
fd_memcpy( &ctx->gossip.tmp_upd_buf, fd_chunk_to_laddr( ctx->gossip_in.mem, chunk ), sz );
526+
}
527+
477528
static void
478529
after_frag( fd_snaprd_tile_t * ctx,
479530
ulong in_idx,
@@ -489,50 +540,80 @@ after_frag( fd_snaprd_tile_t * ctx,
489540
(void)tspub;
490541
(void)sz;
491542

492-
FD_TEST( sig==FD_SNAPSHOT_MSG_CTRL_ACK || sig==FD_SNAPSHOT_MSG_CTRL_MALFORMED );
493-
494-
if( FD_LIKELY( sig==FD_SNAPSHOT_MSG_CTRL_ACK ) ) ctx->ack_cnt++;
495-
else {
496-
FD_TEST( ctx->state!=FD_SNAPRD_STATE_SHUTDOWN &&
497-
ctx->state!=FD_SNAPRD_STATE_COLLECTING_PEERS &&
498-
ctx->state!=FD_SNAPRD_STATE_WAITING_FOR_PEERS );
499-
500-
switch( ctx->state) {
501-
case FD_SNAPRD_STATE_READING_FULL_FILE:
502-
case FD_SNAPRD_STATE_FLUSHING_FULL_FILE:
503-
case FD_SNAPRD_STATE_FLUSHING_FULL_FILE_RESET:
504-
FD_LOG_ERR(( "error reading snapshot from local file `%s`", ctx->local_in.full_snapshot_path ));
505-
case FD_SNAPRD_STATE_READING_INCREMENTAL_FILE:
506-
case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_FILE:
507-
FD_LOG_ERR(( "error reading snapshot from local file `%s`", ctx->local_in.incremental_snapshot_path ));
508-
case FD_SNAPRD_STATE_READING_FULL_HTTP:
509-
case FD_SNAPRD_STATE_READING_INCREMENTAL_HTTP:
510-
FD_LOG_NOTICE(( "error downloading snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2",
511-
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), ctx->addr.port ));
512-
fd_sshttp_cancel( ctx->sshttp );
513-
fd_ssping_invalidate( ctx->ssping, ctx->addr, fd_log_wallclock() );
514-
fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_RESET_FULL, 0UL, 0UL, 0UL, 0UL, 0UL );
515-
ctx->state = FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET;
516-
break;
517-
case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP:
518-
case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP:
519-
FD_LOG_NOTICE(( "error downloading snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2",
520-
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), ctx->addr.port ));
521-
fd_sshttp_cancel( ctx->sshttp );
522-
fd_ssping_invalidate( ctx->ssping, ctx->addr, fd_log_wallclock() );
523-
/* We would like to transition to FULL_HTTP_RESET, but we can't
524-
do it just yet, because we have already sent a DONE control
525-
fragment, and need to wait for acknowledges to come back
526-
first, to ensure there's only one control message outstanding
527-
at a time. */
528-
ctx->malformed = 1;
543+
if( FD_UNLIKELY( ctx->in_kind[ in_idx ]==IN_KIND_GOSSIP ) ) {
544+
fd_gossip_update_message_t * msg = &ctx->gossip.tmp_upd_buf;
545+
switch( msg->tag ) {
546+
case FD_GOSSIP_UPDATE_TAG_CONTACT_INFO: {
547+
fd_ip4_port_t cur_addr = ctx->gossip.ci_table[ msg->contact_info.idx ];
548+
fd_ip4_port_t new_addr = msg->contact_info.contact_info->sockets[ FD_CONTACT_INFO_SOCKET_RPC ];
549+
if( FD_UNLIKELY( cur_addr.l!=new_addr.l ) ) {
550+
if( FD_LIKELY( !!cur_addr.l ) ) fd_ssping_remove( ctx->ssping, cur_addr );
551+
if( FD_LIKELY( !!new_addr.l ) ) {
552+
FD_LOG_INFO(( "adding contact info for peer "FD_IP4_ADDR_FMT ":%hu ",
553+
FD_IP4_ADDR_FMT_ARGS( new_addr.addr ), fd_ushort_bswap( new_addr.port ) ));
554+
fd_ssping_add( ctx->ssping, new_addr );
555+
}
556+
}
557+
ctx->gossip.ci_table[ msg->contact_info.idx ] = new_addr;
558+
}
529559
break;
530-
case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET:
560+
case FD_GOSSIP_UPDATE_TAG_CONTACT_INFO_REMOVE: {
561+
fd_ip4_port_t addr = ctx->gossip.ci_table[ msg->contact_info_remove.idx ];
562+
if( FD_LIKELY( !!addr.l ) ) fd_ssping_remove( ctx->ssping, addr );
563+
ctx->gossip.ci_table[ msg->contact_info_remove.idx ].l = 0UL;
564+
}
531565
break;
532-
default:
533-
FD_LOG_ERR(( "unexpected state %d", ctx->state ));
566+
case FD_GOSSIP_UPDATE_TAG_SNAPSHOT_HASHES:
567+
/* TODO */
534568
break;
535569
}
570+
571+
} else {
572+
FD_TEST( sig==FD_SNAPSHOT_MSG_CTRL_ACK || sig==FD_SNAPSHOT_MSG_CTRL_MALFORMED );
573+
574+
if( FD_LIKELY( sig==FD_SNAPSHOT_MSG_CTRL_ACK ) ) ctx->ack_cnt++;
575+
else {
576+
FD_TEST( ctx->state!=FD_SNAPRD_STATE_SHUTDOWN &&
577+
ctx->state!=FD_SNAPRD_STATE_COLLECTING_PEERS &&
578+
ctx->state!=FD_SNAPRD_STATE_WAITING_FOR_PEERS );
579+
580+
switch( ctx->state) {
581+
case FD_SNAPRD_STATE_READING_FULL_FILE:
582+
case FD_SNAPRD_STATE_FLUSHING_FULL_FILE:
583+
case FD_SNAPRD_STATE_FLUSHING_FULL_FILE_RESET:
584+
FD_LOG_ERR(( "error reading snapshot from local file `%s`", ctx->local_in.full_snapshot_path ));
585+
case FD_SNAPRD_STATE_READING_INCREMENTAL_FILE:
586+
case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_FILE:
587+
FD_LOG_ERR(( "error reading snapshot from local file `%s`", ctx->local_in.incremental_snapshot_path ));
588+
case FD_SNAPRD_STATE_READING_FULL_HTTP:
589+
case FD_SNAPRD_STATE_READING_INCREMENTAL_HTTP:
590+
FD_LOG_NOTICE(( "error downloading snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2",
591+
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), fd_ushort_bswap( ctx->addr.port ) ));
592+
fd_sshttp_cancel( ctx->sshttp );
593+
fd_ssping_invalidate( ctx->ssping, ctx->addr, fd_log_wallclock() );
594+
fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_RESET_FULL, 0UL, 0UL, 0UL, 0UL, 0UL );
595+
ctx->state = FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET;
596+
break;
597+
case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP:
598+
case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP:
599+
FD_LOG_NOTICE(( "error downloading snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2",
600+
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), fd_ushort_bswap( ctx->addr.port ) ));
601+
fd_sshttp_cancel( ctx->sshttp );
602+
fd_ssping_invalidate( ctx->ssping, ctx->addr, fd_log_wallclock() );
603+
/* We would like to transition to FULL_HTTP_RESET, but we can't
604+
do it just yet, because we have already sent a DONE control
605+
fragment, and need to wait for acknowledges to come back
606+
first, to ensure there's only one control message outstanding
607+
at a time. */
608+
ctx->malformed = 1;
609+
break;
610+
case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET:
611+
break;
612+
default:
613+
FD_LOG_ERR(( "unexpected state %d", ctx->state ));
614+
break;
615+
}
616+
}
536617
}
537618
}
538619

@@ -619,9 +700,10 @@ unprivileged_init( fd_topo_t * topo,
619700
void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
620701

621702
FD_SCRATCH_ALLOC_INIT( l, scratch );
622-
fd_snaprd_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snaprd_tile_t), sizeof(fd_snaprd_tile_t) );
623-
void * _sshttp = FD_SCRATCH_ALLOC_APPEND( l, fd_sshttp_align(), fd_sshttp_footprint() );
624-
void * _ssping = FD_SCRATCH_ALLOC_APPEND( l, fd_ssping_align(), fd_ssping_footprint( 65536UL ) );
703+
fd_snaprd_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snaprd_tile_t), sizeof(fd_snaprd_tile_t) );
704+
void * _sshttp = FD_SCRATCH_ALLOC_APPEND( l, fd_sshttp_align(), fd_sshttp_footprint() );
705+
void * _ssping = FD_SCRATCH_ALLOC_APPEND( l, fd_ssping_align(), fd_ssping_footprint( 65536UL ) );
706+
void * _ci_table = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_ip4_port_t), sizeof(fd_ip4_port_t)*FD_CONTACT_INFO_TABLE_SIZE );
625707

626708
ctx->ack_cnt = 0UL;
627709
ctx->malformed = 0;
@@ -646,27 +728,50 @@ unprivileged_init( fd_topo_t * topo,
646728
ctx->sshttp = fd_sshttp_join( fd_sshttp_new( _sshttp ) );
647729
FD_TEST( ctx->sshttp );
648730

649-
if( FD_LIKELY( !strcmp( tile->snaprd.cluster, "testnet" ) ) ) {
650-
fd_ip4_port_t initial_peers[ 2UL ] = {
651-
{ .addr = FD_IP4_ADDR( 35 , 214, 172, 227 ), .port = 8899 },
652-
{ .addr = FD_IP4_ADDR( 145, 40 , 95 , 69 ), .port = 8899 }, /* Solana testnet peer */
653-
};
654-
for( ulong i=0UL; i<2UL; i++ ) fd_ssping_add( ctx->ssping, initial_peers[ i ] );
655-
} else if( FD_LIKELY( !strcmp( tile->snaprd.cluster, "private" ) ) ) {
656-
fd_ip4_port_t initial_peers[ 1UL ] = {
657-
{ .addr = FD_IP4_ADDR( 147, 28, 185, 47 ), .port = 8899 } /* A private cluster peer */
658-
};
659-
for( ulong i=0UL; i<1UL; i++ ) fd_ssping_add( ctx->ssping, initial_peers[ i ] );
660-
} else if (FD_LIKELY( !strcmp( tile->snaprd.cluster, "mainnet" ) ) ) {
731+
ctx->gossip.ci_table = _ci_table;
732+
/* zero-out memory so that we can perform null checks in after_frag */
733+
fd_memset( ctx->gossip.ci_table, 0, sizeof(fd_ip4_port_t)*FD_CONTACT_INFO_TABLE_SIZE );
734+
735+
FD_TEST( tile->in_cnt<=MAX_IN_LINKS );
736+
uchar has_gossip_in = 0;
737+
for( ulong i=0UL; i<(tile->in_cnt); i++ ){
738+
fd_topo_link_t * in_link = &topo->links[ tile->in_link_id[ i ] ];
739+
if( 0==strcmp( in_link->name, "gossip_out" ) ) {
740+
has_gossip_in = 1;
741+
ctx->in_kind[ i ] = IN_KIND_GOSSIP;
742+
ctx->gossip_in.mem = topo->workspaces[ topo->objs[ in_link->dcache_obj_id ].wksp_id ].wksp;
743+
ctx->gossip_in.chunk0 = fd_dcache_compact_chunk0( ctx->gossip_in.mem, in_link->dcache );
744+
ctx->gossip_in.wmark = fd_dcache_compact_wmark ( ctx->gossip_in.mem, in_link->dcache, in_link->mtu );
745+
ctx->gossip_in.mtu = in_link->mtu;
746+
} else if( 0==strcmp( in_link->name, "snapdc_rd" ) ||
747+
0==strcmp( in_link->name, "snapin_rd" ) ) {
748+
ctx->in_kind[ i ] = IN_KIND_SNAPCTL;
749+
}
750+
}
751+
752+
if( FD_UNLIKELY( !has_gossip_in ) ) {
753+
FD_LOG_NOTICE(( "no gossip input link found, using initial peers for %s", tile->snaprd.cluster ));
754+
if( FD_LIKELY( !strcmp( tile->snaprd.cluster, "testnet" ) ) ) {
755+
fd_ip4_port_t initial_peers[ 2UL ] = {
756+
{ .addr = FD_IP4_ADDR( 35 , 214, 172, 227 ), .port = fd_ushort_bswap(8899) },
757+
{ .addr = FD_IP4_ADDR( 145, 40 , 95 , 69 ), .port = fd_ushort_bswap(8899) }, /* Solana testnet peer */
758+
};
759+
for( ulong i=0UL; i<2UL; i++ ) fd_ssping_add( ctx->ssping, initial_peers[ i ] );
760+
} else if( FD_LIKELY( !strcmp( tile->snaprd.cluster, "private" ) ) ) {
761+
fd_ip4_port_t initial_peers[ 1UL ] = {
762+
{ .addr = FD_IP4_ADDR( 147, 28, 185, 47 ), .port = fd_ushort_bswap( 8899 ) } /* A private cluster peer */
763+
};
764+
for( ulong i=0UL; i<1UL; i++ ) fd_ssping_add( ctx->ssping, initial_peers[ i ] );
765+
} else if (FD_LIKELY( !strcmp( tile->snaprd.cluster, "mainnet" ) ) ) {
661766
fd_ip4_port_t initial_peers[ 3UL ] = {
662-
{ .addr = FD_IP4_ADDR( 149, 255, 37 , 130 ), .port = 8899 },
663-
{ .addr = FD_IP4_ADDR( 34 , 1 , 238, 227 ), .port = 8899 },
664-
{ .addr = FD_IP4_ADDR( 34 , 1 , 139, 131 ), .port = 8899 }
767+
{ .addr = FD_IP4_ADDR( 149, 255, 37 , 130 ), .port = fd_ushort_bswap( 8899 ) },
768+
{ .addr = FD_IP4_ADDR( 34 , 1 , 238, 227 ), .port = fd_ushort_bswap( 8899 ) },
769+
{ .addr = FD_IP4_ADDR( 34 , 1 , 139, 131 ), .port = fd_ushort_bswap( 8899 ) }
665770
};
666771
for( ulong i=0UL; i<3UL; i++ ) fd_ssping_add( ctx->ssping, initial_peers[ i ] );
667-
}
668-
else {
669-
FD_LOG_ERR(( "unexpected cluster %s", tile->snaprd.cluster ));
772+
} else {
773+
FD_LOG_ERR(( "unexpected cluster %s", tile->snaprd.cluster ));
774+
}
670775
}
671776

672777
if( FD_UNLIKELY( tile->out_cnt!=1UL ) ) FD_LOG_ERR(( "tile `" NAME "` has %lu outs, expected 1", tile->out_cnt ));
@@ -687,6 +792,8 @@ unprivileged_init( fd_topo_t * topo,
687792
#define STEM_CALLBACK_SHOULD_SHUTDOWN should_shutdown
688793
#define STEM_CALLBACK_METRICS_WRITE metrics_write
689794
#define STEM_CALLBACK_AFTER_CREDIT after_credit
795+
#define STEM_CALLBACK_BEFORE_FRAG before_frag
796+
#define STEM_CALLBACK_DURING_FRAG during_frag
690797
#define STEM_CALLBACK_AFTER_FRAG after_frag
691798

692799
#include "../../disco/stem/fd_stem.c"

src/discof/restore/utils/fd_sshttp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fd_sshttp_init( fd_sshttp_t * http,
133133

134134
struct sockaddr_in addr_in = {
135135
.sin_family = AF_INET,
136-
.sin_port = fd_ushort_bswap( addr.port ),
136+
.sin_port = addr.port,
137137
.sin_addr = { .s_addr = addr.addr }
138138
};
139139

@@ -259,7 +259,7 @@ follow_redirect( fd_sshttp_t * http,
259259
}
260260

261261
FD_LOG_NOTICE(( "following redirect to http://" FD_IP4_ADDR_FMT ":%hu%.*s",
262-
FD_IP4_ADDR_FMT_ARGS( http->addr.addr ), http->addr.port,
262+
FD_IP4_ADDR_FMT_ARGS( http->addr.addr ), fd_ushort_bswap( http->addr.port ),
263263
(int)headers[ 0 ].value_len, headers[ 0 ].value ));
264264

265265
fd_sshttp_cancel( http );

src/discof/restore/utils/fd_ssping.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ poll_advance( fd_ssping_t * ssping,
375375
score_treap_ele_remove( ssping->score_treap, peer, ssping->pool );
376376
}
377377

378-
FD_LOG_INFO(( "pinged " FD_IP4_ADDR_FMT ":%hu in %lu ns", FD_IP4_ADDR_FMT_ARGS( peer->addr.addr ), peer->addr.port, peer->latency_nanos ));
378+
FD_LOG_INFO(( "pinged " FD_IP4_ADDR_FMT ":%hu in %lu ns", FD_IP4_ADDR_FMT_ARGS( peer->addr.addr ), fd_ushort_bswap(peer->addr.port), peer->latency_nanos ));
379379
peer->state = PEER_STATE_VALID;
380380
peer->deadline_nanos = now + PEER_DEADLINE_NANOS_VALID;
381381

@@ -395,7 +395,7 @@ peer_connect( fd_ssping_t * ssping,
395395

396396
struct sockaddr_in addr = {
397397
.sin_family = AF_INET,
398-
.sin_port = fd_ushort_bswap( peer->addr.port ),
398+
.sin_port = peer->addr.port,
399399
.sin_addr = { .s_addr = peer->addr.addr }
400400
};
401401

@@ -422,7 +422,7 @@ fd_ssping_advance( fd_ssping_t * ssping,
422422
while( !deadline_list_is_empty( ssping->unpinged, ssping->pool ) ) {
423423
fd_ssping_peer_t * peer = deadline_list_ele_pop_head( ssping->unpinged, ssping->pool );
424424

425-
FD_LOG_INFO(( "pinging " FD_IP4_ADDR_FMT ":%hu", FD_IP4_ADDR_FMT_ARGS( peer->addr.addr ), peer->addr.port ));
425+
FD_LOG_INFO(( "pinging " FD_IP4_ADDR_FMT ":%hu", FD_IP4_ADDR_FMT_ARGS( peer->addr.addr ), fd_ushort_bswap( peer->addr.port ) ));
426426
int result = peer_connect( ssping, peer );
427427
if( FD_UNLIKELY( -1==result ) ) {
428428
peer->state = PEER_STATE_INVALID;

0 commit comments

Comments
 (0)