Skip to content

Optehdl cleanup #735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/opteadm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository.workspace = true
# XXX For the time being opteadm needs to set the engine feature to
# get all the types. Once there types are move to their appropriate
# place this feature flag will be replaced/removed.
opte = { workspace = true, features = ["api", "engine", "std"] }
opte = { workspace = true, features = ["api", "std"] }
opte-ioctl.workspace = true
oxide-vpc = { workspace = true, features = ["api", "engine", "std"] }

Expand Down
15 changes: 6 additions & 9 deletions bin/opteadm/src/bin/opteadm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use opte::engine::print::print_tcp_flows;
use opte::engine::print::print_uft;
use opteadm::COMMIT_COUNT;
use opteadm::OpteAdm;
use oxide_vpc::api::AddFwRuleReq;
use oxide_vpc::api::AddRouterEntryReq;
use oxide_vpc::api::Address;
use oxide_vpc::api::ClearVirt2BoundaryReq;
Expand All @@ -48,6 +49,7 @@ use oxide_vpc::api::RouterTarget;
use oxide_vpc::api::SNat4Cfg;
use oxide_vpc::api::SNat6Cfg;
use oxide_vpc::api::SetExternalIpsReq;
use oxide_vpc::api::SetFwRulesReq;
use oxide_vpc::api::SetVirt2BoundaryReq;
use oxide_vpc::api::SetVirt2PhysReq;
use oxide_vpc::api::TunnelEndpoint;
Expand Down Expand Up @@ -565,7 +567,7 @@ fn print_port(t: &mut impl Write, pi: PortInfo) -> std::io::Result<()> {

fn main() -> anyhow::Result<()> {
let cmd = Command::parse();
let hdl = opteadm::OpteAdm::open(OpteAdm::XDE_CTL)?;
let hdl = OpteAdm::open()?;

match cmd {
Command::ListPorts => {
Expand Down Expand Up @@ -595,7 +597,7 @@ fn main() -> anyhow::Result<()> {
}

Command::DumpLayer { port, name } => {
let resp = &hdl.get_layer_by_name(&port, &name)?;
let resp = &hdl.dump_layer(&port, &name)?;
print!("Port {port} - ");
print_layer(resp)?;
}
Expand All @@ -605,7 +607,6 @@ fn main() -> anyhow::Result<()> {
}

Command::ClearLft { port, layer } => {
let hdl = opteadm::OpteAdm::open(OpteAdm::XDE_CTL)?;
hdl.clear_lft(&port, &layer)?;
}

Expand All @@ -622,7 +623,6 @@ fn main() -> anyhow::Result<()> {
}

Command::DumpV2B => {
let hdl = opteadm::OpteAdm::open(OpteAdm::XDE_CTL)?;
print_v2b(&hdl.dump_v2b()?)?;
}

Expand All @@ -633,7 +633,7 @@ fn main() -> anyhow::Result<()> {
action,
priority,
};
hdl.add_firewall_rule(&port, &rule)?;
hdl.add_firewall_rule(&AddFwRuleReq { port_name: port, rule })?;
}

Command::SetFwRules { port } => {
Expand All @@ -645,8 +645,7 @@ fn main() -> anyhow::Result<()> {
rules.push(r);
}

let hdl = opteadm::OpteAdm::open(OpteAdm::XDE_CTL)?;
hdl.set_firewall_rules(&port, rules)?;
hdl.set_firewall_rules(&SetFwRulesReq { port_name: port, rules })?;
}

Command::CreateXde {
Expand Down Expand Up @@ -742,7 +741,6 @@ fn main() -> anyhow::Result<()> {
}

Command::SetV2B { prefix, tunnel_endpoint } => {
let hdl = opteadm::OpteAdm::open(OpteAdm::XDE_CTL)?;
let tep = tunnel_endpoint
.into_iter()
.map(|ip| TunnelEndpoint {
Expand All @@ -755,7 +753,6 @@ fn main() -> anyhow::Result<()> {
}

Command::ClearV2B { prefix, tunnel_endpoint } => {
let hdl = opteadm::OpteAdm::open(OpteAdm::XDE_CTL)?;
let tep = tunnel_endpoint
.into_iter()
.map(|ip| TunnelEndpoint {
Expand Down
Loading