mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
feat: Close network on shutdown
This commit is contained in:
parent
9f6fbc3f7c
commit
4571fe9c4f
@ -31,8 +31,7 @@ configureDHCP() {
|
|||||||
error "and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 16
|
error "and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 16
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while [ ! ip link set "${VM_NET_TAP}" up ]
|
while ! ip link set "${VM_NET_TAP}" up; do
|
||||||
do
|
|
||||||
info "Waiting for address to become available..."
|
info "Waiting for address to become available..."
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
@ -132,8 +131,7 @@ configureNAT () {
|
|||||||
|
|
||||||
ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge
|
ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge
|
||||||
|
|
||||||
while [ ! ip link set dockerbridge up ]
|
while ! ip link set dockerbridge up; do
|
||||||
do
|
|
||||||
info "Waiting for address to become available..."
|
info "Waiting for address to become available..."
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
@ -141,8 +139,7 @@ configureNAT () {
|
|||||||
# QEMU Works with taps, set tap to the bridge created
|
# QEMU Works with taps, set tap to the bridge created
|
||||||
ip tuntap add dev "${VM_NET_TAP}" mode tap
|
ip tuntap add dev "${VM_NET_TAP}" mode tap
|
||||||
|
|
||||||
while [ ! ip link set "${VM_NET_TAP}" up promisc on ]
|
while ! ip link set "${VM_NET_TAP}" up promisc on; do
|
||||||
do
|
|
||||||
info "Waiting for tap to become available..."
|
info "Waiting for tap to become available..."
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
@ -182,13 +179,18 @@ configureNAT () {
|
|||||||
|
|
||||||
closeNetwork () {
|
closeNetwork () {
|
||||||
|
|
||||||
ip link set "${VM_NET_TAP}" down
|
if [[ "${DHCP}" == [Yy1]* ]]; then
|
||||||
ip link delete "${VM_NET_TAP}"
|
|
||||||
|
|
||||||
if [[ "${DHCP}" != [Yy1]* ]]; then
|
|
||||||
|
|
||||||
ip link set dockerbridge down
|
ip link set "${VM_NET_TAP}" down || true
|
||||||
ip link delete dockerbridge
|
ip link delete "${VM_NET_TAP}" || true
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
ip link set "${VM_NET_TAP}" down promisc off || true
|
||||||
|
ip link delete "${VM_NET_TAP}" || true
|
||||||
|
|
||||||
|
ip link set dockerbridge down || true
|
||||||
|
ip link delete dockerbridge || true
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user