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
Container private networking broken with hostBridge enabled #52417
Comments
This seems like not to hard to fix right? Do you want to take a stab at it yourself, or shall I take a look at it? |
@tadfisher do you have interest in taking a stab at this? Otherwise i'll put it on my todo list |
I hope someone can look at this soon, it really bites me! I don't understand it well enough now to look myself. What might be a workaround in the mean time? Should I specify the |
I think just moving the host bridge specification part out of the if statement should do the trick, the port part can probably be moved out as well. Here is a patch, but I haven't tested it yet: --- a/nixos/modules/virtualisation/containers.nix
+++ b/nixos/modules/virtualisation/containers.nix
@@ -90,18 +90,20 @@ let
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ]; then
extraFlags+=" --network-veth"
- if [ -n "$HOST_BRIDGE" ]; then
- extraFlags+=" --network-bridge=$HOST_BRIDGE"
- fi
- if [ -n "$HOST_PORT" ]; then
- OIFS=$IFS
- IFS=","
- for i in $HOST_PORT
- do
- extraFlags+=" --port=$i"
- done
- IFS=$OIFS
- fi
fi
+
+ if [ -n "$HOST_PORT" ]; then
+ OIFS=$IFS
+ IFS=","
+ for i in $HOST_PORT
+ do
+ extraFlags+=" --port=$i"
+ done
+ IFS=$OIFS
+ fi
+
+ if [ -n "$HOST_BRIDGE" ]; then
+ extraFlags+=" --network-bridge=$HOST_BRIDGE"
+ fi
extraFlags+=" ${concatStringsSep " " (mapAttrsToList nspawnExtraVethArgs cfg.extraVeths)}" |
@uvNikita, thanks for the fast reply! Have you been able to test it yet yourself? I think I am seeing the same behavior with this patch applied (that is, my container still comes up with only a |
@qolii I changed the patch a bit and it's working on my tests now. Can you double check that it fixes the problem for you as well? |
Could we write a VM Test that checks the behaviour? To stop these regressions in the future? |
According to systemd-nspawn(1), --network-bridge implies --network-veth, and --port option is supported only when private networking is enabled. Fixes NixOS#52417.
@arianvp good point! I now added a test the PR. |
Hi @uvNikita, it works perfectly now! Thanks! |
Issue description
Since #49392 was merged, containers configured with
privateNetworking
andhostBridge
but nothostAddress
orlocalAddress
fail to create the veth pair.It should be pretty obvious by reading through that PR what the cause is; since
hostBridge
obviates bothhostAddress
andlocalAddress
, we still need to pass--network-bridge=
and allow the container to bind to an address via DHCP, even when neitherhostAddress
norlocalAddress
are configured.Steps to reproduce
Minimal configuration:
Technical details
"x86_64-linux"
Linux 4.19.9, NixOS, 19.03pre162671.44b02b52ea6 (Koi)
yes
yes
nix-env (Nix) 2.1.3
"nixos-19.03pre162671.44b02b52ea6"
""
/nix/var/nix/profiles/per-user/root/channels/nixos
The text was updated successfully, but these errors were encountered: