Skip to content

Commit

Permalink
Add limited MRT support (#60)
Browse files Browse the repository at this point in the history
* Add limited MRT support

* Bump minimal version in ci to 1.76

* Fix compiler warning about irrefutable pattern for Infallible Error case

* Bump inetnum to 1.1
  • Loading branch information
DRiKE authored Nov 20, 2024
1 parent e9cf9c7 commit a9be11c
Show file tree
Hide file tree
Showing 8 changed files with 1,205 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [1.71, stable, beta]
rust: [1.76, stable, beta]
steps:
- name: Checkout repository
uses: actions/checkout@v1
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ description = "A Library with Building Blocks for BGP Routing"
documentation = "https://docs.rs/routecore/"
repository = "https://github.com/NLnetLabs/routecore"
edition = "2021"
rust-version = "1.71"
rust-version = "1.76"
keywords = ["routing", "bgp"]
license = "BSD-3-Clause"

[dependencies]
inetnum = { version = "0.1.0", features = ["arbitrary", "serde"] }
inetnum = { version = "0.1.1", features = ["arbitrary", "serde"] }
arbitrary = { version = "1.3.1", optional = true, features = ["derive"] }
bytes = { version = "1.2", optional = true }
chrono = { version = "0.4.20", optional = true, default-features = false }
Expand All @@ -22,6 +22,7 @@ octseq = { version = "0.4.0", optional = true, features = ["bytes"] }
paste = { version = "1" }
serde = { version = "1.0.165", optional = true, features = ["derive"] }
tokio = { version = ">=1.24.2", optional = true, features = ["io-util", "macros", "net", "sync", "rt-multi-thread", "time"] }
rayon = { version = "1.10", optional = true }

[dev-dependencies]
memmap2 = "0.9"
Expand All @@ -32,5 +33,6 @@ default = ["bgp"]
bgp = ["bytes", "log", "octseq", "const-str"]
bmp = ["bgp", "chrono"]
fsm = ["tokio"]
mrt = ["bgp", "fsm", "rayon", "serde"]
bgpsec = []

18 changes: 9 additions & 9 deletions src/bgp/message/update_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ where
{
// XXX there should be a HopPath::compose_len really, instead of
// relying on .to_as_path() first.
if let Ok(wireformat) = aspath.to_as_path::<Vec<u8>>() {
if wireformat.compose_len() > u16::MAX.into() {
return Err(ComposeError::AttributeTooLarge(
PathAttributeType::AsPath,
wireformat.compose_len()
));
}
} else {
return Err(ComposeError::InvalidAttribute)
let wireformat = octseq::builder::infallible(
aspath.to_as_path::<Vec<u8>>()
);

if wireformat.compose_len() > u16::MAX.into() {
return Err(ComposeError::AttributeTooLarge(
PathAttributeType::AsPath,
wireformat.compose_len()
));
}

self.attributes.set(aspath);
Expand Down
4 changes: 2 additions & 2 deletions src/bgp/nlri/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub fn parse_prefix_for_len<R: Octets>(
Ok(res)
}

pub(super) fn parse_v4_prefix<R: Octets>(parser: &mut Parser<'_, R>)
pub(crate) fn parse_v4_prefix<R: Octets>(parser: &mut Parser<'_, R>)
-> Result<Prefix, ParseError>
{
let prefix_bits = parser.parse_u8()?;
Expand All @@ -89,7 +89,7 @@ pub(super) fn parse_v4_prefix_for_len<R: Octets>(
)
}

pub(super) fn parse_v6_prefix<R: Octets>(parser: &mut Parser<'_, R>)
pub(crate) fn parse_v6_prefix<R: Octets>(parser: &mut Parser<'_, R>)
-> Result<Prefix, ParseError>
{
let prefix_bits = parser.parse_u8()?;
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ pub mod bgpsec;
#[cfg(feature = "bmp")]
pub mod bmp;

#[cfg(feature = "mrt")]
pub mod mrt;

pub mod flowspec;

pub use octseq::Octets;
Expand Down
Loading

0 comments on commit a9be11c

Please sign in to comment.