diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2020-02-21 08:24:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-21 08:24:49 +0000 |
commit | 1ddb140d95c6a1ab914f1d9f3d5169b12074c333 (patch) | |
tree | 64bf58d9759a0f96f6064fc237fdac4a32d3c294 /nixos/modules/tasks/network-interfaces.nix | |
parent | c38529df78e402f945a8d51439b2c92d2a249d86 (diff) | |
parent | cd3597b4864935a8dc978b711a4847a6132b8a2c (diff) | |
download | nixpkgs-1ddb140d95c6a1ab914f1d9f3d5169b12074c333.tar nixpkgs-1ddb140d95c6a1ab914f1d9f3d5169b12074c333.tar.gz nixpkgs-1ddb140d95c6a1ab914f1d9f3d5169b12074c333.tar.bz2 nixpkgs-1ddb140d95c6a1ab914f1d9f3d5169b12074c333.tar.lz nixpkgs-1ddb140d95c6a1ab914f1d9f3d5169b12074c333.tar.xz nixpkgs-1ddb140d95c6a1ab914f1d9f3d5169b12074c333.tar.zst nixpkgs-1ddb140d95c6a1ab914f1d9f3d5169b12074c333.zip |
Merge pull request #53033 from netixx/openvswitch-improved-systemd
openvswitch: better integration with systemd
Diffstat (limited to 'nixos/modules/tasks/network-interfaces.nix')
-rw-r--r-- | nixos/modules/tasks/network-interfaces.nix | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index cef9c38c2e3..9542a60beee 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -13,7 +13,7 @@ let slaves = concatMap (i: i.interfaces) (attrValues cfg.bonds) ++ concatMap (i: i.interfaces) (attrValues cfg.bridges) - ++ concatMap (i: i.interfaces) (attrValues cfg.vswitches); + ++ concatMap (i: attrNames (filterAttrs (name: config: ! (config.type == "internal" || hasAttr name cfg.interfaces)) i.interfaces)) (attrValues cfg.vswitches); slaveIfs = map (i: cfg.interfaces.${i}) (filter (i: cfg.interfaces ? ${i}) slaves); @@ -336,6 +336,32 @@ let }; + vswitchInterfaceOpts = {name, ...}: { + + options = { + + name = mkOption { + description = "Name of the interface"; + example = "eth0"; + type = types.str; + }; + + vlan = mkOption { + description = "Vlan tag to apply to interface"; + example = 10; + type = types.nullOr types.int; + default = null; + }; + + type = mkOption { + description = "Openvswitch type to assign to interface"; + example = "internal"; + type = types.nullOr types.str; + default = null; + }; + }; + }; + hexChars = stringToCharacters "0123456789abcdef"; isHexString = s: all (c: elem c hexChars) (stringToCharacters (toLower s)); @@ -486,8 +512,8 @@ in networking.vswitches = mkOption { default = { }; example = - { vs0.interfaces = [ "eth0" "eth1" ]; - vs1.interfaces = [ "eth2" "wlan0" ]; + { vs0.interfaces = { eth0 = { }; lo1 = { type="internal"; }; }; + vs1.interfaces = [ { name = "eth2"; } { name = "lo2"; type="internal"; } ]; }; description = '' @@ -504,9 +530,8 @@ in interfaces = mkOption { example = [ "eth0" "eth1" ]; - type = types.listOf types.str; - description = - "The physical network interfaces connected by the vSwitch."; + description = "The physical network interfaces connected by the vSwitch."; + type = with types; loaOf (submodule vswitchInterfaceOpts); }; controllers = mkOption { @@ -530,6 +555,25 @@ in ''; }; + # TODO: custom "openflow version" type, with list from existing openflow protocols + supportedOpenFlowVersions = mkOption { + type = types.listOf types.str; + example = [ "OpenFlow10" "OpenFlow13" "OpenFlow14" ]; + default = [ "OpenFlow13" ]; + description = '' + Supported versions to enable on this switch. + ''; + }; + + # TODO: use same type as elements from supportedOpenFlowVersions + openFlowVersion = mkOption { + type = types.str; + default = "OpenFlow13"; + description = '' + Version of OpenFlow protocol to use when communicating with the switch internally (e.g. with <literal>openFlowRules</literal>). + ''; + }; + extraOvsctlCmds = mkOption { type = types.lines; default = ""; |