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