Skip to content

Commit

Permalink
networking/bonds: fix examples
Browse files Browse the repository at this point in the history
After the change of the bonding options, the examples were not quite correct.
The diff is over-the top because the new `let` needs everything indented.

Also add a small docstring to the `networkd` attr in the networking test.

(cherry picked from commit 22c2651)
  • Loading branch information
Profpatsch authored and globin committed Mar 8, 2017
1 parent 2461c29 commit 9dc3f75
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 82 deletions.
163 changes: 82 additions & 81 deletions nixos/modules/tasks/network-interfaces.nix
Expand Up @@ -560,101 +560,102 @@ in

};

networking.bonds = mkOption {
default = { };
example = literalExample {
bond0 = {
interfaces = [ "eth0" "wlan0" ];
miimon = 100;
networking.bonds =
let
driverOptionsExample = {
miimon = "100";
mode = "active-backup";
};
fatpipe.interfaces = [ "enp4s0f0" "enp4s0f1" "enp5s0f0" "enp5s0f1" ];
};
description = ''
This option allows you to define bond devices that aggregate multiple,
underlying networking interfaces together. The value of this option is
an attribute set. Each attribute specifies a bond, with the attribute
name specifying the name of the bond's network interface
'';
in mkOption {
default = { };
example = literalExample {
bond0 = {
interfaces = [ "eth0" "wlan0" ];
driverOptions = driverOptionsExample;
};
anotherBond.interfaces = [ "enp4s0f0" "enp4s0f1" "enp5s0f0" "enp5s0f1" ];
};
description = ''
This option allows you to define bond devices that aggregate multiple,
underlying networking interfaces together. The value of this option is
an attribute set. Each attribute specifies a bond, with the attribute
name specifying the name of the bond's network interface
'';

type = with types; attrsOf (submodule {
type = with types; attrsOf (submodule {

options = {
options = {

interfaces = mkOption {
example = [ "enp4s0f0" "enp4s0f1" "wlan0" ];
type = types.listOf types.str;
description = "The interfaces to bond together";
};
interfaces = mkOption {
example = [ "enp4s0f0" "enp4s0f1" "wlan0" ];
type = types.listOf types.str;
description = "The interfaces to bond together";
};

driverOptions = mkOption {
type = types.attrsOf types.str;
default = {};
example = literalExample driverOptionsExample;
description = ''
Options for the bonding driver.
Documentation can be found in
<link xlink:href="https://www.kernel.org/doc/Documentation/networking/bonding.txt" />
'';

driverOptions = mkOption {
type = types.attrsOf types.str;
default = {};
example = literalExample {
interfaces = [ "eth0" "wlan0" ];
miimon = 100;
mode = "active-backup";
};
description = ''
Options for the bonding driver.
Documentation can be found in
<link xlink:href="https://www.kernel.org/doc/Documentation/networking/bonding.txt" />
'';

};
lacp_rate = mkOption {
default = null;
example = "fast";
type = types.nullOr types.str;
description = ''
DEPRECATED, use `driverOptions`.
Option specifying the rate in which we'll ask our link partner
to transmit LACPDU packets in 802.3ad mode.
'';
};

lacp_rate = mkOption {
default = null;
example = "fast";
type = types.nullOr types.str;
description = ''
DEPRECATED, use `driverOptions`.
Option specifying the rate in which we'll ask our link partner
to transmit LACPDU packets in 802.3ad mode.
'';
};
miimon = mkOption {
default = null;
example = 100;
type = types.nullOr types.int;
description = ''
DEPRECATED, use `driverOptions`.
Miimon is the number of millisecond in between each round of polling
by the device driver for failed links. By default polling is not
enabled and the driver is trusted to properly detect and handle
failure scenarios.
'';
};

miimon = mkOption {
default = null;
example = 100;
type = types.nullOr types.int;
description = ''
DEPRECATED, use `driverOptions`.
Miimon is the number of millisecond in between each round of polling
by the device driver for failed links. By default polling is not
enabled and the driver is trusted to properly detect and handle
failure scenarios.
'';
};
mode = mkOption {
default = null;
example = "active-backup";
type = types.nullOr types.str;
description = ''
DEPRECATED, use `driverOptions`.
The mode which the bond will be running. The default mode for
the bonding driver is balance-rr, optimizing for throughput.
More information about valid modes can be found at
https://www.kernel.org/doc/Documentation/networking/bonding.txt
'';
};

mode = mkOption {
default = null;
example = "active-backup";
type = types.nullOr types.str;
description = ''
DEPRECATED, use `driverOptions`.
The mode which the bond will be running. The default mode for
the bonding driver is balance-rr, optimizing for throughput.
More information about valid modes can be found at
https://www.kernel.org/doc/Documentation/networking/bonding.txt
'';
};
xmit_hash_policy = mkOption {
default = null;
example = "layer2+3";
type = types.nullOr types.str;
description = ''
DEPRECATED, use `driverOptions`.
Selects the transmit hash policy to use for slave selection in
balance-xor, 802.3ad, and tlb modes.
'';
};

xmit_hash_policy = mkOption {
default = null;
example = "layer2+3";
type = types.nullOr types.str;
description = ''
DEPRECATED, use `driverOptions`.
Selects the transmit hash policy to use for slave selection in
balance-xor, 802.3ad, and tlb modes.
'';
};

};

});
};
});
};

networking.macvlans = mkOption {
default = { };
Expand Down
4 changes: 3 additions & 1 deletion nixos/tests/networking.nix
@@ -1,4 +1,6 @@
{ system ? builtins.currentSystem, networkd }:
{ system ? builtins.currentSystem
# bool: whether to use networkd in the tests
, networkd }:

with import ../lib/testing.nix { inherit system; };
with pkgs.lib;
Expand Down

0 comments on commit 9dc3f75

Please sign in to comment.