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/networkd: add missing options #44233

Merged
merged 1 commit into from Aug 16, 2018

Conversation

jfrankenau
Copy link
Member

Motivation for this change

The networkd module misses quite a few options which I'd like to use.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Fits CONTRIBUTING.md.

@Mic92
Copy link
Member

Mic92 commented Jul 30, 2018

Probably should be also backported.

Copy link
Member

@andir andir left a comment

Choose a reason for hiding this comment

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

This doesn't look to bad. I have not checked every option there is.

One thing that always was an issue in the past:
How do we keep that list updated? What was your process to add(&test) the missing fields?

Are you targeting the current systemd-networkd version from unstable or from the systemd master branch?

@Mic92
Copy link
Member

Mic92 commented Jul 31, 2018

I suppose once it is complete, it can be updated by diffing man/{systemd.network.xml,systemd.netdev.xml} between version tags of our systemd fork.

@jfrankenau
Copy link
Member Author

jfrankenau commented Jul 31, 2018

Yes, I have been using the man pages and mostly been going through by hand and some XML queries on their sources using xq from the yq package. Diffing would be the best way to go when thinking about updating it. I have actually used the man pages from systemd 239 which means that there are some options which are not yet supported but not the other way around I think. I hope that 239 comes to NixOS in the near future anyway.

Personally I have mixed feelings about replicating all those options in Nix. It is a tedious process and oftentimes not clear which NixOS option to use when looking at the systemd man pages, especially when systemd allows specifying an option more than once which needs to be abstracted into a list in Nix. Take for example systemd.network.networks.<name>.address and systemd.network.networks.<name>.addresses: One goes into [Network], the other contains [Address] sections and both are lists. I'd prefer on option tree which more closely resembles systemd units but that is difficult.

@Mic92
Copy link
Member

Mic92 commented Aug 1, 2018

Personally I by pass nixos's module system for networkd: https://github.com/Mic92/dotfiles/blob/master/nixos/network-configuration.nix#L185

@Mic92
Copy link
Member

Mic92 commented Aug 1, 2018

I started working on v239 support NixOS/systemd#20

@flokli
Copy link
Contributor

flokli commented Aug 12, 2018

@jflanglois can you have a look if everything from #40573 is included in your PR? We could then close #40573

@jflanglois
Copy link
Contributor

jflanglois commented Aug 13, 2018

@flokli did you mean @jfrankenau? ;)

@flokli
Copy link
Contributor

flokli commented Aug 13, 2018

yes, of course - github autocompletion gone wrong, sorry :-)

@jflanglois
Copy link
Contributor

No worries!

@jfrankenau
Copy link
Member Author

@flokli, yes of course. I have added your changes.

@Mic92 Mic92 merged commit 3d36e7c into NixOS:master Aug 16, 2018
@flokli flokli mentioned this pull request Aug 16, 2018
8 tasks
@jfrankenau jfrankenau deleted the networkd-fix-options branch August 16, 2018 09:41
@lopsided98
Copy link
Contributor

Did you test this with link definitions? It looks like you used range instead of assertRange at b2f1790#diff-7d08c03fc593d925ed022e395579c866R33, which completely breaks link configurations. See #45447.

@jfrankenau
Copy link
Member Author

@lopsided98, sorry. I blame auto completion for it. ;)

@lopsided98
Copy link
Contributor

Those same lines also break 32-bit Nix, because integers are 32 bits signed, so 4294967295 exceeds their maximum value. I'm not sure what to do about that. Do we really need to check the range of those options?

@Mic92
Copy link
Member

Mic92 commented Aug 23, 2018

Checking that it is an integer should be enough.

@aszlig
Copy link
Member

aszlig commented Aug 28, 2018

@lopsided98: Ah, sorry, didn't see your comments as I've commented on the corresponding commit directly.

@lopsided98
Copy link
Contributor

See #45722 for a fix.

aszlig added a commit to aszlig/nix that referenced this pull request Aug 28, 2018
Using a 64bit integer on 32bit systems will come with a bit of a
performance overhead, but given that Nix doesn't use a lot of integers
compared to other types, I think the overhead is neglicible also
considering that 32bit systems are in decline.

The biggest advantage however is that when we use a consistent integer
size accross all platforms it's less likely that we miss things that we
break due to that. One example would be:

NixOS/nixpkgs#44233

