Skip to content

Commit

Permalink
fix query selector for bgp filters and communities (#6072)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgoodfellow authored Jul 12, 2024
1 parent fe60eb9 commit e4bcfee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 8 additions & 6 deletions nexus/db-queries/src/db/datastore/bgp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,14 @@ impl DataStore {
&self,
opctx: &OpContext,
port_settings_id: Uuid,
interface_name: &String,
interface_name: &str,
addr: IpNetwork,
) -> ListResultVec<SwitchPortBgpPeerConfigCommunity> {
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
Expand All @@ -592,7 +592,7 @@ impl DataStore {
&self,
opctx: &OpContext,
port_settings_id: Uuid,
interface_name: &String,
interface_name: &str,
addr: IpNetwork,
) -> LookupResult<Option<Vec<SwitchPortBgpPeerConfigAllowExport>>> {
use db::schema::switch_port_settings_bgp_peer_config as db_peer;
Expand All @@ -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)
Expand All @@ -637,7 +638,7 @@ impl DataStore {
&self,
opctx: &OpContext,
port_settings_id: Uuid,
interface_name: &String,
interface_name: &str,
addr: IpNetwork,
) -> LookupResult<Option<Vec<SwitchPortBgpPeerConfigAllowImport>>> {
use db::schema::switch_port_settings_bgp_peer_config as db_peer;
Expand All @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions nexus/src/app/background/tasks/sync_switch_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit e4bcfee

Please sign in to comment.