Skip to content
Open
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
13 changes: 8 additions & 5 deletions bin/opteadm/src/bin/opteadm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,17 @@ enum Command {
#[arg(long)]
src_underlay_addr: Ipv6Addr,

/// The MTU that should be assigned to the newly created OPTE port.
///
/// If unset, this will default to the standard Ethernet MTU of 1500.
#[arg(long)]
mtu: Option<u32>,

#[command(flatten)]
external_net: ExternalNetConfig,

#[command(flatten)]
dhcp: DhcpConfig,

#[arg(long)]
passthrough: bool,
},

/// Delete an xde device
Expand Down Expand Up @@ -823,7 +826,7 @@ fn main() -> anyhow::Result<()> {
src_underlay_addr,
dhcp,
external_net,
passthrough,
mtu,
} => {
let ip_cfg = match private_ip {
IpAddr::Ip4(private_ip) => {
Expand Down Expand Up @@ -877,7 +880,7 @@ fn main() -> anyhow::Result<()> {
dhcp: dhcp.into(),
};

hdl.create_xde(&name, cfg, passthrough)?;
hdl.create_xde(&name, cfg, mtu)?;
}

Command::DeleteXde { name } => {
Expand Down
2 changes: 1 addition & 1 deletion crates/opte-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub use ulp::*;
///
/// We rely on CI and the check-api-version.sh script to verify that
/// this number is incremented anytime the oxide-api code changes.
pub const API_VERSION: u64 = 40;
pub const API_VERSION: u64 = 41;

/// Major version of the OPTE package.
pub const MAJOR_VERSION: u64 = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/opte-ioctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl OpteHdl {
&self,
name: &str,
cfg: VpcCfg,
passthrough: bool,
mtu: Option<u32>,
) -> Result<NoResp, Error> {
use libnet::link;

Expand All @@ -139,7 +139,7 @@ impl OpteHdl {

let xde_devname = name.into();
let cmd = OpteCmd::CreateXde;
let req = CreateXdeReq { xde_devname, linkid, cfg, passthrough };
let req = CreateXdeReq { xde_devname, linkid, cfg, mtu };

let res = run_cmd_ioctl(self.device.as_raw_fd(), cmd, Some(&req));

Expand Down
7 changes: 3 additions & 4 deletions lib/oxide-vpc/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,10 @@ pub struct CreateXdeReq {
/// details.
pub cfg: VpcCfg,

/// This is a development tool for completely bypassing OPTE processing.
/// The MTU we should assign to the newly created OPTE port.
///
/// XXX Pretty sure we aren't making much use of this anymore, and
/// should go away before v1.
pub passthrough: bool,
/// If unset, this will default to the standard Ethernet MTU of 1500.
pub mtu: Option<u32>,
}

pub type SNat4Cfg = SNatCfg<Ipv4Addr>;
Expand Down
4 changes: 2 additions & 2 deletions xde-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl OptePort {
dhcp: DhcpCfg::default(),
};
let adm = OpteHdl::open()?;
adm.create_xde(name, cfg.clone(), false)?;
adm.create_xde(name, cfg.clone(), None)?;
Ok(OptePort {
name: name.into(),
cfg,
Expand Down Expand Up @@ -372,7 +372,7 @@ impl OptePort {
dhcp: DhcpCfg::default(),
};
let adm = OpteHdl::open()?;
adm.create_xde(name, cfg.clone(), false)?;
adm.create_xde(name, cfg.clone(), None)?;
Ok(OptePort {
name: name.into(),
cfg,
Expand Down
37 changes: 4 additions & 33 deletions xde/src/xde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ pub struct XdeDev {
linkid: datalink_id_t,
mh: *mut mac::mac_handle,
link_state: mac::link_state_t,
mtu: u32,

// The OPTE port associated with this xde device.
//
Expand All @@ -626,10 +627,6 @@ pub struct XdeDev {
port_v2p: Arc<overlay::Virt2Phys>,
port_igw_map: KMutex<Option<InternetGatewayMap>>,

// Pass the packets through to the underlay devices, skipping
// opte-core processing.
passthrough: bool,

pub vni: Vni,

// These are clones of the underlay ports initialized by the
Expand Down Expand Up @@ -1195,12 +1192,14 @@ fn create_xde(req: &CreateXdeReq) -> Result<NoResp, OpteError> {
};

let mut guest_addr = cfg.guest_mac.bytes();
let mtu = req.mtu.unwrap_or(u32::from(ETHERNET_MTU));

let mut xde = Arc::new(XdeDev {
devname: req.xde_devname.clone(),
linkid: req.linkid,
mh: ptr::null_mut(),
link_state: mac::link_state_t::Down,
mtu,
port: new_port(
req.xde_devname.clone(),
&cfg,
Expand All @@ -1213,7 +1212,6 @@ fn create_xde(req: &CreateXdeReq) -> Result<NoResp, OpteError> {
port_v2p,
vni: cfg.vni,
port_igw_map: KMutex::new(None),
passthrough: req.passthrough,
u1,
u2,
underlay_capab,
Expand Down Expand Up @@ -1241,7 +1239,7 @@ fn create_xde(req: &CreateXdeReq) -> Result<NoResp, OpteError> {
mreg.m_priv_props = core::ptr::null_mut();
mreg.m_instance = c_uint::MAX; // let mac handle this
mreg.m_min_sdu = 1;
mreg.m_max_sdu = u32::from(ETHERNET_MTU); // TODO hardcode
mreg.m_max_sdu = mtu;
mreg.m_multicast_sdu = 0;
mreg.m_margin = crate::sys::VLAN_TAGSZ;
mreg.m_v12n = mac::MAC_VIRT_NONE as u32;
Expand Down Expand Up @@ -2842,19 +2840,6 @@ fn xde_mc_tx_one<'a>(
}
};

// Send straight to underlay in passthrough mode.
if src_dev.passthrough {
// TODO We need to deal with flow control. This could actually
// get weird, this is the first provider to use mac_tx(). Is
// there something we can learn from aggr here? I need to
// refresh my memory on all of this.
//
// TODO Is there way to set mac_tx to must use result?
drop(parsed_pkt);
postbox.post_underlay(UnderlayIndex::U1, TxHint::NoneOrMixed, pkt);
return;
}

let port = &src_dev.port;

// The port processing code will fire a probe that describes what
Expand Down Expand Up @@ -3538,13 +3523,6 @@ fn xde_rx_one(
None
};

// We are in passthrough mode, skip OPTE processing.
if dev.passthrough {
drop(parsed_pkt);
postbox.post(port_key, pkt);
return None;
}

let port = &dev.port;

let res = port.process(Direction::In, parsed_pkt);
Expand Down Expand Up @@ -3651,13 +3629,6 @@ fn xde_rx_one_direct(
None
};

// We are in passthrough mode, skip OPTE processing.
if dev.passthrough {
drop(parsed_pkt);
postbox.post(port_key, pkt);
return;
}

let port = &dev.port;

let res = port.process(Direction::In, parsed_pkt);
Expand Down