On Hydra it will evaluate, because the evaluator runs on a 64bit
machine, but when evaluating the same on a 32bit machine it will fail,
so using 64bit integers should make that consistent.

While the change of the type in value.hh is rather easy to do, we have a
few more options available for doing the conversion in the lexer:

  * Via an #ifdef on the architecture and using strtol() or strtoll()
    accordingly depending on which architecture we are. For the #ifdef
    we would need another AX_COMPILE_CHECK_SIZEOF in configure.ac.
  * Using istringstream, which would involve copying the value.
  * As we're already using boost, lexical_cast might be a good idea.

Spoiler: I went for the latter, first of all because lexical_cast does
have an overload for const char* and second of all, because it doesn't
involve copying around the input string. Also, it seems to come with a
bigger overhead than boost::lexical_cast:

https://www.boost.org/doc/libs/release/doc/html/boost_lexical_cast/performance.html

The first method (still using strtol/strtoll) also wasn't something I
pursued further, because it is also locale-aware which I doubt is what
we want, given that the regex for int is [0-9]+.

Signed-off-by: aszlig <aszlig@nix.build>
Fixes: NixOS#2339
aszlig added a commit to aszlig/nix that referenced this pull request Aug 28, 2018
Using a 64bit integer on 32bit systems will come with a bit of a
performance overhead, but given that Nix doesn't use a lot of integers
compared to other types, I think the overhead is negligible also
considering that 32bit systems are in decline.

The biggest advantage however is that when we use a consistent integer
size across all platforms it's less likely that we miss things that we
break due to that. One example would be:

NixOS/nixpkgs#44233

On Hydra it will evaluate, because the evaluator runs on a 64bit
machine, but when evaluating the same on a 32bit machine it will fail,
so using 64bit integers should make that consistent.

While the change of the type in value.hh is rather easy to do, we have a
few more options available for doing the conversion in the lexer:

  * Via an #ifdef on the architecture and using strtol() or strtoll()
    accordingly depending on which architecture we are. For the #ifdef
    we would need another AX_COMPILE_CHECK_SIZEOF in configure.ac.
  * Using istringstream, which would involve copying the value.
  * As we're already using boost, lexical_cast might be a good idea.

Spoiler: I went for the latter, first of all because lexical_cast does
have an overload for const char* and second of all, because it doesn't
involve copying around the input string. Also, it seems to come with a
bigger overhead than boost::lexical_cast:

https://www.boost.org/doc/libs/release/doc/html/boost_lexical_cast/performance.html

The first method (still using strtol/strtoll) also wasn't something I
pursued further, because it is also locale-aware which I doubt is what
we want, given that the regex for int is [0-9]+.

Signed-off-by: aszlig <aszlig@nix.build>
Fixes: NixOS#2339
aszlig added a commit to aszlig/nix that referenced this pull request Aug 28, 2018
Using a 64bit integer on 32bit systems will come with a bit of a
performance overhead, but given that Nix doesn't use a lot of integers
compared to other types, I think the overhead is negligible also
considering that 32bit systems are in decline.

The biggest advantage however is that when we use a consistent integer
size across all platforms it's less likely that we miss things that we
break due to that. One example would be:

NixOS/nixpkgs#44233

On Hydra it will evaluate, because the evaluator runs on a 64bit
machine, but when evaluating the same on a 32bit machine it will fail,
so using 64bit integers should make that consistent.

While the change of the type in value.hh is rather easy to do, we have a
few more options available for doing the conversion in the lexer:

  * Via an #ifdef on the architecture and using strtol() or strtoll()
    accordingly depending on which architecture we are. For the #ifdef
    we would need another AX_COMPILE_CHECK_SIZEOF in configure.ac.
  * Using istringstream, which would involve copying the value.
  * As we're already using boost, lexical_cast might be a good idea.

Spoiler: I went for the latter, first of all because lexical_cast does
have an overload for const char* and second of all, because it doesn't
involve copying around the input string. Also, because istringstream
seems to come with a bigger overhead than boost::lexical_cast:

https://www.boost.org/doc/libs/release/doc/html/boost_lexical_cast/performance.html

The first method (still using strtol/strtoll) also wasn't something I
pursued further, because it is also locale-aware which I doubt is what
we want, given that the regex for int is [0-9]+.

Signed-off-by: aszlig <aszlig@nix.build>
Fixes: NixOS#2339
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

8 participants