nixos/networking: More fixes
This commit is contained in:
parent
017e6b72c1
commit
7ecb084b77
@ -1026,6 +1026,7 @@ in
|
||||
|
||||
systemd.services.systemd-networkd = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
before = [ "network-interfaces.target" ];
|
||||
restartTriggers = [ config.environment.etc."systemd/network".source ];
|
||||
};
|
||||
|
||||
|
@ -33,8 +33,8 @@ let
|
||||
done
|
||||
[ "$UPDATED" -eq "1" ] && break
|
||||
done
|
||||
ip link set "${i}" down || true
|
||||
ip link del "${i}" || true
|
||||
ip link set "${i}" down 2>/dev/null || true
|
||||
ip link del "${i}" 2>/dev/null || true
|
||||
'';
|
||||
|
||||
in
|
||||
@ -43,12 +43,6 @@ in
|
||||
|
||||
config = mkIf (!cfg.useNetworkd) {
|
||||
|
||||
systemd.targets."network-interfaces" =
|
||||
{ description = "All Network Interfaces";
|
||||
wantedBy = [ "network.target" ];
|
||||
unitConfig.X-StopOnReconfiguration = true;
|
||||
};
|
||||
|
||||
systemd.services =
|
||||
let
|
||||
|
||||
@ -240,6 +234,7 @@ in
|
||||
# Bring up the bond and enslave the specified interfaces
|
||||
ip link set "${n}" up
|
||||
${flip concatMapStrings v.interfaces (i: ''
|
||||
ip link set "${i}" down
|
||||
ip link set "${i}" master "${n}"
|
||||
'')}
|
||||
'';
|
||||
|
@ -11,6 +11,11 @@ let
|
||||
hasSits = cfg.sits != { };
|
||||
hasBonds = cfg.bonds != { };
|
||||
|
||||
slaves = concatMap (i: i.interfaces) (attrValues cfg.bonds)
|
||||
++ concatMap (i: i.interfaces) (attrValues cfg.bridges);
|
||||
|
||||
slaveIfs = map (i: cfg.interfaces.${i}) slaves;
|
||||
|
||||
# We must escape interfaces due to the systemd interpretation
|
||||
subsystemDevice = interface:
|
||||
"sys-subsystem-net-devices-${escapeSystemdPath interface}.device";
|
||||
@ -589,6 +594,9 @@ in
|
||||
(flip map interfaces (i: {
|
||||
assertion = i.subnetMask == null;
|
||||
message = "The networking.interfaces.${i.name}.subnetMask option is defunct. Use prefixLength instead.";
|
||||
})) ++ (flip map slaveIfs (i: {
|
||||
assertion = i.ip4 == [ ] && i.ipAddress == null && i.ip6 == [ ] && i.ipv6Address == null;
|
||||
message = "The networking.interfaces.${i.name} must not have any defined ips when it is a slave.";
|
||||
})) ++ [
|
||||
{
|
||||
assertion = cfg.hostId == null || (stringLength cfg.hostId == 8 && isHexString cfg.hostId);
|
||||
@ -657,6 +665,12 @@ in
|
||||
pkgs.openresolv
|
||||
];
|
||||
|
||||
systemd.targets."network-interfaces" =
|
||||
{ description = "All Network Interfaces";
|
||||
wantedBy = [ "network.target" ];
|
||||
unitConfig.X-StopOnReconfiguration = true;
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
network-local-commands = {
|
||||
description = "Extra networking commands.";
|
||||
|
@ -55,7 +55,9 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client->waitForUnit("network-interfaces.target");
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-interfaces.target");
|
||||
$router->waitForUnit("network.target");
|
||||
|
||||
# Make sure dhcpcd is not started
|
||||
@ -101,9 +103,10 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client->waitForUnit("network-interfaces.target");
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-interfaces.target");
|
||||
$router->waitForUnit("network.target");
|
||||
$client->waitForUnit("dhcpcd.service");
|
||||
|
||||
# Wait until we have an ip address on each interface
|
||||
$client->succeed("while ! ip addr show dev eth1 | grep '192.168.1'; do true; done");
|
||||
@ -144,9 +147,10 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client->waitForUnit("network-interfaces.target");
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-interfaces.target");
|
||||
$router->waitForUnit("network.target");
|
||||
$client->waitForUnit("dhcpcd.service");
|
||||
|
||||
# Wait until we have an ip address on each interface
|
||||
$client->succeed("while ! ip addr show dev eth1 | grep '192.168.1'; do true; done");
|
||||
@ -177,6 +181,8 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
mode = "balance-rr";
|
||||
interfaces = [ "eth1" "eth2" ];
|
||||
};
|
||||
interfaces.eth1.ip4 = mkOverride 0 [ ];
|
||||
interfaces.eth2.ip4 = mkOverride 0 [ ];
|
||||
interfaces.bond.ip4 = mkOverride 0
|
||||
[ { inherit address; prefixLength = 30; } ];
|
||||
};
|
||||
@ -189,9 +195,16 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client1->waitForUnit("network-interfaces.target");
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network-interfaces.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
|
||||
$client1->succeed("ip link >&2");
|
||||
$client1->succeed("systemctl status bond-netdev -l");
|
||||
$client2->succeed("ip link >&2");
|
||||
$client2->succeed("systemctl status bond-netdev -l");
|
||||
|
||||
# Test bonding
|
||||
$client1->succeed("ping -c 2 192.168.1.1");
|
||||
$client1->succeed("ping -c 2 192.168.1.2");
|
||||
@ -232,8 +245,11 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client1->waitForUnit("network-interfaces.target");
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network-interfaces.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-interfaces.target");
|
||||
$router->waitForUnit("network.target");
|
||||
|
||||
# Test bridging
|
||||
@ -267,9 +283,10 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client->waitForUnit("network-interfaces.target");
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-interfaces.target");
|
||||
$router->waitForUnit("network.target");
|
||||
$client->waitForUnit("dhcpcd.service");
|
||||
|
||||
# Wait until we have an ip address on each interface
|
||||
$client->succeed("while ! ip addr show dev eth1 | grep '192.168.1'; do true; done");
|
||||
@ -311,7 +328,9 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client1->waitForUnit("network-interfaces.target");
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network-interfaces.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
|
||||
$client1->succeed("ip addr >&2");
|
||||
@ -350,7 +369,9 @@ import ./make-test.nix ({ networkd, test, ... }:
|
||||
''
|
||||
startAll;
|
||||
|
||||
$client1->waitForUnit("network-interfaces.target");
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network-interfaces.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
|
||||
# Test vlan is setup
|
||||
|
Loading…
Reference in New Issue
Block a user