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 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_FINISHING ||
236 0 : ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) {
237 0 : fd_stem_publish( stem, 0UL, ctx->pending_ctrl_sig, 0UL, 0UL, 0UL, 0UL, 0UL );
238 0 : ctx->pending_ctrl_sig = 0UL;
239 0 : return;
240 0 : } else FD_TEST( ctx->state==FD_SNAPSHOT_STATE_PROCESSING );
241 0 : }
242 :
243 0 : if( ctx->state!=FD_SNAPSHOT_STATE_PROCESSING ) {
244 0 : fd_log_sleep( (long)1e6 );
245 0 : return;
246 0 : }
247 :
248 0 : uchar * out = fd_chunk_to_laddr( ctx->out_dc.mem, ctx->out_dc.chunk );
249 :
250 0 : if( ctx->load_file ) {
251 0 : long result = read( ctx->load_full ? ctx->local_full_fd : ctx->local_incr_fd, out, ctx->out_dc.mtu );
252 0 : if( FD_UNLIKELY( result<=0L ) ) {
253 0 : if( result==0L ) ctx->state = FD_SNAPSHOT_STATE_FINISHING;
254 0 : else if( FD_UNLIKELY( errno!=EAGAIN && errno!=EINTR ) ) {
255 0 : FD_LOG_WARNING(( "read() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
256 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
257 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_CTRL_ERROR, 0UL, 0UL, 0UL, 0UL, 0UL );
258 0 : return; /* verbose return */
259 0 : }
260 0 : } else {
261 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_DATA, ctx->out_dc.chunk, (ulong)result, 0UL, 0UL, 0UL );
262 0 : ctx->out_dc.chunk = fd_dcache_compact_next( ctx->out_dc.chunk, (ulong)result, ctx->out_dc.chunk0, ctx->out_dc.wmark );
263 0 : *charge_busy = 1;
264 0 : return; /* verbose return */
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_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_META, ctx->out_dc.chunk, sizeof(fd_ssctrl_meta_t), 0UL, 0UL, 0UL );
287 0 : ctx->out_dc.chunk = next_chunk;
288 0 : }
289 0 : if( FD_LIKELY( data_len!=0UL ) ) {
290 0 : fd_stem_publish( stem, 0UL, FD_SNAPSHOT_MSG_DATA, ctx->out_dc.chunk, data_len, 0UL, 0UL, 0UL );
291 0 : ctx->out_dc.chunk = fd_dcache_compact_next( ctx->out_dc.chunk, data_len, ctx->out_dc.chunk0, ctx->out_dc.wmark );
292 0 : ctx->bytes_in_batch += data_len;
293 :
294 : /* measure download speed every 100 MiB */
295 0 : if(ctx->bytes_in_batch>=100<<20UL) {
296 0 : ctx->end_batch = fd_log_wallclock();
297 : /* download speed in MiB/s = bytes/nanoseconds * 1e9/(1 second) * 1/(1MiB = 1<<20UL) = 1e9/(1024*1024) ~= 954 */
298 0 : ctx->download_speed_mibs = (double)(ctx->bytes_in_batch*954) / (double)(ctx->end_batch - ctx->start_batch);
299 0 : if( FD_UNLIKELY( ctx->download_speed_mibs<ctx->config.min_download_speed_mibs ) ) {
300 : /* cancel the snapshot load if the download speed is less
301 : than the minimum download speed. */
302 0 : FD_LOG_WARNING(( "download speed %.2f MiB/s is below the minimum threshold %.2f MiB/s, cancelling snapshot download",
303 0 : ctx->download_speed_mibs, (double)(ctx->config.min_download_speed_mibs) ));
304 0 : transition_malformed(ctx, stem );
305 0 : }
306 0 : ctx->start_batch = ctx->end_batch;
307 0 : ctx->bytes_in_batch = 0UL;
308 0 : }
309 0 : }
310 0 : *charge_busy = 1;
311 0 : break;
312 0 : }
313 0 : case FD_SSHTTP_ADVANCE_DONE:
314 0 : ctx->state = FD_SNAPSHOT_STATE_FINISHING;
315 0 : break;
316 0 : case FD_SSHTTP_ADVANCE_ERROR:
317 0 : transition_malformed( ctx, stem );
318 0 : fd_sshttp_cancel( ctx->sshttp );
319 0 : break;
320 0 : default: FD_LOG_ERR(( "unexpected fd_sshttp_advance result %d", result ));
321 0 : }
322 0 : }
323 0 : }
324 :
325 : static int
326 : returnable_frag( fd_snapld_tile_t * ctx,
327 : ulong in_idx FD_PARAM_UNUSED,
328 : ulong seq FD_PARAM_UNUSED,
329 : ulong sig,
330 : ulong chunk,
331 : ulong sz,
332 : ulong ctl FD_PARAM_UNUSED,
333 : ulong tsorig FD_PARAM_UNUSED,
334 : ulong tspub FD_PARAM_UNUSED,
335 0 : fd_stem_context_t * stem ) {
336 0 : FD_TEST( !ctx->pending_ctrl_sig );
337 :
338 0 : if( ctx->state==FD_SNAPSHOT_STATE_ERROR && sig!=FD_SNAPSHOT_MSG_CTRL_FAIL ) {
339 : /* Control messages move along the snapshot load pipeline. Since
340 : error conditions can be triggered by any tile in the pipeline,
341 : it is possible to be in error state and still receive otherwise
342 : valid messages. Only a fail message can revert this. */
343 0 : return 0;
344 0 : };
345 :
346 0 : int forward_msg = 1;
347 :
348 0 : switch( sig ) {
349 :
350 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_FULL:
351 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_INCR: {
352 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
353 0 : ctx->state = FD_SNAPSHOT_STATE_PROCESSING;
354 0 : FD_TEST( sz==sizeof(fd_ssctrl_init_t) && sz<=ctx->out_dc.mtu );
355 0 : fd_ssctrl_init_t const * msg_in = fd_chunk_to_laddr_const( ctx->in_rd.base, chunk );
356 0 : ctx->load_full = sig==FD_SNAPSHOT_MSG_CTRL_INIT_FULL;
357 0 : ctx->load_file = msg_in->file;
358 0 : ctx->sent_meta = 0;
359 0 : ctx->is_https = msg_in->is_https;
360 0 : if( ctx->load_file ) {
361 0 : if( FD_UNLIKELY( 0!=lseek( ctx->load_full ? ctx->local_full_fd : ctx->local_incr_fd, 0, SEEK_SET ) ) )
362 0 : FD_LOG_ERR(( "lseek(0) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
363 0 : } else {
364 0 : if( ctx->load_full ) fd_sshttp_init( ctx->sshttp, msg_in->addr, msg_in->hostname, msg_in->is_https, msg_in->path, msg_in->path_len, fd_log_wallclock() );
365 0 : else fd_sshttp_init( ctx->sshttp, msg_in->addr, msg_in->hostname, msg_in->is_https, msg_in->path, msg_in->path_len, fd_log_wallclock() );
366 0 : }
367 0 : fd_ssctrl_init_t * msg_out = fd_chunk_to_laddr( ctx->out_dc.mem, ctx->out_dc.chunk );
368 0 : fd_memcpy( msg_out, msg_in, sz );
369 0 : fd_stem_publish( stem, 0UL, sig, ctx->out_dc.chunk, sz, 0UL, 0UL, 0UL );
370 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 );
371 0 : forward_msg = 0; // we are forwarding the control message in the `fd_sstrl_init_t` message
372 0 : break;
373 0 : }
374 :
375 0 : case FD_SNAPSHOT_MSG_CTRL_FINI: {
376 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_PROCESSING ) ) {
377 : /* snapld should be in the finishing state when reading from a
378 : file or downloading from http. It is only allowed to still
379 : be in progress for shutting down an https connection. Save
380 : the sig here and send the message when snapld is in the
381 : finishing state. */
382 0 : FD_TEST( ctx->is_https );
383 0 : ctx->pending_ctrl_sig = sig;
384 0 : forward_msg = 0;
385 0 : break;
386 0 : }
387 0 : else FD_TEST( ctx->state==FD_SNAPSHOT_STATE_FINISHING );
388 0 : break;
389 0 : }
390 :
391 0 : case FD_SNAPSHOT_MSG_CTRL_NEXT:
392 0 : case FD_SNAPSHOT_MSG_CTRL_DONE: {
393 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
394 0 : break;
395 0 : }
396 :
397 0 : case FD_SNAPSHOT_MSG_CTRL_ERROR: {
398 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
399 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
400 0 : break;
401 0 : }
402 :
403 0 : case FD_SNAPSHOT_MSG_CTRL_FAIL:
404 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
405 0 : fd_sshttp_cancel( ctx->sshttp );
406 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
407 0 : break;
408 :
409 0 : case FD_SNAPSHOT_MSG_CTRL_SHUTDOWN: {
410 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
411 0 : ctx->state = FD_SNAPSHOT_STATE_SHUTDOWN;
412 0 : break;
413 0 : }
414 :
415 : /* FD_SNAPSHOT_MSG_DATA is not possible */
416 0 : default: {
417 0 : FD_LOG_ERR(( "unexpected control sig %lu", sig ));
418 0 : break;
419 0 : }
420 0 : }
421 :
422 : /* Forward the control message down the pipeline */
423 0 : if( FD_LIKELY( forward_msg ) ) {
424 0 : fd_stem_publish( stem, 0UL, sig, 0UL, 0UL, 0UL, 0UL, 0UL );
425 0 : }
426 :
427 0 : return 0;
428 0 : }
429 :
430 : /* Up to one frag from after_credit plus one from returnable_frag */
431 0 : #define STEM_BURST 2UL
432 :
433 0 : #define STEM_LAZY 1000L
434 :
435 0 : #define STEM_CALLBACK_CONTEXT_TYPE fd_snapld_tile_t
436 0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_snapld_tile_t)
437 :
438 : #define STEM_CALLBACK_SHOULD_SHUTDOWN should_shutdown
439 0 : #define STEM_CALLBACK_METRICS_WRITE metrics_write
440 0 : #define STEM_CALLBACK_AFTER_CREDIT after_credit
441 0 : #define STEM_CALLBACK_RETURNABLE_FRAG returnable_frag
442 :
443 : #include "../../disco/stem/fd_stem.c"
444 :
445 : fd_topo_run_tile_t fd_tile_snapld = {
446 : .name = NAME,
447 : .populate_allowed_seccomp = populate_allowed_seccomp,
448 : .populate_allowed_fds = populate_allowed_fds,
449 : .scratch_align = scratch_align,
450 : .scratch_footprint = scratch_footprint,
451 : .loose_footprint = loose_footprint,
452 : .privileged_init = privileged_init,
453 : .unprivileged_init = unprivileged_init,
454 : .run = stem_run,
455 : .keep_host_networking = 1,
456 : .allow_connect = 1,
457 : .rlimit_file_cnt = 5UL, /* stderr, log, http, full/incr local files */
458 : };
459 :
460 : #undef NAME
|