Skip to content

Commit

Permalink
Simplify configuration, adapt packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
DRiKE committed Oct 30, 2024
1 parent f4835e3 commit 6be8363
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 465 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

22 changes: 5 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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 = ...
Expand Down
134 changes: 134 additions & 0 deletions etc/filters.roto
Original file line number Diff line number Diff line change
@@ -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
// }
//}

64 changes: 64 additions & 0 deletions etc/rotonda.conf
Original file line number Diff line number Diff line change
@@ -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"
60 changes: 0 additions & 60 deletions etc/rotonda.conf.system-service

This file was deleted.

Loading

0 comments on commit 6be8363

Please sign in to comment.