Conversation
read_sys_net() lets callers handle a missing sysfs attribute through on_enoent, but only for ENOENT and ENOTDIR. For mac802154_hwsim WPAN interfaces, device/device links to a directory, so reading it raised IsADirectoryError out of device_devid(). That made get_interfaces() fail, and with it network configuration in the init-local stage. Handle EISDIR like a missing attribute, so device_devid() returns None for such interfaces. Fixes canonicalGH-4257
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.
Proposed Commit Message
Additional Context
Fixes #4257
In the sysfs layout from the report,
/sys/class/net/wpan1/device/devicelinks to/sys/devices/platform/mac802154_hwsim, which is a directory. Reading it raisedIsADirectoryError(EISDIR).read_sys_net()passes ENOENT and ENOTDIR toon_enoent, but not EISDIR, so the error escapedread_sys_net_safe()anddevice_devid()and madeget_interfaces()fail.With this change
device_devid()returnsNonefor such interfaces, the same as for interfaces withoutdevice/device. Callers that don't passon_enoentstill get the exception.New tests cover three cases, and all three fail without the fix:
read_sys_net()passes a directory toon_enoentdevice_devid()with the WPAN layout from the reportget_interfaces()lists a WPAN interface next to an ethernet oneI don't have 802.15.4 hardware or the
mac802154_hwsimmodule loaded here, so the reported layout is reproduced in the unit tests. Verified with the pinned black, isort, ruff, pylint and mypy, and the full unit suite passes (5,782 tests).Test Steps
On a machine where
mac802154_hwsimis available:Without this change the
get_interfaces()call raisesIsADirectoryError, as in the report. With it, the call should return normally.Merge type