wireguard: convert "table" to an interface option

Do the right thing, and use multiple interfaces for policy routing. For example, WireGuard interfaces do not allow multiple routes for the same CIDR range.
This commit is contained in:
evujumenuk 2017-08-08 01:45:19 +02:00 committed by GitHub
parent 6070d91e93
commit eaab02b94f

View File

@ -79,6 +79,16 @@ let
description = "A list of commands called after shutting down the interface."; description = "A list of commands called after shutting down the interface.";
}; };
table = mkOption {
default = "main";
type = types.str;
description = ''The kernel routing table to add this interface's
associated routes to. Setting this is useful for e.g. policy routing
("ip rule") or virtual routing and forwarding ("ip vrf"). Both numeric
table IDs and table names (/etc/rt_tables) can be used. Defaults to
"main".'';
};
peers = mkOption { peers = mkOption {
default = []; default = [];
description = "Peers linked to the interface."; description = "Peers linked to the interface.";
@ -160,14 +170,6 @@ let
interval of 25 seconds; however, most users will not need this.''; interval of 25 seconds; however, most users will not need this.'';
}; };
table = mkOption {
default = "main";
type = types.str;
description = ''The kernel routing table to add this peer's associated
routes to. Setting this is useful for e.g. policy routing ("ip rule")
or virtual routing and forwarding ("ip vrf"). Both numeric table IDs
and table names (/etc/rt_tables) can be used. Defaults to "main".'';
};
}; };
}; };
@ -217,7 +219,7 @@ let
(map (peer: (map (peer:
(map (allowedIP: (map (allowedIP:
"${ipCommand} route replace ${allowedIP} dev ${name} table ${peer.table}" "${ipCommand} route replace ${allowedIP} dev ${name} table ${values.table}"
) peer.allowedIPs) ) peer.allowedIPs)
) values.peers) ) values.peers)