Skip to content

Commit

Permalink
BUGFIX: 6316 - be more specific when checking `allow_export_list_acti…
Browse files Browse the repository at this point in the history
…ve` (#6318)

This change updates the queries to lookup peers by
`switch_port_settings_id` AND peer `address` when checking
`allow_export_list_active` column.

Related
---
#6316
  • Loading branch information
internet-diglett authored Aug 14, 2024
1 parent 4a6be3a commit 9d8078b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nexus/db-model/src/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,13 @@ pub struct SwitchPortBgpPeerConfigCommunity {
)]
#[diesel(table_name = switch_port_settings_bgp_peer_config_allow_export)]
pub struct SwitchPortBgpPeerConfigAllowExport {
/// Parent switch port configuration
pub port_settings_id: Uuid,
/// Interface peer is reachable on
pub interface_name: String,
/// Peer Address
pub addr: IpNetwork,
/// Allowed Prefix
pub prefix: IpNetwork,
}

Expand All @@ -660,9 +664,13 @@ pub struct SwitchPortBgpPeerConfigAllowExport {
)]
#[diesel(table_name = switch_port_settings_bgp_peer_config_allow_import)]
pub struct SwitchPortBgpPeerConfigAllowImport {
/// Parent switch port configuration
pub port_settings_id: Uuid,
/// Interface peer is reachable on
pub interface_name: String,
/// Peer Address
pub addr: IpNetwork,
/// Allowed Prefix
pub prefix: IpNetwork,
}

Expand Down
2 changes: 2 additions & 0 deletions nexus/db-queries/src/db/datastore/bgp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ impl DataStore {
.transaction(&conn, |conn| async move {
let active = peer_dsl::switch_port_settings_bgp_peer_config
.filter(db_peer::port_settings_id.eq(port_settings_id))
.filter(db_peer::addr.eq(addr))
.select(db_peer::allow_export_list_active)
.limit(1)
.first_async::<bool>(&conn)
Expand Down Expand Up @@ -652,6 +653,7 @@ impl DataStore {
.transaction(&conn, |conn| async move {
let active = peer_dsl::switch_port_settings_bgp_peer_config
.filter(db_peer::port_settings_id.eq(port_settings_id))
.filter(db_peer::addr.eq(addr))
.select(db_peer::allow_import_list_active)
.limit(1)
.first_async::<bool>(&conn)
Expand Down

0 comments on commit 9d8078b

Please sign in to comment.