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

parser: accept the special MAC address options (LP: #2045096) #427

Merged
merged 1 commit into from Feb 26, 2024

Conversation

daniloegea
Copy link
Collaborator

@daniloegea daniloegea commented Dec 7, 2023

Besides the actual MAC address value, Network Manager also accepts the following values: preserve, permanent, random and stable.

When set via NetworkManager, these special values would end up in the passthrough section. But if users try to set it manually, the parsing would fail.

This changes add support for these special values for the NetworkManager renderer and return an error if the user tries to use them with networkd.

Related to https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/2045096

Description

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Adds example YAML for new feature.
  • (Optional) Closes an open bug in Launchpad.

Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OKish, I guess.
Although, I don't like the fact of diverging possible values, depending on the chosen backend too much.

I wonder if similar behavior could be implemented on the "networkd" backend, using udev's [Link].MACAddressPolicy= setting? https://www.freedesktop.org/software/systemd/man/latest/systemd.link.html#MACAddressPolicy=

As I see from parse-nm.c those cases have already been handled for NetworkManager integration (using "passthrough"). I wonder how this bug was hit in the first place? Was it a manual modification of the NetworkManager genrated YAML by the user?

@daniloegea
Copy link
Collaborator Author

I assumed the used modified it manually, yes. Although I can't confirm that (I saw you just asked them).

I'll look at the networkd options, supporting them sounds like a good idea.

Thanks!

@daniloegea
Copy link
Collaborator Author

So, I added support for the options supported by networkd as well, "persistent" and "random". It was a bit harder because it involves multiple files and the option is different (MACAddress vs MACAddressPolicy).

@daniloegea daniloegea requested a review from slyon January 10, 2024 14:50
Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for implementing it for the networkd backend, too!

Overall, this is looking good to me, but I'd like to see an additional integration test, to make sure the new MACAddressPolicy= don't interfere with /usr/lib/systemd/network/99-default.link.

Also let's try to combine the "persistent"+"permanent" and "random", instead of special casing all of them (see inline comment).

src/networkd.c Outdated Show resolved Hide resolved
doc/netplan-yaml.md Outdated Show resolved Hide resolved
@daniloegea daniloegea force-pushed the macaddress_random branch 5 times, most recently from c34cd18 to d9a07f9 Compare February 22, 2024 13:43
@daniloegea daniloegea changed the title parser: accept the special NM values for MAC address parser: accept the special MAC address options Feb 22, 2024
Besides the actual MAC address value, Network Manager and networkd
also accept special options to control the assignment of a MAC address.

The options supported are: permanent, random, stable and preserve.

All these options are supported by Network Manager. Only 'permanent'
(which will be translated to 'persistent') and 'random' are supported by
networkd and will be added to the .link file.
@daniloegea
Copy link
Collaborator Author

Thanks Lukas, I tried to address all of your comments. As for the integration test, I couldn't get the option random working in our autopkgtest environment. I believe it has to do with the virtual ethernet we use to simulate an ethernet interface. It works fine with a real ethernet interface though. It also works when NetworkManager is used so I added a test for NetworkManager only.

@daniloegea
Copy link
Collaborator Author

Is the documentation checks failing because of this?

( index: line 70) broken https://askubuntu.com/questions/tagged/netplan - 403 Client Error: Forbidden for url: https://askubuntu.com/questions/tagged/netplan

@slyon slyon changed the title parser: accept the special MAC address options parser: accept the special MAC address options (LP: #2045096) Feb 26, 2024
Copy link
Collaborator

@slyon slyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

Is the documentation checks failing because of this?

( index: line 70) broken https://askubuntu.com/questions/tagged/netplan - 403 Client Error: Forbidden for url: https://askubuntu.com/questions/tagged/netplan

Yes, we can ignore that for now.

@slyon slyon merged commit f675f76 into canonical:main Feb 26, 2024
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants