Line data Source code
1 : #include "../fd_config.h" 2 : #include "../fd_action.h" 3 : 4 : #include "../../../waltz/ip/fd_fib4.h" 5 : #include "../../../waltz/mib/fd_netdev_tbl.h" 6 : #include "../../../waltz/neigh/fd_neigh4_map.h" 7 : #include "../../../util/pod/fd_pod_format.h" 8 : 9 : #include <net/if.h> 10 : #include <stdio.h> 11 : 12 : void 13 : netconf_cmd_fn( args_t * args, 14 0 : config_t * config ) { 15 0 : (void)args; 16 : 17 0 : fd_topo_t * topo = &config->topo; 18 0 : ulong wksp_id = fd_topo_find_wksp( topo, "netbase" ); 19 0 : if( FD_UNLIKELY( wksp_id==ULONG_MAX ) ) { 20 0 : FD_LOG_ERR(( "netbase workspace not found" )); 21 0 : } 22 0 : fd_topo_wksp_t * netbase = &topo->workspaces[ wksp_id ]; 23 : 24 0 : ulong tile_id = fd_topo_find_tile( topo, "netlnk", 0UL ); 25 0 : if( FD_UNLIKELY( tile_id==ULONG_MAX ) ) { 26 0 : FD_LOG_ERR(( "netlnk tile not found" )); 27 0 : } 28 0 : fd_topo_tile_t * tile = &topo->tiles[ tile_id ]; 29 : 30 0 : fd_topo_join_workspace( topo, netbase, FD_SHMEM_JOIN_MODE_READ_ONLY, FD_TOPO_CORE_DUMP_LEVEL_DISABLED ); 31 : 32 0 : puts( "\nINTERFACES\n" ); 33 0 : fd_netdev_tbl_join_t netdev[1]; 34 0 : FD_TEST( fd_netdev_tbl_join( netdev, fd_topo_obj_laddr( topo, tile->netlink.netdev_tbl_obj_id ) ) ); 35 0 : fd_netdev_tbl_fprintf( netdev, stdout ); 36 0 : fd_netdev_tbl_leave( netdev ); 37 : 38 0 : puts( "\nIPv4 ROUTES (main)\n" ); 39 0 : fd_fib4_t fib4_main[1]; 40 0 : FD_TEST( fd_fib4_join( fib4_main, fd_topo_obj_laddr( topo, tile->netlink.fib4_main_obj_id ) ) ); 41 0 : fd_fib4_fprintf( fib4_main, stdout ); 42 0 : fd_fib4_leave( fib4_main ); 43 : 44 0 : puts( "\nIPv4 ROUTES (local)\n" ); 45 0 : fd_fib4_t fib4_local[1]; 46 0 : FD_TEST( fd_fib4_join( fib4_local, fd_topo_obj_laddr( topo, tile->netlink.fib4_local_obj_id ) ) ); 47 0 : fd_fib4_fprintf( fib4_local, stdout ); 48 0 : fd_fib4_leave( fib4_local ); 49 : 50 0 : printf( "\nNEIGHBOR TABLE (%.16s)\n\n", tile->netlink.neigh_if ); 51 0 : fd_neigh4_hmap_t neigh4[1]; 52 0 : ulong neigh4_obj_id = tile->netlink.neigh4_obj_id; 53 0 : ulong ele_max = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.ele_max", neigh4_obj_id ); 54 0 : ulong probe_max = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.probe_max", neigh4_obj_id ); 55 0 : ulong seed = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.seed", neigh4_obj_id ); 56 0 : FD_TEST( (ele_max!=ULONG_MAX) & (probe_max!=ULONG_MAX) & (seed!=ULONG_MAX) ); 57 0 : FD_TEST( fd_neigh4_hmap_join( neigh4, fd_topo_obj_laddr( topo, neigh4_obj_id ), ele_max, probe_max, seed ) ); 58 0 : fd_neigh4_hmap_fprintf( neigh4, stdout ); 59 0 : fd_neigh4_hmap_leave( neigh4 ); 60 : 61 0 : puts( "" ); 62 0 : } 63 : 64 : action_t fd_action_netconf = { 65 : .name = "netconf", 66 : .args = NULL, 67 : .fn = netconf_cmd_fn, 68 : .require_config = 1, 69 : .perm = NULL, 70 : .description = "Print network configuration", 71 : .detail = "Connects to a running validator and prints the networking state its\n" 72 : "net tiles have discovered, including the routing (FIB), interface (MIB), and\n" 73 : "neighbor (ARP) tables.", 74 : };