Repository navigation
Description
While doing a demo dry run we somehow got into a state where the opte1 xde device was removed from DLS (what dladm shows), but the OPTE Port opte1 was not deleted. No one on the call knows how this happened. It seems like something had possibly gone wrong with instance stop that left some state around, but we don't really know.
In this scenario we cannot manually delete the opte1 OPTE Port via opteadm because the xde handler code expects to be able to delete the DLS devnet ID.
// destroy dls devnet device
let ret = unsafe {
dls::dls_devnet_destroy(xde.mh, &mut xde.linkid, boolean_t::B_TRUE)
};
However, since the DLS device was already deleted this always fails. So then I recommended unloading the xde driver in order to clear the state, but that resulted in the following crash:
WARNING: panicked at 'called `Result::unwrap()` on an `Err` value: xde_underlay_port { name: "net0", mh: 0xfffffeb1d99b4028, mch: MacClient { close_flags: 0, mch: 0xfffffeb1cf1dd8e8 }, mph: 0xfffffeb1e2b05e08 }', src/xde.rs:947:51
The problem code is:
let state = Box::from_raw(rstate as *mut XdeState);
let underlay = state.underlay.into_inner();
match underlay {
Some(underlay) => {
let u1 = Arc::try_unwrap(underlay.u1).unwrap();
Specifically, since there is still an outstanding port, there is more than one strong ref to the underlay (u1).
The solution is probably to have detatch first check that there are no existing ports, otherwise it needs to immediately return failure. However, in this scenario, that would mean there is no way to get OPTE/xde out of this broken state without restarting the machine. So perhaps, along with this change, we also need some "force" option for the delete port command so that it will delete the OPTE Port even if the DLS devnet device doesn't exist.
Activity
rzezeski commentedon Jul 8, 2022
I have a hunch on how we got into this state based on oxidecomputer/omicron#1364. For this example we'll assume a guest using an OPTE Port of
opte0(as reported byopteadm list-ports), which has a DLS devnet entry name ofopte0(as reported bydladm), and a VNIC ofvopte0(as reported bydladm). The guest's viona has a handle open tovopte0. With that setup I think the following steps get us into trouble:vopte0, say an instance ofsnoop(1M)run by the operator.Dropimpl for Omicron'sOptePortstructure. This drop impl does two things: attempts to deletevopte0, and then attempts to call theOpteCmd::DeleteXdecommand.vopte0deletion fails because the snoop process is holding onto it. But the drop impl proceeds to run theDeleteXdecommand anyways.DeleteXdecommand has 3 steps: delete the DLS devnet entry, unregister the mac provider, remove the device from thedevslist (which is whatopteadm list-portsis based on).vopte0). Upon failure theDeleteXdecommand returns immediately, and thus the device is never removed from thedevslist.The reason this can happen is that the DLS devnet entry is not actually opened by anything in this scenario, and thus the
dls_devnet_t.dd_ref == 1. This allows the DLS devnet entry to be deleted even though the mac provider and OPTE port still exist. There are two things to consider here:rzezeski commentedon Jul 8, 2022
To prove this is the case we can look at state on host
sock. Notice that thedd_refforvopte0is 2 because viona has it opened, butopte0is 1 because nothing has it open. And if you look at the impl fordls_devnet_unset()you'll see that it proceeds with deletion so long asdd_ref == 1.rzezeski commentedon Jul 11, 2022
Just to be completely sure I had this right I replicated the scenario described in oxidecomputer/omicron#1364 and verified that DLS devent deletion succeeds while mac unregister fails.
First,
dladmbefore stopping the instance.vopte0.Sled agent log reports failure.
DTrace one-liner shows that
dls_devnet_destroy()succeeds whilemac_unregister()fails.dladm shows
opte0link is gone, butvopte0still exists.opteadm shows that
opte0still exists.xde detach panicked on Arc::try_unwrap (#178)
rzezeski commentedon Jul 11, 2022
I tested the fix by putting my host into the state described above and then verifying that xde refuses to detach.
rzezeski commentedon Jul 11, 2022
Addressed in 0e78c72.