Skip to content

Commit

Permalink
vlan plumbing
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgoodfellow committed May 2, 2024
1 parent 90741fe commit 7e47592
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 34 deletions.
56 changes: 28 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ rev = "7ee353a470ea59529ee1b34729681da887aa88ce"

[workspace.dependencies.dpd-client]
git = "https://github.com/oxidecomputer/dendrite"
branch = "main"
branch = "vlan"
package = "dpd-client"

[workspace.dependencies.dendrite-common]
git = "https://github.com/oxidecomputer/dendrite"
branch = "main"
branch = "vlan"
package = "common"

[patch."https://github.com/oxidecomputer/netadm-sys"]
Expand Down
4 changes: 4 additions & 0 deletions bgp/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ pub struct SessionInfo {

/// Policy governing exported routes.
pub allow_export: ImportExportPolicy,

/// Vlan tag to assign to data plane routes created by this session.
pub vlan_id: Option<u16>,
}

impl SessionInfo {
Expand Down Expand Up @@ -2074,6 +2077,7 @@ impl<Cnx: BgpConnection + 'static> SessionRunner<Cnx> {
id,
as_path,
}),
vlan_id: lock!(self.session).vlan_id,
};

if let Err(e) =
Expand Down
1 change: 1 addition & 0 deletions ddm/src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ pub fn add_routes_dendrite(
port_id,
link_id,
tgt_ip: gw,
vlan_id: None,
};
let route_set = types::RouteSet {
cidr: cidr.into(),
Expand Down
10 changes: 10 additions & 0 deletions mg-lower/src/dendrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub(crate) struct RouteHash {
pub(crate) port_id: PortId,
pub(crate) link_id: types::LinkId,
pub(crate) nexthop: IpAddr,
pub(crate) vlan_id: Option<u16>,
}

impl RouteHash {
Expand All @@ -42,6 +43,7 @@ impl RouteHash {
port_id: PortId,
link_id: types::LinkId,
nexthop: IpAddr,
vlan_id: Option<u16>,
) -> Result<Self, &'static str> {
match (cidr, nexthop) {
(Cidr::V4(_), IpAddr::V4(_)) | (Cidr::V6(_), IpAddr::V6(_)) => {
Expand All @@ -50,6 +52,7 @@ impl RouteHash {
port_id,
link_id,
nexthop,
vlan_id,
})
}
_ => Err("mismatched subnet and target"),
Expand Down Expand Up @@ -77,6 +80,7 @@ impl RouteHash {
port_id,
link_id,
nexthop: path.nexthop,
vlan_id: path.vlan_id,
};

Ok(rh)
Expand Down Expand Up @@ -166,6 +170,7 @@ where
let tag = dpd.inner().tag.clone();
let port_id = r.port_id;
let link_id = r.link_id;
let vlan_id = r.vlan_id;

let target = match (r.cidr, r.nexthop) {
(Cidr::V4(c), IpAddr::V4(tgt_ip)) => {
Expand All @@ -191,6 +196,7 @@ where
port_id,
link_id,
tgt_ip,
vlan_id,
}
.into()
}
Expand All @@ -217,6 +223,7 @@ where
port_id,
link_id,
tgt_ip,
vlan_id,
}
.into()
}
Expand Down Expand Up @@ -360,6 +367,7 @@ pub(crate) fn get_routes_for_prefix(
r.port_id,
r.link_id,
r.tgt_ip.into(),
r.vlan_id,
) {
Ok(rh) => result.push(rh),
Err(e) => {
Expand All @@ -380,6 +388,7 @@ pub(crate) fn get_routes_for_prefix(
r.port_id,
r.link_id,
r.tgt_ip.into(),
r.vlan_id,
)
.unwrap()
})
Expand All @@ -402,6 +411,7 @@ pub(crate) fn get_routes_for_prefix(
r.port_id,
r.link_id,
r.tgt_ip.into(),
r.vlan_id,
)
.unwrap()
})
Expand Down
3 changes: 3 additions & 0 deletions mgadm/src/bgp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ pub struct Neighbor {
#[arg(long)]
pub enforce_first_as: bool,

#[arg(long)]
pub vlan_id: u16,

/// Autonomous system number for the router to add the neighbor to.
#[clap(env)]
pub asn: u32,
Expand Down
3 changes: 3 additions & 0 deletions mgadm/src/static_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum Ipv4PrefixParseError {
pub struct StaticRoute4 {
pub destination: Ipv4Prefix,
pub nexthop: Ipv4Addr,
pub vlan_id: Option<u16>,
}

#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -72,6 +73,7 @@ pub async fn commands(command: Commands, client: Client) -> Result<()> {
length: route.destination.len,
},
nexthop: route.nexthop,
vlan_id: route.vlan_id,
}],
},
};
Expand All @@ -86,6 +88,7 @@ pub async fn commands(command: Commands, client: Client) -> Result<()> {
length: route.destination.len,
},
nexthop: route.nexthop,
vlan_id: route.vlan_id,
}],
},
};
Expand Down
2 changes: 2 additions & 0 deletions mgd/src/bgp_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ pub(crate) mod helpers {
enforce_first_as: rq.enforce_first_as,
allow_import: rq.allow_import.clone(),
allow_export: rq.allow_export.clone(),
vlan_id: rq.vlan_id,
..Default::default()
};

Expand Down Expand Up @@ -785,6 +786,7 @@ pub(crate) mod helpers {
enforce_first_as: rq.enforce_first_as,
allow_import: rq.allow_import.clone(),
allow_export: rq.allow_export.clone(),
vlan_id: rq.vlan_id,
})?;

if start_session {
Expand Down
Loading

0 comments on commit 7e47592

Please sign in to comment.