Skip to content

Commit

Permalink
Add LLDP (#5196)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Nieuwejaar authored Mar 11, 2024
1 parent 72cdbd7 commit 145f25c
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 18 deletions.
1 change: 1 addition & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub const CLICKHOUSE_PORT: u16 = 8123;
pub const CLICKHOUSE_KEEPER_PORT: u16 = 9181;
pub const OXIMETER_PORT: u16 = 12223;
pub const DENDRITE_PORT: u16 = 12224;
pub const LLDP_PORT: u16 = 12230;
pub const MGD_PORT: u16 = 4676;
pub const DDMD_PORT: u16 = 8000;
pub const MGS_PORT: u16 = 12225;
Expand Down
12 changes: 12 additions & 0 deletions package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,15 @@ source.sha256 = "151aeb26414989cad571b3886786efbeeafd91c41a93a747c784cdc654d5876
output.type = "zone"
output.intermediate_only = true

[package.lldp]
service_name = "lldp"
source.type = "prebuilt"
source.repo = "lldp"
source.commit = "e165090e393df90874329265799480e221884236"
source.sha256 = "004a6488a948d894fa203222aa42e159e1ae12c13751607852302d111e2c58e6"
output.type = "zone"
output.intermediate_only = true

[package.dendrite-stub]
service_name = "dendrite"
only_for_targets.switch = "stub"
Expand Down Expand Up @@ -648,6 +657,7 @@ source.type = "composite"
source.packages = [
"omicron-gateway-asic.tar.gz",
"dendrite-asic.tar.gz",
"lldp.tar.gz",
"wicketd.tar.gz",
"wicket.tar.gz",
"mg-ddm.tar.gz",
Expand All @@ -671,6 +681,7 @@ source.type = "composite"
source.packages = [
"omicron-gateway-stub.tar.gz",
"dendrite-stub.tar.gz",
"lldp.tar.gz",
"wicketd.tar.gz",
"wicket.tar.gz",
"mg-ddm.tar.gz",
Expand All @@ -694,6 +705,7 @@ source.type = "composite"
source.packages = [
"omicron-gateway-softnpu.tar.gz",
"dendrite-softnpu.tar.gz",
"lldp.tar.gz",
"wicketd.tar.gz",
"wicket.tar.gz",
"mg-ddm.tar.gz",
Expand Down
90 changes: 72 additions & 18 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ use omicron_common::address::CRUCIBLE_PORT;
use omicron_common::address::DENDRITE_PORT;
use omicron_common::address::DNS_HTTP_PORT;
use omicron_common::address::DNS_PORT;
use omicron_common::address::LLDP_PORT;
use omicron_common::address::MGS_PORT;
use omicron_common::address::RACK_PREFIX;
use omicron_common::address::SLED_PREFIX;
Expand Down Expand Up @@ -470,6 +471,7 @@ enum SwitchService {
ManagementGatewayService,
Wicketd { baseboard: Baseboard },
Dendrite { asic: DendriteAsic },
Lldpd { baseboard: Baseboard },
Tfport { pkt_source: String, asic: DendriteAsic },
Uplink,
MgDdm { mode: String },
Expand All @@ -483,6 +485,7 @@ impl crate::smf_helper::Service for SwitchService {
SwitchService::ManagementGatewayService => "mgs",
SwitchService::Wicketd { .. } => "wicketd",
SwitchService::Dendrite { .. } => "dendrite",
SwitchService::Lldpd { .. } => "lldpd",
SwitchService::Tfport { .. } => "tfport",
SwitchService::Uplink { .. } => "uplink",
SwitchService::MgDdm { .. } => "mg-ddm",
Expand Down Expand Up @@ -1019,7 +1022,10 @@ impl ServiceManager {
let mut devices = vec![];
for svc_details in zone_args.sled_local_services() {
match svc_details {
SwitchService::Dendrite { asic: DendriteAsic::TofinoAsic } => {
SwitchService::Dendrite {
asic: DendriteAsic::TofinoAsic,
..
} => {
if let Ok(Some(n)) = tofino::get_tofino() {
if let Ok(device_path) = n.device_path() {
devices.push(device_path);
Expand All @@ -1032,6 +1038,7 @@ impl ServiceManager {
}
SwitchService::Dendrite {
asic: DendriteAsic::SoftNpuPropolisDevice,
..
} => {
devices.push("/dev/tty03".into());
}
Expand Down Expand Up @@ -2374,6 +2381,15 @@ impl ServiceManager {
None
};

let sidecar_revision = match &self.inner.sidecar_revision {
SidecarRevision::Physical(rev) => rev.to_string(),
SidecarRevision::SoftZone(rev)
| SidecarRevision::SoftPropolis(rev) => format!(
"softnpu_front_{}_rear_{}",
rev.front_port_count, rev.rear_port_count
),
};

if let Some(gateway) = maybe_gateway {
running_zone.add_default_route(gateway).map_err(|err| {
Error::ZoneCommand { intent: "Adding Route".to_string(), err }
Expand Down Expand Up @@ -2596,19 +2612,7 @@ impl ServiceManager {
"config/port_config",
"/opt/oxide/dendrite/misc/sidecar_config.toml",
)?;
let sidecar_revision =
match self.inner.sidecar_revision {
SidecarRevision::Physical(ref rev) => rev,
_ => {
return Err(Error::SidecarRevision(
anyhow::anyhow!(
"expected physical \
sidecar revision"
),
))
}
};
smfh.setprop("config/board_rev", sidecar_revision)?;
smfh.setprop("config/board_rev", &sidecar_revision)?;
}
DendriteAsic::TofinoStub => smfh.setprop(
"config/port_config",
Expand Down Expand Up @@ -2710,6 +2714,39 @@ impl ServiceManager {

smfh.refresh()?;
}
SwitchService::Lldpd { baseboard } => {
info!(self.inner.log, "Setting up lldpd service");

match baseboard {
Baseboard::Gimlet {
identifier, model, ..
}
| Baseboard::Pc { identifier, model, .. } => {
smfh.setprop(
"config/scrimlet_id",
identifier,
)?;
smfh.setprop(
"config/scrimlet_model",
model,
)?;
}
Baseboard::Unknown => {}
}
smfh.setprop(
"config/board_rev",
&sidecar_revision,
)?;

smfh.delpropvalue("config/address", "*")?;
for address in &request.zone.addresses {
smfh.addpropvalue(
"config/address",
&format!("[{}]:{}", address, LLDP_PORT),
)?;
}
smfh.refresh()?;
}
SwitchService::Uplink => {
// Nothing to do here - this service is special and
// configured in
Expand Down Expand Up @@ -3509,13 +3546,14 @@ impl ServiceManager {
| SledMode::Scrimlet { asic: DendriteAsic::TofinoAsic } => {
vec![
SwitchService::Dendrite { asic: DendriteAsic::TofinoAsic },
SwitchService::Lldpd { baseboard: baseboard.clone() },
SwitchService::ManagementGatewayService,
SwitchService::Tfport {
pkt_source: "tfpkt0".to_string(),
asic: DendriteAsic::TofinoAsic,
},
SwitchService::Uplink,
SwitchService::Wicketd { baseboard },
SwitchService::Wicketd { baseboard: baseboard.clone() },
SwitchService::Mgd,
SwitchService::MgDdm { mode: "transit".to_string() },
]
Expand All @@ -3527,9 +3565,10 @@ impl ServiceManager {
data_links = vec!["vioif0".to_owned()];
vec![
SwitchService::Dendrite { asic },
SwitchService::Lldpd { baseboard: baseboard.clone() },
SwitchService::ManagementGatewayService,
SwitchService::Uplink,
SwitchService::Wicketd { baseboard },
SwitchService::Wicketd { baseboard: baseboard.clone() },
SwitchService::Mgd,
SwitchService::MgDdm { mode: "transit".to_string() },
SwitchService::Tfport {
Expand Down Expand Up @@ -3557,9 +3596,10 @@ impl ServiceManager {
}
vec![
SwitchService::Dendrite { asic },
SwitchService::Lldpd { baseboard: baseboard.clone() },
SwitchService::ManagementGatewayService,
SwitchService::Uplink,
SwitchService::Wicketd { baseboard },
SwitchService::Wicketd { baseboard: baseboard.clone() },
SwitchService::Mgd,
SwitchService::MgDdm { mode: "transit".to_string() },
SwitchService::Tfport {
Expand Down Expand Up @@ -3823,7 +3863,10 @@ impl ServiceManager {
smfh.refresh()?;
}
SwitchService::Dendrite { .. } => {
info!(self.inner.log, "configuring dendrite zone");
info!(
self.inner.log,
"configuring dendrite service"
);
if let Some(info) = self.inner.sled_info.get() {
smfh.setprop("config/rack_id", info.rack_id)?;
smfh.setprop(
Expand Down Expand Up @@ -3881,6 +3924,17 @@ impl ServiceManager {
);
}
}
SwitchService::Lldpd { .. } => {
info!(self.inner.log, "configuring lldp service");
smfh.delpropvalue("config/address", "*")?;
for address in &request.addresses {
smfh.addpropvalue(
"config/address",
&format!("[{}]:{}", address, LLDP_PORT),
)?;
}
smfh.refresh()?;
}
SwitchService::Tfport { .. } => {
// Since tfport and dpd communicate using localhost,
// the tfport service shouldn't need to be
Expand Down
52 changes: 52 additions & 0 deletions tools/update_lldp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -o pipefail
set -o errexit

SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

function usage {
echo "usage: $0 [-c COMMIT] [-n]"
echo
echo " -c COMMIT Ask to update Lldp to a specific commit."
echo " If this is unset, Github is queried."
echo " -n Dry-run"
exit 1
}

PACKAGES=(
"lldp"
)

CRATES=(
"lldp"
)

REPO="oxidecomputer/lldp"

. "$SOURCE_DIR/update_helpers.sh"

function main {
TARGET_COMMIT=""
DRY_RUN=""
while getopts "c:n" o; do
case "${o}" in
c)
TARGET_COMMIT="$OPTARG"
;;
n)
DRY_RUN="yes"
;;
*)
usage
;;
esac
done

TARGET_COMMIT=$(get_latest_commit_from_gh "$REPO" "$TARGET_COMMIT")
install_toml2json
do_update_packages "$TARGET_COMMIT" "$DRY_RUN" "$REPO" "${PACKAGES[@]}"
do_update_crates "$TARGET_COMMIT" "$DRY_RUN" "$REPO" "${CRATES[@]}"
}

main "$@"

0 comments on commit 145f25c

Please sign in to comment.