Skip to content

Commit f94b990

Browse files
committed
Merge branch 'main' into trey/unnumbered-cleanup
Signed-off-by: Trey Aspelund <trey@oxidecomputer.com>
2 parents 45c818a + 3b64226 commit f94b990

9 files changed

Lines changed: 968 additions & 327 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
#:
3+
#: name = "build-dhcp-server"
4+
#: variety = "basic"
5+
#: target = "helios-2.0"
6+
#: rust_toolchain = "stable"
7+
#: skip_clone = true
8+
#: output_rules = [
9+
#: "=/work/dhcp-server",
10+
#: ]
11+
12+
set -x
13+
set -e
14+
set -o pipefail
15+
16+
#
17+
# Allow this program to run either under buildomat, or in a local clone:
18+
#
19+
if [[ ${CI:-} == true ]]; then
20+
WORK=/work
21+
22+
pfexec pkg install protobuf git
23+
else
24+
if [[ -z ${WORK} || ! -d ${WORK} ]]; then
25+
printf 'ERROR: set WORK when running manually\n' >&2
26+
exit 1
27+
fi
28+
fi
29+
30+
cargo --version
31+
rustc --version
32+
33+
banner 'dhcp-server'
34+
35+
git clone https://github.com/oxidecomputer/omicron.git "${WORK}/ci/omicron"
36+
cd "${WORK}/ci/omicron"
37+
# shellcheck source=/dev/null
38+
source env.sh
39+
if [[ ${CI:-} == true ]]; then
40+
# shellcheck source=/dev/null
41+
source .github/buildomat/ci-env.sh
42+
./tools/install_builder_prerequisites.sh -y
43+
fi
44+
cargo build -p end-to-end-tests --bin dhcp-server --release
45+
cp target/release/dhcp-server "${WORK}/"

.github/buildomat/jobs/build-interop.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#: target = "helios-2.0"
66
#: rust_toolchain = "stable"
77
#: skip_clone = true
8+
#:
9+
#: enable = false
10+
#:
811
#: access_repos = [
912
#: "oxidecomputer/testbed",
1013
#: ]

.github/buildomat/jobs/falcon-lab.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#: "/work/*",
99
#: ]
1010
#:
11-
#: [dependencies.build-interop]
12-
#: job = "build-interop"
11+
#: [dependencies.build-dhcp-server]
12+
#: job = "build-dhcp-server"
1313
#:
1414
#: [dependencies.build]
1515
#: job = "build"
@@ -43,7 +43,7 @@ export FALCON_DATASET="cpool/falcon"
4343

4444
banner 'setup'
4545

46-
cp /input/build-interop/work/dhcp-server .
46+
cp /input/build-dhcp-server/work/dhcp-server .
4747
cp /input/build/work/release/falcon-lab .
4848
cp /input/build/work/release/mgd .
4949
cp /input/build/work/release/ddmd .

bgp/src/router.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
524524
IpNet::V6(_) => None,
525525
})
526526
.collect();
527-
self.db.create_origin4(&prefix4)?;
527+
self.db.create_origin4(self.config.asn, &prefix4)?;
528528

529529
// Skip network propagation if router is shutdown
530530
if !self.shutdown.load(Ordering::Acquire) {
@@ -534,7 +534,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
534534
}
535535

536536
pub fn set_origin4(&self, prefixes: Vec<IpNet>) -> Result<(), Error> {
537-
let origin4 = self.db.get_origin4()?;
537+
let origin4 = self.db.get_origin4(self.config.asn)?;
538538
let current: BTreeSet<&Ipv4Net> = origin4.iter().collect();
539539

540540
let prefix4: Vec<Ipv4Net> = prefixes
@@ -554,7 +554,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
554554
let to_announce: Vec<Ipv4Net> =
555555
new.difference(&current).map(|x| **x).collect();
556556

557-
self.db.set_origin4(&prefix4)?;
557+
self.db.set_origin4(self.config.asn, &prefix4)?;
558558

559559
// Skip network propagation if router is shutdown
560560
if !self.shutdown.load(Ordering::Acquire) {
@@ -565,13 +565,13 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
565565
}
566566

567567
pub fn clear_origin4(&self) -> Result<(), Error> {
568-
let current = self.db.get_origin4()?;
568+
let current = self.db.get_origin4(self.config.asn)?;
569569

570570
// Skip network propagation if router is shutdown
571571
if !self.shutdown.load(Ordering::Acquire) {
572572
self.withdraw_origin4(current);
573573
}
574-
self.db.clear_origin4()?;
574+
self.db.clear_origin4(self.config.asn)?;
575575
Ok(())
576576
}
577577

@@ -628,7 +628,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
628628
IpNet::V4(_) => None,
629629
})
630630
.collect();
631-
self.db.create_origin6(&prefix6)?;
631+
self.db.create_origin6(self.config.asn, &prefix6)?;
632632

633633
// Skip network propagation if router is shutdown
634634
if !self.shutdown.load(Ordering::Acquire) {
@@ -638,7 +638,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
638638
}
639639

