Line data Source code
1 : /* This stage disables the "tx-udp-segmentation" offload on the loopback 2 : interface. If left enabled, AF_XDP will drop loopback UDP packets sent 3 : by processes that enable TX segmentation via SOL_UDP/UDP_SEGMENT sockopt 4 : or cmsg. 5 : 6 : TLDR tx-udp-segmentation and AF_XDP are incompatible. */ 7 : 8 : #include "configure.h" 9 : 10 : #include "fd_ethtool_ioctl.h" 11 : 12 0 : #define NAME "ethtool-loopback" 13 : 14 : static int 15 0 : enabled( fd_config_t const * config ) { 16 : 17 : /* only enable if network stack is XDP */ 18 0 : if( 0!=strcmp( config->net.provider, "xdp" ) ) return 0; 19 : 20 0 : return 1; 21 0 : } 22 : 23 : static void 24 : init_perm( fd_cap_chk_t * chk, 25 0 : fd_config_t const * config FD_PARAM_UNUSED ) { 26 0 : fd_cap_chk_root( chk, NAME, "disable loopback " FD_ETHTOOL_FEATURE_TXUDPSEG " with `ethtool --offload lo " FD_ETHTOOL_FEATURE_TXUDPSEG " off`" ); 27 0 : } 28 : 29 : static void 30 0 : init( fd_config_t const * config FD_PARAM_UNUSED ) { 31 0 : fd_ethtool_ioctl_t ioc; 32 0 : if( FD_UNLIKELY( &ioc != fd_ethtool_ioctl_init( &ioc, "lo" ) ) ) 33 0 : FD_LOG_ERR(( "error configuring network device (lo), unable to init ethtool ioctl" )); 34 : 35 0 : FD_TEST( 0==fd_ethtool_ioctl_feature_set( &ioc, FD_ETHTOOL_FEATURE_TXUDPSEG, 0 ) ); 36 : 37 0 : fd_ethtool_ioctl_fini( &ioc ); 38 0 : } 39 : 40 : static configure_result_t 41 : check( fd_config_t const * config FD_PARAM_UNUSED, 42 0 : int check_type FD_PARAM_UNUSED ) { 43 0 : fd_ethtool_ioctl_t ioc; 44 0 : if( FD_UNLIKELY( &ioc != fd_ethtool_ioctl_init( &ioc, "lo" ) ) ) 45 0 : FD_LOG_ERR(( "error configuring network device (lo), unable to init ethtool ioctl" )); 46 : 47 0 : int udpseg_active; 48 0 : FD_TEST( 0==fd_ethtool_ioctl_feature_test( &ioc, FD_ETHTOOL_FEATURE_TXUDPSEG, &udpseg_active ) ); 49 : 50 0 : fd_ethtool_ioctl_fini( &ioc ); 51 : 52 0 : if( udpseg_active ) { 53 0 : NOT_CONFIGURED( "device `lo` has " FD_ETHTOOL_FEATURE_TXUDPSEG " enabled. Should be disabled" ); 54 0 : } 55 : 56 0 : CONFIGURE_OK(); 57 0 : } 58 : 59 : configure_stage_t fd_cfg_stage_ethtool_loopback = { 60 : .name = NAME, 61 : .always_recreate = 0, 62 : .enabled = enabled, 63 : .init_perm = init_perm, 64 : .fini_perm = NULL, 65 : .init = init, 66 : .fini = NULL, 67 : .check = check, 68 : }; 69 : 70 : #undef NAME