We have a possibly unique situation in the FreeBSD iavf(4) driver that requires a change in how VLANs are unregistered in iflib.
By default on ice(4), the Linux PF enables VLAN anti-spoof for VFs that it spawns. This functionality causes the PF driver to generate MDD events when the VF transmits a packet with a VLAN tag that the PF didn't explicitly allow for the VF.
These "Malicious Driver Detection" events cause the offending packet to be dropped, which wouldn't be a big deal if it stopped there. However, the PF disrupts the VF's functionality, requiring the VF to be ifconfig down/up to continue transmitting/receiving again.
To go back to the original problem, it can happen that a VLAN is unregistered (so the VF notifies the PF that it is no longer using that VLAN), but the VF's software queues still have VLAN tagged packets in them, causing them to be to transmitted after the VLAN has been unconfigured, causing the MDD events described above. This patch changes the iflib_unregister_vlan() flow to do an iflib_stop() first before unregistering the VLAN, causing those still-queued Tx packets to be flushed before removing the VLAN, thus avoiding this situation. This patch should still be functionally equivalent to what was done before in other respects, since it just separates the iflib_stop() and iflib_init_locked() steps that were included in the one iflib_if_init_locked() function call before.
That said, I don't think IFCAP_VLAN_HWFILTER really applies to this situation; this would probably still be a problem even if it was turned off. An older revision of this patch just checked that capability; that's the smallest possible diff that would solve this issue, but I don't think it's the best solution.
As well, this patch is against stable/11, but it really applies to all versions of iflib.