1
1
#define _GNU_SOURCE /* dup3 */
2
2
#include "fd_sock_tile_private.h"
3
+ #include "../fd_net_common.h"
3
4
#include "../../topo/fd_topo.h"
4
5
#include "../../../util/net/fd_eth.h"
5
6
#include "../../../util/net/fd_ip4.h"
27
28
Must be aligned by alignof(struct cmsghdr) */
28
29
#define FD_SOCK_CMSG_MAX (64UL)
29
30
31
+ /* Value of the sock_idx for Firedancer repair intake.
32
+ Used to determine whether repair packets should go to shred vs repair tile.
33
+ This value is validated at startup. */
34
+ #define REPAIR_SHRED_SOCKET_ID (4U)
35
+
30
36
static ulong
31
37
populate_allowed_seccomp ( fd_topo_t const * topo ,
32
38
fd_topo_tile_t const * tile ,
@@ -200,7 +206,7 @@ privileged_init( fd_topo_t * topo,
200
206
DST_PROTO_TPU_QUIC , /* quic_transaction_listen_port */
201
207
DST_PROTO_SHRED , /* shred_listen_port (turbine) */
202
208
DST_PROTO_GOSSIP , /* gossip_listen_port */
203
- DST_PROTO_SHRED , /* shred_listen_port (repair) */
209
+ DST_PROTO_REPAIR , /* shred_listen_port (repair) */
204
210
DST_PROTO_REPAIR /* repair_serve_listen_port */
205
211
};
206
212
for ( uint candidate_idx = 0U ; candidate_idx < 6 ; candidate_idx ++ ) {
@@ -209,6 +215,12 @@ privileged_init( fd_topo_t * topo,
209
215
if ( candidate_idx > FD_SOCK_TILE_MAX_SOCKETS ) FD_LOG_ERR (( "too many sockets" ));
210
216
ushort port = (ushort )udp_port_candidates [ candidate_idx ];
211
217
218
+ /* Validate value of REPAIR_SHRED_SOCKET_ID */
219
+ if ( udp_port_candidates [sock_idx ]== tile -> sock .net .repair_intake_listen_port )
220
+ FD_TEST ( sock_idx == REPAIR_SHRED_SOCKET_ID );
221
+ if ( udp_port_candidates [sock_idx ]== tile -> sock .net .repair_serve_listen_port )
222
+ FD_TEST ( sock_idx == REPAIR_SHRED_SOCKET_ID + 1 );
223
+
212
224
char const * target_link = udp_port_links [ candidate_idx ];
213
225
ctx -> link_rx_map [ sock_idx ] = 0xFF ;
214
226
for ( ulong j = 0UL ; j < (tile -> out_cnt ); j ++ ) {
@@ -351,7 +363,6 @@ poll_rx_socket( fd_sock_tile_t * ctx,
351
363
if ( FD_UNLIKELY ( sa -> sin_family != AF_INET ) ) {
352
364
/* unreachable */
353
365
FD_LOG_ERR (( "Received packet with unexpected sin_family %i" , sa -> sin_family ));
354
- continue ;
355
366
}
356
367
357
368
long daddr = -1 ;
@@ -397,7 +408,20 @@ poll_rx_socket( fd_sock_tile_t * ctx,
397
408
ulong chunk = fd_laddr_to_chunk ( base , eth_hdr );
398
409
ulong sig = fd_disco_netmux_sig ( sa -> sin_addr .s_addr , fd_ushort_bswap ( sa -> sin_port ), 0U , proto , hdr_sz );
399
410
ulong tspub = fd_frag_meta_ts_comp ( ts );
400
- fd_stem_publish ( stem , rx_link , sig , chunk , frame_sz , 0UL , 0UL , tspub );
411
+
412
+ /* default for repair intake is to send to [shreds] to shred tile.
413
+ ping messages should be routed to the repair. */
414
+ if ( FD_UNLIKELY ( sock_idx == REPAIR_SHRED_SOCKET_ID && frame_sz == REPAIR_PING_SZ ) ) {
415
+ uchar repair_rx_link = ctx -> link_rx_map [ REPAIR_SHRED_SOCKET_ID + 1 ];
416
+ fd_sock_link_rx_t * repair_link = ctx -> link_rx + repair_rx_link ;
417
+ uchar * repair_buf = fd_chunk_to_laddr ( repair_link -> base , repair_link -> chunk );
418
+ memcpy ( repair_buf , eth_hdr , frame_sz );
419
+ fd_stem_publish ( stem , repair_rx_link , sig , repair_link -> chunk , frame_sz , 0UL , 0UL , tspub );
420
+ repair_link -> chunk = fd_dcache_compact_next ( repair_link -> chunk , FD_NET_MTU , repair_link -> chunk0 , repair_link -> wmark );
421
+ } else {
422
+ fd_stem_publish ( stem , rx_link , sig , chunk , frame_sz , 0UL , 0UL , tspub );
423
+ }
424
+
401
425
last_chunk = chunk ;
402
426
}
403
427
0 commit comments