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 : ulong wksp_id = fd_topo_find_wksp( topo, "netbase" );
22 0 : if( FD_UNLIKELY( wksp_id==ULONG_MAX ) ) {
23 0 : FD_LOG_ERR(( "netbase workspace not found" ));
24 0 : }
25 0 : fd_topo_wksp_t * netbase = &topo->workspaces[ wksp_id ];
26 0 : ulong net_wksp_id = fd_topo_find_wksp( topo, "net" );
27 0 : if( FD_UNLIKELY( net_wksp_id==ULONG_MAX ) ) FD_LOG_ERR(( "net workspace not found" ));
28 0 : fd_topo_wksp_t * net_wksp = &topo->workspaces[ net_wksp_id ];
29 :
30 0 : ulong tile_id = fd_topo_find_tile( topo, "netlnk", 0UL );
31 0 : if( FD_UNLIKELY( tile_id==ULONG_MAX ) ) {
32 0 : FD_LOG_ERR(( "netlnk tile not found" ));
33 0 : }
34 0 : fd_topo_tile_t * tile = &topo->tiles[ tile_id ];
35 0 : ulong net_tile_id = fd_topo_find_tile( topo, "net", 0UL );
36 0 : if( FD_UNLIKELY( net_tile_id==ULONG_MAX ) ) FD_LOG_ERR(( "net tile not found" ));
37 0 : fd_topo_tile_t * net_tile = &topo->tiles[ net_tile_id ];
38 :
39 0 : fd_bootinfo_check_layout( config );
40 0 : fd_topo_join_workspace( topo, netbase, FD_SHMEM_JOIN_MODE_READ_ONLY, FD_TOPO_CORE_DUMP_LEVEL_DISABLED );
41 0 : fd_topo_join_workspace( topo, net_wksp, FD_SHMEM_JOIN_MODE_READ_ONLY, FD_TOPO_CORE_DUMP_LEVEL_DISABLED );
42 :
43 0 : puts( "\nINTERFACES\n" );
44 0 : fd_netdev_tbl_join_t netdev[1];
45 0 : FD_TEST( fd_netdev_tbl_join( netdev, fd_topo_obj_laddr( topo, tile->netlink.netdev_tbl_obj_id ) ) );
46 0 : fd_netdev_tbl_fprintf( netdev, stdout );
47 0 : fd_netdev_tbl_leave( netdev );
48 :
49 0 : puts( "\nIPv4 ROUTES (main)\n" );
50 0 : fd_fib4_t fib4_main[1];
51 0 : FD_TEST( fd_net_tile_fib4_join( fib4_main, topo, net_tile, 1 ) );
52 0 : fd_fib4_fprintf( fib4_main, stdout );
53 0 : fd_fib4_leave( fib4_main );
54 :
55 0 : puts( "\nIPv4 ROUTES (local)\n" );
56 0 : fd_fib4_t fib4_local[1];
57 0 : FD_TEST( fd_net_tile_fib4_join( fib4_local, topo, net_tile, 0 ) );
58 0 : fd_fib4_fprintf( fib4_local, stdout );
59 0 : fd_fib4_leave( fib4_local );
60 :
61 0 : printf( "\nNEIGHBOR TABLE (%.16s)\n\n", tile->netlink.neigh_if );
62 0 : fd_neigh4_hmap_t neigh4[1];
63 0 : ulong neigh4_obj_id = tile->netlink.neigh4_obj_id;
64 0 : ulong ele_max = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.ele_max", neigh4_obj_id );
65 0 : ulong probe_max = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.probe_max", neigh4_obj_id );
66 0 : ulong seed = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.seed", neigh4_obj_id );
67 0 : FD_TEST( (ele_max!=ULONG_MAX) & (probe_max!=ULONG_MAX) & (seed!=ULONG_MAX) );
68 0 : FD_TEST( fd_neigh4_hmap_join( neigh4, fd_topo_obj_laddr( topo, neigh4_obj_id ), ele_max, probe_max, seed ) );
69 0 : fd_neigh4_hmap_fprintf( neigh4, stdout );
70 0 : fd_neigh4_hmap_leave( neigh4 );
71 :
72 0 : puts( "" );
73 0 : }
74 :
75 : action_t fd_action_netconf = {
76 : .name = "netconf",
77 : .args = NULL,
78 : .fn = netconf_cmd_fn,
79 : .require_config = 0,
80 : .perm = NULL,
81 : .description = "Print network configuration",
82 : .detail = "Connects to a running validator and prints the networking state its\n"
83 : "net tiles have discovered, including the routing (FIB), interface (MIB), and\n"
84 : "neighbor (ARP) tables.",
85 : };
|