Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge long-living absorb-fsm #56

Merged
merged 161 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
d16d5cc
WIP PathAttributesBuilder
DRiKE Feb 6, 2024
3adb585
Use type alias AttributesMap everywhere
DRiKE Feb 6, 2024
125948f
Add fn remove_attribute
DRiKE Feb 6, 2024
9636412
rough outline RouteWorkshop
density215 Feb 12, 2024
f082cbe
Serialize route
density215 Feb 13, 2024
d71103e
FlowSpecNlri generic over Octets
density215 Feb 13, 2024
43ebbaa
make_route
density215 Feb 13, 2024
03b009f
bytes::Bytes
density215 Feb 13, 2024
f025e45
clippy & rustfmt
density215 Feb 13, 2024
c637d37
bump minimal bytes version to something that works
density215 Feb 13, 2024
088fa8d
WorkshopAttribute
density215 Feb 13, 2024
49d6907
wrapped types for PathAttribute data fields & ConventionalNextHop var…
density215 Feb 14, 2024
c4f2ef4
merge impl macros
density215 Feb 14, 2024
68d8235
cleanup
density215 Feb 14, 2024
10bb67c
cleanup
density215 Feb 14, 2024
0b61d10
remove unused fn
density215 Feb 14, 2024
2df9a19
cleanup
density215 Feb 14, 2024
732a802
Use PaMap in update_builder
density215 Feb 14, 2024
14e9f21
use more attributes.set
density215 Feb 14, 2024
d77fb9b
remove AttrChangeSet
density215 Feb 15, 2024
8884944
varia
density215 Feb 15, 2024
2ef9caa
move add_attribute and FromAttribute trait
density215 Feb 16, 2024
4b05c9c
eliminate PathAttributeType in PaMap
density215 Feb 16, 2024
28bd7f7
single NLRI facilities
density215 Feb 22, 2024
adce9e2
Workshop without Options
density215 Feb 22, 2024
1de1ac6
impl traits on AfiSafiNlris
density215 Feb 22, 2024
bf0b4cf
remove weird single_first_nlri method
density215 Feb 26, 2024
9bc915e
clippy
density215 Feb 26, 2024
912a530
Set Partial flag when composing an UnimplementedPathAttribute
DRiKE Feb 26, 2024
17deeb6
Remove unnecessary layer in PathAttributes enum, impl Attribute on ty…
DRiKE Feb 26, 2024
74a94fe
Fix tests
DRiKE Feb 26, 2024
422c2dc
Cleanup
DRiKE Feb 26, 2024
c565171
Provide default fn impls in FromAttribute trait
DRiKE Feb 26, 2024
416814d
Get rid of Default impl for PathAttribute
DRiKE Feb 26, 2024
f2abf4b
Rename attributes_owned to into_attributes
DRiKE Feb 26, 2024
5e567a7
Return replaced value from PaMap.set/add_attribute
DRiKE Feb 26, 2024
f96a767
Cleanup in UpdateBuilder
DRiKE Feb 27, 2024
3d0eb2b
WIP new afisafi mod in bgp
DRiKE Feb 27, 2024
ce8920f
Make <Octs> optional in afisafi macro
DRiKE Feb 28, 2024
84c712a
Make MpReachNlriBuilder::new_for_nlri pub
DRiKE Feb 29, 2024
acdbb1e
Display impl for Origin
density215 Feb 29, 2024
5524cb3
WIP AfiSafiParse trait
DRiKE Feb 29, 2024
9d1dfac
pub the new communities
density215 Feb 29, 2024
8617b49
fix builders
density215 Feb 29, 2024
08b459f
NlriIter generic over AfiSafiParse
DRiKE Feb 29, 2024
580ef94
Merge remote-tracking branch 'refs/remotes/origin/path-attributes-bui…
DRiKE Feb 29, 2024
c7e6322
Test for generic iteration
DRiKE Feb 29, 2024
f0bf4c5
Test iterating over an Addpath Nlri
DRiKE Feb 29, 2024
d601004
Cleanup
DRiKE Feb 29, 2024
c7cb212
Cleanup / reordering
DRiKE Feb 29, 2024
98f5f85
Trying alternative Addpath approaches
DRiKE Feb 29, 2024
599fd1e
Introduce addpath! macro
DRiKE Feb 29, 2024
cb2ea70
Add (likely useless) next_with on NlriIter
DRiKE Mar 4, 2024
d05afe8
Get rid of BasicNlri in new afisafi module
DRiKE Mar 4, 2024
18673d5
Cleanup
DRiKE Mar 4, 2024
2a3e541
Call typeenum! macro from afisafi! macro to create Afi enum
DRiKE Mar 4, 2024
401b755
Fill in all AFI/SAFI combos in macro call, as a TODO list
DRiKE Mar 4, 2024
655958c
Reordering in new afisafi module
DRiKE Mar 4, 2024
25ef23d
Include Addpath variants in Nlri enum, impl Display addpath! macro
DRiKE Mar 5, 2024
0f74284
Add From<Addpath variants> for Nlri enum
DRiKE Mar 5, 2024
14c8fd7
Start reorganizing new afisafi stuff into bgp::nlri module
DRiKE Mar 5, 2024
c436c4b
Generate NlriIter constructors in macro
DRiKE Mar 5, 2024
7f3bb29
Add notes on why fn iter on Nlri structs in macro is currently not po…
DRiKE Mar 5, 2024
416ca6c
Add Ipv4MplsVpnUnicast
DRiKE Mar 5, 2024
063eac0
Add Ipv4RouteTarget, do not rely on old nlri.rs anymore
DRiKE Mar 5, 2024
b236e14
Add fn afi_safis on UpdateMessage
DRiKE Mar 5, 2024
4676217
Add FlowSpecNlri
DRiKE Mar 5, 2024
7f44f2b
Support conversion between (non-)Addpath variants
DRiKE Mar 5, 2024
82173c7
Add Ipv6{Multicast, MplsUnicast, MplsVpnUnicast, FlowSpec}
DRiKE Mar 5, 2024
5f3905d
Add L2VpnVpls
DRiKE Mar 6, 2024
6307b8b
Add L2VpnEvpn
DRiKE Mar 6, 2024
e84a6af
Adopt new AfiSafi / Nlri types throughout codebase
DRiKE Mar 19, 2024
b1f4717
Remove unnecessary type arguments
DRiKE Mar 21, 2024
b0d704b
Reintroduction of BasicNlri etc
DRiKE Mar 22, 2024
431debf
Switch over to inetnum crate
DRiKE Mar 22, 2024
22758a4
Fix tests
DRiKE Mar 22, 2024
e4190fa
Clippy
DRiKE Mar 22, 2024
15afa31
Comment out everything BasicNlri related
DRiKE Mar 22, 2024
7e0feec
Remove unused afisafi_nlri.rs from bgp::workshop
DRiKE Mar 22, 2024
accd569
Remove old, unused bgp::message::nlri module
DRiKE Mar 22, 2024
7539ee0
Remove unused {addr,asn} modules as we use the inetnum crate now
DRiKE Mar 22, 2024
0e37d92
Conditionally derive De/Serialize for all NLRI related types
DRiKE Mar 22, 2024
6606341
Add From impls for FlowSpecNlri
DRiKE Mar 22, 2024
c8b541c
Add fn {announcement,withdrawal}_fams() on UpdateMessage
DRiKE Mar 22, 2024
42e90d2
Fix docstring/doctests wrt change to inetnum
DRiKE Mar 25, 2024
349923e
Make some NLRI related pub
DRiKE Mar 25, 2024
42d269b
Mark Nlri as Eq
DRiKE Mar 25, 2024
98121c4
Remove pub fn iter_for_afi_safi
DRiKE Mar 25, 2024
af12707
Introduce enum NlriType
DRiKE Mar 25, 2024
99f4667
Use NlriType instead of AfiSafiType in Update(Builder) where applicable
DRiKE Mar 25, 2024
ca54e23
this can go now
density215 Mar 26, 2024
a996da4
Make NextHop live on RouteWorkshop
DRiKE Mar 26, 2024
9484e51
Merge remote-tracking branch 'refs/remotes/origin/path-attributes-bui…
DRiKE Mar 26, 2024
0b0bbf2
Cleanup after merge and add basic tests
DRiKE Mar 26, 2024
8786965
Leave the nexthop compability check on AfiSafiNlri for now
DRiKE Mar 26, 2024
d10f30d
Make Update::typed_withdrawals consistent with ~announcements, fix bu…
DRiKE Mar 26, 2024
de0f76e
Add PartialEq impls for all concrete NLRI and the Nlri enum
DRiKE Mar 26, 2024
a6b0399
Fix test
DRiKE Mar 26, 2024
6d21885
Clean up
DRiKE Mar 26, 2024
adcf1d2
Update fuzz/Cargo.lock
DRiKE Mar 26, 2024
4f2aefd
Add fn remove_non_transitives on PaMap
DRiKE Mar 26, 2024
4d2497c
Clean up
DRiKE Mar 26, 2024
09f389c
Use .is_ok_and since we have MSRV >=1.70
DRiKE Mar 26, 2024
198c3c1
Add test for fn announcement_fams
DRiKE Mar 27, 2024
5082346
Comment on return type alternatives for fn typed_announcements
DRiKE Mar 27, 2024
ae65639
Message:from_octets should take a ref to the optional SessionConfig a…
DRiKE Mar 27, 2024
8c17e13
Move in everything from rotonda-fsm
DRiKE Mar 27, 2024
8021ab1
Clippy
DRiKE Mar 27, 2024
aaa9061
Fix test
DRiKE Mar 27, 2024
845a5e4
Set edition to 2021 in rustfmt.toml
DRiKE Mar 27, 2024
874ecc7
RustFmt the bgp::fsm module
DRiKE Mar 27, 2024
de4bb05
Add Eq markers for (Addpath)Nlri types
DRiKE Mar 28, 2024
f8706e4
Add TryFrom<(Prefix, PathId>) for Ipv{4,6}{Uni,Multi}castAddpathNlri
DRiKE Mar 28, 2024
fe381bc
Derive Copy on certain (non-Addpath) NLRI types
DRiKE Mar 28, 2024
f86281c
Add missing LargeCommunity case to fn store in workshop
DRiKE Apr 2, 2024
c2f013b
add Eq and Copy impls for *Nlri
density215 Apr 3, 2024
c85fc6e
Merge remote-tracking branch 'origin/absorb-fsm' into absorb-fsm
DRiKE Apr 3, 2024
71a493b
Remove clashing Eq impls after merge
DRiKE Apr 3, 2024
181e78d
impl NlriCompose for all NLRI types
DRiKE Apr 3, 2024
a41b9f4
ignore what is not an actual doctest anyway
DRiKE Apr 3, 2024
d21deea
Clippy
DRiKE Apr 3, 2024
60de3a6
Fix missing withdrawal length octets in UpdateMessage::fmt_pcap_string()
DRiKE Apr 3, 2024
7e07c45
Add missing NEXT_HOP in PDU used in unit tests
DRiKE Apr 3, 2024
a93ddcb
remove from_pa_map method
density215 Apr 3, 2024
df892ae
Merge branch 'absorb-fsm' of github.com:NLnetLabs/routecore into abso…
density215 Apr 3, 2024
7780fc6
Introduce AFI specific variants of fn parse_prefix
DRiKE Apr 3, 2024
c62b5f6
Misc changes in RouteDistinguisher
DRiKE Apr 4, 2024
7a6ed93
Copy over Prefix related skip_ fns from old nlri module
DRiKE Apr 4, 2024
ac2008d
Suppress dead_code warnings for skip fns for now
DRiKE Apr 4, 2024
fea1290
Loosen trait bounds on AfiSafiNlri / Route<N> / RouteWorkshop
DRiKE Apr 4, 2024
61021d7
Blanket impl Display in afisafi macro
DRiKE Apr 4, 2024
110c7ed
Implement (Partial)Ord for all NLRI types and enum Nlri, derive Copy …
DRiKE Apr 8, 2024
1e3852d
Add fuzz target for Nlri Ord implementation
DRiKE Apr 8, 2024
aaead96
Enhancements and tests for MPLS(-VPN) and RouteTarget NLRI
DRiKE Apr 10, 2024
d7aa1c8
Clippy and clean up
DRiKE Apr 10, 2024
0b4303b
Optimize fn prefix_bits_to_bytes
DRiKE Apr 11, 2024
1ce4659
Make UpdateBuilder::{from_attributes_builder,from_workshop} really ge…
DRiKE Apr 16, 2024
3155076
Fix docstring breaking syntax highlighting
DRiKE May 15, 2024
c4935d2
Derive and impl Arbitrary for path attributes and PaMap
DRiKE May 15, 2024
49c801b
Make ASN iterator over segment a bit more flexible for fuzzing
DRiKE May 15, 2024
4231283
Methods on AsPath to support path selection, other misc. changes
DRiKE May 15, 2024
5af0bc6
Add path selection based on Ord
DRiKE May 15, 2024
dba6987
Add fuzz target testing the total ordering of path selection OrdStrats
DRiKE May 15, 2024
c6664e4
Add tests for path selection methods on AsPath
DRiKE May 15, 2024
0d797e2
Clippy
DRiKE May 15, 2024
779779c
Don't interpret snippets as doctest code
DRiKE May 15, 2024
cc24811
Properly feature gate the Arbitrary impl on PaMap
DRiKE May 15, 2024
38edc55
Bump minimal arbitrary version to 1.3.1 for IpAddr
DRiKE May 15, 2024
92cd188
Make certain HopPath From impls more flexible
DRiKE May 16, 2024
fd60455
More flexible conversions between OrdStrats, total ordering fail test
DRiKE May 16, 2024
35ea1ba
Comment out Rfc4271 strat in fuzz test
DRiKE May 16, 2024
c0c7f96
RustFmt on bgp::path_selection
DRiKE May 16, 2024
9ea3ac1
Cleanup of (outdated) comments
DRiKE May 16, 2024
a0c5299
Feature flag maintenance
DRiKE May 16, 2024
a427e7c
spelling corrections
density215 May 21, 2024
6adb040
Use bool newtypes instead of enums in SessionConfig c.s. (#55)
DRiKE May 28, 2024
773a9f6
Do not re-export AfiSafiType as AfiSafi in bgp::types
DRiKE May 28, 2024
0e791ba
Rename trait AfiSafiParse to NlriParse
DRiKE May 28, 2024
84ef2c8
Helpers on bgp::path_selection
DRiKE May 29, 2024
bc2dd1d
Tweaks/additions to helpers on bgp::path_selection
DRiKE May 29, 2024
586ac67
Merge branch 'main' into absorb-fsm
DRiKE May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@ keywords = ["routing", "bgp"]
license = "BSD-3-Clause"

[dependencies]
arbitrary = { version = "1", optional = true, features = ["derive"] }
bytes = { version = "1", optional = true }
inetnum = { version = "0.1.0", 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 }
const-str = { version = "0.5", optional = true, features = ["case"] }
log = { version = "0.4.4", optional = true }
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 = ["sync", "rt"] }
tokio = { version = ">=1.24.2", optional = true, features = ["io-util", "macros", "net", "sync", "rt-multi-thread", "time"] }

