Skip to content

Various MTU fixes. #749

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

Merged
merged 4 commits into from
May 8, 2025
Merged
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
15 changes: 12 additions & 3 deletions lib/opte/src/ddi/mblk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,10 @@ impl MsgBlk {

/// Return the offloads currently requested by a packet.
#[cfg_attr(any(feature = "std", test), allow(unused))]
pub fn offload_flags(&self) -> MblkOffloadFlags {
pub fn offload_flags(&self) -> MblkOffloadInfo {
let mut cso_out = 0u32;
let mut lso_out = 0u32;
let mut mss = 0u32;

#[cfg(all(not(feature = "std"), not(test)))]
unsafe {
Expand All @@ -806,15 +807,23 @@ impl MsgBlk {
);
illumos_sys_hdrs::mac::mac_lso_get(
self.0.as_ptr(),
ptr::null_mut(),
&raw mut mss,
&raw mut lso_out,
);
};

MblkOffloadFlags::from_bits_retain(cso_out | lso_out)
MblkOffloadInfo {
flags: MblkOffloadFlags::from_bits_retain(cso_out | lso_out),
mss,
}
}
}

pub struct MblkOffloadInfo {
pub flags: MblkOffloadFlags,
pub mss: u32,
}

impl AsMblk for MsgBlk {
fn unwrap_mblk(self) -> Option<NonNull<mblk_t>> {
let ptr_out = self.0;
Expand Down
38 changes: 22 additions & 16 deletions lib/oxide-vpc/src/engine/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ impl StaticAction for EncapAction {
}
};

let phys_target = match target {
let (is_internal, phys_target) = match target {
RouterTargetInternal::InternetGateway(_) => {
action_meta.set_internal_target(false);
match self.v2b.get(&flow_id.dst_ip()) {
Some(phys) => {
// Hash the packet onto a route target. This is a very
Expand All @@ -248,21 +247,24 @@ impl StaticAction for EncapAction {
Some(target) => target,
None => return Ok(AllowOrDeny::Deny),
};
PhysNet {
ether: MacAddr::from(TUNNEL_ENDPOINT_MAC),
ip: target.ip,
vni: target.vni,
}
(
false,
PhysNet {
ether: MacAddr::from(TUNNEL_ENDPOINT_MAC),
ip: target.ip,
vni: target.vni,
},
)
}
None => return Ok(AllowOrDeny::Deny),
}
}

RouterTargetInternal::Ip(virt_ip) => match self.v2p.get(&virt_ip) {
Some(phys) => {
action_meta.set_internal_target(true);
PhysNet { ether: phys.ether, ip: phys.ip, vni: self.vni }
}
Some(phys) => (
true,
PhysNet { ether: phys.ether, ip: phys.ip, vni: self.vni },
),

// The router target has specified a VPC IP we do not
// currently know about; this could be for two
Expand All @@ -283,11 +285,14 @@ impl StaticAction for EncapAction {

RouterTargetInternal::VpcSubnet(_) => {
match self.v2p.get(&flow_id.dst_ip()) {
Some(phys) => PhysNet {
ether: phys.ether,
ip: phys.ip,
vni: self.vni,
},
Some(phys) => (
true,
PhysNet {
ether: phys.ether,
ip: phys.ip,
vni: self.vni,
},
),

// The guest is attempting to contact a VPC IP we
// do not currently know about; this could be for
Expand All @@ -309,6 +314,7 @@ impl StaticAction for EncapAction {
}
}
};
action_meta.set_internal_target(is_internal);

let tfrm = HdrTransform {
name: ENCAP_NAME.to_string(),
Expand Down
19 changes: 10 additions & 9 deletions xde/src/xde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ fn guest_loopback(
// if necessary.
let pkt = if pkt
.offload_flags()
.flags
.intersects(MblkOffloadFlags::HCK_TX_FLAGS)
{
mac_hw_emul(pkt, MacEmul::HWCKSUM_EMUL)
Expand Down Expand Up @@ -1653,7 +1654,7 @@ unsafe extern "C" fn xde_mc_tx(
unsafe fn xde_mc_tx_one(src_dev: &XdeDev, mut pkt: MsgBlk) -> *mut mblk_t {
let parser = src_dev.port.network().parser();
let mblk_addr = pkt.mblk_addr();
let offload_flags = pkt.offload_flags();
let offload_req = pkt.offload_flags();
let parsed_pkt = match Packet::parse_outbound(pkt.iter_mut(), parser) {
Ok(pkt) => pkt,
Err(e) => {
Expand Down Expand Up @@ -1763,22 +1764,22 @@ unsafe fn xde_mc_tx_one(src_dev: &XdeDev, mut pkt: MsgBlk) -> *mut mblk_t {
// Boost MSS to use full jumbo frames if we know our path
// can be served purely on internal links.
// Recall that SDU does not include L2 size, hence 'non_eth_payl'
let mut flags = offload_flags;
let inner_mtu = if mtu_unrestricted {
src_dev.underlay_capab.mtu - encap_len
let mut flags = offload_req.flags;
let mss = if mtu_unrestricted {
src_dev.underlay_capab.mtu - encap_len - non_eth_payl_bytes
} else {
u32::from(ETHERNET_MTU)
offload_req.mss
};
let mss = inner_mtu - non_eth_payl_bytes;

// As underlay devices may need to emulate tunnelled LSO, then we
// need to strip the flag to prevent a drop, in cases where we'd
// ask to split a packet back into... 1 segment.
// Hardware tends to handle this without issue.
if ulp_meoi.meoi_len.saturating_sub(
u32::try_from(Ethernet::MINIMUM_LENGTH)
.expect("14B < u32::MAX"),
) <= inner_mtu
non_eth_payl_bytes
+ u32::try_from(Ethernet::MINIMUM_LENGTH)
.expect("14B < u32::MAX"),
) <= mss
{
flags.remove(MblkOffloadFlags::HW_LSO);
}
Expand Down