Skip to content

Commit 1ff7d4c

Browse files
authored
Move DEFAULT_RIB_PRIORITY consts to mg-api-types (#757)
Signed-off-by: Trey Aspelund <trey@oxidecomputer.com>
1 parent 95aae63 commit 1ff7d4c

10 files changed

Lines changed: 32 additions & 22 deletions

File tree

bgp/src/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ use mg_api_types::bgp::policy::{ImportExportPolicy4, ImportExportPolicy6};
3434
pub(crate) use mg_api_types::bgp::session::{
3535
FsmEventCategory, FsmEventRecord, FsmStateKind, MessageHistory,
3636
};
37+
pub use mg_api_types::rdb::DEFAULT_RIB_PRIORITY_BGP;
3738
use mg_api_types::rdb::path::BgpPathProperties;
3839
use mg_api_types::rdb::prefix::{Prefix, Prefix4, Prefix6};
3940
use mg_api_types::rdb::rib::AddressFamily;
4041
use mg_api_types_versions::v1;
4142
use mg_common::{lock, read_lock, write_lock};
43+
pub use rdb::DEFAULT_ROUTE_PRIORITY;
4244
use rdb::{Asn, Db};
43-
pub use rdb::{DEFAULT_RIB_PRIORITY_BGP, DEFAULT_ROUTE_PRIORITY};
4445
use schemars::JsonSchema;
4546
use serde::{Deserialize, Serialize};
4647
use slog::Logger;

mg-api-types/versions/src/impls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
//! Functional code for the latest versions of types.
66
77
pub(crate) mod bgp;
8-
mod rdb;
8+
pub(crate) mod rdb;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
/// The default RIB Priority of BGP routes.
6+
pub const DEFAULT_RIB_PRIORITY_BGP: u8 = 20;
7+
8+
/// The default RIB Priority of Static routes.
9+
pub const DEFAULT_RIB_PRIORITY_STATIC: u8 = 1;

mg-api-types/versions/src/impls/rdb/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5+
pub(crate) mod constants;
56
mod path;
67
mod prefix;

mg-api-types/versions/src/latest.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ pub mod rdb {
170170
pub mod router {
171171
pub use crate::v1::rdb::router::BgpRouterInfo;
172172
}
173+
174+
pub use crate::impls::rdb::constants::DEFAULT_RIB_PRIORITY_BGP;
175+
pub use crate::impls::rdb::constants::DEFAULT_RIB_PRIORITY_STATIC;
173176
}
174177

175178
pub mod ndp {

mgadm/src/static_routing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use anyhow::Result;
66
use clap::{Args, Subcommand};
77
use mg_admin_client::Client;
8+
use mg_api_types::rdb::DEFAULT_RIB_PRIORITY_STATIC;
89
use mg_api_types::rdb::prefix::{Prefix4, Prefix6};
910
use mg_common::println_nopipe;
1011
use oxnet::{Ipv4Net, Ipv6Net};
11-
use rdb::DEFAULT_RIB_PRIORITY_STATIC;
1212
use std::net::{Ipv4Addr, Ipv6Addr};
1313

1414
#[derive(Subcommand, Debug)]

rdb/src/bestpath.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ mod test {
131131
use std::str::FromStr;
132132

133133
use super::bestpaths;
134-
use crate::{
134+
use crate::types::test_helpers::path_sets_equal;
135+
use mg_api_types::rdb::path::{BgpPathProperties, Path};
136+
use mg_api_types::rdb::{
135137
DEFAULT_RIB_PRIORITY_BGP, DEFAULT_RIB_PRIORITY_STATIC,
136-
types::test_helpers::path_sets_equal,
137138
};
138-
use mg_api_types::rdb::path::{BgpPathProperties, Path};
139139

140140
// Bestpaths is purely a function of the path info itself, so we don't
141141
// need a Rib or Prefix, just a set of candidate paths and a set of

rdb/src/db.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,9 +1480,10 @@ impl Reaper {
14801480
#[cfg(test)]
14811481
mod test {
14821482
use crate::{
1483-
DEFAULT_RIB_PRIORITY_STATIC, StaticRouteKey, db::Db, test::TestDb,
1484-
types::PrefixDbKey, types::test_helpers::path_vecs_equal,
1483+
StaticRouteKey, db::Db, test::TestDb, types::PrefixDbKey,
1484+
types::test_helpers::path_vecs_equal,
14851485
};
1486+
use mg_api_types::rdb::DEFAULT_RIB_PRIORITY_STATIC;
14861487
use mg_api_types::rdb::path::Path;
14871488
use mg_api_types::rdb::prefix::{Prefix, Prefix4, Prefix6};
14881489
use mg_api_types::rdb::rib::AddressFamily;
@@ -1521,12 +1522,13 @@ mod test {
15211522
#[test]
15221523
fn test_rib() {
15231524
use crate::StaticRouteKey;
1524-
use crate::{
1525-
DEFAULT_RIB_PRIORITY_BGP, DEFAULT_RIB_PRIORITY_STATIC, db::Db,
1526-
};
1525+
use crate::db::Db;
15271526
use mg_api_types::bgp::peer::PeerId;
15281527
use mg_api_types::rdb::path::{BgpPathProperties, Path};
15291528
use mg_api_types::rdb::prefix::{Prefix, Prefix4};
1529+
use mg_api_types::rdb::{
1530+
DEFAULT_RIB_PRIORITY_BGP, DEFAULT_RIB_PRIORITY_STATIC,
1531+
};
15301532
// init test vars
15311533
let p0 = Prefix::from("192.168.0.0/24".parse::<Prefix4>().unwrap());
15321534
let p1 = Prefix::from("192.168.1.0/24".parse::<Prefix4>().unwrap());
@@ -2254,13 +2256,13 @@ mod test {
22542256
/// `shutdown` is not part of `Path::Ord` identity.
22552257
#[test]
22562258
fn test_set_nexthop_shutdown_replaces_path() {
2257-
use crate::{
2258-
DEFAULT_RIB_PRIORITY_BGP, DEFAULT_RIB_PRIORITY_STATIC,
2259-
StaticRouteKey,
2260-
};
2259+
use crate::StaticRouteKey;
22612260
use mg_api_types::bgp::peer::PeerId;
22622261
use mg_api_types::rdb::path::{BgpPathProperties, Path};
22632262
use mg_api_types::rdb::prefix::{Prefix, Prefix4, Prefix6};
2263+
use mg_api_types::rdb::{
2264+
DEFAULT_RIB_PRIORITY_BGP, DEFAULT_RIB_PRIORITY_STATIC,
2265+
};
22642266

22652267
let db = get_test_db();
22662268

rdb/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ mod proptest;
1919
/// The priority routes default to.
2020
pub const DEFAULT_ROUTE_PRIORITY: u64 = u64::MAX;
2121

22-
/// The default RIB Priority of BGP routes.
23-
pub const DEFAULT_RIB_PRIORITY_BGP: u8 = 20;
24-
25-
/// The default RIB Priority of Static routes.
26-
pub const DEFAULT_RIB_PRIORITY_STATIC: u8 = 1;
27-
2822
pub const COMPONENT_RDB: &str = "rdb";
2923
pub const MOD_DB: &str = "database";
3024

rdb/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub mod test_helpers {
366366
#[cfg(test)]
367367
mod test {
368368
use super::*;
369-
use crate::DEFAULT_RIB_PRIORITY_BGP;
369+
use mg_api_types::rdb::DEFAULT_RIB_PRIORITY_BGP;
370370
use std::{
371371
cmp::Ordering, collections::BTreeSet, net::IpAddr, str::FromStr,
372372
};

0 commit comments

Comments
 (0)