[dev-dependencies]
memmap2 = "0.9"
serde_test = "1"

[features]
default = []
default = ["bgp"]
bgp = ["bytes", "log", "octseq", "const-str"]
bmp = ["bgp", "chrono"]
fsm = ["tokio"]
bgpsec = []

52 changes: 45 additions & 7 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ name = "parse_open_message"
path = "fuzz_targets/parse_open_message.rs"
test = false
doc = false

[[bin]]
name = "nlri_ord"
path = "fuzz_targets/nlri_ord.rs"
test = false
doc = false

[[bin]]
name = "path_selection"
path = "fuzz_targets/path_selection.rs"
test = false
doc = false
32 changes: 32 additions & 0 deletions fuzz/fuzz_targets/nlri_ord.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![no_main]

use std::cmp::Ordering::*;
use libfuzzer_sys::fuzz_target;
use routecore::bgp::nlri::afisafi::Nlri;

fuzz_target!(|data: (Nlri<&[u8]>, Nlri<&[u8]>, Nlri<&[u8]>)| {
let (a, b, c) = data;
match (a.cmp(&b), b.cmp(&c)) {
// a < b < c
(Less, Less) => assert_eq!(a.cmp(&c), Less),
// a < b == c
(Less, Equal) => assert_eq!(a.cmp(&c), Less),
// a < b > c
(Less, Greater) => { } ,

// a == b == c
(Equal, Equal) => assert_eq!(a.cmp(&c), Equal),
// a == b < c
(Equal, Less) => assert_eq!(a.cmp(&c), Less),
// a == b > c
(Equal, Greater) => assert_eq!(a.cmp(&c), Greater),

// a > b > c
(Greater, Greater) => assert_eq!(a.cmp(&c), Greater),
// a > b < c
(Greater, Less) => { },
// a > b == c
(Greater, Equal) => assert_eq!(a.cmp(&c), Greater),
}
});

