Repository navigation
A radio leaves zone 0 with one station, whatever netdevs the last net zone left on it - #305
Merged
Merged
Conversation
The net zone holds CAP_NET_ADMIN in its namespace and can give its NIC any name the kernel takes: a leading dash, a quote, an escape, bytes that are not UTF-8. When the zone ends the NIC comes back to zone 0 under that name, and the next start handed it on as it was. A name that is not UTF-8 failed every later start, since kryptikd looked up the lossy copy, and kept the machine offline until a reboot. Any other reached the fresh zone's script: a quote ended the name in the nft uplink set and could add kryptik0 to it, and a leading dash reached dhcpcd as an option. kryptikd now reads each physical interface's name as the kernel holds it, with its index, and renames one that is not plain, a lower-case letter then lower-case letters and digits, to the kernel's nic%d before it moves. netzone-init.sh names the device to ip with dev, so a plain name that is also an ip keyword is still read as a name.
…tart making kryptik0
… zone left on it The net zone can add netdevs to its radio, an AP, mesh or monitor one, or delete the one it has, and cfg80211 returns the wiphy to zone 0 with whatever is on it. A second netdev failed every later start: the first carry moved the wiphy with both, and the second found no such interface. A radio with none was never carried again, so Wi-Fi was gone until a reboot. Before it lists what to carry, kryptikd now gives a radio with no netdev a station named nic<N> (nl80211 NEW_INTERFACE), deletes all but the first netdev of a radio with several (DEL_INTERFACE), and lists each radio once. The zones suite leaves the net zone's radio with a monitor netdev beside the station, then with none, restarts the zone each time, and sees the next one get the radio with one station and join the access point again.
… since which to keep was the last zone's choice
…cannot find by name through zone 0's sysfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #304 (nic-renamed-plain); merge that first. This PR's own change is its last two commits, a0c093a and 0a2d261.
What was wrong. The net zone holds
CAP_NET_ADMINand generic netlink, so it can add netdevs to its radio (an AP, mesh or monitor one) or delete the one it has. When the zone ends, cfg80211 returns the wiphy to zone 0 with whatever netdevs are on it. Each case defeats the restart that is meant to give a fresh net zone:carry_nicof the first moved the wiphy, and the second went with it.carry_nicof the second then found no such interface, and the plumb failed. The zone crash-looped until a reboot.physical_interfaceslists netdevs, so Wi-Fi was gone until a reboot.What changed.
compartments/kryptikd/src/netzone.rs: beforephysical_interfaceslists what to carry, a zone 0 radio with no netdev gets a station namednic<N>(bare_radios, read from sysfs). A radio with several netdevs has them all deleted and gets a fresh station too, since which one to keep would be the old zone's choice; the fresh station also takes the radio's own address. So each radio leaves with one station, as a boot gives it. linux-distro-fe suggested both: deleting the extras rather than letting them ride along (a second station can knock the first off its network, and an AP or monitor netdev the old zone made should not travel on), and deleting them all rather than keeping the first by name. A netdev that cannot be deleted goes along with its radio, which is still carried once.physical_interfaces_undernow also returns each netdev's wiphy.compartments/kryptikd/src/netlink.rs:new_station(NL80211_CMD_NEW_INTERFACE, iftype station, the name a%dtemplate) anddel_interface(NL80211_CMD_DEL_INTERFACEby ifindex).compartments/kryptikd/src/netzone/tests.rs:bare_radios_are_the_ones_no_netdev_holdsruns over a fake sysfs.build/guest-tests/zones-check.sh: the new checkradio-recarriedruns after wifi-egress, over the simulated radio, in two rounds. First it adds a monitor netdev namedamon0, which sorts before the station, inside the net zone. Then it deletes every netdev on the radio. Each round stops the service, waits forphy0in zone 0, and starts the service again. The check passes only if the zone held 2 and then 0 netdevs on the radio, and the next zone got exactly one each time, a freshnic<N>, and joined the access point again (READYwithwifi=<the SSID>). wifi-beyond then runs on the re-carried radio.tools/image/zones-test.sh: lists the verdict on a line of its own.docs/design/net-zone.md: the wireless section and the tests.How the run proves it. CI runs the unit test. In the Distro run's zones suite,
radio-recarriedfails on main: the first round's start fails at the second netdev and never comesREADYwith the SSID, and in the second round no radio is carried. With this change both rounds join.Merges clean with every open PR except #180 and #207, which already conflict with main.