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/scripted-networking: use udev to configure link MACAddress and MTUBytes #88032

Merged
merged 1 commit into from May 22, 2020

Conversation

@flokli
Copy link
Contributor

flokli commented May 17, 2020

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
#82941.

This continues clean-up work done in
#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: #74471
Closes: #87116

Motivation for this change
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.

cc @goertzenator

@flokli flokli requested review from fpletz, andir, petabyteboy and lovesegfault May 17, 2020
@flokli
Copy link
Contributor Author

flokli commented May 17, 2020

I ran all the nixosTests.networking.scripted tests, they still succeed.

@goertzenator can you give this a try? Maybe we could also add setting a custom mac address on a bridge, if that's what your setup looks like (#87116 (comment)).

@peterhoeg
Copy link
Member

peterhoeg commented May 18, 2020

This is very nice. I have some local changes that also writes out .network and .link files for wireguard (this is obviously only for systemd-networkd) instead of using our custom code. I should have some time this coming weekend to get a PR going for that.

@flokli
Copy link
Contributor Author

flokli commented May 18, 2020

@peterhoeg thanks for the positive feedback! Happy to take a look at your PR once it's ready.

I assume this won't clash with what's done here, right?

@flokli flokli requested review from Ma27, Mic92, globin and lheckemann May 18, 2020
@Mic92 Mic92 removed their request for review May 18, 2020
@Ma27
Ma27 approved these changes May 18, 2020
@flokli
Copy link
Contributor Author

flokli commented May 19, 2020

@lheckemann let me know if you agree on #88032 (comment) - happy to change the occurences to map then, too.

@flokli flokli force-pushed the flokli:scripted-networking-link branch from 68de6bc to 2812cbe May 21, 2020
@flokli flokli requested a review from lheckemann May 21, 2020
@flokli
Copy link
Contributor Author

flokli commented May 21, 2020

I updated the release notes as requested and changed the concatMap to map as well, PTAL.

…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
#82941.

This continues clean-up work done in
#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: #74471
Closes: #87116
@flokli flokli force-pushed the flokli:scripted-networking-link branch from 2812cbe to 822918d May 22, 2020
@flokli
Copy link
Contributor Author

flokli commented May 22, 2020

Rebased on latest master to conflict in the docbook.

@flokli flokli merged commit a02f3fb into NixOS:master May 22, 2020
1 check failed
1 check failed
editorconfig editorconfig
Details
@flokli flokli deleted the flokli:scripted-networking-link branch May 22, 2020
@goertzenator
Copy link
Contributor

goertzenator commented May 29, 2020

I'm a little late to the show, but today I cherry picked this commit onto 20.03 and my bridge interface with custom MAC address booted up perfectly! Thank you @flokli for your hard work.

@flokli
Copy link
Contributor Author

flokli commented May 31, 2020

Thanks for the confirmation, nice to hear it works for you :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.