Skip to content

Commit 4d7286a

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

File tree

3 files changed

+175
-69
lines changed

3 files changed

+175
-69
lines changed

src/discof/restore/fd_snaprd_tile.c

Lines changed: 170 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,79 @@ 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+
}
531564
break;
532-
default:
533-
FD_LOG_ERR(( "unexpected state %d", ctx->state ));
565+
case FD_GOSSIP_UPDATE_TAG_SNAPSHOT_HASHES:
566+
/* TODO */
534567
break;
535568
}
569+
570+
} else {
571+
FD_TEST( sig==FD_SNAPSHOT_MSG_CTRL_ACK || sig==FD_SNAPSHOT_MSG_CTRL_MALFORMED );
572+
573+
if( FD_LIKELY( sig==FD_SNAPSHOT_MSG_CTRL_ACK ) ) ctx->ack_cnt++;
574+
else {
575+
FD_TEST( ctx->state!=FD_SNAPRD_STATE_SHUTDOWN &&
576+
ctx->state!=FD_SNAPRD_STATE_COLLECTING_PEERS &&
577+
ctx->state!=FD_SNAPRD_STATE_WAITING_FOR_PEERS );
578+
579+
switch( ctx->state) {
580+
case FD_SNAPRD_STATE_READING_FULL_FILE:
581+
case FD_SNAPRD_STATE_FLUSHING_FULL_FILE:
582+
case FD_SNAPRD_STATE_FLUSHING_FULL_FILE_RESET:
583+
FD_LOG_ERR(( "error reading snapshot from local file `%s`", ctx->local_in.full_snapshot_path ));
584+
case FD_SNAPRD_STATE_READING_INCREMENTAL_FILE:
585+
case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_FILE:
586+
FD_LOG_ERR(( "error reading snapshot from local file `%s`", ctx->local_in.incremental_snapshot_path ));
587+
case FD_SNAPRD_STATE_READING_FULL_HTTP:
588+
case FD_SNAPRD_STATE_READING_INCREMENTAL_HTTP:
589+
FD_LOG_NOTICE(( "error downloading snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2",
590+
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), fd_ushort_bswap( ctx->addr.port ) ));
591+
fd_sshttp_cancel( ctx->sshttp );
592+
fd_ssping_invalidate( ctx->ssping, ctx->addr, fd_log_wallclock() );
593+
fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_RESET_FULL, 0UL, 0UL, 0UL, 0UL, 0UL );
594+
ctx->state = FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET;
595+
break;
596+
case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP:
597+
case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP:
598+
FD_LOG_NOTICE(( "error downloading snapshot from http://" FD_IP4_ADDR_FMT ":%hu/snapshot.tar.bz2",
599+
FD_IP4_ADDR_FMT_ARGS( ctx->addr.addr ), fd_ushort_bswap( ctx->addr.port ) ));
600+
fd_sshttp_cancel( ctx->sshttp );
601+
fd_ssping_invalidate( ctx->ssping, ctx->addr, fd_log_wallclock() );
602+
/* We would like to transition to FULL_HTTP_RESET, but we can't
603+
do it just yet, because we have already sent a DONE control
604+
fragment, and need to wait for acknowledges to come back
605+
first, to ensure there's only one control message outstanding
606+
at a time. */
607+
ctx->malformed = 1;
608+
break;
609+
case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET:
610+
break;
611+
default:
612+
FD_LOG_ERR(( "unexpected state %d", ctx->state ));
613+
break;
614+
}
615+
}
536616
}
537617
}
538618

@@ -619,9 +699,10 @@ unprivileged_init( fd_topo_t * topo,
619699
void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
620700

621701
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 ) );
702+
fd_snaprd_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snaprd_tile_t), sizeof(fd_snaprd_tile_t) );
703+
void * _sshttp = FD_SCRATCH_ALLOC_APPEND( l, fd_sshttp_align(), fd_sshttp_footprint() );
704+
void * _ssping = FD_SCRATCH_ALLOC_APPEND( l, fd_ssping_align(), fd_ssping_footprint( 65536UL ) );
705+
void * _ci_table = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_ip4_port_t), sizeof(fd_ip4_port_t)*FD_CONTACT_INFO_TABLE_SIZE );
625706

626707
ctx->ack_cnt = 0UL;
627708
ctx->malformed = 0;
@@ -646,27 +727,50 @@ unprivileged_init( fd_topo_t * topo,
646727
ctx->sshttp = fd_sshttp_join( fd_sshttp_new( _sshttp ) );
647728
FD_TEST( ctx->sshttp );
648729

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

672776
if( FD_UNLIKELY( tile->out_cnt!=1UL ) ) FD_LOG_ERR(( "tile `" NAME "` has %lu outs, expected 1", tile->out_cnt ));
@@ -687,6 +791,8 @@ unprivileged_init( fd_topo_t * topo,
687791
#define STEM_CALLBACK_SHOULD_SHUTDOWN should_shutdown
688792
#define STEM_CALLBACK_METRICS_WRITE metrics_write
689793
#define STEM_CALLBACK_AFTER_CREDIT after_credit
794+
#define STEM_CALLBACK_BEFORE_FRAG before_frag
795+
#define STEM_CALLBACK_DURING_FRAG during_frag
690796
#define STEM_CALLBACK_AFTER_FRAG after_frag
691797

692798
#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)