19 changes: 7 additions & 12 deletions fuzz/fuzz_targets/parse_update_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,18 @@ use routecore::bgp::message::{UpdateMessage, SessionConfig};
use routecore::bgp::message::update_builder::UpdateBuilder;

fuzz_target!(|data: (&[u8], SessionConfig)| {
if let Ok(upd) = UpdateMessage::from_octets(data.0, data.1) {
if let Ok(upd) = UpdateMessage::from_octets(data.0, &data.1) {
if let Ok(pas) = upd.path_attributes() {
for pa in pas.into_iter() {
if let Ok(pa) = pa {
let _ = pa.to_owned();
}
let _ = pa.unwrap().to_owned();
}
}
/*
if let Ok(builder) = UpdateBuilder::from_update_message(
&upd,
data.1,
target,
) {
let _ = builder.into_message(); //.unwrap();
if let Ok(iter) = upd.announcements() {
iter.count();
}
if let Ok(iter) = upd.withdrawals() {
iter.count();
}
*/
}
});

Expand Down
80 changes: 80 additions & 0 deletions fuzz/fuzz_targets/path_selection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#![no_main]

use std::cmp::Ordering::*;
use libfuzzer_sys::fuzz_target;
use routecore::bgp::{path_attributes::PaMap, path_selection::{OrdRoute, Rfc4271, SkipMed, TiebreakerInfo}};

fn verify_ord<T>(a: &T, b: &T, c: &T)
where T: Ord
{
match (a.cmp(b), b.cmp(c)) {
// a < b < c
(Less, Less) => assert_eq!(a.cmp(c), Less),
// a < b == c
(Less, Equal) => assert_eq!(a.cmp(c), Less),
// a < b > c
(Less, Greater) => { } ,

// a == b == c
(Equal, Equal) => {
assert_eq!(a.cmp(c), Equal);
// Test PartialEq
assert!(a == b);
assert!(b == c);
}
// a == b < c
(Equal, Less) => assert_eq!(a.cmp(c), Less),
// a == b > c
(Equal, Greater) => assert_eq!(a.cmp(c), Greater),

// a > b > c
(Greater, Greater) => assert_eq!(a.cmp(c), Greater),
// a > b < c
(Greater, Less) => { },
// a > b == c
(Greater, Equal) => assert_eq!(a.cmp(c), Greater),
}
}

// XXX while doing fuzz_target!(|data: &[u8]| ... and then creating an
// Unstructured from `data` can be useful, the Debug output becomes quite
// useless. It'll be just a bunch of bytes without any structure.
// So, something like
// fuzz_target!(|data: (OrdRoute, OrdRoute, OrdRoute)| {
// has benefits.
//

fuzz_target!(|data: (
PaMap, TiebreakerInfo,
PaMap, TiebreakerInfo,
PaMap, TiebreakerInfo
)|{

//dbg!(&data);

let a = match OrdRoute::<SkipMed>::try_new(&data.0, data.1) {
Ok(r) => r,
Err(_) => return,
};
let b = match OrdRoute::<SkipMed>::try_new(&data.2, data.3) {
Ok(r) => r,
Err(_) => return,
};
let c = match OrdRoute::<SkipMed>::try_new(&data.4, data.5) {
Ok(r) => r,
Err(_) => return,
};

//dbg!("skipmed");
verify_ord(&a, &b, &c);

//dbg!("rfc4271");
/*
verify_ord(
&a.into_strat::<Rfc4271>(),
&b.into_strat::<Rfc4271>(),
&c.into_strat::<Rfc4271>()
);
*/

});
4 changes: 3 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
max_width = 78
edition = "2021"
max_width = 78

Loading
Loading