From e4bcfeeef8b73d60fd880a4bce3cd2465cb11c65 Mon Sep 17 00:00:00 2001 From: Ryan Goodfellow Date: Fri, 12 Jul 2024 15:26:48 -0700 Subject: [PATCH] fix query selector for bgp filters and communities (#6072) --- nexus/db-queries/src/db/datastore/bgp.rs | 14 ++++++++------ .../background/tasks/sync_switch_configuration.rs | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/nexus/db-queries/src/db/datastore/bgp.rs b/nexus/db-queries/src/db/datastore/bgp.rs index d73e7ff327..1244184c1d 100644 --- a/nexus/db-queries/src/db/datastore/bgp.rs +++ b/nexus/db-queries/src/db/datastore/bgp.rs @@ -572,14 +572,14 @@ impl DataStore { &self, opctx: &OpContext, port_settings_id: Uuid, - interface_name: &String, + interface_name: &str, addr: IpNetwork, ) -> ListResultVec { use db::schema::switch_port_settings_bgp_peer_config_communities::dsl; let results = dsl::switch_port_settings_bgp_peer_config_communities .filter(dsl::port_settings_id.eq(port_settings_id)) - .filter(dsl::interface_name.eq(interface_name.clone())) + .filter(dsl::interface_name.eq(interface_name.to_owned())) .filter(dsl::addr.eq(addr)) .load_async(&*self.pool_connection_authorized(opctx).await?) .await @@ -592,7 +592,7 @@ impl DataStore { &self, opctx: &OpContext, port_settings_id: Uuid, - interface_name: &String, + interface_name: &str, addr: IpNetwork, ) -> LookupResult>> { use db::schema::switch_port_settings_bgp_peer_config as db_peer; @@ -619,7 +619,8 @@ impl DataStore { dsl::switch_port_settings_bgp_peer_config_allow_export .filter(db_allow::port_settings_id.eq(port_settings_id)) .filter( - db_allow::interface_name.eq(interface_name.clone()), + db_allow::interface_name + .eq(interface_name.to_owned()), ) .filter(db_allow::addr.eq(addr)) .load_async(&conn) @@ -637,7 +638,7 @@ impl DataStore { &self, opctx: &OpContext, port_settings_id: Uuid, - interface_name: &String, + interface_name: &str, addr: IpNetwork, ) -> LookupResult>> { use db::schema::switch_port_settings_bgp_peer_config as db_peer; @@ -664,7 +665,8 @@ impl DataStore { dsl::switch_port_settings_bgp_peer_config_allow_import .filter(db_allow::port_settings_id.eq(port_settings_id)) .filter( - db_allow::interface_name.eq(interface_name.clone()), + db_allow::interface_name + .eq(interface_name.to_owned()), ) .filter(db_allow::addr.eq(addr)) .load_async(&conn) diff --git a/nexus/src/app/background/tasks/sync_switch_configuration.rs b/nexus/src/app/background/tasks/sync_switch_configuration.rs index e8f07726a5..20a12d1127 100644 --- a/nexus/src/app/background/tasks/sync_switch_configuration.rs +++ b/nexus/src/app/background/tasks/sync_switch_configuration.rs @@ -63,6 +63,7 @@ use std::{ }; const DPD_TAG: Option<&'static str> = Some(OMICRON_DPD_TAG); +const PHY0: &str = "phy0"; // This is more of an implementation detail of the BGP implementation. It // defines the maximum time the peering engine will wait for external messages @@ -999,7 +1000,7 @@ impl BackgroundTask for SwitchPortSettingsManager { .communities_for_peer( opctx, port.port_settings_id.unwrap(), - &peer.port, + PHY0, //TODO https://github.com/oxidecomputer/omicron/issues/3062 IpNetwork::from(IpAddr::from(peer.addr)) ).await { Ok(cs) => cs.iter().map(|c| c.community.0).collect(), @@ -1017,7 +1018,7 @@ impl BackgroundTask for SwitchPortSettingsManager { let allow_import = match self.datastore.allow_import_for_peer( opctx, port.port_settings_id.unwrap(), - &peer.port, + PHY0, //TODO https://github.com/oxidecomputer/omicron/issues/3062 IpNetwork::from(IpAddr::from(peer.addr)), ).await { Ok(cs) => cs, @@ -1041,7 +1042,7 @@ impl BackgroundTask for SwitchPortSettingsManager { let allow_export = match self.datastore.allow_export_for_peer( opctx, port.port_settings_id.unwrap(), - &peer.port, + PHY0, //TODO https://github.com/oxidecomputer/omicron/issues/3062 IpNetwork::from(IpAddr::from(peer.addr)), ).await { Ok(cs) => cs,