refactor
This commit is contained in:
1 parent
d9ea3b44a1
commit
1ba1f63776
1 file changed
+5
-6
@@ -201,19 +201,18 @@ connect_container_to_bridge() {
|
|||||||
if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then
|
if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if ! ip link set $GUEST_IFNAME netns $NETNS ; then
|
if ip link set $LOCAL_IFNAME master $BRIDGE &&
|
||||||
|
ip link set $LOCAL_IFNAME up &&
|
||||||
|
ip link set $GUEST_IFNAME netns $NETNS ; then
|
||||||
|
ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME
|
||||||
|
else
|
||||||
# failed before we assigned the veth to the container's
|
# failed before we assigned the veth to the container's
|
||||||
# namespace - delete it
|
# namespace - delete it
|
||||||
ip link del $LOCAL_IFNAME type veth || true
|
ip link del $LOCAL_IFNAME type veth || true
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ip link set $LOCAL_IFNAME master $BRIDGE &&
|
|
||||||
ip link set $LOCAL_IFNAME up &&
|
|
||||||
ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
launch() {
|
launch() {
|
||||||
connect_container_to_bridge &&
|
connect_container_to_bridge &&
|
||||||
check_command_and_run_anything ethtool ip netns exec $NETNS ethtool -K eth0 tx off >/dev/null &&
|
check_command_and_run_anything ethtool ip netns exec $NETNS ethtool -K eth0 tx off >/dev/null &&
|
||||||
|
|||||||
Reference in new issue
Block a user