Skip to content

Commit a9be11c

Browse files
authored
Add limited MRT support (#60)
* 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
1 parent e9cf9c7 commit a9be11c

File tree

8 files changed

+1205
-14
lines changed

8 files changed

+1205
-14
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
os: [ubuntu-latest, windows-latest, macOS-latest]
10-
rust: [1.71, stable, beta]
10+
rust: [1.76, stable, beta]
1111
steps:
1212
- name: Checkout repository
1313
uses: actions/checkout@v1

Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ description = "A Library with Building Blocks for BGP Routing"
77
documentation = "https://docs.rs/routecore/"
88
repository = "https://github.com/NLnetLabs/routecore"
99
edition = "2021"
10-
rust-version = "1.71"
10+
rust-version = "1.76"
1111
keywords = ["routing", "bgp"]
1212
license = "BSD-3-Clause"
1313

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

2627
[dev-dependencies]
2728
memmap2 = "0.9"
@@ -32,5 +33,6 @@ default = ["bgp"]
3233
bgp = ["bytes", "log", "octseq", "const-str"]
3334
bmp = ["bgp", "chrono"]
3435
fsm = ["tokio"]
36+
mrt = ["bgp", "fsm", "rayon", "serde"]
3537
bgpsec = []
3638

src/bgp/message/update_builder.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ where
137137
{
138138
// XXX there should be a HopPath::compose_len really, instead of
139139
// relying on .to_as_path() first.
140-
if let Ok(wireformat) = aspath.to_as_path::<Vec<u8>>() {
141-
if wireformat.compose_len() > u16::MAX.into() {
142-
return Err(ComposeError::AttributeTooLarge(
143-
PathAttributeType::AsPath,
144-
wireformat.compose_len()
145-
));
146-
}
147-
} else {
148-
return Err(ComposeError::InvalidAttribute)
140+
let wireformat = octseq::builder::infallible(
141+
aspath.to_as_path::<Vec<u8>>()
142+
);
143+
144+
if wireformat.compose_len() > u16::MAX.into() {
145+
return Err(ComposeError::AttributeTooLarge(
146+
PathAttributeType::AsPath,
147+
wireformat.compose_len()
148+
));
149149
}
150150

151151
self.attributes.set(aspath);

src/bgp/nlri/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn parse_prefix_for_len<R: Octets>(
6666
Ok(res)
6767
}
6868

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

92-
pub(super) fn parse_v6_prefix<R: Octets>(parser: &mut Parser<'_, R>)
92+
pub(crate) fn parse_v6_prefix<R: Octets>(parser: &mut Parser<'_, R>)
9393
-> Result<Prefix, ParseError>
9494
{
9595
let prefix_bits = parser.parse_u8()?;

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ pub mod bgpsec;
77
#[cfg(feature = "bmp")]
88
pub mod bmp;
99

10+
#[cfg(feature = "mrt")]
11+
pub mod mrt;
12+
1013
pub mod flowspec;
1114

1215
pub use octseq::Octets;

0 commit comments

Comments
 (0)