Skip to content

Check BGP announce set address lot #4391

Open
@rcgoodfellow

Description

@rcgoodfellow

Creating a BGP announcement requires specifying an address lot for the prefix being advertised. But we are not currently checking the address lot reference.

pub async fn bgp_create_announce_set(
&self,
opctx: &OpContext,
announce: &params::BgpAnnounceSetCreate,
) -> CreateResult<(BgpAnnounceSet, Vec<BgpAnnouncement>)> {
use db::schema::bgp_announce_set::dsl as announce_set_dsl;
use db::schema::bgp_announcement::dsl as bgp_announcement_dsl;
let pool = self.pool_connection_authorized(opctx).await?;
pool.transaction_async(|conn| async move {
let bas: BgpAnnounceSet = announce.clone().into();
let db_as: BgpAnnounceSet =
diesel::insert_into(announce_set_dsl::bgp_announce_set)
.values(bas.clone())
.returning(BgpAnnounceSet::as_returning())
.get_result_async::<BgpAnnounceSet>(&conn)
.await?;
let mut db_annoucements = Vec::new();
for a in &announce.announcement {
let an = BgpAnnouncement {
announce_set_id: db_as.id(),
address_lot_block_id: bas.identity.id,
network: a.network.into(),
};
let an =
diesel::insert_into(bgp_announcement_dsl::bgp_announcement)
.values(an.clone())
.returning(BgpAnnouncement::as_returning())
.get_result_async::<BgpAnnouncement>(&conn)
.await?;
db_annoucements.push(an);
}
Ok((db_as, db_annoucements))
})
.await
.map_err(|e| public_error_from_diesel(e, ErrorHandler::Server))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that isn't working.networkingRelated to the networking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions