-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the "established" and "backward-transition" notifications defined in the IETF BGP model. The topology tests data have been update accordingly. Signed-off-by: Renato Westphal <[email protected]>
- Loading branch information
Showing
14 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
// | ||
|
||
pub mod configuration; | ||
pub mod notification; | ||
pub mod rpc; | ||
pub mod state; | ||
pub mod yang; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// Copyright (c) The Holo Core Contributors | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
use holo_northbound::notification; | ||
use holo_northbound::paths::control_plane_protocol; | ||
use holo_northbound::paths::control_plane_protocol::bgp; | ||
use holo_utils::protocol::Protocol; | ||
use holo_yang::ToYang; | ||
|
||
use crate::instance::InstanceUpView; | ||
use crate::neighbor::Neighbor; | ||
|
||
// ===== global functions ===== | ||
|
||
pub(crate) fn established(instance: &InstanceUpView<'_>, nbr: &Neighbor) { | ||
use bgp::neighbors::established::{self, Established}; | ||
|
||
let path = format!( | ||
"{}{}{}", | ||
control_plane_protocol::PATH, | ||
control_plane_protocol::list_keys( | ||
Protocol::BGP.to_yang(), | ||
instance.name | ||
), | ||
established::RELATIVE_PATH, | ||
); | ||
let data = Established { | ||
remote_address: Some(nbr.remote_addr.to_string().into()), | ||
}; | ||
notification::send(&instance.tx.nb, path, data); | ||
} | ||
|
||
pub(crate) fn backward_transition( | ||
instance: &InstanceUpView<'_>, | ||
nbr: &Neighbor, | ||
) { | ||
use bgp::neighbors::backward_transition::notification_received::NotificationReceived; | ||
use bgp::neighbors::backward_transition::notification_sent::NotificationSent; | ||
use bgp::neighbors::backward_transition::{self, BackwardTransition}; | ||
|
||
let path = format!( | ||
"{}{}{}", | ||
control_plane_protocol::PATH, | ||
control_plane_protocol::list_keys( | ||
Protocol::BGP.to_yang(), | ||
instance.name | ||
), | ||
backward_transition::RELATIVE_PATH, | ||
); | ||
let data = BackwardTransition { | ||
remote_addr: Some(nbr.remote_addr.to_string().into()), | ||
notification_received: nbr.notification_rcvd.as_ref().map( | ||
|(time, notif)| NotificationReceived { | ||
last_notification: Some(time.to_rfc3339().into()), | ||
last_error: Some(notif.to_yang()), | ||
last_error_code: Some(notif.error_code.to_string().into()), | ||
last_error_subcode: Some( | ||
notif.error_subcode.to_string().into(), | ||
), | ||
}, | ||
), | ||
notification_sent: nbr.notification_sent.as_ref().map( | ||
|(time, notif)| NotificationSent { | ||
last_notification: Some(time.to_rfc3339().into()), | ||
last_error: Some(notif.to_yang()), | ||
last_error_code: Some(notif.error_code.to_string().into()), | ||
last_error_subcode: Some( | ||
notif.error_subcode.to_string().into(), | ||
), | ||
}, | ||
), | ||
}; | ||
notification::send(&instance.tx.nb, path, data); | ||
} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo1-1/rt1/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.1.2"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.2.3"}}}}]}}} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo1-1/rt2/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.1.1"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.3.4"}}}}]}}} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo1-1/rt3/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.2.1"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"4.4.4.4"}}}}]}}} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo1-1/rt4/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.3.2"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"3.3.3.3"}}}}]}}} |
3 changes: 3 additions & 0 deletions
3
holo-bgp/tests/conformance/topologies/topo2-1/rt1/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.1.2"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.2.4"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.3.5"}}}}]}}} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo2-1/rt2/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.1.1"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.4.3"}}}}]}}} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo2-1/rt3/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.4.2"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.5.6"}}}}]}}} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo2-1/rt4/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.2.1"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.6.6"}}}}]}}} |
2 changes: 2 additions & 0 deletions
2
holo-bgp/tests/conformance/topologies/topo2-1/rt5/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.3.1"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.7.6"}}}}]}}} |
3 changes: 3 additions & 0 deletions
3
holo-bgp/tests/conformance/topologies/topo2-1/rt6/output/northbound-notif.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.7.5"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.5.3"}}}}]}}} | ||
{"ietf-routing:routing":{"control-plane-protocols":{"control-plane-protocol":[{"type":"ietf-bgp:bgp","name":"test","ietf-bgp:bgp":{"neighbors":{"established":{"remote-address":"10.0.6.4"}}}}]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters