Line data Source code
1 : #define _GNU_SOURCE
2 : #include "utils/fd_ssarchive.h"
3 : #include "utils/fd_ssctrl.h"
4 : #include "utils/fd_sshttp.h"
5 :
6 : #include "../../disco/topo/fd_topo.h"
7 : #include "../../disco/metrics/fd_metrics.h"
8 : #include "../../waltz/openssl/fd_openssl_tile.h"
9 :
10 : #include <sys/mman.h> /* memfd_create */
11 : #include <errno.h>
12 : #include <fcntl.h>
13 : #include <unistd.h>
14 : #include <sys/socket.h>
15 :
16 : #include "generated/fd_snapld_tile_seccomp.h"
17 :
18 : #define NAME "snapld"
19 :
20 : /* The snapld tile is responsible for loading data from the local file
21 : or from an HTTP/TCP connection and sending it to the snapdc tile
22 : for later decompression. */
23 :
24 : typedef struct fd_snapld_tile {
25 :
26 : struct {
27 : char path[ PATH_MAX ];
28 : uint min_download_speed_mibs;
29 : } config;
30 :
31 : int state;
32 : ulong pending_ctrl_sig;
33 : int load_full;
34 : int load_file;
35 : int sent_meta;
36 :
37 : ulong bytes_in_batch;
38 : double download_speed_mibs;
39 : long start_batch;
40 : long end_batch;
41 :
42 : int local_full_fd;
43 : int local_incr_fd;
44 : int sockfd;
45 :
46 : int is_https;
47 :
48 : fd_sshttp_t * sshttp;
49 :
50 : struct {
51 : void const * base;
52 : } in_rd;
53 :
54 : struct {
55 : fd_wksp_t * mem;
56 : ulong chunk0;
57 : ulong wmark;
58 : ulong chunk;
59 : ulong mtu;
60 : } out_dc;
61 :
62 : } fd_snapld_tile_t;
63 :
64 : static ulong
65 0 : scratch_align( void ) {
66 0 : return fd_ulong_max( alignof(fd_snapld_tile_t), fd_sshttp_align() );
67 0 : }
68 :
69 : static ulong
70 0 : scratch_footprint( fd_topo_tile_t const * tile FD_PARAM_UNUSED ) {
71 0 : ulong l = FD_LAYOUT_INIT;
72 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_snapld_tile_t), sizeof(fd_snapld_tile_t) );
73 0 : l = FD_LAYOUT_APPEND( l, fd_sshttp_align(), fd_sshttp_footprint() );
74 0 : l = FD_LAYOUT_APPEND( l, fd_alloc_align(), fd_alloc_footprint() );
75 0 : return FD_LAYOUT_FINI( l, scratch_align() );
76 0 : }
77 :
78 : FD_FN_CONST static inline ulong
79 0 : loose_footprint( fd_topo_tile_t const * tile ) {
80 0 : (void)tile;
81 : /* Leftover space for OpenSSL allocations */
82 0 : return 1UL<<26UL; /* 64 MiB */
83 0 : }
84 :
85 : static void
86 : privileged_init( fd_topo_t * topo,
87 0 : fd_topo_tile_t * tile ) {
88 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
89 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
90 0 : fd_snapld_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapld_tile_t), sizeof(fd_snapld_tile_t) );
91 0 : void * _sshttp = FD_SCRATCH_ALLOC_APPEND( l, fd_sshttp_align(), fd_sshttp_footprint() );
92 :
93 0 : #if FD_HAS_OPENSSL
94 0 : void * _alloc = FD_SCRATCH_ALLOC_APPEND( l, fd_alloc_align(), fd_alloc_footprint() );
95 0 : fd_alloc_t * alloc = fd_alloc_join( fd_alloc_new( _alloc, 1UL ), tile->kind_id );
96 0 : fd_ossl_tile_init( alloc );
97 0 : #endif
98 :
99 0 : ctx->sshttp = fd_sshttp_join( fd_sshttp_new( _sshttp ) );
100 0 : FD_TEST( ctx->sshttp );
101 :
102 : /* FIXME: Allow incremental_snapshots=0 config */
103 0 : ulong full_slot = ULONG_MAX;
104 0 : ulong incr_slot = ULONG_MAX;
105 0 : int full_is_zstd = 0;
106 0 : int incr_is_zstd = 0;
107 0 : char full_path[ PATH_MAX ] = { 0 };
108 0 : char incr_path[ PATH_MAX ] = { 0 };
109 0 : ctx->local_full_fd = -1;
110 0 : ctx->local_incr_fd = -1;
111 0 : if( FD_LIKELY( -1!=fd_ssarchive_latest_pair( tile->snapld.snapshots_path, 1,
112 0 : &full_slot, &incr_slot,
113 0 : full_path, incr_path,
114 0 : &full_is_zstd, &incr_is_zstd ) ) ) {
115 0 : FD_TEST( full_slot!=ULONG_MAX );
116 :
117 0 : ctx->local_full_fd = open( full_path, O_RDONLY|O_CLOEXEC|O_NONBLOCK );
118 0 : if( FD_UNLIKELY( -1==ctx->local_full_fd ) ) FD_LOG_ERR(( "open() failed `%s` (%i-%s)", full_path, errno, fd_io_strerror( errno ) ));
119 :
120 0 : if( FD_LIKELY( incr_slot!=ULONG_MAX ) ) {
121 0 : ctx->local_incr_fd = open( incr_path, O_RDONLY|O_CLOEXEC|O_NONBLOCK );
122 0 : if( FD_UNLIKELY( -1==ctx->local_incr_fd ) ) FD_LOG_ERR(( "open() failed `%s` (%i-%s)", incr_path, errno, fd_io_strerror( errno ) ));
123 0 : }
124 0 : }
125 :
126 : /* Create a temporary file descriptor for our socket file descriptor.
127 : It is closed later in unprivileged init so that the sandbox sees
128 : an existent file descriptor. */
129 0 : ctx->sockfd = memfd_create( "snapld.sockfd", 0 );
130 0 : if( FD_UNLIKELY( -1==ctx->sockfd ) ) FD_LOG_ERR(( "memfd_create() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
131 0 : }
132 :
133 : static ulong
134 : populate_allowed_fds( fd_topo_t const * topo,
135 : fd_topo_tile_t const * tile,
136 : ulong out_fds_cnt,
137 0 : int * out_fds ) {
138 0 : if( FD_UNLIKELY( out_fds_cnt<4UL ) ) FD_LOG_ERR(( "out_fds_cnt %lu", out_fds_cnt ));
139 :
140 0 : ulong out_cnt = 0;
141 0 : out_fds[ out_cnt++ ] = 2UL; /* stderr */
142 0 : if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) ) {
143 0 : out_fds[ out_cnt++ ] = fd_log_private_logfile_fd();
144 0 : }
145 :
146 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
147 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
148 0 : fd_snapld_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapld_tile_t), sizeof(fd_snapld_tile_t) );
149 0 : if( FD_LIKELY( -1!=ctx->local_full_fd ) ) out_fds[ out_cnt++ ] = ctx->local_full_fd;
150 0 : if( FD_LIKELY( -1!=ctx->local_incr_fd ) ) out_fds[ out_cnt++ ] = ctx->local_incr_fd;
151 0 : out_fds[ out_cnt++ ] = ctx->sockfd;
152 :
153 0 : return out_cnt;
154 0 : }
155 :
156 : static ulong
157 : populate_allowed_seccomp( fd_topo_t const * topo,
158 : fd_topo_tile_t const * tile,
159 : ulong out_cnt,
160 0 : struct sock_filter * out ) {
161 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
162 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
163 0 : fd_snapld_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapld_tile_t), sizeof(fd_snapld_tile_t) );
164 :
165 0 : populate_sock_filter_policy_fd_snapld_tile( out_cnt, out, (uint)fd_log_private_logfile_fd(), (uint)ctx->local_full_fd, (uint)ctx->local_incr_fd, (uint)ctx->sockfd );
166 0 : return sock_filter_policy_fd_snapld_tile_instr_cnt;
167 0 : }
168 :
169 : static void
170 : unprivileged_init( fd_topo_t * topo,
171 0 : fd_topo_tile_t * tile ) {
172 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
173 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
174 0 : fd_snapld_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapld_tile_t), sizeof(fd_snapld_tile_t) );
175 :
176 0 : fd_memcpy( ctx->config.path, tile->snapld.snapshots_path, PATH_MAX );
177 0 : ctx->config.min_download_speed_mibs = tile->snapld.min_download_speed_mibs;
178 :
179 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
180 0 : ctx->pending_ctrl_sig = 0UL;
181 :
182 0 : ctx->download_speed_mibs = 0.0;
183 0 : ctx->bytes_in_batch = 0UL;
184 0 : ctx->start_batch = 0L;
185 0 : ctx->end_batch = 0L;
186 :
187 0 : FD_TEST( tile->in_cnt==1UL );
188 0 : fd_topo_link_t const * in_link = &topo->links[ tile->in_link_id[ 0 ] ];
189 0 : FD_TEST( 0==strcmp( in_link->name, "snapct_ld" ) );
190 0 : ctx->in_rd.base = fd_topo_obj_wksp_base( topo, in_link->dcache_obj_id );
191 :
192 0 : FD_TEST( tile->out_cnt==1UL );
193 0 : fd_topo_link_t const * out_link = &topo->links[ tile->out_link_id[ 0 ] ];
194 0 : FD_TEST( 0==strcmp( out_link->name, "snapld_dc" ) );
195 0 : ctx->out_dc.mem = fd_topo_obj_wksp_base( topo, out_link->dcache_obj_id );
196 0 : ctx->out_dc.chunk0 = fd_dcache_compact_chunk0( ctx->out_dc.mem, out_link->dcache );
197 0 : ctx->out_dc.wmark = fd_dcache_compact_wmark ( ctx->out_dc.mem, out_link->dcache, out_link->mtu );
198 0 : ctx->out_dc.chunk = ctx->out_dc.chunk0;
199 0 : ctx->out_dc.mtu = out_link->mtu;
200 :
201 : /* We can only close the temporary socket file descriptor after
202 : entering the sandbox because the sandbox checks all file
203 : descriptors are existent. */
204 0 : if( -1==close( ctx->sockfd ) ) FD_LOG_ERR((" close() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
205 0 : }
206 :
207 : static int
208 0 : should_shutdown( fd_snapld_tile_t * ctx ) {
209 0 : return ctx->state==FD_SNAPSHOT_STATE_SHUTDOWN;
210 0 : }
211 :
212 : static void
213 0 : metrics_write( fd_snapld_tile_t * ctx ) {
214 0 : #if FD_HAS_OPENSSL
215 0 : FD_MCNT_SET( SNAPLD, SSL_ALLOC_ERRORS, fd_ossl_alloc_errors );
216 0 : #endif
217 0 : FD_MGAUGE_SET( SNAPLD, STATE, (ulong)(ctx->state) );
218 0 : }
219 :
220 : static void
221 : transition_malformed( fd_snapld_tile_t * ctx,
222 0 : fd_stem_context_t * stem ) {
223 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) return;
224 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
225 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_ERROR, 0UL, 0UL, 0UL, 0UL, 0UL );
226 0 : }
227 :
228 : static void
229 : after_credit( fd_snapld_tile_t * ctx,
230 : fd_stem_context_t * stem,
231 : int * opt_poll_in FD_PARAM_UNUSED,
232 0 : int * charge_busy ) {
233 0 : if( FD_UNLIKELY( ctx->pending_ctrl_sig ) ) {
234 0 : FD_TEST( !ctx->load_file && ctx->is_https );
235 0 : FD_TEST( ctx->pending_ctrl_sig==FD_SNAPSHOT_MSG_CTRL_NEXT ||
236 0 : ctx->pending_ctrl_sig==FD_SNAPSHOT_MSG_CTRL_DONE );
237 0 : if( ctx->state==FD_SNAPSHOT_STATE_FINISHING || ctx->state==FD_SNAPSHOT_STATE_ERROR ) {
238 0 : fd_stem_publish( stem, 0UL, ctx->pending_ctrl_sig, 0UL, 0UL, 0UL, 0UL, 0UL );
239 0 : ctx->pending_ctrl_sig = 0UL;
240 0 : if( ctx->state!=FD_SNAPSHOT_STATE_ERROR ) ctx->state = FD_SNAPSHOT_STATE_IDLE;
241 0 : return;
242 0 : } else FD_TEST( ctx->state==FD_SNAPSHOT_STATE_PROCESSING );
243 0 : }
244 :
245 0 : if( ctx->state!=FD_SNAPSHOT_STATE_PROCESSING ) {
246 0 : fd_log_sleep( (long)1e6 );
247 0 : return;
248 0 : }
249 :
250 0 : uchar * out = fd_chunk_to_laddr( ctx->out_dc.mem, ctx->out_dc.chunk );
251 :
252 0 : if( ctx->load_file ) {
253 0 : long result = read( ctx->load_full ? ctx->local_full_fd : ctx->local_incr_fd, out, ctx->out_dc.mtu );
254 0 : if( FD_UNLIKELY( result<=0L ) ) {
255 0 : if( result==0L ) ctx->state = FD_SNAPSHOT_STATE_FINISHING;
256 0 : else if( FD_UNLIKELY( errno!=EAGAIN && errno!=EINTR ) ) {
257 0 : FD_LOG_WARNING(( "read() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
258 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
259 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_ERROR, 0UL, 0UL, 0UL, 0UL, 0UL );
260 0 : }
261 0 : } else {
262 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_DATA, ctx->out_dc.chunk, (ulong)result, 0UL, 0UL, 0UL );
263 0 : ctx->out_dc.chunk = fd_dcache_compact_next( ctx->out_dc.chunk, (ulong)result, ctx->out_dc.chunk0, ctx->out_dc.wmark );
264 0 : *charge_busy = 1;
265 0 : }
266 0 : } else {
267 0 : ulong data_len = ctx->out_dc.mtu;
268 0 : int result = fd_sshttp_advance( ctx->sshttp, &data_len, out, fd_log_wallclock() );
269 0 : switch( result ) {
270 0 : case FD_SSHTTP_ADVANCE_AGAIN:
271 0 : break;
272 0 : case FD_SSHTTP_ADVANCE_DATA: {
273 0 : if( FD_UNLIKELY( !ctx->sent_meta ) ) {
274 : /* On the first DATA return, the HTTP headers are available
275 : for use. We need to send this metadata downstream, but
276 : need to do so before any data frags. So, we copy any data
277 : we received with the headers (if any) to the next dcache
278 : chunk and then publish both in order. */
279 0 : ctx->start_batch = fd_log_wallclock();
280 0 : ctx->sent_meta = 1;
281 0 : fd_ssctrl_meta_t * meta = (fd_ssctrl_meta_t *)out;
282 0 : ulong next_chunk = fd_dcache_compact_next( ctx->out_dc.chunk, sizeof(fd_ssctrl_meta_t), ctx->out_dc.chunk0, ctx->out_dc.wmark );
283 0 : memmove( fd_chunk_to_laddr( ctx->out_dc.mem, next_chunk ), out, data_len );
284 0 : meta->total_sz = fd_sshttp_content_len( ctx->sshttp );
285 0 : FD_TEST( meta->total_sz!=ULONG_MAX );
286 0 : fd_memcpy( meta->name, fd_sshttp_snapshot_name( ctx->sshttp ), PATH_MAX );
287 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_META, ctx->out_dc.chunk, sizeof(fd_ssctrl_meta_t), 0UL, 0UL, 0UL );
288 0 : ctx->out_dc.chunk = next_chunk;
289 0 : }
290 0 : if( FD_LIKELY( data_len!=0UL ) ) {
291 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_DATA, ctx->out_dc.chunk, data_len, 0UL, 0UL, 0UL );
292 0 : ctx->out_dc.chunk = fd_dcache_compact_next( ctx->out_dc.chunk, data_len, ctx->out_dc.chunk0, ctx->out_dc.wmark );
293 0 : ctx->bytes_in_batch += data_len;
294 :
295 : /* measure download speed every 100 MiB */
296 0 : if(ctx->bytes_in_batch>=100<<20UL) {
297 0 : ctx->end_batch = fd_log_wallclock();
298 : /* download speed in MiB/s = bytes/nanoseconds * 1e9/(1 second) * 1/(1MiB = 1<<20UL) = 1e9/(1024*1024) ~= 954 */
299 0 : ctx->download_speed_mibs = (double)(ctx->bytes_in_batch*954) / (double)(ctx->end_batch - ctx->start_batch);
300 0 : if( FD_UNLIKELY( ctx->download_speed_mibs<ctx->config.min_download_speed_mibs ) ) {
301 : /* cancel the snapshot load if the download speed is less
302 : than the minimum download speed. */
303 0 : FD_LOG_WARNING(( "download speed %.2f MiB/s is below the minimum threshold %.2f MiB/s, cancelling snapshot download",
304 0 : ctx->download_speed_mibs, (double)(ctx->config.min_download_speed_mibs) ));
305 0 : transition_malformed(ctx, stem );
306 0 : }
307 0 : ctx->start_batch = ctx->end_batch;
308 0 : ctx->bytes_in_batch = 0UL;
309 0 : }
310 0 : }
311 0 : *charge_busy = 1;
312 0 : break;
313 0 : }
314 0 : case FD_SSHTTP_ADVANCE_DONE:
315 0 : ctx->state = FD_SNAPSHOT_STATE_FINISHING;
316 0 : break;
317 0 : case FD_SSHTTP_ADVANCE_ERROR:
318 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
319 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_ERROR, 0UL, 0UL, 0UL, 0UL, 0UL );
320 0 : fd_sshttp_cancel( ctx->sshttp );
321 0 : break;
322 0 : default: FD_LOG_ERR(( "unexpected fd_sshttp_advance result %d", result ));
323 0 : }
324 0 : }
325 0 : }
326 :
327 : static int
328 : returnable_frag( fd_snapld_tile_t * ctx,
329 : ulong in_idx FD_PARAM_UNUSED,
330 : ulong seq FD_PARAM_UNUSED,
331 : ulong sig,
332 : ulong chunk,
333 : ulong sz,
334 : ulong ctl FD_PARAM_UNUSED,
335 : ulong tsorig FD_PARAM_UNUSED,
336 : ulong tspub FD_PARAM_UNUSED,
337 0 : fd_stem_context_t * stem ) {
338 0 : FD_TEST( !ctx->pending_ctrl_sig );
339 :
340 0 : switch( sig ) {
341 :
342 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_FULL:
343 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_INCR: {
344 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
345 0 : FD_TEST( sz==sizeof(fd_ssctrl_init_t) && sz<=ctx->out_dc.mtu );
346 0 : fd_ssctrl_init_t const * msg_in = fd_chunk_to_laddr_const( ctx->in_rd.base, chunk );
347 0 : ctx->load_full = sig==FD_SNAPSHOT_MSG_CTRL_INIT_FULL;
348 0 : ctx->load_file = msg_in->file;
349 0 : ctx->state = FD_SNAPSHOT_STATE_PROCESSING;
350 0 : ctx->sent_meta = 0;
351 0 : ctx->is_https = msg_in->is_https;
352 0 : if( ctx->load_file ) {
353 0 : if( FD_UNLIKELY( 0!=lseek( ctx->load_full ? ctx->local_full_fd : ctx->local_incr_fd, 0, SEEK_SET ) ) )
354 0 : FD_LOG_ERR(( "lseek(0) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
355 0 : } else {
356 0 : if( ctx->load_full ) fd_sshttp_init( ctx->sshttp, msg_in->addr, msg_in->hostname, msg_in->is_https, "/snapshot.tar.bz2", 17UL, fd_log_wallclock() );
357 0 : else fd_sshttp_init( ctx->sshttp, msg_in->addr, msg_in->hostname, msg_in->is_https, "/incremental-snapshot.tar.bz2", 29UL, fd_log_wallclock() );
358 0 : }
359 0 : fd_ssctrl_init_t * msg_out = fd_chunk_to_laddr( ctx->out_dc.mem, ctx->out_dc.chunk );
360 0 : fd_memcpy( msg_out, msg_in, sz );
361 0 : fd_stem_publish( stem, 0UL, sig, ctx->out_dc.chunk, sz, 0UL, 0UL, 0UL );
362 0 : ctx->out_dc.chunk = fd_dcache_compact_next( ctx->out_dc.chunk, ctx->out_dc.mtu, ctx->out_dc.chunk0, ctx->out_dc.wmark );
363 0 : return 0;
364 0 : }
365 :
366 0 : case FD_SNAPSHOT_MSG_CTRL_FAIL:
367 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_MSG_CTRL_SHUTDOWN );
368 0 : fd_sshttp_cancel( ctx->sshttp );
369 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
370 0 : break;
371 :
372 0 : case FD_SNAPSHOT_MSG_CTRL_NEXT:
373 0 : case FD_SNAPSHOT_MSG_CTRL_DONE:
374 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_PROCESSING ||
375 0 : ctx->state==FD_SNAPSHOT_STATE_FINISHING ||
376 0 : ctx->state==FD_SNAPSHOT_STATE_ERROR );
377 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_PROCESSING ) ) {
378 : /* snapld should be in the finishing state when reading from a
379 : file or downloading from http. It is only allowed to still
380 : be in progress for shutting down an https connection. Save
381 : the sig here and send the message when snapld is in the
382 : finishing state. */
383 0 : FD_TEST( ctx->is_https );
384 0 : ctx->pending_ctrl_sig = sig;
385 0 : return 0; /* return directly to avoid fowarding the message */
386 0 : }
387 0 : else if( FD_LIKELY( ctx->state==FD_SNAPSHOT_STATE_FINISHING ) ) {
388 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
389 0 : }
390 0 : break;
391 :
392 0 : case FD_SNAPSHOT_MSG_CTRL_SHUTDOWN:
393 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
394 0 : ctx->state = FD_SNAPSHOT_STATE_SHUTDOWN;
395 0 : break;
396 :
397 : /* FD_SNAPSHOT_MSG_CTRL_ERROR and FD_SNAPSHOT_MSG_DATA are not possible */
398 0 : default: FD_LOG_ERR(( "invalid sig %lu", sig ));
399 0 : }
400 :
401 : /* Forward the control message down the pipeline */
402 0 : fd_stem_publish( stem, 0UL, sig, 0UL, 0UL, 0UL, 0UL, 0UL );
403 :
404 0 : return 0;
405 0 : }
406 :
407 : /* Up to one frag from after_credit plus one from returnable_frag */
408 0 : #define STEM_BURST 2UL
409 :
410 0 : #define STEM_LAZY 1000L
411 :
412 0 : #define STEM_CALLBACK_CONTEXT_TYPE fd_snapld_tile_t
413 0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_snapld_tile_t)
414 :
415 : #define STEM_CALLBACK_SHOULD_SHUTDOWN should_shutdown
416 0 : #define STEM_CALLBACK_METRICS_WRITE metrics_write
417 0 : #define STEM_CALLBACK_AFTER_CREDIT after_credit
418 0 : #define STEM_CALLBACK_RETURNABLE_FRAG returnable_frag
419 :
420 : #include "../../disco/stem/fd_stem.c"
421 :
422 : fd_topo_run_tile_t fd_tile_snapld = {
423 : .name = NAME,
424 : .populate_allowed_seccomp = populate_allowed_seccomp,
425 : .populate_allowed_fds = populate_allowed_fds,
426 : .scratch_align = scratch_align,
427 : .scratch_footprint = scratch_footprint,
428 : .loose_footprint = loose_footprint,
429 : .privileged_init = privileged_init,
430 : .unprivileged_init = unprivileged_init,
431 : .run = stem_run,
432 : .keep_host_networking = 1,
433 : .allow_connect = 1,
434 : .rlimit_file_cnt = 5UL, /* stderr, log, http, full/incr local files */
435 : };
436 :
437 : #undef NAME
|