Skip to content

Commit 1df065b

Browse files
committed
chore(routing,config): tidy up code and logs
Polish logs, remove duped methods. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
1 parent 8c46a41 commit 1df065b

4 files changed

Lines changed: 14 additions & 22 deletions

File tree

‎mgmt/src/processor/gwconfigdb.rs‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,13 @@ impl GwConfigDatabase {
4848
self.applied = config;
4949
}
5050

51-
/// Get a refcounted reference to the applied `GwConfig`
52-
pub fn get_applied(&self) -> Arc<ValidatedGwConfig> {
53-
self.applied.clone()
54-
}
55-
5651
/// Get the generation Id of the currently applied config, if any.
5752
#[must_use]
5853
pub fn get_current_gen(&self) -> GenId {
5954
self.applied.genid()
6055
}
6156

62-
/// Get a reference to the config currently applied, if any.
57+
/// Get a refcounted reference to the applied `GwConfig`
6358
#[must_use]
6459
pub fn get_current_config(&self) -> Arc<ValidatedGwConfig> {
6560
self.applied.clone()

‎mgmt/src/processor/proc.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl ConfigProcessor {
188188

189189
/// Attempt to apply the previously applied config.
190190
async fn rollback(&mut self) {
191-
let active = self.config_db.get_applied();
191+
let active = self.config_db.get_current_config();
192192
let active_genid = active.genid();
193193
info!("Rolling back to config with genid {}...", active.genid());
194194
let result = self.apply_gw_config(active.clone()).await.map(drop);

‎routing/src/frr/frrmi.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::router::revent::{ROUTER_EVENTS, RouterEvent, revent};
1515
use config::GenId;
1616

1717
#[allow(unused)]
18-
use tracing::{debug, error, info, trace, warn};
18+
use tracing::{debug, error, info, warn};
1919

2020
use tracectl::trace_target;
2121
trace_target!("frrmi", LevelFilter::DEBUG, &["routing-full"]);
@@ -240,7 +240,7 @@ impl Frrmi {
240240

241241
// Attempt to clean-up the config before re-applying the actual config.
242242
// This is disabled as the blank config is unsuitable for us and providing a suitable
243-
// one requires the ability to build frr configs, which we don't have here.
243+
// one requires the ability to build frr configs, which we don't have here.
244244
if false {
245245
self.requests.push_front(FrrmiRequest::blank());
246246
}
@@ -328,22 +328,22 @@ impl Frrmi {
328328
};
329329
loop {
330330
let pending = self.readb.next_read_len();
331-
trace!("Recv data (read:{} pending:{pending})", self.readb.used);
331+
debug!("Recv data (read:{} pending:{pending})", self.readb.used);
332332
match Self::recv(sock, &mut self.readb, pending) {
333333
Ok(0) => {
334334
revent!(RouterEvent::FrrmiPeerLeft);
335335
return Err(FrrErr::PeerLeft);
336336
}
337337
Ok(_) => {
338-
if self.readb.next_read_len() == 0 {
339-
{
340-
let response = self.readb.deserialize()?;
341-
return Ok(Some(response));
342-
}
338+
let pending = self.readb.next_read_len();
339+
if pending == 0 {
340+
let response = self.readb.deserialize()?;
341+
return Ok(Some(response));
343342
}
344343
// did not receive the complete message and need to read more
344+
debug!("Expecting {pending} octets of data from frr agent");
345345
}
346-
// we must wait. Can't provide a message yet
346+
// we must wait and cannot provide a message yet
347347
Err(ref e) if e.kind() == ErrorKind::WouldBlock => return Ok(None),
348348
// recv failed due to unrecoverable reason. Will restart
349349
Err(e) => return Err(FrrErr::IOFailure(e.to_string())),

‎routing/src/router/ctl.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,13 @@ fn handle_configure(
215215
return;
216216
}
217217

218-
/* request application of frr config */
218+
/* request application of frr config. This is infallible */
219219
if let Some(frr_config) = config.get_frr_config() {
220220
rio.request_frr_config(config.genid(), frr_config.clone());
221221
}
222222

223-
/* generate event depending on result */
224-
match result {
225-
Ok(()) => revent!(RouterEvent::ConfigSuceeded(config.genid())),
226-
Err(_) => revent!(RouterEvent::ConfigFailed(config.genid())),
227-
}
223+
/* generate event: we successfully applied the router config and FRR's is on its way */
224+
revent!(RouterEvent::ConfigSuceeded(config.genid()));
228225

229226
/* reply */
230227
let _ = reply_to.send(RouterCtlReply::Result(result)).map_err(|e| {

0 commit comments

Comments
 (0)