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/network-interfaces: assertion for too long interface names #30127

Merged
merged 1 commit into from Nov 8, 2017

Conversation

florianjacob
Copy link
Contributor

Motivation for this change

I ran into a problem that was really hard to debug when using services.tinc.networks."network-name" with a network name longer than 10 characters, because the resulting interface name of tinc.network-name would exceed the maximum allowed length of interface names and get truncated, and everything breaks because all configuration still expects the full interface name.

This PR makes this implicit failure explicit by adding an assertion to fail rebuild when names are too long, whatever their source or prefix is.

Fixes #15682 as well, which is a similar problem, but with the container service.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@Mic92 Mic92 merged commit 8d145da into NixOS:master Nov 8, 2017
@florianjacob florianjacob deleted the limit_interface_name_length branch November 8, 2017 21:17
# See include/linux/if.h in the kernel sources
assertion = stringLength i.name < 16;
message = ''
The name of networking.interfaces."${i.name}" is too long, it needs to be less than 16 characters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not adhere to the surrounding code and say just ${i.name} instead of adding "s?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@4z3 The idea was to avoid misinterpretations when the interface name contains a dot.

e.g. the tinc nixos module names interfaces like tinc.${networkname}, which would result in the error message The name of networking.interfaces.tinc.examplenet is too long, it needs to be less than 16 characters. This would obscure that the limit is not broken by ${networkname}, but by tinc.${networkname} (and also look like tinc is a submodule of networking.interfaces).

But yes, this is now inconsistent with the surrounding code, forgot about this. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Valid point. Maybe the surroundings should be updated then, for consistency and also because they can produce misinterpretable error messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! Fix at #31476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When enable private network, NixOS container fail to start if hostname too long
4 participants