diff --git a/Cargo.lock b/Cargo.lock index b465a689..79a0916d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2106,6 +2106,8 @@ dependencies = [ [[package]] name = "rotonda-macros" version = "0.4.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb43b66c79248229e670e1159838c926d6a4d440e4bd1731b4963448d6fd7dc9" dependencies = [ "quote", "syn 2.0.82", @@ -2114,6 +2116,8 @@ dependencies = [ [[package]] name = "rotonda-store" version = "0.4.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9ff3d52cdaa52abeecb2ed21401af73bed98484b71759eef54c21c9b0984d65" dependencies = [ "crossbeam-epoch", "crossbeam-utils", diff --git a/Cargo.toml b/Cargo.toml index 052c38d5..50afe576 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -117,23 +117,15 @@ assets = [ ["target/release/rotonda", "usr/bin/", "755"], ["README.md", "usr/share/doc/rotonda/", "644"], ["doc/rotonda.1", "usr/share/man/man1/rotonda.1", "644"], - ["etc/rotonda.conf.system-service", "etc/rotonda/rotonda.conf", "644"], - ["etc/rotonda/rotonda.example.conf", "etc/rotonda/rotonda.example.conf", "644"], - ["etc/rotonda/filters/bgp-in-filter.roto", "etc/rotonda/filters/bgp-in-filter.roto", "644"], - ["etc/rotonda/filters/bmp-in-filter.roto", "etc/rotonda/filters/bmp-in-filter.roto", "644"], - ["etc/rotonda/filters/rib-in-post-filter.roto", "etc/rotonda/filters/rib-in-post-filter.roto", "644"], - ["etc/rotonda/filters/rib-in-pre-filter.roto", "etc/rotonda/filters/rib-in-pre-filter.roto", "644"] + ["etc/rotonda/rotonda.conf", "etc/rotonda/rotonda.conf", "644"], + ["etc/rotonda/filters.roto", "etc/rotonda/filters.roto", "644"], ] maintainer-scripts = "pkg/debian" changelog = "target/debian/changelog" # this will be generated by the pkg workflow copyright = "Copyright (c) 2023, NLnet Labs. All rights reserved." conf-files = [ "/etc/rotonda/rotonda.conf", - "/etc/rotonda/filters/bgp-in-filter.roto", - "/etc/rotonda/filters/bmp-in-filter.roto", - "/etc/rotonda/filters/rib-in-post-filter.roto", - "/etc/rotonda/filters/rib-in-pre-filter.roto", - "/etc/rotonda/rotonda.example.conf" + "/etc/rotonda/filters.roto", ] systemd-units = { unit-name = "rotonda", unit-scripts = "pkg/common", enable = false } @@ -148,12 +140,8 @@ assets = [ { source = "target/release/rotonda", dest = "/usr/bin/rotonda", mode = "755" }, { source = "target/rpm/rotonda.service", dest = "/lib/systemd/system/rotonda.service", mode = "644" }, { source = "doc/rotonda.1", dest = "/usr/share/man/man1/rotonda.1", mode = "644", doc = true }, - { source = "etc/rotonda.conf.system-service", dest = "/etc/rotonda/rotonda.conf", mode = "644", config = true }, - { source = "etc/rotonda/rotonda.example.conf", dest = "/etc/rotonda/rotonda.example.conf", mode = "644", config = true }, - { source = "etc/rotonda/filters/bgp-in-filter.roto", dest = "/etc/rotonda/filters/bgp-in-filter.roto", mode = "644", config = true }, - { source = "etc/rotonda/filters/bmp-in-filter.roto", dest = "/etc/rotonda/filters/bmp-in-filter.roto", mode = "644", config = true }, - { source = "etc/rotonda/filters/rib-in-post-filter.roto", dest = "/etc/rotonda/filters/rib-in-post-filter.roto", mode = "644", config = true }, - { source = "etc/rotonda/filters/rib-in-pre-filter.roto", dest = "/etc/rotonda/filters/rib-in-pre-filter.roto", mode = "644", config = true } + { source = "etc/rotonda/rotonda.conf", dest = "/etc/rotonda/rotonda.conf", mode = "644", config = true }, + { source = "etc/rotonda/filters.roto", dest = "/etc/rotonda/filters.roto", mode = "644", config = true }, ] # These get set using cargo-generate-rpm --set-metadata at package build time. #post_install_script = ... diff --git a/etc/filters.roto b/etc/filters.roto new file mode 100644 index 00000000..312d2bf2 --- /dev/null +++ b/etc/filters.roto @@ -0,0 +1,134 @@ +// The bgp-in filter works on incoming BGP UPDATE messages. +// +// One such message can contain multiple NLRI, thus multiple announcements or +// withdrawals). To act on individual announcements or withdrawals, use the +// 'rib-in' filter-map below. +filter-map bgp-in( + output: Log, + bgp: BgpMsg, + prov: Provenance, +) { + + define { + origin_to_log = AS65536; + community_to_log = 0xffff029a; + } + + apply { + if bgp.aspath_origin(origin_to_log) { + output.log_matched_origin(origin_to_log); + } + if bgp.contains_community(community_to_log) { + output.log_matched_community(community_to_log) + } + + accept + } +} + +// The bmp-in filter works on incoming BMP messages. +// +// While most BMP message will be of type RouteMonitoring (transporting route +// information via an encapsulated BGP UPDATE message), this filter-map can act +// on different types as well. Helper methods are provided, e.g. +// 'is_peer_down()' returns true if the message is a BMP PeerDownNotification. +filter-map bmp-in( + output: Log, + bmp: BmpMsg, + prov: Provenance, +) { + define { + my_asn = AS12345; + asn_to_log = AS65536; + community_to_log = 0xffff029a; + } + + apply { + if bmp.is_peer_down() { + output.log_peer_down() + } + if bmp.is_ibgp(my_asn) { + reject + } else { + if bmp.aspath_contains(asn_to_log) { + output.log_matched_asn(asn_to_log); + } + if bmp.contains_community(community_to_log) { + output.log_matched_community(community_to_log) + } + accept + } + } +} + +// The rib-in-pre filter processes individual routes prior to insertion into the +// main RIB. +// +// Different from the BGP UPDATE message in the bgp-in filter-map, and the BMP +// RouteMonitoring message in the bmp-in filter-map, the rib-in filter works on +// individual announcements and withdrawals, typed Route. +// +// Use the rib-in-pre filter to process routes based on their NLRI (often the +// announced prefix itself), as most other things are simply more efficient to +// do in the bgp-in/bmp-in stage. +// Use the rib-in-post filter below to act on inserted Routes. +filter-map rib-in-pre( + output: Log, + route: Route, + context: RouteContext, +) { + + define { + attribute_to_log = 35; // OTC + my_prefix = 100.40.0.0/17; + //my_prefix = 2001:db8:1::/48; + } + + apply { + //if route.has_attribute(attribute_to_log) { + // accept + //} else { + // reject + //} + if route.prefix_matches(my_prefix) { + output.log_custom(10, 20); + output.log_prefix(my_prefix); + } + + accept + } +} + +// The rib-in-post filter processes Routes that have been accepted by the +// rib-in-pre filter-map, and thus have been inserted in the RIB. +// This filter-map is useful for logging/alerting purposes. + +//filter rib-in-post( +// output: Log, +// route: Route, +// insertion_info: InsertionInfo, +//) { +// +// define { +// some_interesting_prefix = 100.40.0.0/17; +// } +// +// apply { +// //if route.announces(my_prefix) && insertion_info.is_new_best_path() { +// // output.log_best_path() +// //} +// //if insertion_info.path_replaced(my_prefix) { +// // output.log_best_path() +// //} +// +// //if insertion_info.new_peer() { +// // output.log_custom(1,1); +// //} +// //if insertion_info.prefix_new() { +// // output.log_custom(2,1); +// //} +// +// accept // no-op, but required +// } +//} + diff --git a/etc/rotonda.conf b/etc/rotonda.conf new file mode 100644 index 00000000..4df397d7 --- /dev/null +++ b/etc/rotonda.conf @@ -0,0 +1,64 @@ +log_level = "info" # "error", "warn", "info", "debug" or "trace" +log_target = "stderr" # "stderr", "file" or "syslog" +log_facility = "daemon" # used if log_target is "syslog" +log_file = "./rotonda.log" # used if log_target is "file" + +roto_script = "filters.roto" + +http_listen = ["0.0.0.0:8080"] + + +## BMP + +[units.bmp-in] +type = "bmp-tcp-in" +listen = "0.0.0.0:11019" +http_api_path = "/bmp-routers/" +tracing_mode = "Off" + + +## BGP + +#[units.bgp-in] +#type = "bgp-tcp-in" +#listen = "10.1.0.254:179" +#my_asn = 64512 +#my_bgp_id = [10,1,0,254] +# +#[units.bgp-in.peers."10.1.0.1"] +#name = "PeerA" +#remote_asn = [] +#protocols = ["Ipv4Unicast", "Ipv4Multicast", "Ipv6Unicast"] +# +#[units.bgp-in.peers."10.1.0.2"] +#name = "PeerB" +#remote_asn = [] +#protocols = ["Ipv4Unicast", "Ipv6Unicast"] + +## MRT + +#[units.mrt-in] +#type = "mrt-in" +#filename = "path/to/bview.mrt" + + +## RIB + +[units.rib] +type = "rib" +rib_type = "Physical" +sources = ["bmp-in"] +#sources = ["bgp-in", "bmp-in", "mrt-in"] + + +## Targets + +[targets.null] +type = "null-out" +sources = ["rib"] + +#[targets.mqtt] +#type = "mqtt-out" +#sources = ["bmp-in", "bgp-in", "rib"] +#destination = "localhost" +#client_id = "rotonda" diff --git a/etc/rotonda.conf.system-service b/etc/rotonda.conf.system-service deleted file mode 100644 index c50025b4..00000000 --- a/etc/rotonda.conf.system-service +++ /dev/null @@ -1,60 +0,0 @@ -# Sample Rotonda configuration file for systemd service - -log_level = "info" # "error", "warn", "info", "debug" or "trace" -log_target = "syslog" # "stderr", "file" or "syslog" -log_facility = "daemon" # used if log_target is "syslog" - -roto_scripts_path = "/etc/rotonda/filters/" - -http_listen = ["127.0.0.1:8080"] - -[units.bgp-in] -type = "bgp-tcp-in" -listen = "0.0.0.0:179" - -# EDIT THIS: THIS IS AN EXAMPLE VALUE -my_asn = 64512 -# EDIT THIS: THIS IS AN EXAMPLE VALUE -my_bgp_id = [0, 0, 0, 0] - -filter_name = "bgp-in-filter" - -[units.bmp-in] -type = "bmp-tcp-in" -listen = "0.0.0.0:11019" -filter_name = "bmp-in-filter" -http_api_path = "/bmp-routers/" -tracing_mode = "Off" - -[units.rib-in-pre] -type = "rib" -sources = ["bgp-in", "bmp-in"] -rib_type = "Physical" -filter_name = "rib-in-pre-filter" -http_api_path = "/rib-in-pre/" - -[units.rib-in-post] -type = "rib" -sources = ["rib-in-pre"] -rib_type = "Virtual" -vrib_upstream = "rib-in-pre" -filter_name = "rib-in-post-filter" -http_api_path = "/rib-in-post/" - -[targets.null] -type = "null-out" -sources = ["rib-in-post"] - -# Commenting out this whole section will disable the mqtt interface -[targets.mqtt] -type = "mqtt-out" -sources = ["bmp-in", "bgp-in", "rib-in-pre", "rib-in-post"] - -# EDIT THIS OR COMMENT OUT SECTION -client_id = "rotonda" - -# EDIT THIS OR COMMENT OUT SECTION -topic_template = "{id}" - -# EDIT THIS OR COMMENT OUT SECTION -destination = "SOME_IP_ADDRESS:SOME_PORT" diff --git a/etc/rotonda/filters/adj-rib-in-filter-experimental.roto b/etc/rotonda/filters/adj-rib-in-filter-experimental.roto deleted file mode 100644 index a6cefc0b..00000000 --- a/etc/rotonda/filters/adj-rib-in-filter-experimental.roto +++ /dev/null @@ -1,104 +0,0 @@ -filter-map adj-rib-in { - define { - rx nlri: Nlri; - tx rib_in_post_route: RibInPostRoute with Key { peer_id, router_id }; - context this: Context; - - is_rib_in_post = false; - } - - term is-rib-in-post { - match this.nlri { - Unicast(nlri) -> { this.provenance.rib_type == AjdRibInPost }, - Multicast(nlri) -> { this.provenance.rib_type == AjdRibInPost } - } - } - - action set-rib-in-post-true { - is_rib_in_post = true; - } - - action set-rib-in-post { - rib_in_post_route.rib_in_post.set(is_rib_in_post); - rib_in_post_route.peer_id.set(this.provenance.peer_id); - rib_in_post_route.router_id.set(this.provenance.router_id); - } - - apply { - filter match is-rib-in-post { - set-rib-in-post-true; - } - set-rib-in-post; - } -} - -type RibInPostRoute { - peer_id: PeerId, - router_id: String - rib_in_post: Bool -} - -// Context object - -// NLRI properties -// -// .nlri: Nlri, // NLRI for THIS -// .status: RouteStatus, // status for THIS route -// .index: NlriIndex // (MP_REACH | MP_UNREACH | announcement | withdrawal) & position in the NLRIs of the message - -// enum routecore::Nlri -// routes -// struct Route: Unicast(BasicNlri), // (v4/v6, unicast) -// struct Route: Multicast(BasicNlri), // (v4/v6, multicast) - -// routes+ -// Mpls(MplsNlri), // (v4/v6, mpls unicast) -// MplsVpn(MplsVpnNlri), // (v4/v6, mpls vpn unicast) - -// non-routes -// Vpls(VplsNlri), // (l2vpn, vpls) -// FlowSpec: FlowSpec(FlowSpecNlri), // (v4/v6, flowspec) -// RouteTarget(RouteTargetNlri), // (v4, route target) -// Evpn(EvpnNlri), - -// Message Path Attributes -// -// .message { -// aggregator_type -// announcements: [Nlri], -// as_path: AsPath, -// as4_path: AsPath, -// atomic_aggregate: AtomicAggregate, -// communities: [Community], -// local_pref: LocalPref, -// multi_exit_discriminator: MultiExitDisc, -// next_hop: NextHop, -// origin_type: OriginType, -// // TODO -// withdrawals: [Nlri], -// extended_communities: [Community], -// large_communities: [Community] -// ... -// } - -// .provenance { - // String from sysName, sysDescr (BMP) or BGP Identifier (BGP) as - // String, or a user-defined string (set in the bgp-in unit) -// router_id: RouterId, - // (peer_address, peer_asn) (BMP/BGP) -// peer_id: PeerId, - // ([U8] the BGP Identifier) (BMP/BGP) -// peer_bgp_id: PeerBgpId, - // ([U8] 8 bytes, if any, multiple instance routers. -// peer_distuingisher, - // AdjRibInPre | AdjRibInPost | AdjRibOutPre | AdjRibOutPost | - // AdjRibLoc -// peer_rib: RibType - // from the per_peer_header (BMP) or generated by roto (BGP) -// timestamp: u64, -// // TODO -// message_id: (RotondaId, LogicalTime, Hash) -// } - -// ::routers [ router_id, ... ] -// \ No newline at end of file diff --git a/etc/rotonda/filters/adj-rib-in-filter.roto b/etc/rotonda/filters/adj-rib-in-filter.roto deleted file mode 100644 index 984be5a7..00000000 --- a/etc/rotonda/filters/adj-rib-in-filter.roto +++ /dev/null @@ -1,96 +0,0 @@ -filter-map adj-rib-in { - define { - rx route: Route; //Unicast | MultiCast | MplsVpnNlri; - tx rib_in_post_route: RibInPostRoute; // with Key { peer_id, router_id }; - context ctx: RouteContext; - - is_rib_in_post = false; - } - - term is-rib-in-post { - match { - ctx.provenance.peer_rib_type == AjdRibInPost; - } - } - - action set-rib-in-post-true { - //is_rib_in_post = true; - is_rib_in_post.set(true); - } - - action set-rib-in-post { - rib_in_post_route.rib_in_post.set(is_rib_in_post); - rib_in_post_route.peer_id.set(ctx.provenance.peer_id); - rib_in_post_route.router_id.set(ctx.provenance.router_id); - } - - apply { - filter match is-rib-in-post matching { - set-rib-in-post-true; - set-rib-in-post; - }; - filter match is-rib-in-post not matching { - set-rib-in-post; - }; - } -} - -type RibInPostRoute { - peer_id: PeerId, - router_id: String, - rib_in_post: Bool -} - -// Context object - -// NLRI properties -// -// .nlri { -// type: NlriType, -// prefix: Prefix, // prefix, if this NLRI is a route. -// path_id: PathId // Multipath ID, if any -// afi_safi: AfiSafi, // afi_safi for THIS route -// status: RouteStatus, // status for THIS route -// } - -// Unicast(BasicNlri), // (v4/v6, unicast) -// Multicast(BasicNlri), // (v4/v6, multicast) -// Mpls(MplsNlri), // (v4/v6, mpls unicast) -// MplsVpn(MplsVpnNlri), // (v4/v6, mpls vpn unicast) -// Vpls(VplsNlri), // (l2vpn, vpls) -// FlowSpec(FlowSpecNlri), // (v4/v6, flowspec) -// RouteTarget(RouteTargetNlri), // (v4, route target) -// Evpn(EvpnNlri), - - -// Message properties -// -// .message { -// aggregator_type -// announcements: [Nlri], -// as_path: AsPath, -// as4_path: AsPath, -// atomic_aggregate: AtomicAggregate, -// communities: [Community], -// local_pref: LocalPref, -// multi_exit_discriminator: MultiExitDisc, -// next_hop: NextHop, -// origin_type: OriginType, -// // TODO -// withdrawals: [Nlri], -// extended_communities: [Community], -// large_communities: [Community] -// ... -// } - -// .provenance { -// router_id: RouterId, // String from sysName, sysDescr (BMP) or BGP Identifier (BGP) as String, or a user-defined string (set in the bgp-in unit) -// peer_id: PeerId, // (peer_address, peer_asn) (BMP/BGP) -// peer_bgp_id: PeerBgpId, // ([U8] the BGP Identifier) (BMP/BGP) -// peer_distuingisher, // ([U8] 8 bytes, if any, multiple instance routers. -// peer_rib: RibType // AdjRibInPre | AdjRibInPost | AdjRibOutPre | AdjRibOutPost | AdjRibLoc -// timestamp: u64, // from the per_peer_header (BMP) or generated by roto (BGP) -// } - -// ::routers [ router_id, ... ] -// diff --git a/etc/rotonda/filters/bgp-in-filter.roto b/etc/rotonda/filters/bgp-in-filter.roto deleted file mode 100644 index 7635bc13..00000000 --- a/etc/rotonda/filters/bgp-in-filter.roto +++ /dev/null @@ -1,9 +0,0 @@ -filter bgp-in-filter { - define { - rx bgp_msg: BgpUpdateMessage; - } - - apply { - accept; - } -} diff --git a/etc/rotonda/filters/bmp-in-filter.roto b/etc/rotonda/filters/bmp-in-filter.roto deleted file mode 100644 index e4cbb06f..00000000 --- a/etc/rotonda/filters/bmp-in-filter.roto +++ /dev/null @@ -1,44 +0,0 @@ -filter-map bmp-in-filter { - define { - rx bmp_msg: BmpMessage; - tx out_msg: SplitOut; - filtered_asn = AS65000; - } - - term filtered-asn { - match bmp_msg with { - PeerDownNotification(pd_msg) -> { - pd_msg.per_peer_header.asn == filtered_asn; - }, - PeerUpNotification(pu_msg) -> { - pu_msg.per_peer_header.asn == filtered_asn; - }, - RouteMonitoring(rm_msg) -> { - rm_msg.per_peer_header.asn == filtered_asn; - }, - StatisticsReport(sr_msg) -> { - sr_msg.per_peer_header.asn == filtered_asn; - } - } - } - - term is-post-policy { - match bmp_msg with { - RouteMonitoring(rm_msg) -> { - rm_msg.per_peer_header.is_post_policy; - } - } - } - - apply { - filter match filtered-asn matching { return reject; }; - filter match is-post-policy { - // return accept.and_send(rx, out_msg.left); - return accept; - }; - // accept.and_send(rx, out_msg.right); - return accept; - } -} - -type SplitOut { left: BmpMessage, right: BmpMessage } \ No newline at end of file diff --git a/etc/rotonda/filters/rib-in-post-filter.roto b/etc/rotonda/filters/rib-in-post-filter.roto deleted file mode 100644 index 9e97af24..00000000 --- a/etc/rotonda/filters/rib-in-post-filter.roto +++ /dev/null @@ -1,9 +0,0 @@ -filter rib-in-post-filter { - define { - rx route: Route; - } - - apply { - accept; - } -} diff --git a/etc/rotonda/filters/rib-in-pre-filter.roto b/etc/rotonda/filters/rib-in-pre-filter.roto deleted file mode 100644 index e72f8e4b..00000000 --- a/etc/rotonda/filters/rib-in-pre-filter.roto +++ /dev/null @@ -1,9 +0,0 @@ -filter rib-in-pre-filter { - define { - rx route: Route; - } - - apply { - accept; - } -} diff --git a/etc/rotonda/rotonda.builtin.conf b/etc/rotonda/rotonda.builtin.conf deleted file mode 100644 index 8de8e4c1..00000000 --- a/etc/rotonda/rotonda.builtin.conf +++ /dev/null @@ -1,66 +0,0 @@ -# Rotonda configuration file. - -# For information about this file: https://rotonda.docs.nlnetlabs.nl/en/latest/config/global.html -# This is the configuration file that was used to compile the -log_level = "info" # "error", "warn", "info", "debug" or "trace" -log_target = "stderr" # "stderr", "file" or "syslog" -log_facility = "daemon" # used if log_target is "syslog" -log_file = "./rotonda.log" # used if log_target is "file" - -# Optional path to a directory from which any .roto files present will be -# loaded into Rotonda. Filter names used below refer to blocks in the .roto -# files loaded from this directory. -roto_scripts_path = "/etc/rotonda/filters" - -http_listen = ["127.0.0.1:8080"] - -[units.bgp-in] -type = "bgp-tcp-in" -listen = "0.0.0.0:11179" # TODO: When we can drop privileges make this 179 -my_asn = 64512 # Tip: edit me, or comment this unit out -my_bgp_id = [0, 0, 0, 0] # Tip: edit me, or comment this unit out -filter_name = "bgp-in-filter" - -[units.bmp-in] -type = "bmp-tcp-in" -listen = "0.0.0.0:11019" -filter_name = "bmp-in-filter" -http_api_path = "/bmp-routers/" -tracing_mode = "Off" - -# The two RIB units below could have been defined like so: -# -# [units.rib-in-pre] -# type = "rib" -# sources = ["bgp-in", "bmp-in"] -# filter_name = ["rib-in-pre", "rib-in-post"] -# -# But then we don't control the unit naming or HTTP API paths, instead the -# virtual RIB would be named "rib-in-pre-vRIB-0" and its HTTP API path would -# be that of the pRIB with /0/ appended. - -[units.rib-in-pre] -type = "rib" -sources = ["bgp-in", "bmp-in"] -rib_type = "Physical" -filter_name = "rib-in-pre-filter" -http_api_path = "/rib-in-pre/" - -[units.rib-in-post] -type = "rib" -sources = ["rib-in-pre"] -rib_type = "Virtual" -vrib_upstream = "rib-in-pre" -filter_name = "rib-in-post-filter" -http_api_path = "/rib-in-post/" - -[targets.null] -type = "null-out" -sources = ["rib-in-post"] - -[targets.mqtt] -type = "mqtt-out" -sources = ["bmp-in", "bgp-in", "rib-in-pre", "rib-in-post"] -client_id = "rotonda" # Tip: edit me -topic_template = "{id}" # Tip: edit me -destination = "SOME_IP_ADDRESS:SOME_PORT" # Tip: edit me, or comment this target out diff --git a/etc/rotonda/rotonda.example.conf b/etc/rotonda/rotonda.example.conf deleted file mode 100644 index e14da0be..00000000 --- a/etc/rotonda/rotonda.example.conf +++ /dev/null @@ -1,43 +0,0 @@ -log_level = "info" # "error", "warn", "info", "debug" or "trace" -log_target = "stderr" # "stderr", "file" or "syslog" -log_facility = "daemon" # used if log_target is "syslog" -log_file = "./rotonda.log" # used if log_target is "file" - -# Optional path to a directory from which any .roto files present will be -# loaded into Rotonda. Filter names used below refer to blocks in the .roto -# files loaded from this directory. -roto_scripts_path = "etc/rotonda/filters" - -http_listen = ["0.0.0.0:8080"] - -[units.bgp-in] -type = "bgp-tcp-in" -listen = "0.0.0.0:11179" -my_asn = 64512 -my_bgp_id = [0, 0, 0, 0] -filter_name = "bgp-in-filter" - -[units.bmp-in] -type = "bmp-tcp-in" -listen = "0.0.0.0:11019" -filter_name = "bmp-in-filter" -http_api_path = "/bmp-routers/" -tracing_mode = "Off" - -[units.rib-in-pre] -type = "rib" -sources = ["bgp-in", "bmp-in"] -rib_type = "Physical" -filter_name = "rib-in-pre-filter" -http_api_path = "/rib-in-pre/" - -[units.rib-in-post] -type = "rib" -sources = ["bgp-in", "bmp-in"] -rib_type = "Physical" -filter_name = "rib-in-post-filter" -http_api_path = "/rib-in-post/" - -[targets.null] -type = "null-out" -sources = ["rib-in-pre","rib-in-post"] diff --git a/src/manager.rs b/src/manager.rs index 5e6e81d6..d94c660e 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -826,9 +826,16 @@ impl Manager { config: &Config, file: &ConfigFile, ) -> Result<(), Terminate> { - let mut res = Ok(()); - if let Err(err) = self.compile_roto_script(&config.roto_script) { + let roto_script = config.roto_script.as_ref() + .and_then(|roto_script| + file.path() + .and_then(|p| p.parent()) + .map(|d| d.to_path_buf()) + .map(|mut dir|{ dir.push(roto_script); dir}) + ); + + if let Err(err) = self.compile_roto_script(&roto_script) { let msg = format!("Unable to load main Roto script: {err}."); error!("{msg}"); Err(Terminate::error())? @@ -873,7 +880,7 @@ impl Manager { // started Units and Targets. The caller should invoke spawn() to run // each Unit and Target and assign Gates to Units by name. - res + Ok(()) } diff --git a/src/units/bgp_tcp_in/unit.rs b/src/units/bgp_tcp_in/unit.rs index a8e6ccba..1ecc692a 100644 --- a/src/units/bgp_tcp_in/unit.rs +++ b/src/units/bgp_tcp_in/unit.rs @@ -78,8 +78,8 @@ pub struct BgpTcpIn { #[serde(default)] pub filter_name: FilterName, - /// Outgoing BGP UPDATEs can come from these sources. - pub sources: Vec + ///// Outgoing BGP UPDATEs can come from these sources. + //pub sources: Vec } impl PartialEq for BgpTcpIn { @@ -99,7 +99,7 @@ impl BgpTcpIn { my_bgp_id: Default::default(), peer_configs: Default::default(), filter_name: Default::default(), - sources: Vec::new(), + //sources: Vec::new(), } } @@ -140,7 +140,7 @@ impl BgpTcpIn { // XXX refactor BgpTcpInRunner so it does not take the mut BgpTcpIn // so that we can pass self.sources into .run below // That way this unit is a bit more consistent with the RibUnit. - let sources = self.sources.clone(); + //let sources = self.sources.clone(); BgpTcpInRunner::new( self, gate, @@ -150,7 +150,8 @@ impl BgpTcpIn { ingresses, ) .run::<_, _, StandardTcpStream, BgpTcpInRunner>( - sources, + //sources, + Vec::new(), Arc::new(StandardTcpListenerFactory,) ).await }