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

nixos/networking: fix setting MAC Address and MTU in networkd, fix tests #85170

Merged
merged 6 commits into from Apr 14, 2020

Conversation

flokli
Copy link
Contributor

@flokli flokli commented Apr 13, 2020

Motivation for this change

This cleans up code setting MTU and MAC Address. We only use network-link-${interfaceName} in scripted networking, and use the native networkd methods to set it in case of networkd.

This also improves the reliability of the networking tests, and fixes nixosTests.networking.networkd.virtual.

@rnhmjoj We can just backport a501abd5499d8f82f0991a7b78bcbc4169b0537f into 20.03 to fix the test there as well.

Ran all tests in nixosTests.networking.networkd and nixosTests.networking.scripted in master, and 20.03 with a501abd5499d8f82f0991a7b78bcbc4169b0537f cherry-picked, they succeed now 🎉

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@flokli flokli force-pushed the networking-virtual branch 2 times, most recently from 38fca3f to d749e32 Compare April 13, 2020 20:03
This needs to be set in the .linkConfig of a .network
… devices

Setting a MAC Address on a tun interface isn't supported, and invoking
the corresponding command fails.
The unit sets MTU and MAC Address even with networkd enabled, which
isn't necessary anymore, as networkd handles this by itself.
This was whitespace-sensitive, kept fighting with my editor and broke
the tests easily. To fix this, let python convert the output to
individual lines, and strip whitespace from them before comparing.
We only need to wait for network.target to get up, and the
network-addresses-${interfaceName} units are scripted networking only.
Both the scripted and networkd backend now support setting MTU and MAC
Address, so do this in a test to ensure it doesn't break.
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Apr 14, 2020

I run all tests again on x86_64 and aarch64. Everything is passing.

@rnhmjoj rnhmjoj merged commit 86d71dd into NixOS:master Apr 14, 2020
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Apr 14, 2020

Backported the fix in 897182c.

@flokli flokli deleted the networking-virtual branch May 7, 2020 21:38
flokli added a commit to flokli/nixpkgs that referenced this pull request May 22, 2020
…MTUBytes

The `network-link-${i.name}` units raced with other things trying to
configure the interface, or ran before the interface was available.

Instead of running our own set of shell scripts on boot, and hoping
they're executed at the right time, we can make use of udev to configure
the interface *while they appear*, by providing `.link` files in
/etc/systemd/network/*.link to set MACAddress and MTUBytes.

This doesn't require networkd to be enabled, and is populated properly
on non-networkd systems since
NixOS#82941.

This continues clean-up work done in
NixOS#85170 for the scripted networking
stack.

The only leftover part of the `network-link-${i.name}` unit (bringing
the interface up) is moved to the beginning of the
`network-addresses-${i.name}` unit.

Fixes: NixOS#74471
Closes: NixOS#87116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants