Skip to content

Commit 145f25c

Browse files
authored
Add LLDP (#5196)
This adds the `lldp` daemon and CLI to the switch zone and updates `sled-agent` to do the basic configuration and enablement of the service. On its own, this change will not cause the switch zone to advertise or receive `lldp` packets, as no interfaces are configured. That can be done using the CLI in the switch zone for testing on `dogfood` and/or the colo. Adding runtime configuration by `nexus` will be follow-on work.
1 parent 72cdbd7 commit 145f25c

File tree

4 files changed

+137
-18
lines changed

4 files changed

+137
-18
lines changed

common/src/address.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub const CLICKHOUSE_PORT: u16 = 8123;
5050
pub const CLICKHOUSE_KEEPER_PORT: u16 = 9181;
5151
pub const OXIMETER_PORT: u16 = 12223;
5252
pub const DENDRITE_PORT: u16 = 12224;
53+
pub const LLDP_PORT: u16 = 12230;
5354
pub const MGD_PORT: u16 = 4676;
5455
pub const DDMD_PORT: u16 = 8000;
5556
pub const MGS_PORT: u16 = 12225;

package-manifest.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,15 @@ source.sha256 = "151aeb26414989cad571b3886786efbeeafd91c41a93a747c784cdc654d5876
553553
output.type = "zone"
554554
output.intermediate_only = true
555555

556+
[package.lldp]
557+
service_name = "lldp"
558+
source.type = "prebuilt"
559+
source.repo = "lldp"
560+
source.commit = "e165090e393df90874329265799480e221884236"
561+
source.sha256 = "004a6488a948d894fa203222aa42e159e1ae12c13751607852302d111e2c58e6"
562+
output.type = "zone"
563+
output.intermediate_only = true
564+
556565
[package.dendrite-stub]
557566
service_name = "dendrite"
558567
only_for_targets.switch = "stub"
@@ -648,6 +657,7 @@ source.type = "composite"
648657
source.packages = [
649658
"omicron-gateway-asic.tar.gz",
650659
"dendrite-asic.tar.gz",
660+
"lldp.tar.gz",
651661
"wicketd.tar.gz",
652662
"wicket.tar.gz",
653663
"mg-ddm.tar.gz",
@@ -671,6 +681,7 @@ source.type = "composite"
671681
source.packages = [
672682
"omicron-gateway-stub.tar.gz",
673683
"dendrite-stub.tar.gz",
684+
"lldp.tar.gz",
674685
"wicketd.tar.gz",
675686
"wicket.tar.gz",
676687
"mg-ddm.tar.gz",
@@ -694,6 +705,7 @@ source.type = "composite"
694705
source.packages = [
695706
"omicron-gateway-softnpu.tar.gz",
696707
"dendrite-softnpu.tar.gz",
708+
"lldp.tar.gz",
697709
"wicketd.tar.gz",
698710
"wicket.tar.gz",
699711
"mg-ddm.tar.gz",

sled-agent/src/services.rs

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ use omicron_common::address::CRUCIBLE_PORT;
7171
use omicron_common::address::DENDRITE_PORT;
7272
use omicron_common::address::DNS_HTTP_PORT;
7373
use omicron_common::address::DNS_PORT;
74+
use omicron_common::address::LLDP_PORT;
7475
use omicron_common::address::MGS_PORT;
7576
use omicron_common::address::RACK_PREFIX;
7677
use omicron_common::address::SLED_PREFIX;
@@ -470,6 +471,7 @@ enum SwitchService {
470471
ManagementGatewayService,
471472
Wicketd { baseboard: Baseboard },
472473
Dendrite { asic: DendriteAsic },
474+
Lldpd { baseboard: Baseboard },
473475
Tfport { pkt_source: String, asic: DendriteAsic },
474476
Uplink,
475477
MgDdm { mode: String },
@@ -483,6 +485,7 @@ impl crate::smf_helper::Service for SwitchService {
483485
SwitchService::ManagementGatewayService => "mgs",
484486
SwitchService::Wicketd { .. } => "wicketd",
485487
SwitchService::Dendrite { .. } => "dendrite",
488+
SwitchService::Lldpd { .. } => "lldpd",
486489
SwitchService::Tfport { .. } => "tfport",
487490
SwitchService::Uplink { .. } => "uplink",
488491
SwitchService::MgDdm { .. } => "mg-ddm",
@@ -1019,7 +1022,10 @@ impl ServiceManager {
10191022
let mut devices = vec![];
10201023
for svc_details in zone_args.sled_local_services() {
10211024
match svc_details {
1022-
SwitchService::Dendrite { asic: DendriteAsic::TofinoAsic } => {
1025+
SwitchService::Dendrite {
1026+
asic: DendriteAsic::TofinoAsic,
1027+
..
1028+
} => {
10231029
if let Ok(Some(n)) = tofino::get_tofino() {
10241030
if let Ok(device_path) = n.device_path() {
10251031
devices.push(device_path);
@@ -1032,6 +1038,7 @@ impl ServiceManager {
10321038
}
10331039
SwitchService::Dendrite {
10341040
asic: DendriteAsic::SoftNpuPropolisDevice,
1041+
..
10351042
} => {
10361043
devices.push("/dev/tty03".into());
10371044
}
@@ -2374,6 +2381,15 @@ impl ServiceManager {
23742381
None
23752382
};
23762383

2384+
let sidecar_revision = match &self.inner.sidecar_revision {
2385+
SidecarRevision::Physical(rev) => rev.to_string(),
2386+
SidecarRevision::SoftZone(rev)
2387+
| SidecarRevision::SoftPropolis(rev) => format!(
2388+
"softnpu_front_{}_rear_{}",
2389+
rev.front_port_count, rev.rear_port_count
2390+
),
2391+
};
2392+
23772393
if let Some(gateway) = maybe_gateway {
23782394
running_zone.add_default_route(gateway).map_err(|err| {
23792395
Error::ZoneCommand { intent: "Adding Route".to_string(), err }
@@ -2596,19 +2612,7 @@ impl ServiceManager {
25962612
"config/port_config",
25972613
"/opt/oxide/dendrite/misc/sidecar_config.toml",
25982614
)?;
2599-
let sidecar_revision =
2600-
match self.inner.sidecar_revision {
2601-
SidecarRevision::Physical(ref rev) => rev,
2602-
_ => {
2603-
return Err(Error::SidecarRevision(
2604-
anyhow::anyhow!(
2605-
"expected physical \
2606-
sidecar revision"
2607-
),
2608-
))
2609-
}
2610-
};
2611-
smfh.setprop("config/board_rev", sidecar_revision)?;
2615+
smfh.setprop("config/board_rev", &sidecar_revision)?;
26122616
}
26132617
DendriteAsic::TofinoStub => smfh.setprop(
26142618
"config/port_config",
@@ -2710,6 +2714,39 @@ impl ServiceManager {
27102714

27112715
smfh.refresh()?;
27122716
}
2717+
SwitchService::Lldpd { baseboard } => {
2718+
info!(self.inner.log, "Setting up lldpd service");
2719+
2720+
match baseboard {
2721+
Baseboard::Gimlet {
2722+
identifier, model, ..
2723+
}
2724+
| Baseboard::Pc { identifier, model, .. } => {
2725+
smfh.setprop(
2726+
"config/scrimlet_id",
2727+
identifier,
2728+
)?;
2729+
smfh.setprop(
2730+
"config/scrimlet_model",
2731+
model,
2732+
)?;
2733+
}
2734+
Baseboard::Unknown => {}
2735+
}
2736+
smfh.setprop(
2737+
"config/board_rev",
2738+
&sidecar_revision,
2739+
)?;
2740+
2741+
smfh.delpropvalue("config/address", "*")?;
2742+
for address in &request.zone.addresses {
2743+
smfh.addpropvalue(
2744+
"config/address",
2745+
&format!("[{}]:{}", address, LLDP_PORT),
2746+
)?;
2747+
}
2748+
smfh.refresh()?;
2749+
}
27132750
SwitchService::Uplink => {
27142751
// Nothing to do here - this service is special and
27152752
// configured in
@@ -3509,13 +3546,14 @@ impl ServiceManager {
35093546
| SledMode::Scrimlet { asic: DendriteAsic::TofinoAsic } => {
35103547
vec![
35113548
SwitchService::Dendrite { asic: DendriteAsic::TofinoAsic },
3549+
SwitchService::Lldpd { baseboard: baseboard.clone() },
35123550
SwitchService::ManagementGatewayService,
35133551
SwitchService::Tfport {
35143552
pkt_source: "tfpkt0".to_string(),
35153553
asic: DendriteAsic::TofinoAsic,
35163554
},
35173555
SwitchService::Uplink,
3518-
SwitchService::Wicketd { baseboard },
3556+
SwitchService::Wicketd { baseboard: baseboard.clone() },
35193557
SwitchService::Mgd,
35203558
SwitchService::MgDdm { mode: "transit".to_string() },
35213559
]
@@ -3527,9 +3565,10 @@ impl ServiceManager {
35273565
data_links = vec!["vioif0".to_owned()];
35283566
vec![
35293567
SwitchService::Dendrite { asic },
3568+
SwitchService::Lldpd { baseboard: baseboard.clone() },
35303569
SwitchService::ManagementGatewayService,
35313570
SwitchService::Uplink,
3532-
SwitchService::Wicketd { baseboard },
3571+
SwitchService::Wicketd { baseboard: baseboard.clone() },
35333572
SwitchService::Mgd,
35343573
SwitchService::MgDdm { mode: "transit".to_string() },
35353574
SwitchService::Tfport {
@@ -3557,9 +3596,10 @@ impl ServiceManager {
35573596
}
35583597
vec![
35593598
SwitchService::Dendrite { asic },
3599+
SwitchService::Lldpd { baseboard: baseboard.clone() },
35603600
SwitchService::ManagementGatewayService,
35613601
SwitchService::Uplink,
3562-
SwitchService::Wicketd { baseboard },
3602+
SwitchService::Wicketd { baseboard: baseboard.clone() },
35633603
SwitchService::Mgd,
35643604
SwitchService::MgDdm { mode: "transit".to_string() },
35653605
SwitchService::Tfport {
@@ -3823,7 +3863,10 @@ impl ServiceManager {
38233863
smfh.refresh()?;
38243864
}
38253865
SwitchService::Dendrite { .. } => {
3826-
info!(self.inner.log, "configuring dendrite zone");
3866+
info!(
3867+
self.inner.log,
3868+
"configuring dendrite service"
3869+
);
38273870
if let Some(info) = self.inner.sled_info.get() {
38283871
smfh.setprop("config/rack_id", info.rack_id)?;
38293872
smfh.setprop(
@@ -3881,6 +3924,17 @@ impl ServiceManager {
38813924
);
38823925
}
38833926
}
3927+
SwitchService::Lldpd { .. } => {
3928+
info!(self.inner.log, "configuring lldp service");
3929+
smfh.delpropvalue("config/address", "*")?;
3930+
for address in &request.addresses {
3931+
smfh.addpropvalue(
3932+
"config/address",
3933+
&format!("[{}]:{}", address, LLDP_PORT),
3934+
)?;
3935+
}
3936+
smfh.refresh()?;
3937+
}
38843938
SwitchService::Tfport { .. } => {
38853939
// Since tfport and dpd communicate using localhost,
38863940
// the tfport service shouldn't need to be

tools/update_lldp.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
set -o pipefail
4+
set -o errexit
5+
6+
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
7+
8+
function usage {
9+
echo "usage: $0 [-c COMMIT] [-n]"
10+
echo
11+
echo " -c COMMIT Ask to update Lldp to a specific commit."
12+
echo " If this is unset, Github is queried."
13+
echo " -n Dry-run"
14+
exit 1
15+
}
16+
17+
PACKAGES=(
18+
"lldp"
19+
)
20+
21+
CRATES=(
22+
"lldp"
23+
)
24+
25+
REPO="oxidecomputer/lldp"
26+
27+
. "$SOURCE_DIR/update_helpers.sh"
28+
29+
function main {
30+
TARGET_COMMIT=""
31+
DRY_RUN=""
32+
while getopts "c:n" o; do
33+
case "${o}" in
34+
c)
35+
TARGET_COMMIT="$OPTARG"
36+
;;
37+
n)
38+
DRY_RUN="yes"
39+
;;
40+
*)
41+
usage
42+
;;
43+
esac
44+
done
45+
46+
TARGET_COMMIT=$(get_latest_commit_from_gh "$REPO" "$TARGET_COMMIT")
47+
install_toml2json
48+
do_update_packages "$TARGET_COMMIT" "$DRY_RUN" "$REPO" "${PACKAGES[@]}"
49+
do_update_crates "$TARGET_COMMIT" "$DRY_RUN" "$REPO" "${CRATES[@]}"
50+
}
51+
52+
main "$@"

0 commit comments

Comments
 (0)