LCOV - code coverage report
Current view: top level - disco/net/sock - fd_sock_tile.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 490 0.0 %
Date: 2026-06-29 05:51:35 Functions: 0 17 0.0 %

          Line data    Source code
       1             : #define _GNU_SOURCE /* dup3 */
       2             : #include "fd_sock_tile_private.h"
       3             : #include "../fd_net_common.h"
       4             : #include "../../topo/fd_topo.h"
       5             : #include "../../../util/net/fd_eth.h"
       6             : #include "../../../util/net/fd_ip4.h"
       7             : #include "../../../util/net/fd_udp.h"
       8             : 
       9             : #include <stdalign.h> /* alignof */
      10             : #include <errno.h>
      11             : #include <fcntl.h> /* fcntl */
      12             : #include <unistd.h> /* dup3, close */
      13             : #include <netinet/in.h> /* sockaddr_in */
      14             : #include <sys/socket.h> /* socket */
      15             : #include "../../metrics/fd_metrics.h"
      16             : 
      17             : #include "generated/fd_sock_tile_seccomp.h"
      18             : 
      19             : /* recv/sendmmsg packet count in batch and tango burst depth
      20             :    FIXME make configurable in the future?
      21             :    FIXME keep in sync with fd_net_tile_topo.c */
      22           0 : #define STEM_BURST (64UL)
      23             : 
      24             : /* Place RX socket file descriptors in contiguous integer range. */
      25           0 : #define RX_SOCK_FD_MIN (128)
      26             : 
      27             : /* Controls max ancillary data size.
      28             :    Must be aligned by alignof(struct cmsghdr) */
      29           0 : #define FD_SOCK_CMSG_MAX (64UL)
      30             : 
      31             : static ulong
      32             : populate_allowed_seccomp( fd_topo_t const *      topo,
      33             :                           fd_topo_tile_t const * tile,
      34             :                           ulong                  out_cnt,
      35           0 :                           struct sock_filter *   out ) {
      36           0 :   FD_SCRATCH_ALLOC_INIT( l, fd_topo_obj_laddr( topo, tile->tile_obj_id ) );
      37           0 :   fd_sock_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_sock_tile_t), sizeof(fd_sock_tile_t) );
      38             : 
      39           0 :   populate_sock_filter_policy_fd_sock_tile( out_cnt, out, (uint)fd_log_private_logfile_fd(), (uint)ctx->tx_sock, RX_SOCK_FD_MIN, RX_SOCK_FD_MIN+(uint)ctx->sock_cnt );
      40           0 :   return sock_filter_policy_fd_sock_tile_instr_cnt;
      41           0 : }
      42             : 
      43             : static ulong
      44             : populate_allowed_fds( fd_topo_t const *      topo,
      45             :                       fd_topo_tile_t const * tile,
      46             :                       ulong                  out_fds_cnt,
      47           0 :                       int *                  out_fds ) {
      48           0 :   void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
      49           0 :   FD_SCRATCH_ALLOC_INIT( l, scratch );
      50           0 :   fd_sock_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_sock_tile_t), sizeof(fd_sock_tile_t) );
      51             : 
      52           0 :   ulong sock_cnt = ctx->sock_cnt;
      53           0 :   if( FD_UNLIKELY( out_fds_cnt<sock_cnt+3UL ) ) {
      54           0 :     FD_LOG_ERR(( "out_fds_cnt %lu", out_fds_cnt ));
      55           0 :   }
      56             : 
      57           0 :   ulong out_cnt = 0UL;
      58             : 
      59           0 :   out_fds[ out_cnt++ ] = 2; /* stderr */
      60           0 :   if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) ) {
      61           0 :     out_fds[ out_cnt++ ] = fd_log_private_logfile_fd(); /* logfile */
      62           0 :   }
      63           0 :   out_fds[ out_cnt++ ] = ctx->tx_sock;
      64           0 :   for( ulong j=0UL; j<sock_cnt; j++ ) {
      65           0 :     out_fds[ out_cnt++ ] = ctx->pollfd[ j ].fd;
      66           0 :   }
      67           0 :   return out_cnt;
      68           0 : }
      69             : 
      70             : FD_FN_CONST static inline ulong
      71           0 : tx_scratch_footprint( void ) {
      72           0 :   return STEM_BURST * fd_ulong_align_up( FD_NET_MTU, FD_CHUNK_ALIGN );
      73           0 : }
      74             : 
      75             : FD_FN_CONST static inline ulong
      76           0 : scratch_align( void ) {
      77           0 :   return 4096UL;
      78           0 : }
      79             : 
      80             : FD_FN_PURE static inline ulong
      81           0 : scratch_footprint( fd_topo_tile_t const * tile FD_PARAM_UNUSED ) {
      82           0 :   ulong l = FD_LAYOUT_INIT;
      83           0 :   l = FD_LAYOUT_APPEND( l, alignof(fd_sock_tile_t),     sizeof(fd_sock_tile_t)                );
      84           0 :   l = FD_LAYOUT_APPEND( l, alignof(struct iovec),       STEM_BURST*sizeof(struct iovec)       );
      85           0 :   l = FD_LAYOUT_APPEND( l, alignof(struct cmsghdr),     STEM_BURST*FD_SOCK_CMSG_MAX           );
      86           0 :   l = FD_LAYOUT_APPEND( l, alignof(struct sockaddr_in), STEM_BURST*sizeof(struct sockaddr_in) );
      87           0 :   l = FD_LAYOUT_APPEND( l, alignof(struct mmsghdr),     STEM_BURST*sizeof(struct mmsghdr)     );
      88           0 :   l = FD_LAYOUT_APPEND( l, FD_CHUNK_ALIGN,              tx_scratch_footprint()                );
      89           0 :   return FD_LAYOUT_FINI( l, scratch_align() );
      90           0 : }
      91             : 
      92             : /* create_udp_socket creates and configures a new UDP socket for the
      93             :    sock tile at the given file descriptor ID. */
      94             : 
      95             : static void
      96             : create_udp_socket( int    sock_fd,
      97             :                    uint   bind_addr,
      98             :                    ushort udp_port,
      99           0 :                    int    so_rcvbuf ) {
     100             : 
     101           0 :   if( fcntl( sock_fd, F_GETFD, 0 )!=-1 ) {
     102           0 :     FD_LOG_ERR(( "file descriptor %d already exists", sock_fd ));
     103           0 :   } else if( errno!=EBADF ) {
     104           0 :     FD_LOG_ERR(( "fcntl(F_GETFD) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     105           0 :   }
     106             : 
     107           0 :   int orig_fd = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
     108           0 :   if( FD_UNLIKELY( orig_fd<0 ) ) {
     109           0 :     FD_LOG_ERR(( "socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     110           0 :   }
     111             : 
     112           0 :   int reuseport = 1;
     113           0 :   if( FD_UNLIKELY( setsockopt( orig_fd, SOL_SOCKET, SO_REUSEPORT, &reuseport, sizeof(int) )<0 ) ) {
     114           0 :     FD_LOG_ERR(( "setsockopt(SOL_SOCKET,SO_REUSEPORT,1) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     115           0 :   }
     116             : 
     117           0 :   int ip_pktinfo = 1;
     118           0 :   if( FD_UNLIKELY( setsockopt( orig_fd, IPPROTO_IP, IP_PKTINFO, &ip_pktinfo, sizeof(int) )<0 ) ) {
     119           0 :     FD_LOG_ERR(( "setsockopt(IPPROTO_IP,IP_PKTINFO,1) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     120           0 :   }
     121             : 
     122           0 :   if( FD_UNLIKELY( 0!=setsockopt( orig_fd, SOL_SOCKET, SO_RCVBUF, &so_rcvbuf, sizeof(int) ) ) ) {
     123           0 :     FD_LOG_ERR(( "setsockopt(SOL_SOCKET,SO_RCVBUF,%i) failed (%i-%s)", so_rcvbuf, errno, fd_io_strerror( errno ) ));
     124           0 :   }
     125             : 
     126           0 :   struct sockaddr_in saddr = {
     127           0 :     .sin_family      = AF_INET,
     128           0 :     .sin_addr.s_addr = bind_addr,
     129           0 :     .sin_port        = fd_ushort_bswap( udp_port ),
     130           0 :   };
     131           0 :   if( FD_UNLIKELY( 0!=bind( orig_fd, fd_type_pun_const( &saddr ), sizeof(struct sockaddr_in) ) ) ) {
     132           0 :     FD_LOG_ERR(( "bind(0.0.0.0:%i) failed (%i-%s)", udp_port, errno, fd_io_strerror( errno ) ));
     133           0 :   }
     134             : 
     135           0 : # if defined(__linux__)
     136           0 :   int dup_res = dup3( orig_fd, sock_fd, O_CLOEXEC );
     137             : # else
     138             :   int dup_res = dup2( orig_fd, sock_fd );
     139             : # endif
     140           0 :   if( FD_UNLIKELY( dup_res!=sock_fd ) ) {
     141           0 :     FD_LOG_ERR(( "dup2 returned %i (%i-%s)", sock_fd, errno, fd_io_strerror( errno ) ));
     142           0 :   }
     143             : 
     144           0 :   if( FD_UNLIKELY( 0!=close( orig_fd ) ) ) {
     145           0 :     FD_LOG_ERR(( "close(%d) failed (%i-%s)", orig_fd, errno, fd_io_strerror( errno ) ));
     146           0 :   }
     147             : 
     148           0 : }
     149             : 
     150             : static void
     151             : privileged_init( fd_topo_t const *      topo,
     152           0 :                  fd_topo_tile_t const * tile ) {
     153           0 :   void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
     154           0 :   FD_SCRATCH_ALLOC_INIT( l, scratch );
     155           0 :   fd_sock_tile_t *     ctx        = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_sock_tile_t),     sizeof(fd_sock_tile_t)                );
     156           0 :   struct iovec   *     batch_iov  = FD_SCRATCH_ALLOC_APPEND( l, alignof(struct iovec),       STEM_BURST*sizeof(struct iovec)       );
     157           0 :   void *               batch_cmsg = FD_SCRATCH_ALLOC_APPEND( l, alignof(struct cmsghdr),     STEM_BURST*FD_SOCK_CMSG_MAX           );
     158           0 :   struct sockaddr_in * batch_sa   = FD_SCRATCH_ALLOC_APPEND( l, alignof(struct sockaddr_in), STEM_BURST*sizeof(struct sockaddr_in) );
     159           0 :   struct mmsghdr *     batch_msg  = FD_SCRATCH_ALLOC_APPEND( l, alignof(struct mmsghdr),     STEM_BURST*sizeof(struct mmsghdr)     );
     160           0 :   uchar *              tx_scratch = FD_SCRATCH_ALLOC_APPEND( l, FD_CHUNK_ALIGN,              tx_scratch_footprint()                );
     161           0 :   FD_DCHECK_CRIT( scratch==ctx, "invalid layout" );
     162             : 
     163           0 :   fd_memset( ctx,       0, sizeof(fd_sock_tile_t)                );
     164           0 :   fd_memset( batch_iov, 0, STEM_BURST*sizeof(struct iovec)       );
     165           0 :   fd_memset( batch_sa,  0, STEM_BURST*sizeof(struct sockaddr_in) );
     166           0 :   fd_memset( batch_msg, 0, STEM_BURST*sizeof(struct mmsghdr)     );
     167             : 
     168           0 :   ctx->batch_cnt   = 0UL;
     169           0 :   ctx->batch_iov   = batch_iov;
     170           0 :   ctx->batch_cmsg  = batch_cmsg;
     171           0 :   ctx->batch_sa    = batch_sa;
     172           0 :   ctx->batch_msg   = batch_msg;
     173           0 :   ctx->tx_scratch0 = tx_scratch;
     174           0 :   ctx->tx_scratch1 = tx_scratch + tx_scratch_footprint();
     175           0 :   ctx->tx_ptr      = tx_scratch;
     176           0 :   ctx->repair_shred_sock_idx = UINT_MAX;
     177             : 
     178             :   /* Create receive sockets.  Incrementally assign them to file
     179             :      descriptors starting at sock_fd_min. */
     180             : 
     181           0 :   int sock_fd_min = RX_SOCK_FD_MIN;
     182           0 :   ushort udp_port_candidates[] = {
     183           0 :     (ushort)tile->sock.net.legacy_transaction_listen_port,
     184           0 :     (ushort)tile->sock.net.quic_transaction_listen_port,
     185           0 :     (ushort)tile->sock.net.shred_listen_port,
     186           0 :     (ushort)tile->sock.net.gossip_listen_port,
     187           0 :     (ushort)tile->sock.net.repair_client_listen_port,
     188           0 :     (ushort)tile->sock.net.repair_serve_listen_port,
     189           0 :     (ushort)tile->sock.net.txsend_src_port
     190           0 :   };
     191           0 :   static char const * udp_port_links[] = {
     192           0 :     "net_quic",   /* legacy_transaction_listen_port */
     193           0 :     "net_quic",   /* quic_transaction_listen_port */
     194           0 :     "net_shred",  /* shred_listen_port (turbine) */
     195           0 :     "net_gossvf", /* gossip_listen_port */
     196           0 :     "net_shred",  /* shred_listen_port (repair) */
     197           0 :     "net_rserve", /* repair_serve_listen_port */
     198           0 :     "net_txsend"  /* txsend_src_port */
     199           0 :   };
     200           0 :   static uchar const udp_port_protos[] = {
     201           0 :     DST_PROTO_TPU_UDP,  /* legacy_transaction_listen_port */
     202           0 :     DST_PROTO_TPU_QUIC, /* quic_transaction_listen_port */
     203           0 :     DST_PROTO_SHRED,    /* shred_listen_port (turbine) */
     204           0 :     DST_PROTO_GOSSIP,   /* gossip_listen_port */
     205           0 :     DST_PROTO_REPAIR,   /* shred_listen_port (repair) */
     206           0 :     DST_PROTO_RSERVE,   /* repair_serve_listen_port */
     207           0 :     DST_PROTO_SEND      /* send_src_port */
     208           0 :   };
     209           0 :   for( uint candidate_idx=0U; candidate_idx<7; candidate_idx++ ) {
     210           0 :     if( !udp_port_candidates[ candidate_idx ] ) continue;
     211           0 :     uint sock_idx = ctx->sock_cnt;
     212           0 :     if( sock_idx>=FD_SOCK_TILE_MAX_SOCKETS ) FD_LOG_ERR(( "too many sockets" ));
     213           0 :     ushort port = (ushort)udp_port_candidates[ candidate_idx ];
     214             : 
     215           0 :     char const * target_link = udp_port_links[ candidate_idx ];
     216           0 :     ctx->link_rx_map[ sock_idx ] = 0xFF;
     217           0 :     for( ulong j=0UL; j<(tile->out_cnt); j++ ) {
     218           0 :       if( 0==strcmp( topo->links[ tile->out_link_id[ j ] ].name, target_link ) ) {
     219           0 :         ctx->proto_id    [ sock_idx ] = (uchar)udp_port_protos[ candidate_idx ];
     220           0 :         ctx->link_rx_map [ sock_idx ] = (uchar)j;
     221           0 :         ctx->rx_sock_port[ sock_idx ] = (ushort)port;
     222           0 :         break;
     223           0 :       }
     224           0 :     }
     225           0 :     if( ctx->link_rx_map[ sock_idx ]==0xFF ) {
     226             :       /* listen port number has no associated links,
     227             :          i.e. the repair server is disabled, then no net_rserve link. */
     228           0 :       continue;
     229           0 :     }
     230             : 
     231             :     /* Record the socket index of the repair intake socket, so repair
     232             :        ping packets can be routed to the repair tile at runtime. */
     233           0 :     if( tile->sock.net.repair_client_listen_port &&
     234           0 :         udp_port_candidates[ candidate_idx ]==tile->sock.net.repair_client_listen_port )
     235           0 :       ctx->repair_shred_sock_idx = sock_idx;
     236             : 
     237           0 :     int sock_fd = sock_fd_min + (int)sock_idx;
     238           0 :     create_udp_socket( sock_fd, tile->sock.net.bind_address, port, tile->sock.so_rcvbuf );
     239           0 :     ctx->pollfd[ sock_idx ].fd     = sock_fd;
     240           0 :     ctx->pollfd[ sock_idx ].events = POLLIN;
     241           0 :     ctx->sock_cnt++;
     242           0 :   }
     243             : 
     244             :   /* Create transmit socket */
     245             : 
     246           0 :   int tx_sock = socket( AF_INET, SOCK_RAW|SOCK_CLOEXEC, FD_IP4_HDR_PROTOCOL_UDP );
     247           0 :   if( FD_UNLIKELY( tx_sock<0 ) ) {
     248           0 :     FD_LOG_ERR(( "socket(AF_INET,SOCK_RAW|SOCK_CLOEXEC,17) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     249           0 :   }
     250             : 
     251           0 :   if( FD_UNLIKELY( 0!=setsockopt( tx_sock, SOL_SOCKET, SO_SNDBUF, &tile->sock.so_sndbuf, sizeof(int) ) ) ) {
     252           0 :     FD_LOG_ERR(( "setsockopt(SOL_SOCKET,SO_SNDBUF,%i) failed (%i-%s)", tile->sock.so_sndbuf, errno, fd_io_strerror( errno ) ));
     253           0 :   }
     254             : 
     255           0 :   uchar mcast_ttl = 64;
     256           0 :   if( FD_UNLIKELY( 0!=setsockopt( tx_sock, IPPROTO_IP, IP_MULTICAST_TTL, &mcast_ttl, sizeof(mcast_ttl) ) ) ) {
     257           0 :     FD_LOG_ERR(( "setsockopt(IPPROTO_IP,IP_MULTICAST_TTL,%u) failed (%i-%s)", (uint)mcast_ttl, errno, fd_io_strerror( errno ) ));
     258           0 :   }
     259             : 
     260           0 :   ctx->tx_sock      = tx_sock;
     261           0 :   ctx->bind_address = tile->sock.net.bind_address;
     262           0 : }
     263             : 
     264             : static void
     265             : unprivileged_init( fd_topo_t const *      topo,
     266           0 :                    fd_topo_tile_t const * tile ) {
     267           0 :   fd_sock_tile_t * ctx = fd_topo_obj_laddr( topo, tile->tile_obj_id );
     268             : 
     269           0 :   if( FD_UNLIKELY( tile->out_cnt > MAX_NET_OUTS ) ) {
     270           0 :     FD_LOG_ERR(( "sock tile has %lu out links which exceeds the max (%lu)", tile->out_cnt, MAX_NET_OUTS ));
     271           0 :   }
     272             : 
     273           0 :   ctx->repair_rx = 0xFF;
     274           0 :   for( ulong i=0UL; i<(tile->out_cnt); i++ ) {
     275           0 :     if( 0!=strncmp( topo->links[ tile->out_link_id[ i ] ].name, "net_", 4 ) ) {
     276           0 :       FD_LOG_ERR(( "out link %lu is not a net RX link", i ));
     277           0 :     }
     278           0 :     if( 0==strcmp( topo->links[ tile->out_link_id[ i ] ].name, "net_repair" ) ) {
     279           0 :       if( FD_UNLIKELY( ctx->repair_rx!=0xFF ) ) FD_LOG_ERR(( "multiple net_repair out links" ));
     280           0 :       ctx->repair_rx = (uchar)i;
     281           0 :     }
     282           0 :     fd_topo_link_t const * link = &topo->links[ tile->out_link_id[ i ] ];
     283           0 :     ctx->link_rx[ i ].base   = topo->workspaces[ topo->objs[ link->dcache_obj_id ].wksp_id ].wksp;
     284           0 :     ctx->link_rx[ i ].chunk0 = fd_dcache_compact_chunk0( ctx->link_rx[ i ].base, link->dcache );
     285           0 :     ctx->link_rx[ i ].wmark  = fd_dcache_compact_wmark(  ctx->link_rx[ i ].base, link->dcache, link->mtu );
     286           0 :     ctx->link_rx[ i ].chunk  = ctx->link_rx[ i ].chunk0;
     287           0 :     if( FD_UNLIKELY( link->burst < STEM_BURST ) ) {
     288           0 :       FD_LOG_ERR(( "link %lu dcache burst is too low (%lu<%lu)",
     289           0 :                    tile->out_link_id[ i ], link->burst, STEM_BURST ));
     290           0 :     }
     291           0 :   }
     292             : 
     293           0 :   for( ulong i=0UL; i<(tile->in_cnt); i++ ) {
     294           0 :     if( !strstr( topo->links[ tile->in_link_id[ i ] ].name, "_net" ) ) {
     295           0 :       FD_LOG_ERR(( "in link %lu is not a net TX link", i ));
     296           0 :     }
     297           0 :     fd_topo_link_t const * link = &topo->links[ tile->in_link_id[ i ] ];
     298           0 :     ctx->link_tx[ i ].base   = topo->workspaces[ topo->objs[ link->dcache_obj_id ].wksp_id ].wksp;
     299           0 :     ctx->link_tx[ i ].chunk0 = fd_dcache_compact_chunk0( ctx->link_tx[ i ].base, link->dcache );
     300           0 :     ctx->link_tx[ i ].wmark  = fd_dcache_compact_wmark(  ctx->link_tx[ i ].base, link->dcache, link->mtu );
     301           0 :   }
     302             : 
     303           0 : }
     304             : 
     305             : /* RX PATH (socket->tango) ********************************************/
     306             : 
     307             : /* FIXME Pace RX polling and interleave it with TX jobs to reduce TX
     308             :          tail latency */
     309             : 
     310             : /* poll_rx_socket does one recvmmsg batch receive on the given socket
     311             :    index.  Returns the number of packets returned by recvmmsg. */
     312             : 
     313             : static ulong
     314             : poll_rx_socket( fd_sock_tile_t *    ctx,
     315             :                 fd_stem_context_t * stem,
     316             :                 uint                sock_idx,
     317             :                 int                 sock_fd,
     318           0 :                 ushort              proto ) {
     319           0 :   ulong  hdr_sz      = sizeof(fd_eth_hdr_t) + sizeof(fd_ip4_hdr_t) + sizeof(fd_udp_hdr_t);
     320           0 :   ulong  payload_max = FD_NET_MTU-hdr_sz;
     321           0 :   uchar  rx_link     = ctx->link_rx_map[ sock_idx ];
     322           0 :   ushort dport       = ctx->rx_sock_port[ sock_idx ];
     323             : 
     324           0 :   fd_sock_link_rx_t * link = ctx->link_rx + rx_link;
     325           0 :   void * const base       = link->base;
     326           0 :   ulong  const chunk0     = link->chunk0;
     327           0 :   ulong  const wmark      = link->wmark;
     328           0 :   ulong        chunk_next = link->chunk;
     329           0 :   uchar *      cmsg_next  = ctx->batch_cmsg;
     330             : 
     331           0 :   for( ulong j=0UL; j<STEM_BURST; j++ ) {
     332           0 :     ctx->batch_iov[ j ].iov_base = (uchar *)fd_chunk_to_laddr( base, chunk_next ) + hdr_sz;
     333           0 :     ctx->batch_iov[ j ].iov_len  = payload_max;
     334           0 :     ctx->batch_msg[ j ].msg_hdr  = (struct msghdr) {
     335           0 :       .msg_iov        = ctx->batch_iov+j,
     336           0 :       .msg_iovlen     = 1,
     337           0 :       .msg_name       = ctx->batch_sa+j,
     338           0 :       .msg_namelen    = sizeof(struct sockaddr_in),
     339           0 :       .msg_control    = cmsg_next,
     340           0 :       .msg_controllen = FD_SOCK_CMSG_MAX,
     341           0 :     };
     342           0 :     cmsg_next += FD_SOCK_CMSG_MAX;
     343             :     /* Speculatively prepare all chunk indexes for a receive.
     344             :        At function exit, chunks into which a packet was received are
     345             :        committed, all others are freed. */
     346           0 :     chunk_next = fd_dcache_compact_next( chunk_next, FD_NET_MTU, chunk0, wmark );
     347           0 :   }
     348             : 
     349           0 :   int msg_cnt = recvmmsg( sock_fd, ctx->batch_msg, STEM_BURST, MSG_DONTWAIT, NULL );
     350           0 :   if( FD_UNLIKELY( msg_cnt<0 ) ) {
     351           0 :     if( FD_LIKELY( errno==EAGAIN ) ) return 0UL;
     352             :     /* unreachable if socket is in a valid state */
     353           0 :     FD_LOG_ERR(( "recvmmsg failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     354           0 :   }
     355           0 :   long ts = fd_tickcount();
     356           0 :   ctx->metrics.sys_recvmmsg_cnt++;
     357             : 
     358           0 :   if( FD_UNLIKELY( msg_cnt==0 ) ) return 0UL;
     359             : 
     360             :   /* Track the chunk index of the last frag populated, so we can derive
     361             :      the chunk indexes for the next poll_rx_socket call.
     362             :      Guaranteed to be set since msg_cnt>0. */
     363           0 :   ulong last_chunk;
     364             : 
     365           0 :   for( ulong j=0; j<(ulong)msg_cnt; j++ ) {
     366           0 :     uchar * payload         = ctx->batch_iov[ j ].iov_base;
     367           0 :     ulong   payload_sz      = ctx->batch_msg[ j ].msg_len;
     368           0 :     struct sockaddr_in * sa = ctx->batch_msg[ j ].msg_hdr.msg_name;
     369           0 :     ulong frame_sz          = payload_sz + hdr_sz;
     370           0 :     ctx->metrics.rx_bytes_total += frame_sz;
     371           0 :     if( FD_UNLIKELY( sa->sin_family!=AF_INET ) ) {
     372             :       /* unreachable */
     373           0 :       FD_LOG_ERR(( "Received packet with unexpected sin_family %i", sa->sin_family ));
     374           0 :     }
     375             : 
     376           0 :     long daddr = -1;
     377           0 :     struct cmsghdr * cmsg = CMSG_FIRSTHDR( &ctx->batch_msg[ j ].msg_hdr );
     378           0 :     if( FD_LIKELY( cmsg ) ) {
     379           0 :       do {
     380           0 :         if( FD_LIKELY( (cmsg->cmsg_level==IPPROTO_IP) &
     381           0 :                        (cmsg->cmsg_type ==IP_PKTINFO) ) ) {
     382           0 :           struct in_pktinfo const * pi = (struct in_pktinfo const *)CMSG_DATA( cmsg );
     383           0 :           daddr = pi->ipi_addr.s_addr;
     384           0 :         }
     385           0 :         cmsg = CMSG_NXTHDR( &ctx->batch_msg[ j ].msg_hdr, cmsg );
     386           0 :       } while( FD_UNLIKELY( cmsg ) ); /* optimize for 1 cmsg */
     387           0 :     }
     388           0 :     if( FD_UNLIKELY( daddr<0L ) ) {
     389             :       /* unreachable because IP_PKTINFO was set */
     390           0 :       FD_LOG_ERR(( "Missing IP_PKTINFO on incoming packet" ));
     391           0 :     }
     392             : 
     393           0 :     fd_eth_hdr_t * eth_hdr    = (fd_eth_hdr_t *)( payload-42UL );
     394           0 :     fd_ip4_hdr_t * ip_hdr     = (fd_ip4_hdr_t *)( payload-28UL );
     395           0 :     fd_udp_hdr_t * udp_hdr    = (fd_udp_hdr_t *)( payload- 8UL );
     396           0 :     memset( eth_hdr->dst, 0, 6 );
     397           0 :     memset( eth_hdr->src, 0, 6 );
     398           0 :     eth_hdr->net_type = fd_ushort_bswap( FD_ETH_HDR_TYPE_IP );
     399           0 :     *ip_hdr = (fd_ip4_hdr_t) {
     400           0 :       .verihl      = FD_IP4_VERIHL( 4, 5 ),
     401           0 :       .net_tot_len = fd_ushort_bswap( (ushort)( payload_sz+28UL ) ),
     402           0 :       .ttl         = 1,
     403           0 :       .protocol    = FD_IP4_HDR_PROTOCOL_UDP,
     404           0 :     };
     405           0 :     uint daddr_ = (uint)(ulong)daddr;
     406           0 :     memcpy( ip_hdr->saddr_c, &sa->sin_addr.s_addr, 4 );
     407           0 :     memcpy( ip_hdr->daddr_c, &daddr_,              4 );
     408           0 :     *udp_hdr = (fd_udp_hdr_t) {
     409           0 :       .net_sport = sa->sin_port,
     410           0 :       .net_dport = (ushort)fd_ushort_bswap( (ushort)dport ),
     411           0 :       .net_len   = (ushort)fd_ushort_bswap( (ushort)( payload_sz+8UL ) ),
     412           0 :       .check     = 0
     413           0 :     };
     414             : 
     415           0 :     ctx->metrics.rx_pkt_cnt++;
     416           0 :     ulong chunk = fd_laddr_to_chunk( base, eth_hdr );
     417           0 :     ulong sig   = fd_disco_netmux_sig( sa->sin_addr.s_addr, fd_ushort_bswap( sa->sin_port ), sa->sin_addr.s_addr, proto, hdr_sz );
     418           0 :     ulong tspub = fd_frag_meta_ts_comp( ts );
     419             : 
     420             :     /* When a message arrives on the repair intake port, it is sent
     421             :        to the shred tile, unless it is a ping message (identified by
     422             :        the frame size), then it is sent to the repair tile.
     423             :        The repair tile does not own any sockets, so we look up the
     424             :        net_repair link directly.*/
     425           0 :     if( FD_UNLIKELY( sock_idx==ctx->repair_shred_sock_idx && frame_sz==REPAIR_PING_SZ ) ) {
     426           0 :       fd_sock_link_rx_t * repair_link = ctx->link_rx + ctx->repair_rx;
     427           0 :       uchar * repair_buf = fd_chunk_to_laddr( repair_link->base, repair_link->chunk );
     428           0 :       memcpy( repair_buf, eth_hdr, frame_sz );
     429           0 :       fd_stem_publish( stem, ctx->repair_rx, sig, repair_link->chunk, frame_sz, 0UL, 0UL, tspub );
     430           0 :       repair_link->chunk = fd_dcache_compact_next( repair_link->chunk, FD_NET_MTU, repair_link->chunk0, repair_link->wmark );
     431           0 :     } else {
     432           0 :       fd_stem_publish( stem, rx_link, sig, chunk, frame_sz, 0UL, 0UL, tspub );
     433           0 :     }
     434             : 
     435           0 :     last_chunk = chunk;
     436           0 :   }
     437             : 
     438             :   /* Rewind the chunk index to the first free index. */
     439           0 :   link->chunk = fd_dcache_compact_next( last_chunk, FD_NET_MTU, chunk0, wmark );
     440           0 :   return (ulong)msg_cnt;
     441           0 : }
     442             : 
     443             : static ulong
     444             : poll_rx( fd_sock_tile_t *    ctx,
     445           0 :          fd_stem_context_t * stem ) {
     446           0 :   ulong pkt_cnt = 0UL;
     447           0 :   if( FD_UNLIKELY( ctx->batch_cnt ) ) {
     448           0 :     FD_LOG_ERR(( "Batch is not clean" ));
     449           0 :   }
     450           0 :   ctx->tx_idle_cnt = 0; /* restart TX polling */
     451           0 :   if( FD_UNLIKELY( fd_syscall_poll( ctx->pollfd, ctx->sock_cnt, 0 )<0 ) ) {
     452           0 :     FD_LOG_ERR(( "fd_syscall_poll failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     453           0 :   }
     454           0 :   for( uint j=0UL; j<ctx->sock_cnt; j++ ) {
     455           0 :     if( ctx->pollfd[ j ].revents & (POLLIN|POLLERR) ) {
     456           0 :       pkt_cnt += poll_rx_socket(
     457           0 :         ctx,
     458           0 :         stem,
     459           0 :         j,
     460           0 :         ctx->pollfd[ j ].fd,
     461           0 :         ctx->proto_id[ j ]
     462           0 :       );
     463           0 :     }
     464           0 :     ctx->pollfd[ j ].revents = 0;
     465           0 :   }
     466           0 :   return pkt_cnt;
     467           0 : }
     468             : 
     469             : /* TX PATH (tango->socket) ********************************************/
     470             : 
     471             : static void
     472           0 : flush_tx_batch( fd_sock_tile_t * ctx ) {
     473           0 :   ulong batch_cnt = ctx->batch_cnt;
     474           0 :   for( int j = 0; j < (int)batch_cnt; /* incremented in loop */ ) {
     475           0 :     int remain   = (int)batch_cnt - j;
     476           0 :     int send_cnt = sendmmsg( ctx->tx_sock, ctx->batch_msg + j, (uint)remain, MSG_DONTWAIT );
     477           0 :     if( send_cnt>=0 ) {
     478           0 :       ctx->metrics.sys_sendmmsg_cnt[ FD_METRICS_ENUM_SOCKET_ERROR_V_NO_ERROR_IDX ]++;
     479           0 :     }
     480           0 :     if( FD_UNLIKELY( send_cnt < remain ) ) {
     481           0 :       ctx->metrics.tx_drop_cnt++;
     482           0 :       if( FD_UNLIKELY( send_cnt < 0 ) ) {
     483           0 :         switch( errno ) {
     484           0 :         case EAGAIN:
     485           0 :         case ENOBUFS:
     486           0 :           ctx->metrics.sys_sendmmsg_cnt[ FD_METRICS_ENUM_SOCKET_ERROR_V_SLOW_IDX ]++;
     487           0 :           break;
     488           0 :         case EPERM:
     489           0 :           ctx->metrics.sys_sendmmsg_cnt[ FD_METRICS_ENUM_SOCKET_ERROR_V_PERMISSION_IDX ]++;
     490           0 :           break;
     491           0 :         case ENETUNREACH:
     492           0 :         case EHOSTUNREACH:
     493           0 :           ctx->metrics.sys_sendmmsg_cnt[ FD_METRICS_ENUM_SOCKET_ERROR_V_UNREACHABLE_IDX ]++;
     494           0 :           break;
     495           0 :         case ENONET:
     496           0 :         case ENETDOWN:
     497           0 :         case EHOSTDOWN:
     498           0 :           ctx->metrics.sys_sendmmsg_cnt[ FD_METRICS_ENUM_SOCKET_ERROR_V_DOWN_IDX ]++;
     499           0 :           break;
     500           0 :         default:
     501           0 :           ctx->metrics.sys_sendmmsg_cnt[ FD_METRICS_ENUM_SOCKET_ERROR_V_OTHER_IDX ]++;
     502             :           /* log with NOTICE, since flushing has a significant negative performance impact */
     503           0 :           FD_LOG_NOTICE(( "sendmmsg failed (%i-%s)", errno, fd_io_strerror( errno ) ));
     504           0 :         }
     505             : 
     506             :         /* first message failed, so skip failing message and continue */
     507           0 :         j++;
     508           0 :       } else {
     509             :         /* send_cnt succeeded, so skip those and also the failing message */
     510           0 :         j += send_cnt + 1;
     511             : 
     512             :         /* add the successful count */
     513           0 :         ctx->metrics.tx_pkt_cnt += (ulong)send_cnt;
     514           0 :       }
     515             : 
     516           0 :       continue;
     517           0 :     }
     518             : 
     519             :     /* send_cnt == batch_cnt, so we sent everything */
     520           0 :     ctx->metrics.tx_pkt_cnt += (ulong)send_cnt;
     521           0 :     break;
     522           0 :   }
     523             : 
     524           0 :   ctx->tx_ptr = ctx->tx_scratch0;
     525           0 :   ctx->batch_cnt = 0;
     526           0 : }
     527             : 
     528             : /* before_frag is called when a new frag has been detected.  The sock
     529             :    tile can do early filtering here in the future.  For example, it may
     530             :    want to install routing logic here to take turns with an XDP tile.
     531             :    (Fast path with slow fallback) */
     532             : 
     533             : static inline int
     534             : before_frag( fd_sock_tile_t * ctx    FD_PARAM_UNUSED,
     535             :              ulong            in_idx FD_PARAM_UNUSED,
     536             :              ulong            seq    FD_PARAM_UNUSED,
     537           0 :              ulong            sig ) {
     538           0 :   ulong proto = fd_disco_netmux_sig_proto( sig );
     539           0 :   if( FD_UNLIKELY( proto!=DST_PROTO_OUTGOING ) ) return 1;
     540           0 :   return 0; /* continue */
     541           0 : }
     542             : 
     543             : /* during_frag is called when a new frag passed early filtering.
     544             :    Speculatively copies data into a sendmmsg buffer.  (If all tiles
     545             :    respect backpressure could eliminate this copy) */
     546             : 
     547             : static inline void
     548             : during_frag( fd_sock_tile_t * ctx,
     549             :              ulong            in_idx,
     550             :              ulong            seq FD_PARAM_UNUSED,
     551             :              ulong            sig,
     552             :              ulong            chunk,
     553             :              ulong            sz,
     554           0 :              ulong            ctl FD_PARAM_UNUSED ) {
     555           0 :   if( FD_UNLIKELY( chunk<ctx->link_tx[ in_idx ].chunk0 || chunk>ctx->link_tx[ in_idx ].wmark || sz>FD_NET_MTU ) ) {
     556           0 :     FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu]", chunk, sz, ctx->link_tx[ in_idx ].chunk0, ctx->link_tx[ in_idx ].wmark ));
     557           0 :   }
     558             : 
     559           0 :   ctx->parsed.invalid = 0;
     560             : 
     561           0 :   ulong const hdr_min = sizeof(fd_eth_hdr_t)+sizeof(fd_ip4_hdr_t)+sizeof(fd_udp_hdr_t);
     562           0 :   if( FD_UNLIKELY( sz<hdr_min ) ) {
     563             :     /* FIXME support ICMP messages in the future?
     564             :        Defer the error to after_frag, where we know we weren't
     565             :        overrun. */
     566           0 :     ctx->parsed.invalid = 1;
     567           0 :     return;
     568           0 :   }
     569             : 
     570           0 :   uchar const * frame   = fd_chunk_to_laddr_const( ctx->link_tx[ in_idx ].base, chunk );
     571           0 :   ulong         hdr_sz  = fd_disco_netmux_sig_hdr_sz( sig );
     572           0 :   uchar const * payload = frame+hdr_sz;
     573           0 :   if( FD_UNLIKELY( hdr_sz>sz || hdr_sz<hdr_min ) ) {
     574           0 :     FD_LOG_ERR(( "packet from in_idx=%lu corrupt: hdr_sz=%lu total_sz=%lu",
     575           0 :                  in_idx, hdr_sz, sz ));
     576           0 :   }
     577           0 :   ulong payload_sz = sz-hdr_sz;
     578             : 
     579           0 :   fd_ip4_hdr_t const * ip_hdr  = (fd_ip4_hdr_t const *)( frame  +sizeof(fd_eth_hdr_t) );
     580           0 :   fd_udp_hdr_t const * udp_hdr = (fd_udp_hdr_t const *)( payload-sizeof(fd_udp_hdr_t) );
     581           0 :   ctx->parsed.ip_version  = FD_IP4_GET_VERSION( *ip_hdr );
     582           0 :   ctx->parsed.ip_protocol = ip_hdr->protocol;
     583           0 :   if( FD_UNLIKELY( ( ctx->parsed.ip_version !=4                       ) |
     584           0 :                    ( ctx->parsed.ip_protocol!=FD_IP4_HDR_PROTOCOL_UDP ) ) ) {
     585             :     /* sock tile only supports IPv4 UDP for now.  Defer the error to
     586             :        after_frag, where we know we weren't overrun. */
     587           0 :     ctx->parsed.invalid = 1;
     588           0 :     return;
     589           0 :   }
     590             : 
     591           0 :   ulong msg_sz = sizeof(fd_udp_hdr_t) + payload_sz;
     592             : 
     593           0 :   ulong batch_idx = ctx->batch_cnt;
     594           0 :   FD_DCHECK_CRIT( batch_idx<STEM_BURST, "flow control error" );
     595           0 :   struct mmsghdr *     msg  = ctx->batch_msg + batch_idx;
     596           0 :   struct sockaddr_in * sa   = ctx->batch_sa  + batch_idx;
     597           0 :   struct iovec   *     iov  = ctx->batch_iov + batch_idx;
     598           0 :   struct cmsghdr *     cmsg = (void *)( (ulong)ctx->batch_cmsg + batch_idx*FD_SOCK_CMSG_MAX );
     599           0 :   uchar *              buf  = ctx->tx_ptr;
     600             : 
     601           0 :   *iov = (struct iovec) {
     602           0 :     .iov_base = buf,
     603           0 :     .iov_len  = msg_sz,
     604           0 :   };
     605           0 :   sa->sin_family      = AF_INET;
     606           0 :   sa->sin_addr.s_addr = FD_LOAD( uint, ip_hdr->daddr_c );
     607           0 :   sa->sin_port        = 0; /* ignored */
     608             : 
     609           0 :   cmsg->cmsg_level = IPPROTO_IP;
     610           0 :   cmsg->cmsg_type  = IP_PKTINFO;
     611           0 :   cmsg->cmsg_len   = CMSG_LEN( sizeof(struct in_pktinfo) );
     612           0 :   struct in_pktinfo * pi = (struct in_pktinfo *)CMSG_DATA( cmsg );
     613           0 :   pi->ipi_ifindex         = 0;
     614           0 :   pi->ipi_addr.s_addr     = 0;
     615           0 :   pi->ipi_spec_dst.s_addr = fd_uint_if( !!ip_hdr->saddr, ip_hdr->saddr, ctx->bind_address );
     616             : 
     617           0 :   *msg = (struct mmsghdr) {
     618           0 :     .msg_hdr = {
     619           0 :       .msg_name       = sa,
     620           0 :       .msg_namelen    = sizeof(struct sockaddr_in),
     621           0 :       .msg_iov        = iov,
     622           0 :       .msg_iovlen     = 1,
     623           0 :       .msg_control    = cmsg,
     624           0 :       .msg_controllen = CMSG_LEN( sizeof(struct in_pktinfo) )
     625           0 :     }
     626           0 :   };
     627             : 
     628           0 :   memcpy( buf, udp_hdr, sizeof(fd_udp_hdr_t) );
     629           0 :   fd_memcpy( buf+sizeof(fd_udp_hdr_t), payload, payload_sz );
     630           0 :   ctx->metrics.tx_bytes_total += sz;
     631           0 : }
     632             : 
     633             : /* after_frag is called when a frag was copied into a sendmmsg buffer. */
     634             : 
     635             : static void
     636             : after_frag( fd_sock_tile_t *    ctx,
     637             :             ulong               in_idx,
     638             :             ulong               seq    FD_PARAM_UNUSED,
     639             :             ulong               sig    FD_PARAM_UNUSED,
     640             :             ulong               sz,
     641             :             ulong               tsorig FD_PARAM_UNUSED,
     642             :             ulong               tspub  FD_PARAM_UNUSED,
     643           0 :             fd_stem_context_t * stem   FD_PARAM_UNUSED ) {
     644             :   /* Commit the packet added in during_frag.  during_frag defers fatal
     645             :      errors to here (where we know we weren't overrun) by setting the
     646             :      invalid flag. */
     647             : 
     648           0 :   if( FD_UNLIKELY( ctx->parsed.invalid ) ) {
     649           0 :     ulong const hdr_min = sizeof(fd_eth_hdr_t)+sizeof(fd_ip4_hdr_t)+sizeof(fd_udp_hdr_t);
     650           0 :     if( FD_UNLIKELY( sz<hdr_min ) ) {
     651             :       /* FIXME support ICMP messages in the future? */
     652           0 :       FD_LOG_ERR(( "packet too small %lu (in_idx=%lu)", sz, in_idx ));
     653           0 :     }
     654           0 :     if( FD_UNLIKELY( ( ctx->parsed.ip_version !=4                       ) |
     655           0 :                      ( ctx->parsed.ip_protocol!=FD_IP4_HDR_PROTOCOL_UDP ) ) ) {
     656           0 :       FD_LOG_ERR(( "packet from in_idx=%lu: sock tile only supports IPv4 UDP for now", in_idx ));
     657           0 :     }
     658           0 :   }
     659             : 
     660           0 :   ctx->tx_idle_cnt = 0;
     661           0 :   ctx->batch_cnt++;
     662             :   /* Technically leaves a gap.  sz is always larger than the payload
     663             :      written to tx_ptr because Ethernet & IPv4 headers were stripped. */
     664           0 :   ctx->tx_ptr += fd_ulong_align_up( sz, FD_CHUNK_ALIGN );
     665             : 
     666           0 :   if( ctx->batch_cnt >= STEM_BURST ) {
     667           0 :     flush_tx_batch( ctx );
     668           0 :   }
     669           0 : }
     670             : 
     671             : /* End TX path ********************************************************/
     672             : 
     673             : /* after_credit is called every stem iteration when there are enough
     674             :    flow control credits to publish a burst of fragments. */
     675             : 
     676             : static inline void
     677             : after_credit( fd_sock_tile_t *    ctx,
     678             :               fd_stem_context_t * stem,
     679             :               int *               poll_in FD_PARAM_UNUSED,
     680           0 :               int *               charge_busy ) {
     681           0 :   if( ctx->tx_idle_cnt > 512 ) {
     682           0 :     if( ctx->batch_cnt ) {
     683           0 :       flush_tx_batch( ctx );
     684           0 :     }
     685           0 :     ulong pkt_cnt = poll_rx( ctx, stem );
     686           0 :     *charge_busy = pkt_cnt!=0;
     687           0 :   }
     688           0 :   ctx->tx_idle_cnt++;
     689           0 : }
     690             : 
     691             : static void
     692           0 : metrics_write( fd_sock_tile_t * ctx ) {
     693           0 :   FD_MCNT_SET( SOCK, SYSCALL_RX,              ctx->metrics.sys_recvmmsg_cnt     );
     694           0 :   FD_MCNT_ENUM_COPY( SOCK, SYSCALL_TX,        ctx->metrics.sys_sendmmsg_cnt     );
     695           0 :   FD_MCNT_SET( SOCK, PKT_RX,                  ctx->metrics.rx_pkt_cnt           );
     696           0 :   FD_MCNT_SET( SOCK, PKT_TX,                  ctx->metrics.tx_pkt_cnt           );
     697           0 :   FD_MCNT_SET( SOCK, PKT_TX_FAILED,          ctx->metrics.tx_drop_cnt          );
     698           0 :   FD_MCNT_SET( SOCK, PKT_TX_BYTES,            ctx->metrics.tx_bytes_total       );
     699           0 :   FD_MCNT_SET( SOCK, PKT_RX_BYTES,            ctx->metrics.rx_bytes_total       );
     700           0 : }
     701             : 
     702             : static ulong
     703             : rlimit_file_cnt( fd_topo_t const *      topo,
     704           0 :                  fd_topo_tile_t const * tile ) {
     705           0 :   fd_sock_tile_t * ctx = fd_topo_obj_laddr( topo, tile->tile_obj_id );
     706           0 :   return RX_SOCK_FD_MIN + ctx->sock_cnt;
     707           0 : }
     708             : 
     709           0 : #define STEM_CALLBACK_CONTEXT_TYPE  fd_sock_tile_t
     710           0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_sock_tile_t)
     711             : 
     712           0 : #define STEM_LAZY ((long)10e6) /* 10ms */
     713             : 
     714           0 : #define STEM_CALLBACK_METRICS_WRITE       metrics_write
     715           0 : #define STEM_CALLBACK_AFTER_CREDIT        after_credit
     716           0 : #define STEM_CALLBACK_BEFORE_FRAG         before_frag
     717           0 : #define STEM_CALLBACK_DURING_FRAG         during_frag
     718           0 : #define STEM_CALLBACK_AFTER_FRAG          after_frag
     719             : 
     720             : #include "../../stem/fd_stem.c"
     721             : 
     722             : fd_topo_run_tile_t fd_tile_sock = {
     723             :   .name                     = "sock",
     724             :   .rlimit_file_cnt_fn       = rlimit_file_cnt,
     725             :   .populate_allowed_seccomp = populate_allowed_seccomp,
     726             :   .populate_allowed_fds     = populate_allowed_fds,
     727             :   .scratch_align            = scratch_align,
     728             :   .scratch_footprint        = scratch_footprint,
     729             :   .privileged_init          = privileged_init,
     730             :   .unprivileged_init        = unprivileged_init,
     731             :   .run                      = stem_run,
     732             : };

Generated by: LCOV version 1.14