Skip to content
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

Generate udev rules files to rename devices #31

Merged
merged 2 commits into from
May 22, 2018

Conversation

daxtens
Copy link
Contributor

@daxtens daxtens commented May 17, 2018

Due to a systemd issue[1], using link files to rename interfaces doesn't work as expected. Link files will not rename an interface if it was already renamed, and interfaces are renamed in initrd, so set-name will often not work as expected when rebooting.

However, rules files will cause a renaming, even if the interface has been renamed in initrd.

So, while we sort out whether the systemd-udev behaviour is broken or not, we can simply generate udev rules files with appropriate renaming info in /run/udev/rules.d/70-netplan-.rules

A file will be created for non-virtual interfaces with both a set-name and a driver or a macaddress in the match stanza. (Renaming from name to name doesn't work.)

This is at least a temporary fix to LP: #1770082.

As far as testing goes, test successful set-name: generations, and a few cases where we expect no files to be generated.

[1] https://github.com/systemd/systemd#9006

The function specifically tests a NM specific udev rule. We're
about to add more udev support, so it would be helpful to have
clearer names.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Due to a systemd issue[1], using link files to rename interfaces
doesn't work as expected. Link files will not rename an interface
if it was already renamed, and interfaces are renamed in initrd, so
set-name will often not work as expected when rebooting.

However, rules files will cause a renaming, even if the interface
has been renamed in initrd.

So, while we sort out whether the systemd-udev behaviour is broken
or not, we can simply generate udev rules files with appropriate
renaming info in /run/udev/rules.d/70-netplan-<interface>.rules

A file will be created for non-virtual interfaces with both a
set-name and a driver or a mac address in the match stanza.
(Renaming from name to name doesn't work.)

This is at least a temporary fix to LP: #1770082

As far as testing goes, test successful set-name: generations, and
a few cases where we expect no files to be generated.

[1] systemd/systemd#9006

Signed-off-by: Daniel Axtens <dja@axtens.net>
@codecov-io
Copy link

Codecov Report

Merging #31 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #31   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          19     19           
  Lines        2093   2110   +17     
=====================================
+ Hits         2093   2110   +17
Impacted Files Coverage Δ
src/networkd.c 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7afef6a...b0c51bf. Read the comment docs.

@cyphermox cyphermox merged commit fd6824c into canonical:master May 22, 2018
@daxtens daxtens deleted the rules branch September 10, 2018 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants