diff --git a/nexus/db-queries/src/db/datastore/switch_port.rs b/nexus/db-queries/src/db/datastore/switch_port.rs index 8fc9ff8649..3a524b7616 100644 --- a/nexus/db-queries/src/db/datastore/switch_port.rs +++ b/nexus/db-queries/src/db/datastore/switch_port.rs @@ -1047,19 +1047,21 @@ async fn do_switch_port_settings_create( let mut link_config = Vec::with_capacity(params.links.len()); for (link_name, c) in ¶ms.links { - /* - let lldp_config_id = match c.lldp.lldp_config { - Some(_) => todo!(), // TODO actual lldp support - None => None, - }; - */ - let lldp_link_config = - LldpLinkConfig::new(true, None, None, None, None, None, None); - lldp_config.push(lldp_link_config.clone()); + let lldp_link_config = LldpLinkConfig::new( + c.lldp.enabled, + c.lldp.link_name.clone(), + c.lldp.link_description.clone(), + c.lldp.chassis_id.clone(), + c.lldp.system_name.clone(), + c.lldp.system_description.clone(), + c.lldp.management_ip.map(|a| a.into()), + ); + let lldp_config_id = lldp_link_config.id; + lldp_config.push(lldp_link_config); link_config.push(SwitchPortLinkConfig::new( psid, - lldp_link_config.id, + lldp_config_id, link_name.clone(), c.mtu, c.fec.into(), diff --git a/nexus/src/app/background/tasks/sync_switch_configuration.rs b/nexus/src/app/background/tasks/sync_switch_configuration.rs index 5a88714ead..d114f99628 100644 --- a/nexus/src/app/background/tasks/sync_switch_configuration.rs +++ b/nexus/src/app/background/tasks/sync_switch_configuration.rs @@ -987,22 +987,29 @@ impl BackgroundTask for SwitchPortSettingsManager { .map(|l| l.fec) .unwrap_or(SwitchLinkFec::None) .into(), - uplink_port_speed: info + uplink_port_speed: info .links .get(0) //TODO https://github.com/oxidecomputer/omicron/issues/3062 .map(|l| l.speed) .unwrap_or(SwitchLinkSpeed::Speed100G) .into(), - lldp: Some(LldpPortConfig { - status: LldpAdminStatus::Enabled, - chassis_id: None, - port_id: None, - port_description: None, - system_name: None, - system_description: Some("description".to_string()), - management_addrs: None, - }), - }; + lldp: info + .link_lldp + .get(0) //TODO https://github.com/oxidecomputer/omicron/issues/3062 + .map(|c| LldpPortConfig { + status: match c.enabled { + true => LldpAdminStatus::Enabled, + false=> LldpAdminStatus::Disabled, + }, + port_id: c.link_name.clone(), + port_description: c.link_description.clone(), + chassis_id: c.chassis_id.clone(), + system_name: c.system_name.clone(), + system_description: c.system_description.clone(), + management_addrs:c.management_ip.map(|a| vec![a.ip().into()]), + }) + } + ; for peer in port_config.bgp_peers.iter_mut() { peer.communities = match self diff --git a/nexus/src/app/rack.rs b/nexus/src/app/rack.rs index cb405278b4..661074bab1 100644 --- a/nexus/src/app/rack.rs +++ b/nexus/src/app/rack.rs @@ -61,6 +61,7 @@ use omicron_common::api::external::Name; use omicron_common::api::external::NameOrId; use omicron_common::api::external::ResourceType; use omicron_common::api::internal::shared::ExternalPortDiscovery; +use omicron_common::api::internal::shared::LldpAdminStatus; use omicron_uuid_kinds::GenericUuid; use omicron_uuid_kinds::SledUuid; use oxnet::IpNet; @@ -608,20 +609,30 @@ impl super::Nexus { .bgp_peers .insert("phy0".to_string(), BgpPeerConfig { peers }); - let link = LinkConfigCreate { - mtu: 1500, //TODO https://github.com/oxidecomputer/omicron/issues/2274 - lldp: LldpLinkConfigCreate { + let lldp = match &uplink_config.lldp { + None => LldpLinkConfigCreate { enabled: false, - link_name: None, - link_description: None, - chassis_id: None, - system_name: None, - system_description: None, - management_ip: None, + ..Default::default() + }, + Some(l) => LldpLinkConfigCreate { + enabled: l.status == LldpAdminStatus::Enabled, + link_name: l.port_id.clone(), + link_description: l.port_description.clone(), + chassis_id: l.chassis_id.clone(), + system_name: l.system_name.clone(), + system_description: l.system_description.clone(), + management_ip: match &l.management_addrs { + Some(a) if !a.is_empty() => Some(a[0]), + _ => None, + }, }, + }; + let link = LinkConfigCreate { + mtu: 1500, //TODO https://github.com/oxidecomputer/omicron/issues/2274 fec: uplink_config.uplink_port_fec.into(), speed: uplink_config.uplink_port_speed.into(), autoneg: uplink_config.autoneg, + lldp, }; port_settings_params.links.insert("phy".to_string(), link); diff --git a/nexus/types/src/external_api/params.rs b/nexus/types/src/external_api/params.rs index 6331165def..c6c0ec6190 100644 --- a/nexus/types/src/external_api/params.rs +++ b/nexus/types/src/external_api/params.rs @@ -1561,7 +1561,7 @@ pub struct LinkConfigCreate { } /// The LLDP configuration associated with a port. -#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)] pub struct LldpLinkConfigCreate { /// Whether or not LLDP is enabled. pub enabled: bool, @@ -1582,7 +1582,7 @@ pub struct LldpLinkConfigCreate { pub system_description: Option, /// The LLDP management IP TLV. - pub management_ip: Option, + pub management_ip: Option, } /// A layer-3 switch interface configuration. When IPv6 is enabled, a link local diff --git a/openapi/nexus.json b/openapi/nexus.json index 3eef819992..f0efe01c36 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -16252,11 +16252,8 @@ "management_ip": { "nullable": true, "description": "The LLDP management IP TLV.", - "allOf": [ - { - "$ref": "#/components/schemas/IpNet" - } - ] + "type": "string", + "format": "ip" }, "system_description": { "nullable": true, diff --git a/sled-agent/src/services.rs b/sled-agent/src/services.rs index 460af18676..149588edcb 100644 --- a/sled-agent/src/services.rs +++ b/sled-agent/src/services.rs @@ -3778,6 +3778,7 @@ impl ServiceManager { if let Some(lldp_config) = &port_config.lldp { let group_name = format!("port_{}", port_config.port); info!(self.inner.log, "setting up {group_name}"); + usmfh.delpropgroup(&group_name)?; lsmfh.addpropgroup(&group_name, "application")?; apv( &lsmfh, @@ -3802,7 +3803,7 @@ impl ServiceManager { apv( &lsmfh, &format!("{group_name}/port_description"), - &lldp_config.port_id, + &lldp_config.port_description, )?; apv( &lsmfh,