@@ -79,20 +79,6 @@ impl ConfigChannelRequest {
7979 }
8080}
8181
82- /// A configuration processor entity. This is the RPC-independent entity responsible for
83- /// accepting/rejecting configurations, storing them in the configuration database and
84- /// applying them.
85- pub ( crate ) struct ConfigProcessor {
86- config_db : GwConfigDatabase ,
87- rx : mpsc:: Receiver < ConfigChannelRequest > ,
88- router_ctl : RouterCtlSender ,
89- vpc_mgr : VpcManager < RequiredInformationBase > ,
90- vpcmapw : VpcMapWriter < VpcMapName > ,
91- nattablew : NatTablesWriter ,
92- natallocatorw : NatAllocatorWriter ,
93- vnitablesw : VpcDiscTablesWriter ,
94- vpc_stats_store : Arc < VpcStatsStore > ,
95- }
9682/// Populate FRR status into the dataplane status structure
9783pub async fn populate_status_with_frr (
9884 status : & mut DataplaneStatus ,
@@ -103,25 +89,47 @@ pub async fn populate_status_with_frr(
10389 if let Ok ( Some ( FrrAppliedConfig { genid, .. } ) ) = router_ctl. get_frr_applied_config ( ) . await {
10490 frr = frr. set_applied_config_gen ( genid) ;
10591 }
106-
10792 status. set_frr_status ( frr) ;
10893}
10994
95+ /// A configuration processor entity. This is the RPC-independent entity responsible for
96+ /// accepting/rejecting configurations, storing them in the configuration database and
97+ /// applying them.
98+ pub ( crate ) struct ConfigProcessor {
99+ config_db : GwConfigDatabase ,
100+ rx : mpsc:: Receiver < ConfigChannelRequest > ,
101+ vpc_mgr : VpcManager < RequiredInformationBase > ,
102+ proc_params : ConfigProcessorParams ,
103+ }
104+
105+ pub struct ConfigProcessorParams {
106+ // channel to router
107+ pub router_ctl : RouterCtlSender ,
108+
109+ // writer for vpc mapping table
110+ pub vpcmapw : VpcMapWriter < VpcMapName > ,
111+
112+ // writer for stateless NAT tables
113+ pub nattablesw : NatTablesWriter ,
114+
115+ // writer for stateful NAT allocator
116+ pub natallocatorw : NatAllocatorWriter ,
117+
118+ // writer for VPC routing table
119+ pub vpcdtablesw : VpcDiscTablesWriter ,
120+
121+ // store for vpc stats
122+ pub vpc_stats_store : Arc < VpcStatsStore > ,
123+ }
124+
110125impl ConfigProcessor {
111126 const CHANNEL_SIZE : usize = 1 ; // This should not be changed
112127
113128 /////////////////////////////////////////////////////////////////////////////////
114129 /// Create a [`ConfigProcessor`]
115130 /////////////////////////////////////////////////////////////////////////////////
116131 #[ must_use]
117- pub ( crate ) fn new (
118- router_ctl : RouterCtlSender ,
119- vpcmapw : VpcMapWriter < VpcMapName > ,
120- nattablew : NatTablesWriter ,
121- natallocatorw : NatAllocatorWriter ,
122- vnitablesw : VpcDiscTablesWriter ,
123- vpc_stats_store : Arc < stats:: VpcStatsStore > ,
124- ) -> ( Self , Sender < ConfigChannelRequest > ) {
132+ pub ( crate ) fn new ( proc_params : ConfigProcessorParams ) -> ( Self , Sender < ConfigChannelRequest > ) {
125133 debug ! ( "Creating config processor..." ) ;
126134 let ( tx, rx) = mpsc:: channel ( Self :: CHANNEL_SIZE ) ;
127135
@@ -133,16 +141,11 @@ impl ConfigProcessor {
133141 let netlink = Arc :: new ( netlink) ;
134142 let vpc_mgr = VpcManager :: < RequiredInformationBase > :: new ( netlink) ;
135143
136- let processor = Self {
144+ let processor = ConfigProcessor {
137145 config_db : GwConfigDatabase :: new ( ) ,
138146 rx,
139- router_ctl,
140147 vpc_mgr,
141- vpcmapw,
142- nattablew,
143- natallocatorw,
144- vnitablesw,
145- vpc_stats_store,
148+ proc_params,
146149 } ;
147150 ( processor, tx)
148151 }
@@ -190,15 +193,16 @@ impl ConfigProcessor {
190193 debug ! ( "The current config is {}" , current. genid( ) ) ;
191194 }
192195
196+ // FIXME(fredi): pass &mut self.params
193197 apply_gw_config (
194198 & self . vpc_mgr ,
195199 & mut config,
196200 current. as_deref ( ) ,
197- & mut self . router_ctl ,
198- & mut self . vpcmapw ,
199- & mut self . nattablew ,
200- & mut self . natallocatorw ,
201- & mut self . vnitablesw ,
201+ & mut self . proc_params . router_ctl ,
202+ & mut self . proc_params . vpcmapw ,
203+ & mut self . proc_params . nattablesw ,
204+ & mut self . proc_params . natallocatorw ,
205+ & mut self . proc_params . vpcdtablesw ,
202206 )
203207 . await ?;
204208
@@ -219,15 +223,16 @@ impl ConfigProcessor {
219223 let rollback_cfg = current. unwrap_or ( ExternalConfig :: BLANK_GENID ) ;
220224 info ! ( "Rolling back to config '{rollback_cfg}'..." ) ;
221225 if let Some ( prior) = self . config_db . get_mut ( rollback_cfg) {
226+ // FIXME(fredi): pass &mut self.params
222227 let _ = apply_gw_config (
223228 & self . vpc_mgr ,
224229 prior,
225230 None ,
226- & mut self . router_ctl ,
227- & mut self . vpcmapw ,
228- & mut self . nattablew ,
229- & mut self . natallocatorw ,
230- & mut self . vnitablesw ,
231+ & mut self . proc_params . router_ctl ,
232+ & mut self . proc_params . vpcmapw ,
233+ & mut self . proc_params . nattablesw ,
234+ & mut self . proc_params . natallocatorw ,
235+ & mut self . proc_params . vpcdtablesw ,
231236 )
232237 . await ;
233238 }
@@ -262,9 +267,11 @@ impl ConfigProcessor {
262267 async fn handle_get_dataplane_status ( & mut self ) -> ConfigResponse {
263268 let mut status = DataplaneStatus :: new ( ) ;
264269
265- let names = self . vpc_stats_store . snapshot_names ( ) . await ;
266- let pair_snap = self . vpc_stats_store . snapshot_pairs ( ) . await ;
267- let vpc_snap = self . vpc_stats_store . snapshot_vpcs ( ) . await ;
270+ let stats_store = & self . proc_params . vpc_stats_store ;
271+
272+ let names = stats_store. snapshot_names ( ) . await ;
273+ let pair_snap = stats_store. snapshot_pairs ( ) . await ;
274+ let vpc_snap = stats_store. snapshot_vpcs ( ) . await ;
268275
269276 // Helper to check if a flow stats has any traffic
270277 #[ inline]
@@ -375,7 +382,7 @@ impl ConfigProcessor {
375382 }
376383
377384 // FRR minimal info
378- populate_status_with_frr ( & mut status, & mut self . router_ctl ) . await ;
385+ populate_status_with_frr ( & mut status, & mut self . proc_params . router_ctl ) . await ;
379386
380387 ConfigResponse :: GetDataplaneStatus ( Box :: new ( status) )
381388 }
@@ -587,6 +594,7 @@ fn apply_device_config(device: &DeviceConfig) -> ConfigResult {
587594
588595#[ allow( clippy:: too_many_arguments) ]
589596/// Main function to apply a config
597+ // FIXME(fredi): receive &mut self.params
590598async fn apply_gw_config (
591599 vpc_mgr : & VpcManager < RequiredInformationBase > ,
592600 config : & mut GwConfig ,
0 commit comments