-
Notifications
You must be signed in to change notification settings - Fork 207
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
Handling encoding issues on netplan status #521
Conversation
1a409eb
to
ea285b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM. With a few (non-critical) inline comments.
netplan_cli/cli/state.py
Outdated
# Used for wifi testing | ||
'ieee80211_radiotap': 'wifi', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Could you please provide some instruction of how this can be used for wifi testing? Either as part of the PR description or a code comment. I cannot see it being used in the automated tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry. This is the device type for the device hwsim0
created by the mac80211_hwsim
module.
I used it to test my changes and noticed warnings from netplan status
.
This is how networkctl
sees it: 7 hwsim0 ieee80211_radiotap off unmanaged
I added it to the list to avoid this warning from netplan status
:
~# netplan status
Unknown device type: ieee80211_radiotap
Unknown device type: ieee80211_radiotap
Online state: online
...
I'll improve the comment.
key = r'^Wi-?Fi access point: (.*) \(.*\)' | ||
if match := re.match(key, line): | ||
ssid = match.group(1) | ||
# TODO: Find a better way to retrieve the SSID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick (non-blocking): We should try getting this information from the networkctl --json=short
output instead.
IIRC, this was not implemented back when we first wanted to use it in netplan status
, but I can see it on systems using systemd v255+ today: networkctl --json=short status wlp0s20f3 | jq | grep SSID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes it's not available. The output below is from one of my laptops:
danilo@danilo-Aspire-ES1-572:~$ networkctl --json=short status wlp2s0 | jq | grep SSID
"BSSID": [
danilo@danilo-Aspire-ES1-572:~$
On another laptop it will give me the SSID though. I suspect it might be some limitation of the driver, I don't really know.
That's the reason why I changed it to get it from Network Manager when NM is the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in these cases we will show it like this on netplan status
:
● 5: wlan2 wifi/"(null)" UP (networkd: wlan2)
The networkctl output was changed from "WiFi access point" to "Wi-Fi access point" as part of systemd commit 8fff78a1dded105e1ee87bc66e29ef2fd61bf8c9. Use a regex that matches both formats to keep it compatible with older versions of networkd.
Non-ascii characters returned from external programs (such as nmcli) are being replaced by "?".
The ID is extracted from the file name. For Wi-Fi connections, the SSID will also be present in the file name and we need to remove it in order to extract the netdef ID. When non-ascii characters are present in the SSID, NM will represent it using a byte sequence separated with ;. The semicolons are escaped in the file name when we emit the .nmconnection file. In order to find and remove the SSID from the file name, so we can get the netdef ID, we need to convert it to the same representation. To detect this situation we check if the SSID is present in the file name. If it's not, it likely because the SSID contains non-ascii characters.
This workaround is intended to properly decode non-ascii SSIDs returned by networkctl. In such a case, a sequence of bytes (in octal notation) will be returned and we were displaying this string in netplan status.
networkctl might return "(null)" as the SSID value. Use Network Manager to get the SSID when it's the backend.
ea285b8
to
f933e58
Compare
Description
This PR addresses some issues with
netplan status
:SSID is not displayed with newer systemd
On Ubuntu Noble for example,
netplan status
will not show the SSID for wifi interfaces.The problem was likely caused by systemd/systemd@8fff78a.
The output of external programs was broken if non-ascii characters are present.
Netdef IDs were not being extracted correctly from file names when non-ascii characters were escaped.
Retrieving the SSID via
networkctl
wasn't producing the readable SSID string.To verify the enigmatic trick used in the commit
state/SSID: handle non-ascii SSIDs
:The output should be
áéíóú¢¢¢£££
.The line 1 above is what we receive from networkctl and we are currently displaying it as the SSID in
netplan status
.networkctl
andiw
will not retrieve the SSID and"(null)"
will be displayed. This problem was fixed for Network Manager connections (where the SSID is retrieved via nmcli) but is still there when networkd is the backend.Example:
● 3: wlp2s0 wifi/"(null)" UP (NetworkManager: wlp2s0)
Checklist
make check
successfully.make check-coverage
).