@@ -11,7 +11,7 @@ mod statistics;
1111
1212use crate :: packet_processor:: start_router;
1313use crate :: statistics:: MetricsServer ;
14- use args:: { CmdArgs , Parser } ;
14+ use args:: { LaunchConfiguration , TracingConfigSection } ;
1515
1616use drivers:: dpdk:: DriverDpdk ;
1717use drivers:: kernel:: DriverKernel ;
@@ -53,71 +53,72 @@ fn setup_pipeline<Buf: PacketBufferMut>() -> DynPipeline<Buf> {
5353 }
5454}
5555
56- fn process_tracing_cmds ( args : & CmdArgs ) {
57- if let Some ( tracing) = args . tracing ( )
56+ fn process_tracing_cmds ( cfg : & TracingConfigSection ) {
57+ if let Some ( tracing) = & cfg . config
5858 && let Err ( e) = get_trace_ctl ( ) . setup_from_string ( tracing)
5959 {
6060 error ! ( "Invalid tracing configuration: {e}" ) ;
6161 panic ! ( "Invalid tracing configuration: {e}" ) ;
6262 }
63- if args. show_tracing_tags ( ) {
64- let out = get_trace_ctl ( )
65- . as_string_by_tag ( )
66- . unwrap_or_else ( |e| e. to_string ( ) ) ;
67- println ! ( "{out}" ) ;
68- std:: process:: exit ( 0 ) ;
63+ match cfg. show . tags {
64+ args:: TracingDisplayOption :: Hide => { }
65+ args:: TracingDisplayOption :: Show => {
66+ let out = get_trace_ctl ( )
67+ . as_string_by_tag ( )
68+ . unwrap_or_else ( |e| e. to_string ( ) ) ;
69+ println ! ( "{out}" ) ;
70+ std:: process:: exit ( 0 ) ;
71+ }
6972 }
70- if args . show_tracing_targets ( ) {
73+ if cfg . show . targets == args :: TracingDisplayOption :: Show {
7174 let out = get_trace_ctl ( )
7275 . as_string ( )
7376 . unwrap_or_else ( |e| e. to_string ( ) ) ;
7477 println ! ( "{out}" ) ;
7578 std:: process:: exit ( 0 ) ;
7679 }
77- if args. tracing_config_generate ( ) {
78- let out = get_trace_ctl ( )
79- . as_config_string ( )
80- . unwrap_or_else ( |e| e. to_string ( ) ) ;
81- println ! ( "{out}" ) ;
82- std:: process:: exit ( 0 ) ;
83- }
80+ // if args.tracing_config_generate() {
81+ // let out = get_trace_ctl()
82+ // .as_config_string()
83+ // .unwrap_or_else(|e| e.to_string());
84+ // println!("{out}");
85+ // std::process::exit(0);
86+ // }
8487}
8588
8689fn main ( ) {
90+ let launch_config = LaunchConfiguration :: inherit ( ) ;
8791 init_logging ( ) ;
88- let args = CmdArgs :: parse ( ) ;
89- process_tracing_cmds ( & args ) ;
92+ info ! ( "launch config: {launch_config:?}" ) ;
93+ process_tracing_cmds ( & launch_config . tracing ) ;
9094
9195 info ! ( "Starting gateway process..." ) ;
9296
9397 let ( stop_tx, stop_rx) = std:: sync:: mpsc:: channel ( ) ;
9498 ctrlc:: set_handler ( move || stop_tx. send ( ( ) ) . expect ( "Error sending SIGINT signal" ) )
9599 . expect ( "failed to set SIGINT handler" ) ;
96100
97- let grpc_addr = match args. get_grpc_address ( ) {
98- Ok ( addr) => addr,
99- Err ( e) => {
100- error ! ( "Invalid gRPC address configuration: {e}" ) ;
101- panic ! ( "Management service configuration error. Aborting..." ) ;
102- }
103- } ;
101+ let grpc_addr = launch_config. config_server . address ;
104102
105103 /* router parameters */
106- let Ok ( config) = RouterParamsBuilder :: default ( )
107- . metrics_addr ( args . metrics_address ( ) )
108- . cli_sock_path ( args . cli_sock_path ( ) )
109- . cpi_sock_path ( args . cpi_sock_path ( ) )
110- . frr_agent_path ( args . frr_agent_path ( ) )
104+ let config = match RouterParamsBuilder :: default ( )
105+ . metrics_addr ( launch_config . metrics . address )
106+ . cli_sock_path ( launch_config . cli . cli_sock_path )
107+ . cpi_sock_path ( launch_config . routing . control_plane_socket )
108+ . frr_agent_path ( launch_config . routing . frr_agent_socket )
111109 . build ( )
112- else {
113- error ! ( "Bad router configuration" ) ;
114- panic ! ( "Bad router configuration" ) ;
110+ {
111+ Ok ( config) => config,
112+ Err ( e) => {
113+ error ! ( "error building router parameters: {e}" ) ;
114+ panic ! ( "error building router parameters: {e}" ) ;
115+ }
115116 } ;
116117
117118 // start the router; returns control-plane handles and a pipeline factory (Arc<... Fn() -> DynPipeline<_> >)
118119 let setup = start_router ( config) . expect ( "failed to start router" ) ;
119120
120- MetricsServer :: new ( args . metrics_address ( ) , setup. stats ) ;
121+ let _metrics_server = MetricsServer :: new ( launch_config . metrics . address , setup. stats ) ;
121122
122123 /* pipeline builder */
123124 let pipeline_factory = setup. pipeline ;
@@ -135,25 +136,19 @@ fn main() {
135136 . expect ( "Failed to start gRPC server" ) ;
136137
137138 /* start driver with the provided pipeline builder */
138- match args. get_driver_name ( ) {
139- "dpdk" => {
140- info ! ( "Using driver DPDK..." ) ;
141- DriverDpdk :: start ( args. eal_params ( ) , & setup_pipeline) ;
142- }
143- "kernel" => {
144- info ! ( "Using driver kernel..." ) ;
145- DriverKernel :: start (
146- args. kernel_interfaces ( ) ,
147- args. kernel_num_workers ( ) ,
148- & pipeline_factory,
149- ) ;
139+ let _keep = match & launch_config. driver {
140+ args:: DriverConfigSection :: Dpdk ( dpdk_driver_config) => {
141+ let ( eal, devices) =
142+ DriverDpdk :: start ( dpdk_driver_config. eal_args . clone ( ) , & setup_pipeline) ;
143+ info ! ( "Now using driver DPDK..." ) ;
144+ Some ( ( eal, devices) )
150145 }
151- other => {
152- error ! ( "Unknown driver '{other}'. Aborting..." ) ;
153- panic ! ( "Packet processing pipeline failed to start. Aborting..." ) ;
146+ args:: DriverConfigSection :: Kernel ( kernel_driver_config) => {
147+ DriverKernel :: start ( & kernel_driver_config. interfaces , 2 , & pipeline_factory) ;
148+ info ! ( "Now using driver kernel..." ) ;
149+ None
154150 }
155- }
156-
151+ } ;
157152 stop_rx. recv ( ) . expect ( "failed to receive stop signal" ) ;
158153 info ! ( "Shutting down dataplane" ) ;
159154 std:: process:: exit ( 0 ) ;
0 commit comments