Skip to content

Commit

Permalink
Add blackhole tile (#1632)
Browse files Browse the repository at this point in the history
* add new tiles

* add in blackhole tile

* remove for now

* changes
  • Loading branch information
arjain4 authored Apr 24, 2024
1 parent 7eecb38 commit ebeaa94
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/fdctl/Local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $(call add-objs,run/tiles/fd_bank,fd_fdctl)
$(call add-objs,run/tiles/fd_shred,fd_fdctl)
$(call add-objs,run/tiles/fd_store,fd_fdctl)
$(call add-objs,run/tiles/fd_sign,fd_fdctl)
$(call add-objs,run/tiles/fd_blackhole,fd_fdctl)

# fdctl topologies
$(call add-objs,run/topos/fd_frankendancer,fd_fdctl)
Expand Down
2 changes: 2 additions & 0 deletions src/app/fdctl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern fd_topo_run_tile_t fd_tile_shred;
extern fd_topo_run_tile_t fd_tile_store;
extern fd_topo_run_tile_t fd_tile_sign;
extern fd_topo_run_tile_t fd_tile_metric;
extern fd_topo_run_tile_t fd_tile_blackhole;

fd_topo_run_tile_t * TILES[] = {
&fd_tile_net,
Expand All @@ -41,6 +42,7 @@ fd_topo_run_tile_t * TILES[] = {
&fd_tile_store,
&fd_tile_sign,
&fd_tile_metric,
&fd_tile_blackhole,
NULL,
};

Expand Down
38 changes: 38 additions & 0 deletions src/app/fdctl/run/tiles/fd_blackhole.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "tiles.h"

/**
* Tile used to filter out all packets when used as a consumer.
* As the name suggests, it is a "black hole" for incoming packets.
*/

static void
before_frag( void * _ctx FD_PARAM_UNUSED,
ulong in_idx FD_PARAM_UNUSED,
ulong seq FD_PARAM_UNUSED,
ulong sig FD_PARAM_UNUSED,
int * opt_filter ) {
*opt_filter = 1;
}

static ulong
populate_allowed_fds( void * scratch,
ulong out_fds_cnt,
int * out_fds ) {
(void)scratch;
if( FD_UNLIKELY( out_fds_cnt < 2 ) ) FD_LOG_ERR(( "out_fds_cnt %lu", out_fds_cnt ));

ulong out_cnt = 0;
out_fds[ out_cnt++ ] = 2; /* stderr */
if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) )
out_fds[ out_cnt++ ] = fd_log_private_logfile_fd(); /* logfile */
return out_cnt;
}

fd_topo_run_tile_t fd_tile_blackhole = {
.name = "blackhole",
.mux_flags = FD_MUX_FLAG_MANUAL_PUBLISH | FD_MUX_FLAG_COPY,
.burst = 1UL,
.mux_before_frag = before_frag,
.populate_allowed_fds = populate_allowed_fds,
.privileged_init = NULL,
};
2 changes: 2 additions & 0 deletions src/app/fddev/main1.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern fd_topo_run_tile_t fd_tile_shred;
extern fd_topo_run_tile_t fd_tile_store;
extern fd_topo_run_tile_t fd_tile_sign;
extern fd_topo_run_tile_t fd_tile_metric;
extern fd_topo_run_tile_t fd_tile_blackhole;

extern fd_topo_run_tile_t fd_tile_bencho;
extern fd_topo_run_tile_t fd_tile_benchg;
Expand All @@ -59,6 +60,7 @@ fd_topo_run_tile_t * TILES[] = {
&fd_tile_store,
&fd_tile_sign,
&fd_tile_metric,
&fd_tile_blackhole,
&fd_tile_bencho,
&fd_tile_benchg,
&fd_tile_benchs,
Expand Down

0 comments on commit ebeaa94

Please sign in to comment.