640640
pub fn set_origin6(&self, prefixes: Vec<IpNet>) -> Result<(), Error> {
641-
let origin6 = self.db.get_origin6()?;
641+
let origin6 = self.db.get_origin6(self.config.asn)?;
642642
let current: BTreeSet<&Ipv6Net> = origin6.iter().collect();
643643

644644
let prefix6: Vec<Ipv6Net> = prefixes
@@ -658,7 +658,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
658658
let to_announce: Vec<Ipv6Net> =
659659
new.difference(&current).map(|x| **x).collect();
660660

661-
self.db.set_origin6(&prefix6)?;
661+
self.db.set_origin6(self.config.asn, &prefix6)?;
662662

663663
// Skip network propagation if router is shutdown
664664
if !self.shutdown.load(Ordering::Acquire) {
@@ -669,16 +669,26 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
669669
}
670670

671671
pub fn clear_origin6(&self) -> Result<(), Error> {
672-
let current = self.db.get_origin6()?;
672+
let current = self.db.get_origin6(self.config.asn)?;
673673

674674
// Skip network propagation if router is shutdown
675675
if !self.shutdown.load(Ordering::Acquire) {
676676
self.withdraw_origin6(current);
677677
}
678-
self.db.clear_origin6()?;
678+
self.db.clear_origin6(self.config.asn)?;
679679
Ok(())
680680
}
681681

682+
/// Prefixes this router is currently originating into IPv4 unicast.
683+
pub fn originated4(&self) -> Result<Vec<Ipv4Net>, rdb::error::Error> {
684+
self.db.get_origin4(self.config.asn)
685+
}
686+
687+
/// Prefixes this router is currently originating into IPv6 unicast.
688+
pub fn originated6(&self) -> Result<Vec<Ipv6Net>, rdb::error::Error> {
689+
self.db.get_origin6(self.config.asn)
690+
}
691+
682692
fn announce_origin6(&self, prefixes: Vec<Ipv6Net>) {
683693
if prefixes.is_empty() {
684694
return;
@@ -788,7 +798,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
788798
}
789799

790800
fn announce_all(&self) -> Result<(), Error> {
791-
let originated4 = self.db.get_origin4()?;
801+
let originated4 = self.db.get_origin4(self.config.asn)?;
792802

793803
if !originated4.is_empty() {
794804
slog::debug!(
@@ -802,7 +812,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
802812
}
803813

804814
// Also announce IPv6 originated routes
805-
let originated6 = self.db.get_origin6()?;
815+
let originated6 = self.db.get_origin6(self.config.asn)?;
806816

807817
if !originated6.is_empty() {
808818
slog::debug!(

bgp/src/session.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6048,7 +6048,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
60486048

60496049
// Collect the prefixes this router is originating.
60506050
let originated4 = if pc.ipv4_unicast.negotiated() {
6051-
match self.db.get_origin4() {
6051+
match self.db.get_origin4(self.asn) {
60526052
Ok(value) => value,
60536053
Err(e) => {
60546054
//TODO possible death loop. Should we just panic here?
@@ -6067,7 +6067,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
60676067
};
60686068

60696069
let originated6 = if pc.ipv6_unicast.negotiated() {
6070-
match self.db.get_origin6() {
6070+
match self.db.get_origin6(self.asn) {
60716071
Ok(value) => value,
60726072
Err(e) => {
60736073
//TODO possible death loop. Should we just panic here?
@@ -6156,7 +6156,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
61566156
sa: &ShaperApplication,
61576157
) -> anyhow::Result<()> {
61586158
// Get originated IPv4 routes
6159-
let originated4 = match self.db.get_origin4() {
6159+
let originated4 = match self.db.get_origin4(self.asn) {
61606160
Ok(originated) => originated,
61616161
Err(e) => {
61626162
anyhow::bail!("failed to get originated IPv4 from db: {e}");
@@ -6172,7 +6172,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
61726172
}
61736173

61746174
// Get originated IPv6 routes
6175-
let originated6 = match self.db.get_origin6() {
6175+
let originated6 = match self.db.get_origin6(self.asn) {
61766176
Ok(originated) => originated,
61776177
Err(e) => {
61786178
anyhow::bail!("failed to get originated IPv6 from db: {e}");
@@ -6275,7 +6275,8 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
62756275
AdminEvent::ExportPolicyChanged(previous) => {
62766276
match previous {
62776277
ImportExportPolicy::V4(previous4) => {
6278-
let originated = match self.db.get_origin4() {
6278+
let originated = match self.db.get_origin4(self.asn)
6279+
{
62796280
Ok(value) => value,
62806281
Err(e) => {
62816282
session_log!(
@@ -6378,7 +6379,8 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
63786379
FsmState::Established(pc)
63796380
}
63806381
ImportExportPolicy::V6(previous6) => {
6381-
let originated = match self.db.get_origin6() {
6382+
let originated = match self.db.get_origin6(self.asn)
6383+
{
63826384
Ok(value) => value,
63836385
Err(e) => {
63846386
session_log!(
@@ -8323,7 +8325,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
83238325
return Ok(());
83248326
}
83258327

8326-
let originated = match self.db.get_origin4() {
8328+
let originated = match self.db.get_origin4(self.asn) {
83278329
Ok(value) => value,
83288330
Err(e) => {
83298331
session_log!(
@@ -8356,7 +8358,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
83568358
return Ok(());
83578359
}
83588360

8359-
let originated = match self.db.get_origin6() {
8361+
let originated = match self.db.get_origin6(self.asn) {
83608362
Ok(value) => value,
83618363
Err(e) => {
83628364
session_log!(
@@ -8413,7 +8415,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
84138415

84148416
/// Update this router's RIB based on an update message from a peer.
84158417
fn update_rib(&self, update: &UpdateMessage, pc: &PeerConnection<Cnx>) {
8416-
let originated4 = match self.db.get_origin4() {
8418+
let originated4 = match self.db.get_origin4(self.asn) {
84178419
Ok(value) => value,
84188420
Err(e) => {
84198421
session_log!(
@@ -8553,7 +8555,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
85538555
}
85548556
}
85558557
MpReachNlri::Ipv6Unicast(reach6) => {
8556-
let originated6 = match self.db.get_origin6() {
8558+
let originated6 = match self.db.get_origin6(self.asn) {
85578559
Ok(value) => value,
85588560
Err(e) => {
85598561
session_log!(
@@ -8653,7 +8655,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
86538655
.remove_bgp_prefixes(&mp_withdrawn4, &self.peer_id());
86548656
}
86558657
MpUnreachNlri::Ipv6Unicast(unreach6) => {
8656-
let originated6 = match self.db.get_origin6() {
8658+
let originated6 = match self.db.get_origin6(self.asn) {
86578659
Ok(value) => value,
86588660
Err(e) => {
86598661
session_log!(

0 commit comments

Comments
 (0)