Skip to content

Commit

Permalink
nixos-modules/microvm/interfaces: always use ip link delete
Browse files Browse the repository at this point in the history
Fixes Github issue #302
  • Loading branch information
astro committed Dec 3, 2024
1 parent c07e1dd commit 700ca19
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nixos-modules/microvm/interfaces.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in
set -eou pipefail
'' + lib.concatMapStrings ({ id, mac, ... }: ''
if [ -e /sys/class/net/${id} ]; then
${pkgs.iproute2}/bin/ip tuntap del name '${id}' mode tap ${tapFlags}
${pkgs.iproute2}/bin/ip link delete '${id}'
fi
${pkgs.iproute2}/bin/ip tuntap add name '${id}' mode tap user '${user}' ${tapFlags}
Expand All @@ -35,7 +35,7 @@ in
tap-down = ''
set -ou pipefail
'' + lib.concatMapStrings ({ id, mac, ... }: ''
${pkgs.iproute2}/bin/ip tuntap del name '${id}' mode tap ${tapFlags}
${pkgs.iproute2}/bin/ip link delete '${id}'
'') tapInterfaces;
}
) (
Expand All @@ -44,7 +44,7 @@ in
set -eou pipefail
'' + lib.concatMapStrings ({ id, mac, macvtap, ... }: ''
if [ -e /sys/class/net/${id} ]; then
${pkgs.iproute2}/bin/ip link del name '${id}'
${pkgs.iproute2}/bin/ip link delete '${id}'
fi
${pkgs.iproute2}/bin/ip link add link '${macvtap.link}' name '${id}' address '${mac}' type macvtap '${macvtap.mode}'
${pkgs.iproute2}/bin/ip link set '${id}' allmulticast on
Expand All @@ -56,7 +56,7 @@ in
macvtap-down = ''
set -ou pipefail
'' + lib.concatMapStrings ({ id, ... }: ''
${pkgs.iproute2}/bin/ip link del name '${id}'
${pkgs.iproute2}/bin/ip link delete '${id}'
'') macvtapInterfaces;
}
) ];
Expand Down

0 comments on commit 700ca19

Please sign in to comment.