diff options
author | Thomas Strobel <ts468@cam.ac.uk> | 2015-09-22 15:49:17 +0200 |
---|---|---|
committer | Thomas Strobel <ts468@cam.ac.uk> | 2015-09-25 11:55:27 +0200 |
commit | 59bc47c9ede58f3cdfdfea18297375627ac99c6c (patch) | |
tree | c8f05bfa2bdc5d93e8345fef2dba0b10e69325e1 /nixos/modules/tasks/network-interfaces.nix | |
parent | 000a2108ba10df725065004e1f3d2fb793078f71 (diff) | |
download | nixpkgs-59bc47c9ede58f3cdfdfea18297375627ac99c6c.tar nixpkgs-59bc47c9ede58f3cdfdfea18297375627ac99c6c.tar.gz nixpkgs-59bc47c9ede58f3cdfdfea18297375627ac99c6c.tar.bz2 nixpkgs-59bc47c9ede58f3cdfdfea18297375627ac99c6c.tar.lz nixpkgs-59bc47c9ede58f3cdfdfea18297375627ac99c6c.tar.xz nixpkgs-59bc47c9ede58f3cdfdfea18297375627ac99c6c.tar.zst nixpkgs-59bc47c9ede58f3cdfdfea18297375627ac99c6c.zip |
nixos networking: add vswitch option
Add a configuration option for Open vSwitch that is similar to the option for the Linux kernel ethernet bridge.
Diffstat (limited to 'nixos/modules/tasks/network-interfaces.nix')
-rw-r--r-- | nixos/modules/tasks/network-interfaces.nix | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 9931c977e8f..7af3160e2d4 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -12,7 +12,8 @@ let hasBonds = cfg.bonds != { }; slaves = concatMap (i: i.interfaces) (attrValues cfg.bonds) - ++ concatMap (i: i.interfaces) (attrValues cfg.bridges); + ++ concatMap (i: i.interfaces) (attrValues cfg.bridges) + ++ concatMap (i: i.interfaces) (attrValues cfg.vswitches); slaveIfs = map (i: cfg.interfaces.${i}) (filter (i: cfg.interfaces ? ${i}) slaves); @@ -371,6 +372,81 @@ in options = [ interfaceOpts ]; }; + networking.vswitches = mkOption { + default = { }; + example = + { vs0.interfaces = [ "eth0" "eth1" ]; + vs1.interfaces = [ "eth2" "wlan0" ]; + }; + description = + '' + This option allows you to define Open vSwitches that connect + physical networks together. The value of this option is an + attribute set. Each attribute specifies a vswitch, with the + attribute name specifying the name of the vswitch's network + interface. + ''; + + type = types.attrsOf types.optionSet; + + options = { + + interfaces = mkOption { + example = [ "eth0" "eth1" ]; + type = types.listOf types.str; + description = + "The physical network interfaces connected by the vSwitch."; + }; + + bindInterfaces = mkOption { + type = types.bool; + default = false; + description = '' + If true, then the interfaces of the vSwitch are brought 'up' and especially + also 'down' together with the vSwitch. That requires that every interfaces + is configured as a systemd network services. + ''; + }; + + controllers = mkOption { + type = types.listOf types.str; + default = []; + example = [ "ptcp:6653:[::1]" ]; + description = '' + Specify the controller targets. For the allowed options see <literal>man 8 ovs-vsctl</literal>. + ''; + }; + + openFlowRules = mkOption { + type = types.lines; + default = ""; + example = '' + actions=normal + ''; + description = '' + OpenFlow rules to insert into the Open vSwitch. All <literal>openFlowRules</literal> are + loaded with <literal>ovs-ofctl</literal> within one atomic operation. + ''; + }; + + extraOvsctlCmds = mkOption { + type = types.lines; + default = ""; + example = '' + set-fail-mode <switch_name> secure + set Bridge <switch_name> stp_enable=true + ''; + description = '' + Commands to manipulate the Open vSwitch database. Every line executed with <literal>ovs-vsctl</literal>. + All commands are bundled together with the operations for adding the interfaces + into one atomic operation. + ''; + }; + + }; + + }; + networking.bridges = mkOption { default = { }; example = @@ -766,6 +842,8 @@ in services.mstpd = mkIf needsMstpd { enable = true; }; + virtualisation.vswitch = mkIf (cfg.vswitches != { }) { enable = true; }; + }; } |