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

Fix: nixos-container does not always apply extraVeth ips #107127

Merged
merged 1 commit into from Dec 29, 2020

Conversation

queezle42
Copy link
Contributor

Motivation for this change

The nixos-container always creates configured extraVeths, but does not always set configured IPs (containers.<name>.extraVeths.<name>.hostAddress, etc.) for them.

Things done
  • [n/a] 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)
  • [n/a] Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • [n/a] Tested execution of all binary files (usually in ./result/bin/)
  • [n/a] 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.

@andir
Copy link
Member

andir commented Dec 19, 2020

Thanks for this PR! 👍

Can you maybe write a bit more about how this manifests (I can imagine how but for documentation purposes) and add that to the commit message while following the commit format documented in the CONTRIBUTING.md?

It might be good to explicitly state how to verify the behaviour.

Fixes that `containers.<name>.extraVeths.<name>` configuration was not
always applied.

When configuring `containers.<name>.extraVeths.<name>` and not
configuring one of `containers.<name>.localAddress`, `.localAddress6`,
`.hostAddress`, `.hostAddress6` or `.hostBridge` the veth was created,
but otherwise no configuration (i.e. no ip) was applied.

nixos-container always configures the primary veth (when `.localAddress`
or `.hostAddress` is set) to be the containers default gateway, so
this fix is required to create a veth in containers that use a different
default gateway.

To test this patch configure the following container and check if the
addresses are applied:
```
  containers.testveth = {
    extraVeths.testveth = {
      hostAddress = "192.168.13.2";
      localAddress = "192.168.13.1";
    };
    config = {...}:{};
  };
```
@queezle42
Copy link
Contributor Author

@andir Thanks for the feedback. I have added a better explanation and a PoC to the commit message.

@andir
Copy link
Member

andir commented Dec 19, 2020

This looks fine to me. I haven't used containers in a looooong time. Maybe @adisbladis is using them as he also touched these files?

@queezle42 queezle42 changed the title Fix nixos-container extraVeths ip configuration is not always applied Fix: nixos-container does not always apply extraVeth ips Dec 20, 2020
@teto
Copy link
Member

teto commented Dec 20, 2020

also testing it

@queezle42
Copy link
Contributor Author

This is a simple change that moves existing code out of an unrelated condition, so a review should be very quick. Is there something I can do to get this merged?

@Lassulus Lassulus merged commit 86102eb into NixOS:master Dec 29, 2020
@queezle42 queezle42 deleted the nixos-container-extraVeth-fix branch April 24, 2022 22:40
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

5 participants