Skip to content

Commit 6044efa

Browse files
committed
feat(status): style fixes and formatting
Signed-off-by: Sergey Matov <[email protected]>
1 parent bb69aef commit 6044efa

File tree

8 files changed

+21
-60
lines changed

8 files changed

+21
-60
lines changed

args/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ pub struct BmpConfigSection {
575575
/// 3. **Transfer**: Passed via sealed memfd to the worker process
576576
/// 4. **Worker Process**: Calls [`LaunchConfiguration::inherit()`] to access the config
577577
///
578-
/// // TODO: implement bytecheck::Validate in addition to CheckBytes on all components of the launch config.
578+
/// TODO: implement bytecheck::Validate in addition to CheckBytes on all components of the launch config.
579579
#[derive(
580580
Debug,
581581
PartialEq,
@@ -1278,12 +1278,10 @@ E.g. default=error,all=info,nat=debug will set the default target to error, and
12781278
)]
12791279
tracing: Option<String>,
12801280

1281-
// ===== BMP ARGS =====
1282-
/// Enable BMP server
1281+
/// Enable BMP server, addres and interval
12831282
#[arg(long, default_value_t = false, help = "Enable BMP server")]
12841283
bmp_enable: bool,
12851284

1286-
/// BMP bind address
12871285
#[arg(
12881286
long,
12891287
value_name = "IP:PORT",
@@ -1292,7 +1290,6 @@ E.g. default=error,all=info,nat=debug will set the default target to error, and
12921290
)]
12931291
bmp_address: SocketAddr,
12941292

1295-
/// BMP periodic interval for housekeeping/flush (ms)
12961293
#[arg(
12971294
long,
12981295
value_name = "MILLISECONDS",

config/src/internal/routing/bgp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub struct BgpNeighCapabilities {
6868
pub ext_nhop: bool,
6969
pub fqdn: bool,
7070
pub software_ver: bool,
71-
// TODO: ORF
71+
// ORF
7272
}
7373

7474
#[derive(Clone, Debug)]
@@ -350,6 +350,7 @@ impl AfIpv4Ucast {
350350
pub fn set_vrf_imports(&mut self, imports: VrfImports) {
351351
self.imports = Some(imports);
352352
}
353+
// redistribution is configured by adding one or more redistribute objects
353354
pub fn redistribute(&mut self, redistribute: Redistribute) {
354355
self.redistribute.push(redistribute);
355356
}

mgmt/src/processor/confbuild/internal.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,8 @@ impl VpcRoutingConfigIpv4 {
181181
}
182182
}
183183

184-
/// Build BGP config for a VPC VRF (no BMP attached here!)
185-
fn vpc_vrf_bgp_config(
186-
vpc: &Vpc,
187-
asn: u32,
188-
router_id: Option<Ipv4Addr>,
189-
) -> BgpConfig {
184+
/// Build BGP config for a VPC VRF (bmp is applied elsewhere)
185+
fn vpc_vrf_bgp_config(vpc: &Vpc, asn: u32, router_id: Option<Ipv4Addr>) -> BgpConfig {
190186
let mut bgp = BgpConfig::new(asn).set_vrf_name(vpc.vrf_name());
191187
if let Some(router_id) = router_id {
192188
bgp.set_router_id(router_id);
@@ -233,7 +229,7 @@ fn build_vpc_internal_config(
233229
/* build VRF config */
234230
let mut vrf_cfg = vpc_vrf_config(vpc)?;
235231

236-
/* build bgp config (no BMP here) */
232+
/* build bgp config */
237233
let mut bgp = vpc_vrf_bgp_config(vpc, asn, router_id);
238234

239235
if vpc.num_peerings() > 0 {
@@ -269,7 +265,7 @@ fn build_internal_overlay_config(
269265
Ok(())
270266
}
271267

272-
/// Public entry — build without BMP
268+
/// without BMP
273269
pub fn build_internal_config(config: &GwConfig) -> Result<InternalConfig, ConfigError> {
274270
build_internal_config_with_bmp(config, None)
275271
}
@@ -307,12 +303,7 @@ pub fn build_internal_config_with_bmp(
307303
let asn = bgp.asn;
308304
let router_id = bgp.router_id;
309305
if !external.overlay.vpc_table.is_empty() {
310-
build_internal_overlay_config(
311-
&external.overlay,
312-
asn,
313-
router_id,
314-
&mut internal,
315-
)?;
306+
build_internal_overlay_config(&external.overlay, asn, router_id, &mut internal)?;
316307
} else {
317308
debug!("The configuration does not specify any VPCs...");
318309
}

mgmt/src/processor/proc.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ impl ConfigProcessor {
280280

281281
/// RPC handler: get dataplane status
282282
async fn handle_get_dataplane_status(&mut self) -> ConfigResponse {
283-
// std::sync::RwLock::read() -> Result<Guard, PoisonError>. Unwrap then clone.
284283
let mut status: DataplaneStatus = {
285284
let guard = self
286285
.proc_params
@@ -675,10 +674,6 @@ async fn apply_gw_config(
675674
let pairs = update_stats_vpc_mappings(config, vpcmapw);
676675
drop(pairs); // pairs used by caller
677676

678-
// NOTE: If we need to inject/override BMP per-VRF here, prefer adding a helper once
679-
// InternalConfig exposes a mutable VRF accessor. For now, BMP config is built in
680-
// the internal build stage and applied by the routing layer.
681-
682677
/* apply config in router */
683678
apply_router_config(&kernel_vrfs, config, router_ctl).await?;
684679

routing/src/bmp/bmp_render.rs

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright Open Network Fabric Authors
33

4-
//! Minimal & safe renderer for NetGauze BMP messages into DataplaneStatus.
5-
//! Keeps API usage conservative and aligned with the code you pasted.
4+
//! BMP message handlers to update internal DataplaneStatus model.
65
76
use netgauze_bgp_pkt::BgpMessage;
8-
use netgauze_bmp_pkt::{BmpMessage, BmpPeerType};
97
use netgauze_bmp_pkt::v3::{
108
BmpMessageValue, PeerDownNotificationMessage, PeerUpNotificationMessage,
119
RouteMonitoringMessage, StatisticsReportMessage,
1210
};
11+
use netgauze_bmp_pkt::{BmpMessage, BmpPeerType};
1312

1413
use config::internal::status::{
1514
BgpMessageCounters, BgpMessages, BgpNeighborPrefixes, BgpNeighborSessionState,
1615
BgpNeighborStatus, BgpStatus, BgpVrfStatus, DataplaneStatus,
1716
};
1817

19-
// -----------------------------------------------------------------------------
20-
// Public entry points
21-
// -----------------------------------------------------------------------------
22-
23-
/// Backward-compat shim for older callers (typo in earlier drafts).
2418
#[inline]
2519
pub fn hande_bmp_message(status: &mut DataplaneStatus, msg: &BmpMessage) {
2620
handle_bmp_message(status, msg)
@@ -41,11 +35,6 @@ pub fn handle_bmp_message(status: &mut DataplaneStatus, msg: &BmpMessage) {
4135
BmpMessage::V4(_) => {}
4236
}
4337
}
44-
45-
// -----------------------------------------------------------------------------
46-
// Helpers: mapping / extraction
47-
// -----------------------------------------------------------------------------
48-
4938
fn key_from_peer_header(peer: &netgauze_bmp_pkt::PeerHeader) -> String {
5039
// Build a stable-ish key: "<bgp_id>-<peer_as>-<ip|-none>-<rd?>"
5140
let id = peer.bgp_id();
@@ -84,10 +73,7 @@ fn ensure_vrf<'a>(bgp: &'a mut BgpStatus, vrf: &str) -> &'a mut BgpVrfStatus {
8473
bgp.vrfs.entry(vrf.to_string()).or_default()
8574
}
8675

87-
fn ensure_neighbor<'a>(
88-
vrf: &'a mut BgpVrfStatus,
89-
neigh_key: &str,
90-
) -> &'a mut BgpNeighborStatus {
76+
fn ensure_neighbor<'a>(vrf: &'a mut BgpVrfStatus, neigh_key: &str) -> &'a mut BgpNeighborStatus {
9177
vrf.neighbors
9278
.entry(neigh_key.to_string())
9379
.or_insert_with(|| BgpNeighborStatus {
@@ -109,10 +95,6 @@ fn post_policy_from_peer_type(pt: BmpPeerType) -> bool {
10995
}
11096
}
11197

112-
// -----------------------------------------------------------------------------
113-
// Handlers
114-
// -----------------------------------------------------------------------------
115-
11698
fn on_peer_up(status: &mut DataplaneStatus, pu: &PeerUpNotificationMessage) {
11799
let peer = pu.peer_header();
118100
let vrf = get_vrf_from_peer_header(peer);
@@ -127,13 +109,10 @@ fn on_peer_up(status: &mut DataplaneStatus, pu: &PeerUpNotificationMessage) {
127109
neigh.remote_router_id = peer.bgp_id().to_string();
128110
neigh.peer_port = pu.remote_port().unwrap_or_default() as u32;
129111
set_neighbor_session_state(neigh, BgpNeighborSessionState::Established);
130-
131-
// Optional: try to infer local_as from the OPEN we sent (kept simple)
132112
if let BgpMessage::Open(open) = pu.sent_message() {
133113
neigh.local_as = open.my_as() as u32;
134114
}
135115

136-
// Initialize empty message counters on establishment
137116
if neigh.messages.is_none() {
138117
neigh.messages = Some(BgpMessages {
139118
received: Some(BgpMessageCounters::new()),
@@ -187,9 +166,7 @@ fn on_route_monitoring(status: &mut DataplaneStatus, rm: &RouteMonitoringMessage
187166

188167
// We don't parse NLRI depth here; increment by 1 as a placeholder per RM message
189168
if post {
190-
pref.received_pre_policy = pref
191-
.received_pre_policy
192-
.saturating_add(0); // post-policy => don't bump pre
169+
pref.received_pre_policy = pref.received_pre_policy.saturating_add(0); // post-policy => don't bump pre
193170
pref.received = pref.received.saturating_add(1);
194171
} else {
195172
pref.received_pre_policy = pref.received_pre_policy.saturating_add(1);
@@ -212,6 +189,5 @@ fn on_statistics(status: &mut DataplaneStatus, sr: &StatisticsReportMessage) {
212189
sent: Some(BgpMessageCounters::new()),
213190
});
214191

215-
// You can walk `sr.counters()` and map specific statistics to your model later.
216-
// For now, we keep StatisticsReport as a no-op for counters.
192+
//TODO: smatov: add more later
217193
}

routing/src/bmp/server.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,14 @@ async fn handle_peer<H: BmpHandler>(
103103
if cfg.tcp_nodelay {
104104
let _ = sock.set_nodelay(true);
105105
}
106-
// NOTE: cfg.tcp_recv_buf kept for future tuning; Tokio has no stable API to set recv buf.
107-
108106
// Frame the stream as BMP
109107
let codec = BmpCodec::default();
110108
let mut reader = FramedRead::new(sock, codec);
111109

112110
while let Some(frame) = reader.next().await {
113111
match frame {
114112
Ok(msg) => {
115-
// netgauze_bmp_pkt::BmpMessage for both v3 and v4
113+
// netgauze_bmp_pkt::BmpMessage for both v3 and v4. TODO: smatov: v4 handling
116114
handler.on_message(peer, msg).await;
117115
}
118116
Err(e) => {

routing/src/frr/renderer/bgp.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ impl Render for AfIpv4Ucast {
326326
cfg += MARKER;
327327
cfg += "address-family ipv4 unicast";
328328

329+
/* activate neighbors in AF */
329330
bgp.neighbors
330331
.iter()
331332
.filter(|neigh| neigh.ipv4_unicast)
@@ -361,6 +362,7 @@ impl Render for AfIpv6Ucast {
361362
cfg += MARKER;
362363
cfg += "address-family ipv6 unicast";
363364

365+
/* activate neighbors in AF */
364366
bgp.neighbors
365367
.iter()
366368
.filter(|neigh| neigh.ipv6_unicast)
@@ -396,6 +398,7 @@ impl Render for AfL2vpnEvpn {
396398
cfg += MARKER;
397399
cfg += "address-family l2vpn evpn";
398400

401+
/* activate neighbors in AF */
399402
bgp.neighbors
400403
.iter()
401404
.filter(|neigh| neigh.l2vpn_evpn)
@@ -506,7 +509,7 @@ impl Render for BgpConfig {
506509
config += format!(" bgp router-id {router_id}");
507510
}
508511

509-
/* BGP options */
512+
/* BGP options: todo */
510513
config += self.options.render(&());
511514

512515
/* BGP neighbors */

routing/src/router/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ impl Router {
173173
Ok(router)
174174
}
175175

176-
/// Stop this router. This stops the router IO task and drops the interface table, adjacency table,
177-
/// VRF table and the FIB table.
176+
/// Stop this router. This stops the router IO thread and drops the interface table, adjacency table
177+
/// vrf table and the fib table.
178178
pub fn stop(&mut self) {
179179
if let Err(e) = self.rio_handle.finish() {
180180
error!("Failed to stop IO for router '{}': {e}", self.name);

0 commit comments

Comments
 (0)