mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 21:25:30 +03:00
nixos/tests: add test for static routes
This commit is contained in:
parent
d00c91c5da
commit
f41111c4da
3 changed files with 72 additions and 8 deletions
|
@ -210,12 +210,13 @@ let
|
|||
${flip concatMapStrings (i.ipv4Routes ++ i.ipv6Routes) (route:
|
||||
let
|
||||
cidr = "${route.address}/${toString route.prefixLength}";
|
||||
nextHop = optionalString (route.nextHop != null) ''via "${route.nextHop}"'';
|
||||
via = optionalString (route.via != null) ''via "${route.via}"'';
|
||||
options = concatStrings (mapAttrsToList (name: val: "${name} ${val} ") route.options);
|
||||
in
|
||||
''
|
||||
echo "${cidr}" >> $state
|
||||
echo -n "adding route ${cidr}... "
|
||||
if out=$(ip route add "${cidr}" ${route.options} ${nextHop} dev "${i.name}" 2>&1); then
|
||||
if out=$(ip route add "${cidr}" ${options} ${via} dev "${i.name}" 2>&1); then
|
||||
echo "done"
|
||||
elif ! echo "$out" | grep "File exists" >/dev/null 2>&1; then
|
||||
echo "failed"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue